efi: Enable BGRT loading under Xen

The BGRT table can be parsed if EFI_PARAVIRT is enabled, even if
EFI_MEMMAP is not. Xen will take care of preserving the image even if
EfiBootServicesData memory is reclaimed already, or invalidate the table
if it didn't preserve it - in both cases accesing the table itself under
virt is safe. Also allow the ESRT to be in reclaimable memory, as that
is where future Xen versions will put it.
This is similar approach as was taken for ESRT table in 01de145dc7
"efi: Actually enable the ESRT under Xen".

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
This commit is contained in:
Marek Marczykowski-Górecki
2026-03-09 13:17:23 +01:00
committed by Ard Biesheuvel
parent 80e80a703e
commit eaeff8411f

View File

@@ -29,11 +29,12 @@ void __init efi_bgrt_init(struct acpi_table_header *table)
void *image;
struct bmp_header bmp_header;
struct acpi_table_bgrt *bgrt = &bgrt_tab;
int mem_type;
if (acpi_disabled)
return;
if (!efi_enabled(EFI_MEMMAP))
if (!efi_enabled(EFI_MEMMAP) && !efi_enabled(EFI_PARAVIRT))
return;
if (table->length < sizeof(bgrt_tab)) {
@@ -62,7 +63,9 @@ void __init efi_bgrt_init(struct acpi_table_header *table)
goto out;
}
if (efi_mem_type(bgrt->image_address) != EFI_BOOT_SERVICES_DATA) {
mem_type = efi_mem_type(bgrt->image_address);
if (mem_type != EFI_BOOT_SERVICES_DATA &&
mem_type != EFI_ACPI_RECLAIM_MEMORY) {
pr_notice("Ignoring BGRT: invalid image address\n");
goto out;
}