All of lore.kernel.org
 help / color / mirror / Atom feed
* [tip:x86/urgent] x86/boot: EFI_MIXED should not prohibit loading above 4G
       [not found] <1402140380-15377-1-git-send-email-matt@console-pimps.org>
@ 2014-06-07 16:33 ` tip-bot for Matt Fleming
  2014-06-09 12:54   ` Vivek Goyal
  1 sibling, 0 replies; 10+ messages in thread
From: tip-bot for Matt Fleming @ 2014-06-07 16:33 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, dyoung, tglx, vgoyal, matt.fleming

Commit-ID:  745c51673e289acf4d9ffc2835524de73ef923fd
Gitweb:     http://git.kernel.org/tip/745c51673e289acf4d9ffc2835524de73ef923fd
Author:     Matt Fleming <matt.fleming@intel.com>
AuthorDate: Sat, 7 Jun 2014 12:26:20 +0100
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Sat, 7 Jun 2014 09:31:00 -0700

x86/boot: EFI_MIXED should not prohibit loading above 4G

commit 7d453eee36ae ("x86/efi: Wire up CONFIG_EFI_MIXED") introduced a
regression for the functionality to load kernels above 4G. The relevant
(incorrect) reasoning behind this change can be seen in the commit
message,

  "The xloadflags field in the bzImage header is also updated to reflect
  that the kernel supports both entry points by setting both of
  XLF_EFI_HANDOVER_32 and XLF_EFI_HANDOVER_64 when CONFIG_EFI_MIXED=y.
  XLF_CAN_BE_LOADED_ABOVE_4G is disabled so that the kernel text is
  guaranteed to be addressable with 32-bits."

This is obviously bogus since 32-bit EFI loaders will never place the
kernel above the 4G mark. So this restriction is entirely unnecessary.

But things are worse than that - since we want to encourage people to
always compile with CONFIG_EFI_MIXED=y so that their kernels work out of
the box for both 32-bit and 64-bit firmware, commit 7d453eee36ae
effectively disables XLF_CAN_BE_LOADED_ABOVE_4G completely.

Remove the overzealous and superfluous restriction and restore the
XLF_CAN_BE_LOADED_ABOVE_4G functionality.

Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Link: http://lkml.kernel.org/r/1402140380-15377-1-git-send-email-matt@console-pimps.org
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
---
 arch/x86/boot/header.S | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
index 0ca9a5c..84c2234 100644
--- a/arch/x86/boot/header.S
+++ b/arch/x86/boot/header.S
@@ -375,8 +375,7 @@ xloadflags:
 # define XLF0 0
 #endif
 
-#if defined(CONFIG_RELOCATABLE) && defined(CONFIG_X86_64) && \
-	!defined(CONFIG_EFI_MIXED)
+#if defined(CONFIG_RELOCATABLE) && defined(CONFIG_X86_64)
    /* kernel/boot_param/ramdisk could be loaded above 4g */
 # define XLF1 XLF_CAN_BE_LOADED_ABOVE_4G
 #else

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/boot: EFI_MIXED should not prohibit loading above 4G
@ 2014-06-09 12:54   ` Vivek Goyal
  0 siblings, 0 replies; 10+ messages in thread
From: Vivek Goyal @ 2014-06-09 12:54 UTC (permalink / raw)
  To: Matt Fleming
  Cc: H. Peter Anvin, linux-kernel, linux-efi, Matt Fleming, Dave Young

On Sat, Jun 07, 2014 at 12:26:20PM +0100, Matt Fleming wrote:
> From: Matt Fleming <matt.fleming@intel.com>
> 
> commit 7d453eee36ae ("x86/efi: Wire up CONFIG_EFI_MIXED") introduced a
> regression for the functionality to load kernels above 4G. The relevant
> (incorrect) reasoning behind this change can be seen in the commit
> message,
> 
>   "The xloadflags field in the bzImage header is also updated to reflect
>   that the kernel supports both entry points by setting both of
>   XLF_EFI_HANDOVER_32 and XLF_EFI_HANDOVER_64 when CONFIG_EFI_MIXED=y.
>   XLF_CAN_BE_LOADED_ABOVE_4G is disabled so that the kernel text is
>   guaranteed to be addressable with 32-bits."
> 
> This is obviously bogus since 32-bit EFI loaders will never place the
> kernel above the 4G mark. So this restriction is entirely unnecessary.

Hi Matt,

So with new kexec syscall I have written 64bit bzImage loader. For now
I would like to detect this situation and disable loading and once
32bit loader gets implemented it can take care of loading bzImage below
4G.

So how do I find out if EFI is 32bit.

Thanks
Vivek

> 
> But things are worse than that - since we want to encourage people to
> always compile with CONFIG_EFI_MIXED=y so that their kernels work out of
> the box for both 32-bit and 64-bit firmware, commit 7d453eee36ae
> effectively disables XLF_CAN_BE_LOADED_ABOVE_4G completely.
> 
> Remove the overzealous and superfluous restriction and restore the
> XLF_CAN_BE_LOADED_ABOVE_4G functionality.
> 
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Cc: Dave Young <dyoung@redhat.com>
> Cc: Vivek Goyal <vgoyal@redhat.com>
> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
> ---
> 
> Peter, I realise that we're right on the edge of the v3.15 release here,
> so this probably needs marking for stable (it only affects v3.15).
> 
>  arch/x86/boot/header.S | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
> index 0ca9a5c362bc..84c223479e3c 100644
> --- a/arch/x86/boot/header.S
> +++ b/arch/x86/boot/header.S
> @@ -375,8 +375,7 @@ xloadflags:
>  # define XLF0 0
>  #endif
>  
> -#if defined(CONFIG_RELOCATABLE) && defined(CONFIG_X86_64) && \
> -	!defined(CONFIG_EFI_MIXED)
> +#if defined(CONFIG_RELOCATABLE) && defined(CONFIG_X86_64)
>     /* kernel/boot_param/ramdisk could be loaded above 4g */
>  # define XLF1 XLF_CAN_BE_LOADED_ABOVE_4G
>  #else
> -- 
> 1.9.0

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/boot: EFI_MIXED should not prohibit loading above 4G
@ 2014-06-09 12:54   ` Vivek Goyal
  0 siblings, 0 replies; 10+ messages in thread
From: Vivek Goyal @ 2014-06-09 12:54 UTC (permalink / raw)
  To: Matt Fleming
  Cc: H. Peter Anvin, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-efi-u79uwXL29TY76Z2rM5mHXA, Matt Fleming, Dave Young

On Sat, Jun 07, 2014 at 12:26:20PM +0100, Matt Fleming wrote:
> From: Matt Fleming <matt.fleming-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> 
> commit 7d453eee36ae ("x86/efi: Wire up CONFIG_EFI_MIXED") introduced a
> regression for the functionality to load kernels above 4G. The relevant
> (incorrect) reasoning behind this change can be seen in the commit
> message,
> 
>   "The xloadflags field in the bzImage header is also updated to reflect
>   that the kernel supports both entry points by setting both of
>   XLF_EFI_HANDOVER_32 and XLF_EFI_HANDOVER_64 when CONFIG_EFI_MIXED=y.
>   XLF_CAN_BE_LOADED_ABOVE_4G is disabled so that the kernel text is
>   guaranteed to be addressable with 32-bits."
> 
> This is obviously bogus since 32-bit EFI loaders will never place the
> kernel above the 4G mark. So this restriction is entirely unnecessary.

Hi Matt,

So with new kexec syscall I have written 64bit bzImage loader. For now
I would like to detect this situation and disable loading and once
32bit loader gets implemented it can take care of loading bzImage below
4G.

So how do I find out if EFI is 32bit.

Thanks
Vivek

> 
> But things are worse than that - since we want to encourage people to
> always compile with CONFIG_EFI_MIXED=y so that their kernels work out of
> the box for both 32-bit and 64-bit firmware, commit 7d453eee36ae
> effectively disables XLF_CAN_BE_LOADED_ABOVE_4G completely.
> 
> Remove the overzealous and superfluous restriction and restore the
> XLF_CAN_BE_LOADED_ABOVE_4G functionality.
> 
> Cc: "H. Peter Anvin" <hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
> Cc: Dave Young <dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> Cc: Vivek Goyal <vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> Signed-off-by: Matt Fleming <matt.fleming-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> ---
> 
> Peter, I realise that we're right on the edge of the v3.15 release here,
> so this probably needs marking for stable (it only affects v3.15).
> 
>  arch/x86/boot/header.S | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
> index 0ca9a5c362bc..84c223479e3c 100644
> --- a/arch/x86/boot/header.S
> +++ b/arch/x86/boot/header.S
> @@ -375,8 +375,7 @@ xloadflags:
>  # define XLF0 0
>  #endif
>  
> -#if defined(CONFIG_RELOCATABLE) && defined(CONFIG_X86_64) && \
> -	!defined(CONFIG_EFI_MIXED)
> +#if defined(CONFIG_RELOCATABLE) && defined(CONFIG_X86_64)
>     /* kernel/boot_param/ramdisk could be loaded above 4g */
>  # define XLF1 XLF_CAN_BE_LOADED_ABOVE_4G
>  #else
> -- 
> 1.9.0

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/boot: EFI_MIXED should not prohibit loading above 4G
  2014-06-09 12:54   ` Vivek Goyal
  (?)
@ 2014-06-09 13:18   ` Matt Fleming
  2014-06-09 14:15       ` Vivek Goyal
  -1 siblings, 1 reply; 10+ messages in thread
From: Matt Fleming @ 2014-06-09 13:18 UTC (permalink / raw)
  To: Vivek Goyal; +Cc: H. Peter Anvin, LKML, linux-efi, Matt Fleming, Dave Young

On 9 June 2014 13:54, Vivek Goyal <vgoyal@redhat.com> wrote:
> Hi Matt,
>
> So with new kexec syscall I have written 64bit bzImage loader. For now
> I would like to detect this situation and disable loading and once
> 32bit loader gets implemented it can take care of loading bzImage below
> 4G.

What situation do you want to detect? You want to detect when it's
impossible to load a kernel above 4G in the kexec path because you're
booting with 32-bit EFI firmware?

> So how do I find out if EFI is 32bit.

efi_enabled(EFI_64BIT) will tell you that, but you probably also want
to check that EFI runtime services are actually usable with
efi_enabled(EFI_RUNTIME_SERVICES) since if they're not, you'll never
call into the firmware so it doesn't matter where you load the kernel
(this may happen with "noefi" kernel parameter).

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/boot: EFI_MIXED should not prohibit loading above 4G
@ 2014-06-09 14:15       ` Vivek Goyal
  0 siblings, 0 replies; 10+ messages in thread
From: Vivek Goyal @ 2014-06-09 14:15 UTC (permalink / raw)
  To: Matt Fleming; +Cc: H. Peter Anvin, LKML, linux-efi, Matt Fleming, Dave Young

On Mon, Jun 09, 2014 at 02:18:54PM +0100, Matt Fleming wrote:
> On 9 June 2014 13:54, Vivek Goyal <vgoyal@redhat.com> wrote:
> > Hi Matt,
> >
> > So with new kexec syscall I have written 64bit bzImage loader. For now
> > I would like to detect this situation and disable loading and once
> > 32bit loader gets implemented it can take care of loading bzImage below
> > 4G.
> 
> What situation do you want to detect? You want to detect when it's
> impossible to load a kernel above 4G in the kexec path because you're
> booting with 32-bit EFI firmware?

Yes.

> 
> > So how do I find out if EFI is 32bit.
> 
> efi_enabled(EFI_64BIT) will tell you that, but you probably also want
> to check that EFI runtime services are actually usable with
> efi_enabled(EFI_RUNTIME_SERVICES) since if they're not, you'll never
> call into the firmware so it doesn't matter where you load the kernel
> (this may happen with "noefi" kernel parameter).

Ok, thanks. Or I can check whether EFI run time map is there or not. I am
assuming that efi runtime services are not enabled, then run time map
will not be there either.

Thanks
Vivek

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/boot: EFI_MIXED should not prohibit loading above 4G
@ 2014-06-09 14:15       ` Vivek Goyal
  0 siblings, 0 replies; 10+ messages in thread
From: Vivek Goyal @ 2014-06-09 14:15 UTC (permalink / raw)
  To: Matt Fleming
  Cc: H. Peter Anvin, LKML, linux-efi-u79uwXL29TY76Z2rM5mHXA,
	Matt Fleming, Dave Young

On Mon, Jun 09, 2014 at 02:18:54PM +0100, Matt Fleming wrote:
> On 9 June 2014 13:54, Vivek Goyal <vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
> > Hi Matt,
> >
> > So with new kexec syscall I have written 64bit bzImage loader. For now
> > I would like to detect this situation and disable loading and once
> > 32bit loader gets implemented it can take care of loading bzImage below
> > 4G.
> 
> What situation do you want to detect? You want to detect when it's
> impossible to load a kernel above 4G in the kexec path because you're
> booting with 32-bit EFI firmware?

Yes.

> 
> > So how do I find out if EFI is 32bit.
> 
> efi_enabled(EFI_64BIT) will tell you that, but you probably also want
> to check that EFI runtime services are actually usable with
> efi_enabled(EFI_RUNTIME_SERVICES) since if they're not, you'll never
> call into the firmware so it doesn't matter where you load the kernel
> (this may happen with "noefi" kernel parameter).

Ok, thanks. Or I can check whether EFI run time map is there or not. I am
assuming that efi runtime services are not enabled, then run time map
will not be there either.

Thanks
Vivek

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/boot: EFI_MIXED should not prohibit loading above 4G
@ 2014-06-09 14:25         ` Matt Fleming
  0 siblings, 0 replies; 10+ messages in thread
From: Matt Fleming @ 2014-06-09 14:25 UTC (permalink / raw)
  To: Vivek Goyal; +Cc: H. Peter Anvin, LKML, linux-efi, Matt Fleming, Dave Young

On Mon, 09 Jun, at 10:15:12AM, Vivek Goyal wrote:
> 
> Ok, thanks. Or I can check whether EFI run time map is there or not. I am
> assuming that efi runtime services are not enabled, then run time map
> will not be there either.

Yes, if runtime services are unavailable then the runtime map will not
be exported.

Now, you can check for the presence of the runtime map from userland but
please don't use that as your check inside the kernel - this is exactly
what efi_enabled() is for.

-- 
Matt Fleming, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/boot: EFI_MIXED should not prohibit loading above 4G
@ 2014-06-09 14:25         ` Matt Fleming
  0 siblings, 0 replies; 10+ messages in thread
From: Matt Fleming @ 2014-06-09 14:25 UTC (permalink / raw)
  To: Vivek Goyal
  Cc: H. Peter Anvin, LKML, linux-efi-u79uwXL29TY76Z2rM5mHXA,
	Matt Fleming, Dave Young

On Mon, 09 Jun, at 10:15:12AM, Vivek Goyal wrote:
> 
> Ok, thanks. Or I can check whether EFI run time map is there or not. I am
> assuming that efi runtime services are not enabled, then run time map
> will not be there either.

Yes, if runtime services are unavailable then the runtime map will not
be exported.

Now, you can check for the presence of the runtime map from userland but
please don't use that as your check inside the kernel - this is exactly
what efi_enabled() is for.

-- 
Matt Fleming, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/boot: EFI_MIXED should not prohibit loading above 4G
@ 2014-06-09 14:32           ` Vivek Goyal
  0 siblings, 0 replies; 10+ messages in thread
From: Vivek Goyal @ 2014-06-09 14:32 UTC (permalink / raw)
  To: Matt Fleming; +Cc: H. Peter Anvin, LKML, linux-efi, Matt Fleming, Dave Young

On Mon, Jun 09, 2014 at 03:25:59PM +0100, Matt Fleming wrote:
> On Mon, 09 Jun, at 10:15:12AM, Vivek Goyal wrote:
> > 
> > Ok, thanks. Or I can check whether EFI run time map is there or not. I am
> > assuming that efi runtime services are not enabled, then run time map
> > will not be there either.
> 
> Yes, if runtime services are unavailable then the runtime map will not
> be exported.
> 
> Now, you can check for the presence of the runtime map from userland but
> please don't use that as your check inside the kernel - this is exactly
> what efi_enabled() is for.

Ok, I will use efi_enabled() instead.

Thanks
Vivek

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] x86/boot: EFI_MIXED should not prohibit loading above 4G
@ 2014-06-09 14:32           ` Vivek Goyal
  0 siblings, 0 replies; 10+ messages in thread
From: Vivek Goyal @ 2014-06-09 14:32 UTC (permalink / raw)
  To: Matt Fleming
  Cc: H. Peter Anvin, LKML, linux-efi-u79uwXL29TY76Z2rM5mHXA,
	Matt Fleming, Dave Young

On Mon, Jun 09, 2014 at 03:25:59PM +0100, Matt Fleming wrote:
> On Mon, 09 Jun, at 10:15:12AM, Vivek Goyal wrote:
> > 
> > Ok, thanks. Or I can check whether EFI run time map is there or not. I am
> > assuming that efi runtime services are not enabled, then run time map
> > will not be there either.
> 
> Yes, if runtime services are unavailable then the runtime map will not
> be exported.
> 
> Now, you can check for the presence of the runtime map from userland but
> please don't use that as your check inside the kernel - this is exactly
> what efi_enabled() is for.

Ok, I will use efi_enabled() instead.

Thanks
Vivek

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-06-09 14:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1402140380-15377-1-git-send-email-matt@console-pimps.org>
2014-06-07 16:33 ` [tip:x86/urgent] x86/boot: EFI_MIXED should not prohibit loading above 4G tip-bot for Matt Fleming
2014-06-09 12:54 ` [PATCH] " Vivek Goyal
2014-06-09 12:54   ` Vivek Goyal
2014-06-09 13:18   ` Matt Fleming
2014-06-09 14:15     ` Vivek Goyal
2014-06-09 14:15       ` Vivek Goyal
2014-06-09 14:25       ` Matt Fleming
2014-06-09 14:25         ` Matt Fleming
2014-06-09 14:32         ` Vivek Goyal
2014-06-09 14:32           ` Vivek Goyal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.