[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 5/7] x86/kexec: Implement new EFI load types


  • To: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>, Kevin Lampis <kevin.lampis@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Thu, 18 Jun 2026 12:07:37 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DkHDYyG3+RCgBnflcpsFuZgibZJQsWct174RfB6FYx0=; b=ApmLb5UUOrZZ22OV6ERj5mHr3pYeSQmLgWBc6eXgYByI9CWezRFg4YWSq4x6RbYGI+7TlvNE/cuZUQRA+hoKJGGVIpTxsy2GEhnxkN+/Pi7PICuBOCGFqB+YNLno+FBzvUWswneUriAAQpN+Pfow4tChei0dJhkc2iL1OMMY8b0bHtgU8MnohZzv9jMEd3xFcdVJzEiIIpM8q9g79I0WYQGZA8duD2rCypp2XDH/7WgYUKI1X3SZOVYDveXs21YWbHVj4l+dn9QaYcI6QgwNhdn4a/mWQbq2OgrT0i+Da+rhgmYwwuX5uFyiM61zEIt4A4jQouioadipsruDzMRJMw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dRxU1CpOIBF4Rbpa0DPx4QuaeS/vZeRvLB3XdYVRlzsMV1GNh9EJsPJ+/JSdCc5n0iZOMWA+6V7+v7NELRhRR9j/IbuEui1disD4eyNpfsY2OV9UnHWICozFYWsvC1q30riQcFNeqQrS4WMzGSx53o1ESA6P4NwLTR4zbdzFWfNWMSZouK69sCh/NOKrgCBWLIWoot4ZV/K+tmHhiQSpPGY8xlbiCLlkF0U26TxoikS5/6nuXNFnpUlK1LnavP3pS/GQ42qgT4G+gqJDbEPcTIZQnTxYxrOkcOwxdhmJ9UnMdawgL2dZ+iOsYHcxccYwaw9QjYHxyTu3DRJAx6Jsng==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Autocrypt: addr=andrew.cooper3@xxxxxxxxxx; keydata= xsFNBFLhNn8BEADVhE+Hb8i0GV6mihnnr/uiQQdPF8kUoFzCOPXkf7jQ5sLYeJa0cQi6Penp VtiFYznTairnVsN5J+ujSTIb+OlMSJUWV4opS7WVNnxHbFTPYZVQ3erv7NKc2iVizCRZ2Kxn srM1oPXWRic8BIAdYOKOloF2300SL/bIpeD+x7h3w9B/qez7nOin5NzkxgFoaUeIal12pXSR Q354FKFoy6Vh96gc4VRqte3jw8mPuJQpfws+Pb+swvSf/i1q1+1I4jsRQQh2m6OTADHIqg2E ofTYAEh7R5HfPx0EXoEDMdRjOeKn8+vvkAwhviWXTHlG3R1QkbE5M/oywnZ83udJmi+lxjJ5 YhQ5IzomvJ16H0Bq+TLyVLO/VRksp1VR9HxCzItLNCS8PdpYYz5TC204ViycobYU65WMpzWe LFAGn8jSS25XIpqv0Y9k87dLbctKKA14Ifw2kq5OIVu2FuX+3i446JOa2vpCI9GcjCzi3oHV e00bzYiHMIl0FICrNJU0Kjho8pdo0m2uxkn6SYEpogAy9pnatUlO+erL4LqFUO7GXSdBRbw5 gNt25XTLdSFuZtMxkY3tq8MFss5QnjhehCVPEpE6y9ZjI4XB8ad1G4oBHVGK5L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usyhbZrI0U9tJ B8WrhBLXDiYlyJT6zOV2yZFuW47VrLsjYnHwn27hmxTC/7tvG3euCklmkn9Sl9IAKFu29RSo d5bD8kMSCYsTqtTfT6W4A3qHGvIDta3ptLYpIAOD2sY3GYq2nf3Bbzx81wZK14JdDDHUX2Rs 6+ahAA==
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, "jbeulich@xxxxxxxx" <jbeulich@xxxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>, Gerald Elder-Vass <gerald.elder-vass@xxxxxxxxx>
  • Delivery-date: Thu, 18 Jun 2026 11:07:59 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 16/06/2026 11:06 am, Ross Lagerwall wrote:
> On 6/15/26 8:34 PM, Kevin Lampis wrote:
>>> Ok, so here is startup_64, hidden as a magic constant.
>>> ... you're applying the alignment to the pointer and picking
>>> startup_64 out of thin air.
>>
>> I'm going to be cheeky and play the Linux-does-it-too card.
>> https://github.com/torvalds/linux/blob/master/arch/x86/kernel/kexec-
>> bzimage64.c#L660
>>
>>> Either it was loaded correctly (and the alignment is correct), or it was
>>> loaded incorrectly and this is unsafe to do, is it not?
>>
>> This is what the kernel kexec segment looks like in memory
>>
>>                                            .- dest_maddr + alignment
>>     .-dest_maddr                           |
>>     v                                      v
>>     +--------------------------------------+--------------------...
>>     | padding            | real-mode setup | kernel
>>     +--------------------------------------+--------------------...
>> 0x000000                               0x200000


By "real mode setup", for the purposes here that's the PE+/bzImage64
polygot header?

Where does the (hypercall) segment start point?  Surely at the start of
the PE+/bzImage64 header?

>> In the old non-EFI kexec the 16-bit real-mode setup portion is
>> chopped off by the userspace tools and the segment buffer that Xen
>> receives is just the "kernel" part. But we need to pass both the
>> real-mode setup + kernel to kexec_load to pass Secure Boot
>> verification. And add padding so it straddles a 2M boundary like this.
>>
>> What the 0x200000 "alignment" variable is doing is skipping over the
>> real-mode setup and padding.
>>
>> It won't necessarily be 0x200000 though which is why we need to read
>> the value from Linux's setup_header->kernel_alignment.


What is necessary is that the segment dest_maddr is chosen such that the
start of the embedded kernel has correct alignment in the eventual
identity map.  This property is either true or it's not, and there
shouldn't be a round() calculation required to generate the entrypoint.


>>
>> If you're hinting that perhaps userspace should take care of all this
>> and just tell Xen where startup_64 is then perhaps. That would be a
>> bigger change we need to get input from Ross on though.
>>
> 
> It was done in Xen because there was a concern that letting userspace
> pass in an arbitrary start address would potentially allow a Secure Boot
> bypass even if it restricted within the bounds of the kernel image.
> 
> The patch should probably make it clear that this load type _only_ works
> for Linux bzImages using the x86 64-bit boot protocol documented at
> linux/Documentation/arch/x86/boot.rst. I think it needs sanity checks as
> well to ensure that it has actually been given an x86 bzImage and that
> the boot protocol version number is as expected.
> 
> Since it is x86 specific, maybe it wants to move out of common code?

Yes, that's where we're going, but the constraints need understanding first.

The old load types had nothing really architecture specific in it.  It
was a bunch of bytes, and an arbitrary point to jump to.

With this new "EFI" load type, we've got structural information.  We
don't need userspace to pass in a starting point because we can locate
it ourselves.

We do want to restrict it to a valid PE+(x86_64)/bzImage64 polygot, and
this will require arch specific functions to decide whether we like the
image, and to figure out the entrypoint.

~Andrew



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.