x86-64, reboot: Allow reboot= bios and reboot-cpu override on x86-64
tip-bot for H. Peter Anvin
reviewerCommit-ID: 650513979a437c32d7a0a84f0ed952a55bbb5583 Gitweb: http://git.kernel.org/tip/650513979a437c32d7a0a84f0ed952a55bbb5583 Author: H. Peter Anvin <[email protected]> AuthorDate: Sat, 16 Jun 2012 21:47:37 -0700 Committer: H. Peter Anvin <[email protected]> CommitDate: Sun, 17 Jun 2012 10:51:01 -0700
x86-64, reboot: Allow reboot=bios and reboot-cpu override on x86-64
With the revamped realmode trampoline code, it is trivial to extend support for reboot=bios to x86-64. Furthermore, while we are at it, remove the restriction that only we can only override the reboot CPU on 32 bits.
---
arch/x86/include/asm/emergency-restart.h | 2 -
arch/x86/include/asm/realmode.h | 3 +-
arch/x86/include/asm/reboot.h | 4 +-
arch/x86/kernel/reboot.c | 52 +++++++++++-------------
arch/x86/realmode/rm/Makefile | 2 +-
arch/x86/realmode/rm/header.S | 4 +-
arch/x86/realmode/rm/{reboot_32.S => reboot.S} | 26 ++++++++++-
7 files changed, 55 insertions(+), 38 deletions(-)arch/x86/include/asm/emergency-restart.h +0 -2
@@ -4,9 +4,7 @@enum reboot_type {BOOT_TRIPLE ='t' ,BOOT_KBD ='k' , -#ifdef CONFIG_X86_32 BOOT_BIOS ='b' , -#endif BOOT_ACPI ='a' ,BOOT_EFI ='e' ,BOOT_CF9 ='p' ,
arch/x86/include/asm/realmode.h +2 -1
@@ -21,8 +21,9 @@ struct real_mode_header {u32 wakeup_header;#endif /* APM/BIOS reboot */ -#ifdef CONFIG_X86_32 u32 machine_real_restart_asm; +#ifdef CONFIG_X86_64 +u32 machine_real_restart_seg;#endif };
arch/x86/include/asm/reboot.h +2 -2
@@ -18,8 +18,8 @@ extern struct machine_ops machine_ops;void native_machine_crash_shutdown (struct pt_regs *regs);void native_machine_shutdown (void ); -void machine_real_restart (unsigned int type); -/* These must match dispatch_table in reboot_32.S */ +void __noreturn machine_real_restart (unsigned int type); +/* These must match dispatch in arch/x86/realmore/rm/reboot.S */ #define MRR_BIOS 0#define MRR_APM 1
arch/x86/kernel/reboot.c +24 -28
149 lines not on this page · raw message
arch/x86/realmode/rm/Makefile +1 -1
@@ -22,7 +22,7 @@ wakeup-objs += video-bios.o realmode-y += header.o realmode-y += trampoline_$(BITS).o realmode-y += stack.o -realmode-$(CONFIG_X86_32) += reboot_32.o +realmode-y += reboot.o realmode-$(CONFIG_ACPI_SLEEP) += $(wakeup-objs) targets += $(realmode-y)
arch/x86/realmode/rm/header.S +3 -1
@@ -6,6 +6,7 @@ #include <linux/linkage.h> #include <asm/page_types.h> +#include <asm/segment.h> #include "realmode.h"
@@ -28,8 +29,9 @@ GLOBAL(real_mode_header) .long pa_wakeup_header #endif /* APM/BIOS reboot */ -#ifdef CONFIG_X86_32 .long pa_machine_real_restart_asm +#ifdef CONFIG_X86_64 + .long __KERNEL32_CS #endif END(real_mode_header)
arch/x86/realmode/rm/reboot.S renamed from arch/x86/realmode/rm/reboot_32.S +23 -3
@@ -2,6 +2,8 @@ #include <linux/init.h> #include <asm/segment.h> #include <asm/page_types.h> +#include <asm/processor-flags.h> +#include <asm/msr-index.h> #include "realmode.h" /*
@@ -12,13 +14,31 @@ * doesn't work with at least one type of 486 motherboard. It is easy * to stop this code working; hence the copious comments. * - * This code is called with the restart type (0 = BIOS, 1 = APM) in %eax. + * This code is called with the restart type (0 = BIOS, 1 = APM) in + * the primary argument register (%eax for 32 bit, %edi for 64 bit). */ .section ".text32", "ax" .code32 - - .balign 16 ENTRY(machine_real_restart_asm) + +#ifdef CONFIG_X86_64 + + /* 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 */ + +1: + xorl %eax, %eax + xorl %edx, %edx + movl $MSR_EFER, %ecx + wrmsr + + movl %edi, %eax + +#endif /* CONFIG_X86_64 */ + /* Set up the IDT for real mode. */ lidtl pa_machine_real_restart_idt
tip-bot for H. Peter Anvin
reviewer[tip:x86/reboot] x86-64, reboot: Be more paranoid in 64-bit reboot =bios
Commit-ID: 9751d7627582fc1cc64625d63bde9528c14f1544 Gitweb: http://git.kernel.org/tip/9751d7627582fc1cc64625d63bde9528c14f1544 Author: H. Peter Anvin <[email protected]> AuthorDate: Thu, 21 Jun 2012 10:25:03 -0700 Committer: H. Peter Anvin <[email protected]> CommitDate: Thu, 21 Jun 2012 10:25:03 -0700
x86-64, reboot: Be more paranoid in 64-bit reboot=bios
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.
--- arch/x86/realmode/rm/reboot.S | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-)
arch/x86/realmode/rm/reboot.S +6 -2
@@ -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