mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] efi: don't truncate EFI_MEMORY_RUNTIME when setting resource attributes
@ 2026-08-25  8:53 Ahmad Fatoum
  2026-08-28 13:04 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2026-08-25  8:53 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

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@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




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

end of thread, other threads:[~2026-08-28 13:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-25  8:53 [PATCH] efi: don't truncate EFI_MEMORY_RUNTIME when setting resource attributes Ahmad Fatoum
2026-08-28 13:04 ` Sascha Hauer

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