[PATCH 10/15] efi: payload: iomem: use virt_start if set

Ahmad Fatoum a.fatoum at barebox.org
Tue May 27 14:22:55 PDT 2025


If the EFI firmware populates virt_start, we should use that in
preference to phys_start as not to assume a 1:1 mapping.

Signed-off-by: Ahmad Fatoum <a.fatoum at barebox.org>
---
 efi/payload/iomem.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/efi/payload/iomem.c b/efi/payload/iomem.c
index 832f6db72b76..888aa8569ebb 100644
--- a/efi/payload/iomem.c
+++ b/efi/payload/iomem.c
@@ -25,9 +25,10 @@ static int efi_parse_mmap(struct efi_memory_desc *desc, bool verbose)
 		return 0;
 
 	/* XXX At least OVMF doesn't populate ->virt_start and leaves it at zero
-	 * for all mapping. Thus assume a 1:1 mapping and ignore virt_start
+	 * for all mappings. Handles this by assume a 1:1 mapping and falling
+	 * back to phys_start.
 	 */
-	va_base = desc->phys_start;
+	va_base = (uintptr_t)desc->virt_start ?: desc->phys_start;
 
 	switch (desc->type) {
 	case EFI_RESERVED_TYPE:
@@ -124,9 +125,9 @@ static int efi_parse_mmap(struct efi_memory_desc *desc, bool verbose)
 		flags = IORESOURCE_MEM | IORESOURCE_ROM_BIOS_COPY;
 	}
 
-	fullname = xasprintf("%s@%llx", name, desc->phys_start);
+	fullname = xasprintf("%s@%llx", name, (u64)va_base);
 
-	pr_debug("%s: (0x%llx+0x%llx)\n", fullname, va_base, va_size);
+	pr_debug("%s: (%pad+%pad)\n", fullname, &va_base, &va_size);
 
 	res = request_iomem_region(fullname, va_base, va_base + va_size - 1);
 	if (IS_ERR(res)) {
-- 
2.39.5




More information about the barebox mailing list