All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] efi_loader: check memory type in AllocatePages()
@ 2019-04-22 22:39 Heinrich Schuchardt
  0 siblings, 0 replies; only message in thread
From: Heinrich Schuchardt @ 2019-04-22 22:39 UTC (permalink / raw)
  To: u-boot

The UEFI specification prescribes that AllocatePages() checks the memory
type.

Add missing definition of EFI_PERSISTENT_MEMORY_TYPE.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 include/efi.h               | 4 ++++
 lib/efi_loader/efi_memory.c | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/include/efi.h b/include/efi.h
index 3c9d20f8c0..5f415a99cc 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -168,6 +168,10 @@ enum efi_mem_type {
 	 * part of the processor.
 	 */
 	EFI_PAL_CODE,
+	/*
+	 * Non-volatile memory.
+	 */
+	EFI_PERSISTENT_MEMORY_TYPE,

 	EFI_MAX_MEMORY_TYPE,
 	EFI_TABLE_END,	/* For efi_build_mem_table() */
diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index 46681dc208..987cc6dc5f 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -376,6 +376,10 @@ efi_status_t efi_allocate_pages(int type, int memory_type,
 	efi_status_t r = EFI_SUCCESS;
 	uint64_t addr;

+	/* Check import parameters */
+	if (memory_type >= EFI_PERSISTENT_MEMORY_TYPE &&
+	    memory_type <= 0x6FFFFFFF)
+		return EFI_INVALID_PARAMETER;
 	if (!memory)
 		return EFI_INVALID_PARAMETER;

--
2.20.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-04-22 22:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-22 22:39 [U-Boot] [PATCH] efi_loader: check memory type in AllocatePages() Heinrich Schuchardt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.