[PATCH] efi: don't truncate EFI_MEMORY_RUNTIME when setting resource attributes
Ahmad Fatoum
a.fatoum at pengutronix.de
Tue Aug 25 01:53:15 PDT 2026
resource_set_efi_memory_type_attrs() stored the runtime attribute with
res->runtime = attrs & EFI_MEMORY_RUNTIME;
but struct resource declares runtime as a one-bit field and
EFI_MEMORY_RUNTIME is bit 63, so the assignment keeps only the low bit of
the masked value and always stores zero. Every caller passing the
attribute silently ended up with a non-runtime resource.
This went unnoticed because the other places marking a resource as
runtime, common/memory.c and efi_allocate_pages(), assign res->runtime =
true directly. The setter is used by efi/payload/iomem.c, which converts
the firmware-provided memory map into resources when barebox runs as an
EFI payload, so barebox lost the runtime flag on every region it imported.
Assisted-by: Claude:opus-5
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
include/efi/memory.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/efi/memory.h b/include/efi/memory.h
index df980a0f348f..74e714099021 100644
--- a/include/efi/memory.h
+++ b/include/efi/memory.h
@@ -71,7 +71,7 @@ static inline void resource_set_efi_memory_type_attrs(struct resource *res,
u64 attrs)
{
res->type = type;
- res->runtime = attrs & EFI_MEMORY_RUNTIME;
+ res->runtime = !!(attrs & EFI_MEMORY_RUNTIME);
res->attrs = attrs & ~EFI_MEMORY_RUNTIME;
res->flags |= IORESOURCE_TYPE_VALID;
}
--
2.47.3
More information about the barebox
mailing list