Commit bd53147d authored by Eric W. Biederman's avatar Eric W. Biederman Committed by Thomas Gleixner

x86: Fix boot protocol KEEP_SEGMENTS check.

The kernel only ever supports 1 version of the boot protocol
so there is no need to check the boot protocol revision to
see if a feature is supported.

Both x86 and x86_64 support the same boot protocol so we need
to implement the KEEP_SEGMENTS on x86_64 as well.  It isn't
just paravirt bootloaders that could use this functionality.
Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
Cc: Jeremy Fitzhardinge <jeremy@xensource.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Vivek Goyal <vgoyal@in.ibm.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Zachary Amsden <zach@vmware.com>
Cc: Andi Kleen <ak@suse.de>
Acked-by: default avatarH. Peter Anvin <hpa@zytor.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 0cca1ca6
...@@ -33,24 +33,20 @@ ...@@ -33,24 +33,20 @@
.globl startup_32 .globl startup_32
startup_32: startup_32:
/* check to see if KEEP_SEGMENTS flag is meaningful */ cld
cmpw $0x207, BP_version(%esi)
jb 1f
/* test KEEP_SEGMENTS flag to see if the bootloader is asking /* test KEEP_SEGMENTS flag to see if the bootloader is asking
* us to not reload segments */ * us to not reload segments */
testb $(1<<6), BP_loadflags(%esi) testb $(1<<6), BP_loadflags(%esi)
jnz 2f jnz 1f
1: cli cli
movl $(__BOOT_DS),%eax movl $(__BOOT_DS),%eax
movl %eax,%ds movl %eax,%ds
movl %eax,%es movl %eax,%es
movl %eax,%fs movl %eax,%fs
movl %eax,%gs movl %eax,%gs
movl %eax,%ss movl %eax,%ss
1:
2: cld
/* Calculate the delta between where we were compiled to run /* Calculate the delta between where we were compiled to run
* at and where we were actually loaded at. This can only be done * at and where we were actually loaded at. This can only be done
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <asm/pgtable.h> #include <asm/pgtable.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/msr.h> #include <asm/msr.h>
#include <asm/asm-offsets.h>
.section ".text.head" .section ".text.head"
.code32 .code32
...@@ -36,11 +37,17 @@ ...@@ -36,11 +37,17 @@
startup_32: startup_32:
cld cld
/* test KEEP_SEGMENTS flag to see if the bootloader is asking
* us to not reload segments */
testb $(1<<6), BP_loadflags(%esi)
jnz 1f
cli cli
movl $(__KERNEL_DS), %eax movl $(__KERNEL_DS), %eax
movl %eax, %ds movl %eax, %ds
movl %eax, %es movl %eax, %es
movl %eax, %ss movl %eax, %ss
1:
/* Calculate the delta between where we were compiled to run /* Calculate the delta between where we were compiled to run
* at and where we were actually loaded at. This can only be done * at and where we were actually loaded at. This can only be done
......
...@@ -15,12 +15,16 @@ ...@@ -15,12 +15,16 @@
#include <asm/segment.h> #include <asm/segment.h>
#include <asm/thread_info.h> #include <asm/thread_info.h>
#include <asm/ia32.h> #include <asm/ia32.h>
#include <asm/bootparam.h>
#define DEFINE(sym, val) \ #define DEFINE(sym, val) \
asm volatile("\n->" #sym " %0 " #val : : "i" (val)) asm volatile("\n->" #sym " %0 " #val : : "i" (val))
#define BLANK() asm volatile("\n->" : : ) #define BLANK() asm volatile("\n->" : : )
#define OFFSET(sym, str, mem) \
DEFINE(sym, offsetof(struct str, mem))
#define __NO_STUBS 1 #define __NO_STUBS 1
#undef __SYSCALL #undef __SYSCALL
#undef _ASM_X86_64_UNISTD_H_ #undef _ASM_X86_64_UNISTD_H_
...@@ -109,5 +113,11 @@ int main(void) ...@@ -109,5 +113,11 @@ int main(void)
DEFINE(crypto_tfm_ctx_offset, offsetof(struct crypto_tfm, __crt_ctx)); DEFINE(crypto_tfm_ctx_offset, offsetof(struct crypto_tfm, __crt_ctx));
BLANK(); BLANK();
DEFINE(__NR_syscall_max, sizeof(syscalls) - 1); DEFINE(__NR_syscall_max, sizeof(syscalls) - 1);
BLANK();
OFFSET(BP_scratch, boot_params, scratch);
OFFSET(BP_loadflags, boot_params, hdr.loadflags);
OFFSET(BP_hardware_subarch, boot_params, hdr.hardware_subarch);
OFFSET(BP_version, boot_params, hdr.version);
return 0; return 0;
} }
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