EFI: preserve the System Resource Table for dom0
authorDemi Marie Obenour <demi@invisiblethingslab.com>
Tue, 12 Jul 2022 06:39:19 +0000 (08:39 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 12 Jul 2022 06:39:19 +0000 (08:39 +0200)
commitdc7da0874ba4e8fab4c5783055755938ef19fc37
tree63bba3205deeb552e7f76a3dbd68e6cabd60b356
parentd778089ac70e5b8e3bdea0c85fc8c0b9ed0eaf2f
EFI: preserve the System Resource Table for dom0

The EFI System Resource Table (ESRT) is necessary for fwupd to identify
firmware updates to install.  According to the UEFI specification ยง23.4,
the ESRT shall be stored in memory of type EfiBootServicesData.  However,
memory of type EfiBootServicesData is considered general-purpose memory
by Xen, so the ESRT needs to be moved somewhere where Xen will not
overwrite it.  Copy the ESRT to memory of type EfiRuntimeServicesData,
which Xen will not reuse.  dom0 can use the ESRT if (and only if) it is
in memory of type EfiRuntimeServicesData.

Earlier versions of this patch reserved the memory in which the ESRT was
located.  This created awkward alignment problems, and required either
splitting the E820 table or wasting memory.  It also would have required
a new platform op for dom0 to use to indicate if the ESRT is reserved.
By copying the ESRT into EfiRuntimeServicesData memory, the E820 table
does not need to be modified, and dom0 can just check the type of the
memory region containing the ESRT.  The copy is only done if the ESRT is
not already in EfiRuntimeServicesData memory, avoiding memory leaks on
repeated kexec.

See https://lore.kernel.org/xen-devel/20200818184018.GN1679@mail-itl/T/
for details.

Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
Tested-by: Luca Fancellu <luca.fancellu@arm.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/common/efi/boot.c