mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] Allow using BGRT table under Xen dom0
@ 2026-03-09 12:17 Marek Marczykowski-Górecki
  2026-03-09 12:17 ` [PATCH 1/2] efi: make efi_mem_type() and efi_mem_attributes() work on Xen PV Marek Marczykowski-Górecki
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Marek Marczykowski-Górecki @ 2026-03-09 12:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Soumyajyotii Ssarkar, xen-devel, Marek Marczykowski-Górecki,
	Ard Biesheuvel, Ilias Apalodimas, linux-efi

For a long time Xen was invalidating BGRT table as it was reclaiming
BootServicesData memory (where boot graphics is located). This is now changing,
and the boot graphics is preserved. This series has necessary changes to
actually make Linux use the preserved graphics.

This is a companion series to Xen side at
https://lore.kernel.org/xen-devel/20260305191810.31033-1-soumyajyotisarkar23@gmail.com/

CC: Soumyajyotii Ssarkar <soumyajyotisarkar23@gmail.com>
Cc: xen-devel@lists.xenproject.org
Cc: Ard Biesheuvel <ardb@kernel.org> (maintainer:EXTENSIBLE FIRMWARE INTERFACE (EFI))
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> (reviewer:EXTENSIBLE FIRMWARE INTERFACE (EFI))
Cc: linux-efi@vger.kernel.org (open list:EXTENSIBLE FIRMWARE INTERFACE (EFI))

Marek Marczykowski-Górecki (2):
  efi: make efi_mem_type() and efi_mem_attributes() work on Xen PV
  efi: Enable BGRT loading under Xen

 drivers/firmware/efi/efi-bgrt.c |  7 +++++--
 drivers/firmware/efi/efi.c      | 27 +++++++++------------------
 2 files changed, 14 insertions(+), 20 deletions(-)

base-commit: 7e1526209cf972f51281558f1cb979d18e49cdd1
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] efi: make efi_mem_type() and efi_mem_attributes() work on Xen PV
  2026-03-09 12:17 [PATCH 0/2] Allow using BGRT table under Xen dom0 Marek Marczykowski-Górecki
@ 2026-03-09 12:17 ` Marek Marczykowski-Górecki
  2026-03-09 12:17 ` [PATCH 2/2] efi: Enable BGRT loading under Xen Marek Marczykowski-Górecki
  2026-03-09 12:51 ` [PATCH 0/2] Allow using BGRT table under Xen dom0 Ard Biesheuvel
  2 siblings, 0 replies; 4+ messages in thread
From: Marek Marczykowski-Górecki @ 2026-03-09 12:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Soumyajyotii Ssarkar, xen-devel, Marek Marczykowski-Górecki,
	Ard Biesheuvel, Ilias Apalodimas,
	open list:EXTENSIBLE FIRMWARE INTERFACE (EFI)

Xen doesn't give direct access to the EFI memory map, but provides a
hypercall interface for it. efi_mem_desc_lookup() was already adjusted
in aca1d27ac38a "efi: xen: Implement memory descriptor lookup based on
hypercall" to (optionally) use it. Now make efi_mem_type() and
efi_mem_attributes() use common efi_mem_desc_lookup() too.
This also reduces code duplication a bit.
efi_mem_type() retains separate check for -ENOTSUPP error case (even
though no caller seems to rely on this currently).

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
---
 drivers/firmware/efi/efi.c | 27 +++++++++------------------
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index b2fb92a..36efc92 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -983,18 +983,12 @@ char * __init efi_md_typeattr_format(char *buf, size_t size,
  */
 u64 efi_mem_attributes(unsigned long phys_addr)
 {
-	efi_memory_desc_t *md;
+	efi_memory_desc_t md;
 
-	if (!efi_enabled(EFI_MEMMAP))
+	if (efi_mem_desc_lookup(phys_addr, &md))
 		return 0;
 
-	for_each_efi_memory_desc(md) {
-		if ((md->phys_addr <= phys_addr) &&
-		    (phys_addr < (md->phys_addr +
-		    (md->num_pages << EFI_PAGE_SHIFT))))
-			return md->attribute;
-	}
-	return 0;
+	return md.attribute;
 }
 
 /*
@@ -1007,18 +1001,15 @@ u64 efi_mem_attributes(unsigned long phys_addr)
  */
 int efi_mem_type(unsigned long phys_addr)
 {
-	const efi_memory_desc_t *md;
+	const efi_memory_desc_t md;
 
-	if (!efi_enabled(EFI_MEMMAP))
+	if (!efi_enabled(EFI_MEMMAP) && !efi_enabled(EFI_PARAVIRT))
 		return -ENOTSUPP;
 
-	for_each_efi_memory_desc(md) {
-		if ((md->phys_addr <= phys_addr) &&
-		    (phys_addr < (md->phys_addr +
-				  (md->num_pages << EFI_PAGE_SHIFT))))
-			return md->type;
-	}
-	return -EINVAL;
+	if (efi_mem_desc_lookup(phys_addr, &md))
+		return -EINVAL;
+
+	return md.type;
 }
 
 int efi_status_to_err(efi_status_t status)
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] efi: Enable BGRT loading under Xen
  2026-03-09 12:17 [PATCH 0/2] Allow using BGRT table under Xen dom0 Marek Marczykowski-Górecki
  2026-03-09 12:17 ` [PATCH 1/2] efi: make efi_mem_type() and efi_mem_attributes() work on Xen PV Marek Marczykowski-Górecki
@ 2026-03-09 12:17 ` Marek Marczykowski-Górecki
  2026-03-09 12:51 ` [PATCH 0/2] Allow using BGRT table under Xen dom0 Ard Biesheuvel
  2 siblings, 0 replies; 4+ messages in thread
From: Marek Marczykowski-Górecki @ 2026-03-09 12:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Soumyajyotii Ssarkar, xen-devel, Marek Marczykowski-Górecki,
	Ard Biesheuvel, Ilias Apalodimas,
	open list:EXTENSIBLE FIRMWARE INTERFACE (EFI)

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>
---
 drivers/firmware/efi/efi-bgrt.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/efi/efi-bgrt.c b/drivers/firmware/efi/efi-bgrt.c
index 6aafdb6..1da4515 100644
--- a/drivers/firmware/efi/efi-bgrt.c
+++ b/drivers/firmware/efi/efi-bgrt.c
@@ -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;
 	}
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] Allow using BGRT table under Xen dom0
  2026-03-09 12:17 [PATCH 0/2] Allow using BGRT table under Xen dom0 Marek Marczykowski-Górecki
  2026-03-09 12:17 ` [PATCH 1/2] efi: make efi_mem_type() and efi_mem_attributes() work on Xen PV Marek Marczykowski-Górecki
  2026-03-09 12:17 ` [PATCH 2/2] efi: Enable BGRT loading under Xen Marek Marczykowski-Górecki
@ 2026-03-09 12:51 ` Ard Biesheuvel
  2 siblings, 0 replies; 4+ messages in thread
From: Ard Biesheuvel @ 2026-03-09 12:51 UTC (permalink / raw)
  To: Marek Marczykowski-Górecki, linux-kernel
  Cc: Soumyajyotii Ssarkar, xen-devel, Ilias Apalodimas, linux-efi


On Mon, 9 Mar 2026, at 13:17, Marek Marczykowski-Górecki wrote:
> For a long time Xen was invalidating BGRT table as it was reclaiming
> BootServicesData memory (where boot graphics is located). This is now changing,
> and the boot graphics is preserved. This series has necessary changes to
> actually make Linux use the preserved graphics.
>
> This is a companion series to Xen side at
> https://lore.kernel.org/xen-devel/20260305191810.31033-1-soumyajyotisarkar23@gmail.com/
>
> CC: Soumyajyotii Ssarkar <soumyajyotisarkar23@gmail.com>
> Cc: xen-devel@lists.xenproject.org
> Cc: Ard Biesheuvel <ardb@kernel.org> (maintainer:EXTENSIBLE FIRMWARE 
> INTERFACE (EFI))
> Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org> (reviewer:EXTENSIBLE 
> FIRMWARE INTERFACE (EFI))
> Cc: linux-efi@vger.kernel.org (open list:EXTENSIBLE FIRMWARE INTERFACE 
> (EFI))
>
> Marek Marczykowski-Górecki (2):
>   efi: make efi_mem_type() and efi_mem_attributes() work on Xen PV
>   efi: Enable BGRT loading under Xen
>
>  drivers/firmware/efi/efi-bgrt.c |  7 +++++--
>  drivers/firmware/efi/efi.c      | 27 +++++++++------------------
>  2 files changed, 14 insertions(+), 20 deletions(-)
>

Looks good to me - if nobody else has any concerns, I'll queue this up for v7.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-09 12:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-09 12:17 [PATCH 0/2] Allow using BGRT table under Xen dom0 Marek Marczykowski-Górecki
2026-03-09 12:17 ` [PATCH 1/2] efi: make efi_mem_type() and efi_mem_attributes() work on Xen PV Marek Marczykowski-Górecki
2026-03-09 12:17 ` [PATCH 2/2] efi: Enable BGRT loading under Xen Marek Marczykowski-Górecki
2026-03-09 12:51 ` [PATCH 0/2] Allow using BGRT table under Xen dom0 Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®