[U-Boot] [PATCH v5 05/10] sandbox: Allow to execute from RAM

Alexander Graf agraf at suse.de
Fri Jun 22 12:44:13 UTC 2018


With efi_loader, we may want to execute payloads from RAM. By default,
permissions on the RAM region don't allow us to execute from there though.

So let's change the default allocation scheme for RAM to also allow
execution from it. That way payloads that live in U-Boot RAM can be
directly executed.

Signed-off-by: Alexander Graf <agraf at suse.de>

---

v4 -> v5:

  - Replace runtime mprotect() mechanism with mmap() flag
---
 arch/sandbox/cpu/os.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index fc2f9dbc7a..e3fe017b5f 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -144,7 +144,8 @@ void *os_malloc(size_t length)
 {
 	struct os_mem_hdr *hdr;
 
-	hdr = mmap(NULL, length + sizeof(*hdr), PROT_READ | PROT_WRITE,
+	hdr = mmap(NULL, length + sizeof(*hdr),
+		   PROT_READ | PROT_WRITE | PROT_EXEC,
 		   MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
 	if (hdr == MAP_FAILED)
 		return NULL;
-- 
2.12.3



More information about the U-Boot mailing list