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

Re: [PATCH v3] Support ESRT in Xen dom0


  • To: Demi Marie Obenour <demi@xxxxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 22 Sep 2022 08:12:14 +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=/WOUVXNLFDX+WoE27T33pXzOWdL2eC2PH3pSXbEjyGc=; b=eFx1bV+DFc63eP/OIuThfA6YuYQWYHe7QrOGJLuDI7pqGrGBYHMnynQf6FE49IH7IG4twob1j5nSPPp0EyNYrBeFLDqbGGcskuWOos+n+lKX2wIdLMOrM9o9Hgip1NUNue7TR0nXMpc6y3GXHmka7YafnX4b85abSKSMoVZA6z3xRC+PyOPfu62Ie5oYZir8rOetb2LQXNlqLqFPEFEb8oxPxfjtUCWgnFM+DnJWOYMfg0PLJWvbyRHndtIF+deq5VMTjbAUgU+3j1A2nLEiexRz9XRylK/7bx20Ae3Q6CmP5izvz+HYjTjrWp2KpUyl+E8/ery1VUxgZpUXgQyoUQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QH4R5pE22SQBtZ+8Sd0Isy9wFtcvniXleZCUbOnyJwBtEuSRFyoqrCf57Fux1+nwvosUXsOoZUnKIl4/7rawrItBT42pyGYO7BuAJ9FvCuewmcNM+BRxlbFd9XYNp09dPjAWZ83ccykNDFrbkyDIr4wmQElhz0M6bUcdu+EI7s8SLkX4G8HGt8j5sSS0gya/u5M7hJaolFjlGCmpHpd17MYq0EkszIS/+qlb+eZDSLV3xcLeoiViRlQVKL7CcxXt2yBj6LNlMYZmTX+Ehg+nq9C8SDQOUiPZtwmQ2vZPokJrwdrT4zfAhbh/Erz36opoBDi+E2ve0SBsrMXVJR8H4Q==
  • 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, Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>, Ard Biesheuvel <ardb@xxxxxxxxxx>
  • Delivery-date: Thu, 22 Sep 2022 06:12:39 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 22.09.2022 03:09, Demi Marie Obenour wrote:
> On Wed, Sep 21, 2022 at 10:34:04PM +0200, Jan Beulich wrote:
>> 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.
> 
> What about giving that memory to dom0?  dom0’s balloon driver will give
> anything dom0 doesn’t wind up using back to Xen.

While perhaps in principle possible, this would require special casing
in Xen. Except for the memory the initrd comes in, we don't directly
hand memory to Dom0. Instead everything goes through the page allocator
first. Plus if we really were convinced boot services memory needed
retaining, then it would also need retaining across kexec (and hence
shouldn't be left to Dom0 to decide what to do with it).

Jan



 


Rackspace

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