Skip to content

Commit

Permalink
x86/idt: Initialize early IDT before cr4_init_shadow()
Browse files Browse the repository at this point in the history
Moving the early IDT setup out of assembly code breaks the boot on first
generation 486 systems.

The reason is that the call of idt_setup_early_handler, which sets up the
early handlers was added after the call to cr4_init_shadow().

cr4_init_shadow() tries to read CR4 which is not available on those
systems. The accessor function uses a extable fixup to handle the resulting
fault. As the IDT is not set up yet, the cr4 read exception causes an
instantaneous reboot for obvious reasons.

Call idt_setup_early_handler() before cr4_init_shadow() so IDT is set up
before the first exception hits.

Fixes: 87e8178 ("x86/idt: Move early IDT setup out of 32-bit asm")
Reported-and-tested-by:  Matthew Whitehead <whiteheadm@acm.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Andy Lutomirski <luto@kernel.org>
Link: https://lkml.kernel.org/r/alpine.DEB.2.20.1710161210290.1973@nanos
  • Loading branch information
KAGA-KOKO committed Oct 16, 2017
1 parent e6fc454 commit 9c48c09
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions arch/x86/kernel/head32.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ static void __init i386_default_early_setup(void)

asmlinkage __visible void __init i386_start_kernel(void)
{
cr4_init_shadow();

/* Make sure IDT is set up before any exception happens */
idt_setup_early_handler();

cr4_init_shadow();

sanitize_boot_params(&boot_params);

x86_early_init_platform_quirks();
Expand Down

0 comments on commit 9c48c09

Please sign in to comment.