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

Re: Question: Enable LINUX_EFI_MEMRESERVE_TABLE_GUID in EFI


  • To: Ard Biesheuvel <ardb@xxxxxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Thu, 11 Aug 2022 15:34:19 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; 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=UylbPgWVsDiAONscMv2Fw7L/W3G3d6HeG5/uULIKxoM=; b=djni/6HId7quQGxVdx82J70TkZETixZMobPDpCDNWTUNMml4jMACnmeROvUYcLcWe5zb4uQ82p1A0m4tAVcOpzVBHpHjkr2j9IFqPE1OAXM41wbVeRR5JXpzZXfAuIVMbksoPpx4hu+Qv8hf/2A0USWU8WOcXIC24Wb2L8L0+ANi2EtVrxx+2NPEk4OP8AwQNvwPSuCBWkAq+aZVyOU+53470v+7HkZxjDCkgZyX1dRGaWclPPWhoRUfUTnkSIfvESCyXHO1jX+iwLGo9nXuBSC7AEInjOaAy+Xlt0ZJ3CznmkstBu0w1tMxc1LkQDCXJ1fO0XBZIL1XqiKcpmbkjw==
  • 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=UylbPgWVsDiAONscMv2Fw7L/W3G3d6HeG5/uULIKxoM=; b=QiH0n2M/ywiJjt3tMfBvXKT3INc71OrT+0nTK9C+0g4QLYwo3OBpsM69vGu1LprvSzImq98sK2GA9Xkw/9ME0Okpn8i1Sr6JT+J2S7JD8xI9D/3laqbjemVQqrFCpaufVs7zZCkZhxfg9R6HNk8/71Tu/IcUhtqKBo+55D2jxjkdA7zb6R/OmcDcOLqtJsV7YQszVynbC5sfuImyHpCSDFqQxuIzLXMgLdBWSPCqQV9aUwAgpS+K5bbWd0PL4XsrREntWztuj2Re6wdKlGh/t7YKWZtOzNaAgvzrXSVfyf3qk/RIWp7frpQcu5vlXB0yxZbSVxOyHtVA3i8lkA/W6A==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=oZHZb8JMFh6QpZdE1v/Xy+8h/Ei7mZlW2QUR8Z3sy55YXuc4VUl/lnGShGpnfqFymsQuH6YjWgP3CDXKLVZ5XI5kGwynHE/lZjEoeC5jgYVep0+SxEs1rh8oytxpLgkoda0GZ59l8+h0gU5+EXK2WmI1TBnAd+Ipc7oc0tHaIGbPw24UVi9OhQxCe18cy7TqXrmazmb6grqRPlf2vSS+h7Hfo486+zEJbyMp9WBiKPez1ai9LSbQ1+et6oos01SrrU9teoiAn6Nfm9307+iXZcMVQs1v0YyPPiARYJ0g/ll/7TlvHG4H+7cbZht+uGbRuTx5iN98ljMMl8Lm9f8S+A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Uh/RH/hPQVb8rTbbSpwITVsPciexg/MAocxvoIqoA4v8StSR1kjAUlnaTBinwf60ZX8FMfECGdx3U/HaE3uaNkCnuRDZI0Wa4Vh5f9qWyORbXm/f7tFy2mvv4bDb5HxhyYcgW/+DUu3VPBTDNvKMhnnYxmKquouFWZaZXJcamELNtuz7oaKCGfn9vfUlcOoVfG6ciOHcW06GYgt4KX7ZswnlVYKHgD0ofUWQSDMScYe9H4Qe99XqXn8PHDiH0o4q0BuSIGjCtb5384c02EH/4eS3Mp4NlP8FIgATezHUILr7WiP6OheG5ZAjEO9XWFPLailVhwmHcKL7XWpAozhqvg==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: "leo.yan@xxxxxxxxxx" <leo.yan@xxxxxxxxxx>, xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Peter Griffin <peter.griffin@xxxxxxxxxx>, Jerome Forissier <jerome.forissier@xxxxxxxxxx>, Marc Zyngier <maz@xxxxxxxxxx>, Rahul Singh <Rahul.Singh@xxxxxxx>
  • Delivery-date: Thu, 11 Aug 2022 15:34:43 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHYp9oMDnfnppRN40WNR+bqQStYIa2gMcaAgAAFzACACZLNgIAAC6aAgAAB64CAAAf/AA==
  • Thread-topic: Question: Enable LINUX_EFI_MEMRESERVE_TABLE_GUID in EFI

Hi,

> On 11 Aug 2022, at 16:05, Ard Biesheuvel <ardb@xxxxxxxxxx> wrote:
> 
> On Thu, 11 Aug 2022 at 16:59, Bertrand Marquis <Bertrand.Marquis@xxxxxxx> 
> wrote:
>> 
>> Hi Leon,
>> 
>>> On 11 Aug 2022, at 15:17, Leo Yan <leo.yan@xxxxxxxxxx> wrote:
>>> 
>>> Hi Bertrand, Rahul,
>>> 
>>> On Fri, Aug 05, 2022 at 12:05:23PM +0000, Bertrand Marquis wrote:
>>>>> On 5 Aug 2022, at 12:44, Rahul Singh <Rahul.Singh@xxxxxxx> wrote:
>>> 
>>> [...]
>>> 
>>>>>> Looked into the code, the GICv3 driver tries to create persistent
>>>>>> reservations for pending pages, and the persistent reservation table
>>>>>> can be used by kexec/kdump.  For the persistent reservations, it
>>>>>> relies on MEMRESERVE EFI configuration table, but this table is not
>>>>>> supported by xen.efi, I think this is the reason for the above oops.
>>>>> 
>>>>> Yes, you are right above warning is observed because Xen does not support
>>>>> memreserve efi table. I also observed a similar warning on the N1SDP 
>>>>> board.
>>>>>> 
>>>>>> I checked that if I boot a host Linux (without Xen), then the EFI has
>>>>>> provided MEMRESERVE configuration table, I can get below log:
>>>>>> 
>>>>>> #  dmesg | grep MEMRESERVE
>>>>>> [    0.000000] efi: TPMFinalLog=0x807f9ef0000 ACPI 2.0=0x807fa0d0018 ... 
>>>>>> MEMRESERVE=0x807f8141e98
>>>>>> 
>>>>>> Just want to confirm, is anyone working on enabling MEMRESERVE EFI
>>>>>> configuration table for Xen?  And welcome any comments and
>>>>>> suggestions!
>>>>>> 
>>>> 
>>>> No I do not think anybody is working on this at the moment.
>>>> If you want to work on adding support for this in Xen, we can provide 
>>>> support
>>>> and help on reviewing and testing as we have several targets on which we
>>>> observe this (N1SDP and Ava).
>>> 
>>> Thanks for your quick response.
>>> 
>>> I took time to look into the code, below are my conclusions.
>>> 
>>> For a normal UEFI boot flow, UEFI will invoke Linux kernel's EFI stub,
>>> and the EFI stub will install MEMRESERVE EFI configuration table.
>>> This is accomplished in the Linux function install_memreserve_table().
>>> 
>>> Secondly, Xen passes DT to kernel, it synthesizes ACPI compatible
>>> nodes in the device tree and finally kernel parses DT and create the
>>> ACPI table.  In this case, Xen doesn't invoke Linux EFI stub.
>>> 
>>> To be honest, I have very less knowledge for Xen and APCI; just based on
>>> reading code, I think it's hard for Xen to invoke Linux kernel's EFI
>>> stub, this is because Xen needs to provide the EFI runtime services, and
>>> I don't think it's feasible for Xen to pass through UEFI's runtime
>>> service to Linux kernel.  If we implement the EFI runtime services for
>>> Xen, then this would introduce a big implementation.
>>> 
>>> So another option is we simply add MEMRESERVE EFI configuration table
>>> into device tree, just like Xen does for other ACPI tables (e.g.
>>> RSDP?).  And then in Linux kernel, we need to parse the DT binding and
>>> initialize the corresponding variables in kernel, so we need to add
>>> support in the Linux source drivers/firmware/efi/fdtparams.c.
>>> 
>>> Before I proceed, just want to check which option would be the right
>>> way to move forward?  And I am open for any other solution and welcome
>>> suggestions.
>> 
>> When Xen is started using EFI, Linux is then started purely using device tree
>> there is a standard way to define reserved memory to linux using the device
>> tree and Xen should decode the Memreserve entry from EFI and add the
>> corresponding entry in the device tree that we give to linux.
>> 
> 
> This is not what MEMRESERVE is used for. Specifying reservations for
> the current boot is straight-forward. What MEMRESERVE does is specify
> a reservation that survives kexec and is passed on to the next
> kernel(s), as the table is anchored in a structure that is created by
> the EFI stub on the first boot. This is needed for the GICv3 on some
> platforms, as memory that Linux reserves for its interrupt tables can
> never be released again, even across kexec, which means that the GICv3
> will be DMA'ing into that memory if the kexec kernel wants it or not)
> 
> I'd strongly recommend against doing any of the things Xen does for
> ACPI boot today: both the ACPI spec and the kernel documentation about
> ACPI support in the arm64 port is 100% clear that EFI boot is the only
> supported boot method. Issues like this one would have never popped up
> if those rules were adhered to. (/pedantic mode off)

I agree with that in the long term we should find a solution to remove this
system and have something more compliant with EFI/ACPI in Xen.

> 
> In your case, this is a matter of allocating a structure of the right
> type and size, and making it available via the configuration table
> array in the EFI system table that the dom0 kernel receives from Xen
> at boot.
> 
> Please don't add DT entries for this - we should be able to cover this
> using the existing pseudo-EFI boot flow that Xen uses today.

Currently the EFI system table is passed using a device tree generated
by Xen. To add support right now we would need to make the table
available to dom0 and pass its address inside this device tree.

Cheers
Bertrand

> 
> -- 
> Ard.




 


Rackspace

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