linux-efi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* EFI mode after running kexec
@ 2013-08-29  2:26 Greg KH
       [not found] ` <20130829022632.GA26862-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Greg KH @ 2013-08-29  2:26 UTC (permalink / raw)
  To: linux-efi-u79uwXL29TY76Z2rM5mHXA

Hi all,

I've been messing with UEFI booting a kernel and then later on, using
kexec to boot another kernel, and noticed that the kexec'ed kernel is
not really in EFI mode, although the EFI framebuffer seems present and
able to be used.

Is this to be expected?  I'd think that the EFI framebuffer wouldn't be
around anymore.  Odds are this is a BIOS bug, given that the machine I'm
using is a really old UEFI mode (i.e. before secure boot mode ever
showed up), but should it work this way?

And, to get kexec to run the kernel in EFI mode, would require kexec to
treat the kernel as a EFI binary and run it that way, instead of the
"normal" way it currently is, right?

thanks,

greg k-h

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

* Re: EFI mode after running kexec
       [not found] ` <20130829022632.GA26862-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
@ 2013-08-29 12:18   ` Josh Boyer
       [not found]     ` <CA+5PVA7jec5DAxgKachkBw1VFobz4rVMQwcqzYQ7ynk7=+d+zg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Josh Boyer @ 2013-08-29 12:18 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

On Wed, Aug 28, 2013 at 10:26 PM, Greg KH <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org> wrote:
> Hi all,
>
> I've been messing with UEFI booting a kernel and then later on, using
> kexec to boot another kernel, and noticed that the kexec'ed kernel is
> not really in EFI mode, although the EFI framebuffer seems present and
> able to be used.
>
> Is this to be expected?  I'd think that the EFI framebuffer wouldn't be
> around anymore.  Odds are this is a BIOS bug, given that the machine I'm
> using is a really old UEFI mode (i.e. before secure boot mode ever
> showed up), but should it work this way?

AFAIK, it's to be expected at this point.  kexec doesn't work as it
should with UEFI.  I believe Matthew and/or Matt can elaborate
further, but it has to do with only being able to call
ExitBootServices once and providing mappings to the UEFI Runtime
services functions.

> And, to get kexec to run the kernel in EFI mode, would require kexec to
> treat the kernel as a EFI binary and run it that way, instead of the
> "normal" way it currently is, right?

I think so.

josh

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

* Re: EFI mode after running kexec
       [not found]     ` <CA+5PVA7jec5DAxgKachkBw1VFobz4rVMQwcqzYQ7ynk7=+d+zg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2013-08-29 12:35       ` James Bottomley
  2013-08-29 19:20         ` Greg KH
  2013-08-29 19:15       ` Greg KH
  1 sibling, 1 reply; 10+ messages in thread
From: James Bottomley @ 2013-08-29 12:35 UTC (permalink / raw)
  To: Josh Boyer; +Cc: Greg KH, linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

On Thu, 2013-08-29 at 08:18 -0400, Josh Boyer wrote:
> On Wed, Aug 28, 2013 at 10:26 PM, Greg KH <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org> wrote:
> > Hi all,
> >
> > I've been messing with UEFI booting a kernel and then later on, using
> > kexec to boot another kernel, and noticed that the kexec'ed kernel is
> > not really in EFI mode, although the EFI framebuffer seems present and
> > able to be used.
> >
> > Is this to be expected?  I'd think that the EFI framebuffer wouldn't be
> > around anymore.  Odds are this is a BIOS bug, given that the machine I'm
> > using is a really old UEFI mode (i.e. before secure boot mode ever
> > showed up), but should it work this way?
> 
> AFAIK, it's to be expected at this point.  kexec doesn't work as it
> should with UEFI.  I believe Matthew and/or Matt can elaborate
> further, but it has to do with only being able to call
> ExitBootServices once and providing mappings to the UEFI Runtime
> services functions.

There's also the SetVirtualAddressMap() problem ...

> > And, to get kexec to run the kernel in EFI mode, would require kexec to
> > treat the kernel as a EFI binary and run it that way, instead of the
> > "normal" way it currently is, right?
> 
> I think so.

There are two ways we boot a kernel in EFI mode: one is with
BootServices intact (because the bootloader didn't call
ExitBootServices()) which is becoming more common and the other with
only RunTime Services.  The best that can be hoped for in kexec is the
latter, since it's practically impossible to reinitialise the
BootServices once they've been trashed.

James

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

* Re: EFI mode after running kexec
       [not found]     ` <CA+5PVA7jec5DAxgKachkBw1VFobz4rVMQwcqzYQ7ynk7=+d+zg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2013-08-29 12:35       ` James Bottomley
@ 2013-08-29 19:15       ` Greg KH
       [not found]         ` <20130829191543.GA11624-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
  1 sibling, 1 reply; 10+ messages in thread
From: Greg KH @ 2013-08-29 19:15 UTC (permalink / raw)
  To: Josh Boyer; +Cc: linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

On Thu, Aug 29, 2013 at 08:18:39AM -0400, Josh Boyer wrote:
> On Wed, Aug 28, 2013 at 10:26 PM, Greg KH <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org> wrote:
> > Hi all,
> >
> > I've been messing with UEFI booting a kernel and then later on, using
> > kexec to boot another kernel, and noticed that the kexec'ed kernel is
> > not really in EFI mode, although the EFI framebuffer seems present and
> > able to be used.
> >
> > Is this to be expected?  I'd think that the EFI framebuffer wouldn't be
> > around anymore.  Odds are this is a BIOS bug, given that the machine I'm
> > using is a really old UEFI mode (i.e. before secure boot mode ever
> > showed up), but should it work this way?
> 
> AFAIK, it's to be expected at this point.  kexec doesn't work as it
> should with UEFI.

How "should" it work?  It seems to boot a kernel just fine, although not
in EFI mode, which makes sense (I had forgotten about the BootServices
stuff.)

> I believe Matthew and/or Matt can elaborate further, but it has to do
> with only being able to call ExitBootServices once and providing
> mappings to the UEFI Runtime services functions.

That makes sense.

thanks,

greg k-h

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

* Re: EFI mode after running kexec
  2013-08-29 12:35       ` James Bottomley
@ 2013-08-29 19:20         ` Greg KH
       [not found]           ` <20130829192001.GB11624-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Greg KH @ 2013-08-29 19:20 UTC (permalink / raw)
  To: James Bottomley
  Cc: Josh Boyer, linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

On Thu, Aug 29, 2013 at 04:35:23PM +0400, James Bottomley wrote:
> On Thu, 2013-08-29 at 08:18 -0400, Josh Boyer wrote:
> > On Wed, Aug 28, 2013 at 10:26 PM, Greg KH <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org> wrote:
> > > Hi all,
> > >
> > > I've been messing with UEFI booting a kernel and then later on, using
> > > kexec to boot another kernel, and noticed that the kexec'ed kernel is
> > > not really in EFI mode, although the EFI framebuffer seems present and
> > > able to be used.
> > >
> > > Is this to be expected?  I'd think that the EFI framebuffer wouldn't be
> > > around anymore.  Odds are this is a BIOS bug, given that the machine I'm
> > > using is a really old UEFI mode (i.e. before secure boot mode ever
> > > showed up), but should it work this way?
> > 
> > AFAIK, it's to be expected at this point.  kexec doesn't work as it
> > should with UEFI.  I believe Matthew and/or Matt can elaborate
> > further, but it has to do with only being able to call
> > ExitBootServices once and providing mappings to the UEFI Runtime
> > services functions.
> 
> There's also the SetVirtualAddressMap() problem ...

Ugh, that would be a real mess...

> > > And, to get kexec to run the kernel in EFI mode, would require kexec to
> > > treat the kernel as a EFI binary and run it that way, instead of the
> > > "normal" way it currently is, right?
> > 
> > I think so.
> 
> There are two ways we boot a kernel in EFI mode: one is with
> BootServices intact (because the bootloader didn't call
> ExitBootServices()) which is becoming more common and the other with
> only RunTime Services.  The best that can be hoped for in kexec is the
> latter, since it's practically impossible to reinitialise the
> BootServices once they've been trashed.

So that would take some kexec work.  I'm currently working on xen
support in kexec, I'll add this to my "TODO" list for after that gets
done.

thanks,

greg k-h

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

* Re: EFI mode after running kexec
       [not found]         ` <20130829191543.GA11624-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
@ 2013-08-29 20:36           ` Josh Boyer
       [not found]             ` <CA+5PVA5PHc4vOcWwCgTHS=CP8oei-Jc5GK2dfi=EdD_wGVZpXQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Josh Boyer @ 2013-08-29 20:36 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

On Thu, Aug 29, 2013 at 3:15 PM, Greg KH <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org> wrote:
> On Thu, Aug 29, 2013 at 08:18:39AM -0400, Josh Boyer wrote:
>> On Wed, Aug 28, 2013 at 10:26 PM, Greg KH <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org> wrote:
>> > Hi all,
>> >
>> > I've been messing with UEFI booting a kernel and then later on, using
>> > kexec to boot another kernel, and noticed that the kexec'ed kernel is
>> > not really in EFI mode, although the EFI framebuffer seems present and
>> > able to be used.
>> >
>> > Is this to be expected?  I'd think that the EFI framebuffer wouldn't be
>> > around anymore.  Odds are this is a BIOS bug, given that the machine I'm
>> > using is a really old UEFI mode (i.e. before secure boot mode ever
>> > showed up), but should it work this way?
>>
>> AFAIK, it's to be expected at this point.  kexec doesn't work as it
>> should with UEFI.
>
> How "should" it work?  It seems to boot a kernel just fine, although not
> in EFI mode, which makes sense (I had forgotten about the BootServices
> stuff.)

Right, well in my ideal world if you kexec a kernel on a UEFI machine,
the resulting kernel is up and running as the previous kernel was.
Which is to say, it's in UEFI mode.

Maybe that's more hassle than it's worth but that was what I was
thinking when I said "should".  It may be possible to use a kexec'd
kernel as it boots today on these machines.  I believe the current
line of thought from the kdump people is that kdump kernels could
operate in this mode, for example.  That's a short-lived uptime and
scoped usecase though.

josh

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

* Re: EFI mode after running kexec
       [not found]             ` <CA+5PVA5PHc4vOcWwCgTHS=CP8oei-Jc5GK2dfi=EdD_wGVZpXQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2013-08-29 20:53               ` Greg KH
  0 siblings, 0 replies; 10+ messages in thread
From: Greg KH @ 2013-08-29 20:53 UTC (permalink / raw)
  To: Josh Boyer; +Cc: linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

On Thu, Aug 29, 2013 at 04:36:53PM -0400, Josh Boyer wrote:
> On Thu, Aug 29, 2013 at 3:15 PM, Greg KH <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org> wrote:
> > On Thu, Aug 29, 2013 at 08:18:39AM -0400, Josh Boyer wrote:
> >> On Wed, Aug 28, 2013 at 10:26 PM, Greg KH <gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org> wrote:
> >> > Hi all,
> >> >
> >> > I've been messing with UEFI booting a kernel and then later on, using
> >> > kexec to boot another kernel, and noticed that the kexec'ed kernel is
> >> > not really in EFI mode, although the EFI framebuffer seems present and
> >> > able to be used.
> >> >
> >> > Is this to be expected?  I'd think that the EFI framebuffer wouldn't be
> >> > around anymore.  Odds are this is a BIOS bug, given that the machine I'm
> >> > using is a really old UEFI mode (i.e. before secure boot mode ever
> >> > showed up), but should it work this way?
> >>
> >> AFAIK, it's to be expected at this point.  kexec doesn't work as it
> >> should with UEFI.
> >
> > How "should" it work?  It seems to boot a kernel just fine, although not
> > in EFI mode, which makes sense (I had forgotten about the BootServices
> > stuff.)
> 
> Right, well in my ideal world if you kexec a kernel on a UEFI machine,
> the resulting kernel is up and running as the previous kernel was.
> Which is to say, it's in UEFI mode.

I agree, that would be ideal.

> Maybe that's more hassle than it's worth but that was what I was
> thinking when I said "should".  It may be possible to use a kexec'd
> kernel as it boots today on these machines.  I believe the current
> line of thought from the kdump people is that kdump kernels could
> operate in this mode, for example.  That's a short-lived uptime and
> scoped usecase though.

For kdump, yes, but other people use kexec for "real" kernels.  Some
people use kexec as the bootloader itself, as that's the only way to
boot Linux on a platform, so they are not always short-lived at all.

thanks,

greg k-h

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

* Re: EFI mode after running kexec
       [not found]           ` <20130829192001.GB11624-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
@ 2013-08-30 16:44             ` H. Peter Anvin
       [not found]               ` <5220CBEE.20706-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: H. Peter Anvin @ 2013-08-30 16:44 UTC (permalink / raw)
  To: Greg KH
  Cc: James Bottomley, Josh Boyer,
	linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Borislav Petkov

On 08/29/2013 12:20 PM, Greg KH wrote:
>>
>> There's also the SetVirtualAddressMap() problem ...
> 
> Ugh, that would be a real mess...
> 

I and Borislav actually came up with a reasonable solution for SVAM().
It sadly creates a new ABI, but at least is (a) reasonable and (b) seems
to match Windows close enough.  Basically the regions should get mapped
one by one from -4 GB downwards.

	-hpa

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

* Re: EFI mode after running kexec
       [not found]               ` <5220CBEE.20706-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
@ 2013-08-31  4:52                 ` Borislav Petkov
       [not found]                   ` <20130831045244.GA12617-W2mmg7yuTz0QF/eBCRgRTA@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Borislav Petkov @ 2013-08-31  4:52 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Greg KH, James Bottomley, Josh Boyer,
	linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

On Fri, Aug 30, 2013 at 09:44:30AM -0700, H. Peter Anvin wrote:
> I and Borislav actually came up with a reasonable solution for SVAM().
> It sadly creates a new ABI, but at least is (a) reasonable and (b)
> seems to match Windows close enough. Basically the regions should get
> mapped one by one from -4 GB downwards.

Yep, and the mapping works both on OVMF and on my baremetal box. I'm
currently on vacation but will send out the final stuff when I get back.

Teaching the kexec-ed kernel to simply use those mappings *without*
doing SVAM() should be easy afterwards.

Thanks.

-- 
Regards/Gruss,
Boris.

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

* Re: EFI mode after running kexec
       [not found]                   ` <20130831045244.GA12617-W2mmg7yuTz0QF/eBCRgRTA@public.gmane.org>
@ 2013-08-31  4:59                     ` Greg KH
  0 siblings, 0 replies; 10+ messages in thread
From: Greg KH @ 2013-08-31  4:59 UTC (permalink / raw)
  To: Borislav Petkov
  Cc: H. Peter Anvin, James Bottomley, Josh Boyer,
	linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org

On Sat, Aug 31, 2013 at 06:52:44AM +0200, Borislav Petkov wrote:
> On Fri, Aug 30, 2013 at 09:44:30AM -0700, H. Peter Anvin wrote:
> > I and Borislav actually came up with a reasonable solution for SVAM().
> > It sadly creates a new ABI, but at least is (a) reasonable and (b)
> > seems to match Windows close enough. Basically the regions should get
> > mapped one by one from -4 GB downwards.
> 
> Yep, and the mapping works both on OVMF and on my baremetal box. I'm
> currently on vacation but will send out the final stuff when I get back.
> 
> Teaching the kexec-ed kernel to simply use those mappings *without*
> doing SVAM() should be easy afterwards.

Ah, that sounds great, if you need me to test anything, just let me
know, I have some UEFI test boxes I've been working on here...

thanks,

greg k-h

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

end of thread, other threads:[~2013-08-31  4:59 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-29  2:26 EFI mode after running kexec Greg KH
     [not found] ` <20130829022632.GA26862-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2013-08-29 12:18   ` Josh Boyer
     [not found]     ` <CA+5PVA7jec5DAxgKachkBw1VFobz4rVMQwcqzYQ7ynk7=+d+zg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-08-29 12:35       ` James Bottomley
2013-08-29 19:20         ` Greg KH
     [not found]           ` <20130829192001.GB11624-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2013-08-30 16:44             ` H. Peter Anvin
     [not found]               ` <5220CBEE.20706-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
2013-08-31  4:52                 ` Borislav Petkov
     [not found]                   ` <20130831045244.GA12617-W2mmg7yuTz0QF/eBCRgRTA@public.gmane.org>
2013-08-31  4:59                     ` Greg KH
2013-08-29 19:15       ` Greg KH
     [not found]         ` <20130829191543.GA11624-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2013-08-29 20:36           ` Josh Boyer
     [not found]             ` <CA+5PVA5PHc4vOcWwCgTHS=CP8oei-Jc5GK2dfi=EdD_wGVZpXQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-08-29 20:53               ` Greg KH

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).