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

Re: [PATCH v3] Support ESRT in Xen dom0


  • To: Ard Biesheuvel <ardb@xxxxxxxxxx>, Demi Marie Obenour <demi@xxxxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 21 Sep 2022 22:34:04 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=tdxCv7mrQHXczZ8Wu54MQSZROOWZZozu5hVaJ4E5m38=; b=RbUYqbLQoeah0FY2vA6Hven5NF3/oZe9OdOLwoSnsE1PXnkJuQ2dCfgOj/KLdA/XgC1bskXvNv26RiLKbOeJTuXz5GTEV4zuwtIThIVNXneaVMKzbBorToLfg2ObAs2Yj1ie1T/l8E5oeB0lst3ldUp+mwivqFkPNhZSf2tpYHoMzc6Mr9xB5jPyjr2Gt368E4WZEwqPsfNkjthUoqlMPTe+fUo7dZltYr8x4LtrgIfNeRWwip7wpR10S1BoYPob7JbFmb0rrIc51OlIV7VI7AWAm0xRq5g/TsAggtLfCbtJw+1E4iumm2SzRNrsDE5zfoZhIdMCe77sJcSRKg/pkA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jG2aBLkuHhRFNtjfWnGtMcFiveh2BqS+QEg2imgRNrIpEUaDPerb50S8+k5qSWfXG3Ubt0dWQd45feXws/iR3wQhdDuNFmjebgMN0+S56mbHMN1Jaz4ZR2jiwjbqrIfQVNdpM76DQ+vpCVwYBovRMjtVzvKQD3IRa4o7p4CjLh3yyd0glLVOFqYd7Q8vm91UZge4tdmVVZdGL+ZUp5AOMGtQAAEyRnIN/AbI9p2wbJfgF1DJI70ZCEYNfDzFeGAm1KEbRf9v+yUiIaJMh9xM5yBbmj743RoxgbAfKlKGVxscV3Z6x4VSCTRKjTHyb8f3Ipe1oPG7JHy62PNDKNonUA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Juergen Gross <jgross@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>, linux-efi@xxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 21 Sep 2022 20:34:17 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 20.09.2022 18:09, Ard Biesheuvel wrote:
> On Tue, 20 Sept 2022 at 17:54, Jan Beulich <jbeulich@xxxxxxxx> wrote:
>>
>> On 20.09.2022 17:36, Ard Biesheuvel wrote:
>>> On Mon, 19 Sept 2022 at 21:33, Demi Marie Obenour
>>> <demi@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>>>>
>>>> fwupd requires access to the EFI System Resource Table (ESRT) to
>>>> discover which firmware can be updated by the OS.  Currently, Linux does
>>>> not expose the ESRT when running as a Xen dom0.  Therefore, it is not
>>>> possible to use fwupd in a Xen dom0, which is a serious problem for e.g.
>>>> Qubes OS.
>>>>
>>>> Before Xen 4.16, this was not fixable due to hypervisor limitations.
>>>> The UEFI specification requires the ESRT to be in EfiBootServicesData
>>>> memory, which Xen will use for whatever purposes it likes.  Therefore,
>>>> Linux cannot safely access the ESRT, as Xen may have overwritten it.
>>>>
>>>> Starting with Xen 4.17, Xen checks if the ESRT is in EfiBootServicesData
>>>> or EfiRuntimeServicesData memory.  If the ESRT is in EfiBootServicesData
>>>> memory, Xen allocates some memory of type EfiRuntimeServicesData, copies
>>>> the ESRT to it, and finally replaces the ESRT pointer with a pointer to
>>>> the copy.  Since Xen will not clobber EfiRuntimeServicesData memory,
>>>> this ensures that the ESRT can safely be accessed by the OS.  It is safe
>>>> to access the ESRT under Xen if, and only if, it is in memory of type
>>>> EfiRuntimeServicesData.
>>>>
>>>
>>> Thanks for the elaborate explanation. This is really helpful.
>>>
>>> So here, you are explaining that the only way for Xen to prevent
>>> itself from potentially clobbering the ESRT is by creating a
>>> completely new allocation?
>>
>> There are surely other ways, e.g. preserving BootServices* regions
>> alongside RuntimeServices* ones. But as the maintainer of the EFI
>> code in Xen I don't view this as a reasonable approach.
> 
> Why not?

Because it's against the intentions the EFI has (or at least had)
for this memory type. Much more than EfiAcpiReclaimMemory this
type is intended for use as ordinary RAM post-boot.

>>> TBH I still don't think this is a scalable approach. There are other
>>> configuration tables that may be passed in EFI boot services memory,
>>> and MS especially were pushing back in the UEFI forum on adding table
>>> types that were passed in anything other the EfiBootServicesData.
>>
>> Within Xen we might abstract the approach currently implemented in
>> case more such pieces of data appear.
>>
>> While I can easily believe MS might be advocating for this model,
>> I view it as problematic not only for Xen. How would you pass on
>> this information across kexec, for example, without introducing
>> further producer-consumer dependencies requiring separate protocols
>> to be followed?
>>
> 
> In this case, I don't think this is unreasonable for configuration
> tables, which only have a GUID and a base address. If the OS knows the
> GUID, and knows how to interpret the contents, it can decide for
> itself whether or not to preserve it. If it doesn't know the GUID, the
> memory is just treated as available memory [after EBS()]
> 
> I personally think reclaimable memory is more suitable for these
> cases, which is why I am willing to consider that as well. Note that
> the EFI spec now also mandates device trees on ARM to be passed via
> EfiAcpiReclaimMemory, simply because it is the memory type suitable
> for firmware tables that only the OS consumes.

We do preserve EfiAcpiReclaimMemory, for the simple reason that with
Xen "the OS" is ambiguous: Is that Xen or Dom0? Most of ACPI is
handled by Dom0, so we can't very well discard the data before Dom0
starts. (This then also matters for what you've said in the earlier
paragraph. In particular the sets of known GUIDs may be dissimilar
for Xen and the Dom0 kernel. Considering your other remark about
fragmentation you might agree that preserving in-place is not very
desirable.)

Especially with DT mandated to use EfiAcpiReclaimMemory I'm willing
to consider using that type for the storing of ESRT (and whatever
else may appear along these lines). Demi, you may want to check for
both types in your Linux side patch ...

Jan



 


Rackspace

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