]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
efi: Enable BGRT loading under Xen
authorMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Mon, 9 Mar 2026 12:17:23 +0000 (13:17 +0100)
committerArd Biesheuvel <ardb@kernel.org>
Tue, 10 Mar 2026 20:56:46 +0000 (21:56 +0100)
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 01de145dc7fb
"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>
drivers/firmware/efi/efi-bgrt.c

index 6aafdb67dbca4ece30717e709cfb14d448b9f9ae..1da451582812a19bd15470b67746f4e2eb345106 100644 (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;
        }