Re: [PATCHv11 3/9] efi/libstub: Implement support for unaccepted memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, May 14, 2023 at 08:08:07AM +0300, Mika Penttilä wrote:
> > +	status = efi_bs_call(allocate_pool, EFI_LOADER_DATA,
> > +			     sizeof(*unaccepted_table) + bitmap_size,
> > +			     (void **)&unaccepted_table);
> 
> 
> Wonder if EFI_LOADER_DATA guarantees bitmap not to be freed, or should some
> more persistent type be used. If EFI_LOADER_DATA is enough, maybe a comment
> why it is safe could be added.

Ughh.. I've lost the hunk that reserves the memory explicitly while
folding in the patch we discussed with Ard. See below.

But the question is solid.

Ard, do we want to allocate the memory as EFI_RUNTIME_SERVICES_DATA (or
something else?) that got reserved automatically without additional steps?

diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index e15a2005ed93..d817e7afd266 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -765,6 +765,25 @@ int __init efi_config_parse_tables(const efi_config_table_t *config_tables,
 		}
 	}
 
+	if (IS_ENABLED(CONFIG_UNACCEPTED_MEMORY) &&
+	    efi.unaccepted != EFI_INVALID_TABLE_ADDR) {
+		struct efi_unaccepted_memory *unaccepted;
+
+		unaccepted = early_memremap(efi.unaccepted, sizeof(*unaccepted));
+		if (unaccepted) {
+			unsigned long size;
+
+			if (unaccepted->version == 1) {
+				size = sizeof(*unaccepted) + unaccepted->size;
+				memblock_reserve(efi.unaccepted, size);
+			} else {
+				efi.unaccepted = EFI_INVALID_TABLE_ADDR;
+			}
+
+			early_memunmap(unaccepted, sizeof(*unaccepted));
+		}
+	}
+
 	return 0;
 }
 
-- 
  Kiryl Shutsemau / Kirill A. Shutemov




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux