Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1720477
| From | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [patch V2 34/44] x86/idt: Prepare for table based init |
| Date | 2017-08-26 00:10 +0200 |
| Message-ID | <uiuXG-1gP-55@gated-at.bofh.it> (permalink) |
| References | <uiuNX-Yh-7@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
The IDT setup code is handled in several places. All of them use variants
of set_intr_gate() inlines. This can be done with a table based
initialization, which allows to reduce the inline zoo and puts all IDT
related code and information into a single place.
Add the infrastructure.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
arch/x86/kernel/idt.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)
--- a/arch/x86/kernel/idt.c
+++ b/arch/x86/kernel/idt.c
@@ -5,8 +5,49 @@
*/
#include <linux/interrupt.h>
+#include <asm/traps.h>
+#include <asm/proto.h>
#include <asm/desc.h>
+struct idt_data {
+ unsigned int vector;
+ unsigned int segment;
+ struct idt_bits bits;
+ const void *addr;
+};
+
+#define DPL0 0x0
+#define DPL3 0x3
+
+#define DEFAULT_STACK 0
+
+#define G(_vector, _addr, _ist, _type, _dpl, _segment) \
+ { \
+ .vector = _vector, \
+ .bits.ist = _ist, \
+ .bits.type = _type, \
+ .bits.dpl = _dpl, \
+ .bits.p = 1, \
+ .addr = _addr, \
+ .segment = _segment, \
+ }
+
+/* Interrupt gate */
+#define INTG(_vector, _addr) \
+ G(_vector, _addr, DEFAULT_STACK, GATE_INTERRUPT, DPL0, __KERNEL_CS)
+
+/* System interrupt gate */
+#define SYSG(_vector, _addr) \
+ G(_vector, _addr, DEFAULT_STACK, GATE_INTERRUPT, DPL3, __KERNEL_CS)
+
+/* Interrupt gate with interrupt stack */
+#define ISTG(_vector, _addr, _ist) \
+ G(_vector, _addr, _ist, GATE_INTERRUPT, DPL0, __KERNEL_CS)
+
+/* Task gate */
+#define TSKG(_vector, _gdt) \
+ G(_vector, NULL, DEFAULT_STACK, GATE_TASK, DPL0, _gdt << 3)
+
/* Must be page-aligned because the real IDT is used in a fixmap. */
gate_desc idt_table[IDT_ENTRIES] __page_aligned_bss;
@@ -25,6 +66,32 @@ const struct desc_ptr debug_idt_descr =
};
#endif
+static inline void idt_init_desc(gate_desc *gate, const struct idt_data *d)
+{
+ unsigned long addr = (unsigned long) d->addr;
+
+ gate->offset_low = (u16) addr;
+ gate->segment = (u16) d->segment;
+ gate->bits = d->bits;
+ gate->offset_middle = (u16) (addr >> 16);
+#ifdef CONFIG_X86_64
+ gate->offset_high = (u32) (addr >> 32);
+ gate->reserved = 0;
+#endif
+}
+
+static __init void
+idt_setup_from_table(gate_desc *idt, const struct idt_data *t, int size)
+{
+ gate_desc desc;
+
+ for (; size > 0; t++, size--) {
+ idt_init_desc(&desc, t);
+ set_bit(t->vector, used_vectors);
+ write_idt_entry(idt, t->vector, &desc);
+ }
+}
+
/**
* idt_setup_early_handler - Initializes the idt table with early handlers
*/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[patch V2 00/44] x86: Cleanup IDT code Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:00 +0200
[patch V2 23/44] x86/percpu: Use static initializer for GDT entry Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:00 +0200
[patch V2 33/44] x86/idt: Move early IDT setup out of 32bit asm Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:00 +0200
[patch V2 44/44] x86/idt: Hide set_intr_gate() Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:00 +0200
[patch V2 38/44] x86/idt: Move regular trap init to tables Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:00 +0200
[patch V2 02/44] x86/irq: Unexport used_vectors Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:00 +0200
[patch V2 21/44] x86/tracing: Build tracepoints only when they are used Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:00 +0200
[patch V2 04/44] x86/irq: Remove duplicated used_vectors definition Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:00 +0200
[patch V2 39/44] x86/idt: Move APIC gate initialization to tables Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:00 +0200
[patch V2 11/44] x86/apic: Remove the duplicated tracing versions of interrupts Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:00 +0200
[patch V2 29/44] x86/idt: Move 32bit idt_descr to C code Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:10 +0200
[patch V2 16/44] x86/idt: Remove tracing idt completely Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:10 +0200
[patch V2 05/44] x86/boot: Move EISA setup to a proper place Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:10 +0200
[patch V2 17/44] x86/idt: Cleanup the i386 low level entry macros Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:10 +0200
[patch V2 26/44] x86/gdt: Use bitfields for initialization Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:10 +0200
[patch V2 06/44] x86/tracing: Introduce a static key for exception tracing Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:10 +0200
[patch V2 18/44] x86/tracing: Disentangle pagefault and resched IPI tracing key Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:10 +0200
[patch V2 12/44] x86/irqwork: Get rid of duplicated tracing interrupt code Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:10 +0200
[patch V2 20/44] x86/irq_work: Make it depend on APIC Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:10 +0200
[patch V2 09/44] x86/apic: Use this_cpu_ptr in local_timer_interrupt Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:10 +0200
[patch V2 27/44] x86/ldttss: Cleanup 32bit descriptors Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:10 +0200
[patch V2 13/44] x86/mce: Remove duplicated tracing interrupt code Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:10 +0200
[patch V2 36/44] x86/idt: Move debug stack init to table based Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:10 +0200
[patch V2 15/44] x86/smp: Use static key for reschedule interrupt tracing Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:10 +0200
[patch V2 03/44] x86/irq: Get rid of the first_system_vector bogisity Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:10 +0200
[patch V2 14/44] x86/smp: Remove pointless duplicated interrupt code Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:10 +0200
[patch V2 28/44] x86/idt: Create file for IDT related code Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:10 +0200
[patch V2 07/44] x86/traps: Simplify pagefault tracing logic Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:10 +0200
[patch V2 37/44] x86/idt: Move ist stack based traps to table init Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:10 +0200
[patch V2 10/44] x86/irq: Get rid of duplicated trace_x86_platform_ipi() code Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:10 +0200
[patch V2 31/44] x86/idt: Consolidate IDT invalidation Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:10 +0200
[patch V2 25/44] x86: Replace access to desc_struct:a/b fields Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:10 +0200
Re: [patch V2 25/44] x86: Replace access to desc_struct:a/b fields Boris Ostrovsky <boris.ostrovsky@oracle.com> - 2017-08-26 04:20 +0200
[patch V2 34/44] x86/idt: Prepare for table based init Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:10 +0200
[patch V2 22/44] x86/idt: Unify gate_struct handling for 32/64bit Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:10 +0200
[patch V2 32/44] x86/idt: Move early IDT handler setup to IDT code Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:10 +0200
[patch V2 08/44] x86/apic: Remove the duplicated tracing version of local_timer_interrupt Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:10 +0200
[patch V2 30/44] x86/idt: Remove unused set_trap_gate() Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:10 +0200
[patch V2 24/44] x86/fpu: Use bitfield accessors for desc_struct Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:10 +0200
[patch V2 01/44] x86/irq: Remove vector_used_by_percpu_irq() Thomas Gleixner <tglx@linutronix.de> - 2017-08-26 00:20 +0200
csiph-web