Skip to content

Commit 00229a5

Browse files
committed
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: Thomas Gleixner <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 5a2bafc commit 00229a5

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

arch/x86/kernel/idt.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55
#include <linux/interrupt.h>
66

7+
#include <asm/cpu_entry_area.h>
78
#include <asm/traps.h>
89
#include <asm/proto.h>
910
#include <asm/desc.h>
@@ -281,6 +282,19 @@ void __init idt_setup_ist_traps(void)
281282
}
282283
#endif
283284

285+
static void __init idt_map_in_cea(void)
286+
{
287+
/*
288+
* Set the IDT descriptor to a fixed read-only location in the cpu
289+
* entry area, so that the "sidt" instruction will not leak the
290+
* location of the kernel, and to defend the IDT against arbitrary
291+
* memory write vulnerabilities.
292+
*/
293+
cea_set_pte(CPU_ENTRY_AREA_RO_IDT_VADDR, __pa_symbol(idt_table),
294+
PAGE_KERNEL_RO);
295+
idt_descr.address = CPU_ENTRY_AREA_RO_IDT;
296+
}
297+
284298
/**
285299
* idt_setup_apic_and_irq_gates - Setup APIC/SMP and normal interrupt gates
286300
*/
@@ -307,6 +321,10 @@ void __init idt_setup_apic_and_irq_gates(void)
307321
set_intr_gate(i, entry);
308322
}
309323
#endif
324+
/* Map IDT into CPU entry area and reload it. */
325+
idt_map_in_cea();
326+
load_idt(&idt_descr);
327+
310328
idt_setup_done = true;
311329
}
312330

arch/x86/kernel/traps.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,15 +1055,6 @@ void __init trap_init(void)
10551055

10561056
idt_setup_traps();
10571057

1058-
/*
1059-
* Set the IDT descriptor to a fixed read-only location, so that the
1060-
* "sidt" instruction will not leak the location of the kernel, and
1061-
* to defend the IDT against arbitrary memory write vulnerabilities.
1062-
* It will be reloaded in cpu_init() */
1063-
cea_set_pte(CPU_ENTRY_AREA_RO_IDT_VADDR, __pa_symbol(idt_table),
1064-
PAGE_KERNEL_RO);
1065-
idt_descr.address = CPU_ENTRY_AREA_RO_IDT;
1066-
10671058
/*
10681059
* Should be a barrier for any external CPU state:
10691060
*/

0 commit comments

Comments
 (0)