Commit 00229a54 authored by Thomas Gleixner's avatar Thomas Gleixner

x86/idt: Cleanup trap_init()

No point in having all the IDT cruft in trap_init(). Move it into the IDT
code and fixup the comments.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20200528145522.992376498@linutronix.de

parent 5a2bafca
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
*/ */
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <asm/cpu_entry_area.h>
#include <asm/traps.h> #include <asm/traps.h>
#include <asm/proto.h> #include <asm/proto.h>
#include <asm/desc.h> #include <asm/desc.h>
...@@ -281,6 +282,19 @@ void __init idt_setup_ist_traps(void) ...@@ -281,6 +282,19 @@ void __init idt_setup_ist_traps(void)
} }
#endif #endif
static void __init idt_map_in_cea(void)
{
/*
* Set the IDT descriptor to a fixed read-only location in the cpu
* entry area, so that the "sidt" instruction will not leak the
* location of the kernel, and to defend the IDT against arbitrary
* memory write vulnerabilities.
*/
cea_set_pte(CPU_ENTRY_AREA_RO_IDT_VADDR, __pa_symbol(idt_table),
PAGE_KERNEL_RO);
idt_descr.address = CPU_ENTRY_AREA_RO_IDT;
}
/** /**
* idt_setup_apic_and_irq_gates - Setup APIC/SMP and normal interrupt gates * idt_setup_apic_and_irq_gates - Setup APIC/SMP and normal interrupt gates
*/ */
...@@ -307,6 +321,10 @@ void __init idt_setup_apic_and_irq_gates(void) ...@@ -307,6 +321,10 @@ void __init idt_setup_apic_and_irq_gates(void)
set_intr_gate(i, entry); set_intr_gate(i, entry);
} }
#endif #endif
/* Map IDT into CPU entry area and reload it. */
idt_map_in_cea();
load_idt(&idt_descr);
idt_setup_done = true; idt_setup_done = true;
} }
......
...@@ -1055,15 +1055,6 @@ void __init trap_init(void) ...@@ -1055,15 +1055,6 @@ void __init trap_init(void)
idt_setup_traps(); idt_setup_traps();
/*
* Set the IDT descriptor to a fixed read-only location, so that the
* "sidt" instruction will not leak the location of the kernel, and
* to defend the IDT against arbitrary memory write vulnerabilities.
* It will be reloaded in cpu_init() */
cea_set_pte(CPU_ENTRY_AREA_RO_IDT_VADDR, __pa_symbol(idt_table),
PAGE_KERNEL_RO);
idt_descr.address = CPU_ENTRY_AREA_RO_IDT;
/* /*
* Should be a barrier for any external CPU state: * Should be a barrier for any external CPU state:
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment