Skip to content

Commit

Permalink
x86-64, reboot: Be more paranoid in 64-bit reboot=bios
Browse files Browse the repository at this point in the history
Be a bit more paranoid in the transition back to 16-bit mode.  In
particular, in case the kernel is residing above the 4 GiB mark,
switch to the trampoline GDT, and make the jump after turning off
paging a far jump.  In theory, none of this should matter, but it is
exactly the kind of things that broken SMM or virtualization software
could trip up on.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Link: http://lkml.kernel.org/r/tip-jopx7y6g6dbcx4tpal8q0jlr@git.kernel.org
  • Loading branch information
H. Peter Anvin committed Jun 21, 2012
1 parent 2b1b712 commit 9751d76
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions arch/x86/realmode/rm/reboot.S
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@
ENTRY(machine_real_restart_asm)

#ifdef CONFIG_X86_64
/* Switch to trampoline GDT as it is guaranteed < 4 GiB */
movl $__KERNEL_DS, %eax
movl %eax, %ds
lgdtl pa_tr_gdt

/* Disable paging to drop us out of long mode */
movl %cr0, %eax
andl $~X86_CR0_PG, %eax
movl %eax, %cr0
jmp 1f /* "A branch" may be needed here, assume near is OK */
ljmpl $__KERNEL32_CS, $pa_machine_real_restart_paging_off

1:
GLOBAL(machine_real_restart_paging_off)
xorl %eax, %eax
xorl %edx, %edx
movl $MSR_EFER, %ecx
Expand Down

0 comments on commit 9751d76

Please sign in to comment.