* [PATCH] x86: Fix boot protocol KEEP_SEGMENTS check.
@ 2007-10-26 17:29 Eric W. Biederman
2007-10-26 17:59 ` H. Peter Anvin
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Eric W. Biederman @ 2007-10-26 17:29 UTC (permalink / raw)
To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin
Cc: Jeremy Fitzhardinge, Rusty Russell, Vivek Goyal, James Bottomley,
Zachary Amsden, Andi Kleen, linux-kernel, Andrew Morton
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: Eric W. Biederman <ebiederm@xmission.com>
Cc: Jeremy Fitzhardinge <jeremy@xensource.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: H. Peter Anvin <hpa@zytor.com>
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>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@elte.hu>
---
arch/x86/boot/compressed/head_32.S | 12 ++++--------
arch/x86/boot/compressed/head_64.S | 7 +++++++
arch/x86/kernel/asm-offsets_64.c | 10 ++++++++++
3 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
index a0ae2e7..036e635 100644
--- a/arch/x86/boot/compressed/head_32.S
+++ b/arch/x86/boot/compressed/head_32.S
@@ -33,24 +33,20 @@
.globl startup_32
startup_32:
- /* check to see if KEEP_SEGMENTS flag is meaningful */
- cmpw $0x207, BP_version(%esi)
- jb 1f
-
+ cld
/* test KEEP_SEGMENTS flag to see if the bootloader is asking
* us to not reload segments */
testb $(1<<6), BP_loadflags(%esi)
- jnz 2f
+ jnz 1f
-1: cli
+ cli
movl $(__BOOT_DS),%eax
movl %eax,%ds
movl %eax,%es
movl %eax,%fs
movl %eax,%gs
movl %eax,%ss
-
-2: cld
+1:
/* Calculate the delta between where we were compiled to run
* at and where we were actually loaded at. This can only be done
diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
index 4946764..1ccb38a 100644
--- a/arch/x86/boot/compressed/head_64.S
+++ b/arch/x86/boot/compressed/head_64.S
@@ -29,6 +29,7 @@
#include <asm/pgtable.h>
#include <asm/page.h>
#include <asm/msr.h>
+#include <asm/asm-offsets.h>
.section ".text.head"
.code32
@@ -36,11 +37,17 @@
startup_32:
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
movl $(__KERNEL_DS), %eax
movl %eax, %ds
movl %eax, %es
movl %eax, %ss
+1:
/* Calculate the delta between where we were compiled to run
* at and where we were actually loaded at. This can only be done
diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
index 7e50bda..d1b6ed9 100644
--- a/arch/x86/kernel/asm-offsets_64.c
+++ b/arch/x86/kernel/asm-offsets_64.c
@@ -15,12 +15,16 @@
#include <asm/segment.h>
#include <asm/thread_info.h>
#include <asm/ia32.h>
+#include <asm/bootparam.h>
#define DEFINE(sym, val) \
asm volatile("\n->" #sym " %0 " #val : : "i" (val))
#define BLANK() asm volatile("\n->" : : )
+#define OFFSET(sym, str, mem) \
+ DEFINE(sym, offsetof(struct str, mem))
+
#define __NO_STUBS 1
#undef __SYSCALL
#undef _ASM_X86_64_UNISTD_H_
@@ -109,5 +113,11 @@ int main(void)
DEFINE(crypto_tfm_ctx_offset, offsetof(struct crypto_tfm, __crt_ctx));
BLANK();
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;
}
--
1.5.3.rc6.17.g1911
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH] x86: Fix boot protocol KEEP_SEGMENTS check.
2007-10-26 17:29 [PATCH] x86: Fix boot protocol KEEP_SEGMENTS check Eric W. Biederman
@ 2007-10-26 17:59 ` H. Peter Anvin
2007-10-26 18:22 ` Eric W. Biederman
2007-10-26 18:52 ` Jeremy Fitzhardinge
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: H. Peter Anvin @ 2007-10-26 17:59 UTC (permalink / raw)
To: Eric W. Biederman
Cc: Ingo Molnar, Thomas Gleixner, Jeremy Fitzhardinge, Rusty Russell,
Vivek Goyal, James Bottomley, Zachary Amsden, Andi Kleen,
linux-kernel, Andrew Morton
Eric W. Biederman wrote:
>
> 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.
>
Out of curiousity, what other users do you see?
-hpa
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] x86: Fix boot protocol KEEP_SEGMENTS check.
2007-10-26 17:59 ` H. Peter Anvin
@ 2007-10-26 18:22 ` Eric W. Biederman
0 siblings, 0 replies; 7+ messages in thread
From: Eric W. Biederman @ 2007-10-26 18:22 UTC (permalink / raw)
To: H. Peter Anvin
Cc: Ingo Molnar, Thomas Gleixner, Jeremy Fitzhardinge, Rusty Russell,
Vivek Goyal, James Bottomley, Zachary Amsden, Andi Kleen,
linux-kernel, Andrew Morton
"H. Peter Anvin" <hpa@zytor.com> writes:
> Eric W. Biederman wrote:
>>
>> 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.
>>
>
> Out of curiousity, what other users do you see?
Simply that is easier to provide segments that are not fit to be
reloaded before the kernel sets up it's own GDT. Then to ensure you
stick a GDT someplace that won't get stomped.
Especially before we froze which segments numbers the kernel
would load into the boot protocol. I would have used this in
places where I was doing 32bit bootloader work as it is just easier to
support.
Eric
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] x86: Fix boot protocol KEEP_SEGMENTS check.
2007-10-26 17:29 [PATCH] x86: Fix boot protocol KEEP_SEGMENTS check Eric W. Biederman
2007-10-26 17:59 ` H. Peter Anvin
@ 2007-10-26 18:52 ` Jeremy Fitzhardinge
2007-10-26 19:40 ` H. Peter Anvin
2007-10-31 0:49 ` Rusty Russell
3 siblings, 0 replies; 7+ messages in thread
From: Jeremy Fitzhardinge @ 2007-10-26 18:52 UTC (permalink / raw)
To: Eric W. Biederman
Cc: Ingo Molnar, Thomas Gleixner, H. Peter Anvin, Jeremy Fitzhardinge,
Rusty Russell, Vivek Goyal, James Bottomley, Zachary Amsden,
Andi Kleen, linux-kernel, Andrew Morton
Eric W. Biederman wrote:
> 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.
>
Ack. I was planning on sending this patch out today...
J
> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
> Cc: Jeremy Fitzhardinge <jeremy@xensource.com>
> Cc: Rusty Russell <rusty@rustcorp.com.au>
> Cc: H. Peter Anvin <hpa@zytor.com>
> 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>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@elte.hu>
> ---
> arch/x86/boot/compressed/head_32.S | 12 ++++--------
> arch/x86/boot/compressed/head_64.S | 7 +++++++
> arch/x86/kernel/asm-offsets_64.c | 10 ++++++++++
> 3 files changed, 21 insertions(+), 8 deletions(-)
>
> diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
> index a0ae2e7..036e635 100644
> --- a/arch/x86/boot/compressed/head_32.S
> +++ b/arch/x86/boot/compressed/head_32.S
> @@ -33,24 +33,20 @@
> .globl startup_32
>
> startup_32:
> - /* check to see if KEEP_SEGMENTS flag is meaningful */
> - cmpw $0x207, BP_version(%esi)
> - jb 1f
> -
> + cld
> /* test KEEP_SEGMENTS flag to see if the bootloader is asking
> * us to not reload segments */
> testb $(1<<6), BP_loadflags(%esi)
> - jnz 2f
> + jnz 1f
>
> -1: cli
> + cli
> movl $(__BOOT_DS),%eax
> movl %eax,%ds
> movl %eax,%es
> movl %eax,%fs
> movl %eax,%gs
> movl %eax,%ss
> -
> -2: cld
> +1:
>
> /* Calculate the delta between where we were compiled to run
> * at and where we were actually loaded at. This can only be done
> diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
> index 4946764..1ccb38a 100644
> --- a/arch/x86/boot/compressed/head_64.S
> +++ b/arch/x86/boot/compressed/head_64.S
> @@ -29,6 +29,7 @@
> #include <asm/pgtable.h>
> #include <asm/page.h>
> #include <asm/msr.h>
> +#include <asm/asm-offsets.h>
>
> .section ".text.head"
> .code32
> @@ -36,11 +37,17 @@
>
> startup_32:
> 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
> movl $(__KERNEL_DS), %eax
> movl %eax, %ds
> movl %eax, %es
> movl %eax, %ss
> +1:
>
> /* Calculate the delta between where we were compiled to run
> * at and where we were actually loaded at. This can only be done
> diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
> index 7e50bda..d1b6ed9 100644
> --- a/arch/x86/kernel/asm-offsets_64.c
> +++ b/arch/x86/kernel/asm-offsets_64.c
> @@ -15,12 +15,16 @@
> #include <asm/segment.h>
> #include <asm/thread_info.h>
> #include <asm/ia32.h>
> +#include <asm/bootparam.h>
>
> #define DEFINE(sym, val) \
> asm volatile("\n->" #sym " %0 " #val : : "i" (val))
>
> #define BLANK() asm volatile("\n->" : : )
>
> +#define OFFSET(sym, str, mem) \
> + DEFINE(sym, offsetof(struct str, mem))
> +
> #define __NO_STUBS 1
> #undef __SYSCALL
> #undef _ASM_X86_64_UNISTD_H_
> @@ -109,5 +113,11 @@ int main(void)
> DEFINE(crypto_tfm_ctx_offset, offsetof(struct crypto_tfm, __crt_ctx));
> BLANK();
> 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;
> }
>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] x86: Fix boot protocol KEEP_SEGMENTS check.
2007-10-26 17:29 [PATCH] x86: Fix boot protocol KEEP_SEGMENTS check Eric W. Biederman
2007-10-26 17:59 ` H. Peter Anvin
2007-10-26 18:52 ` Jeremy Fitzhardinge
@ 2007-10-26 19:40 ` H. Peter Anvin
2007-10-31 0:49 ` Rusty Russell
3 siblings, 0 replies; 7+ messages in thread
From: H. Peter Anvin @ 2007-10-26 19:40 UTC (permalink / raw)
To: Eric W. Biederman
Cc: Ingo Molnar, Thomas Gleixner, Jeremy Fitzhardinge, Rusty Russell,
Vivek Goyal, James Bottomley, Zachary Amsden, Andi Kleen,
linux-kernel, Andrew Morton
Eric W. Biederman wrote:
> 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: Eric W. Biederman <ebiederm@xmission.com>
> Cc: Jeremy Fitzhardinge <jeremy@xensource.com>
> Cc: Rusty Russell <rusty@rustcorp.com.au>
> Cc: H. Peter Anvin <hpa@zytor.com>
> 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>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@elte.hu>
Btw, Acked-by: H. Peter Anvin <hpa@zytor.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] x86: Fix boot protocol KEEP_SEGMENTS check.
2007-10-26 17:29 [PATCH] x86: Fix boot protocol KEEP_SEGMENTS check Eric W. Biederman
` (2 preceding siblings ...)
2007-10-26 19:40 ` H. Peter Anvin
@ 2007-10-31 0:49 ` Rusty Russell
2007-10-31 1:10 ` Jeremy Fitzhardinge
3 siblings, 1 reply; 7+ messages in thread
From: Rusty Russell @ 2007-10-31 0:49 UTC (permalink / raw)
To: Eric W. Biederman
Cc: Ingo Molnar, Thomas Gleixner, H. Peter Anvin, Jeremy Fitzhardinge,
Vivek Goyal, James Bottomley, Zachary Amsden, Andi Kleen,
linux-kernel, Andrew Morton
On Saturday 27 October 2007 03:29:04 Eric W. Biederman wrote:
> 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.
OK, I'm completely confused, so this is probably a v. dumb question. Doesn't
this boot header come from the boot loader?
Rusty.
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] x86: Fix boot protocol KEEP_SEGMENTS check.
2007-10-31 0:49 ` Rusty Russell
@ 2007-10-31 1:10 ` Jeremy Fitzhardinge
0 siblings, 0 replies; 7+ messages in thread
From: Jeremy Fitzhardinge @ 2007-10-31 1:10 UTC (permalink / raw)
To: Rusty Russell
Cc: Eric W. Biederman, Ingo Molnar, Thomas Gleixner, H. Peter Anvin,
Vivek Goyal, James Bottomley, Zachary Amsden, Andi Kleen,
linux-kernel, Andrew Morton
Rusty Russell wrote:
> On Saturday 27 October 2007 03:29:04 Eric W. Biederman wrote:
>
>> 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.
>>
>
> OK, I'm completely confused, so this is probably a v. dumb question. Doesn't
> this boot header come from the boot loader?
No, other way around. It the kernel telling the bootloader "I
understand boot protocol X", and the bootloader makes sure it doesn't
fill out more than X allows. If the bootloader supports <X, then the
kernel's boot_params structure is pre-constructed with reasonable
default values.
J
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-10-31 1:10 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-26 17:29 [PATCH] x86: Fix boot protocol KEEP_SEGMENTS check Eric W. Biederman
2007-10-26 17:59 ` H. Peter Anvin
2007-10-26 18:22 ` Eric W. Biederman
2007-10-26 18:52 ` Jeremy Fitzhardinge
2007-10-26 19:40 ` H. Peter Anvin
2007-10-31 0:49 ` Rusty Russell
2007-10-31 1:10 ` Jeremy Fitzhardinge
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).