diff mbox series

[v5,05/10] sandbox: Allow to execute from RAM

Message ID 20180622124418.52892-6-agraf@suse.de
State New
Headers show
Series sandbox: efi_loader support | expand

Commit Message

Alexander Graf June 22, 2018, 12:44 p.m. UTC
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@suse.de>

---

v4 -> v5:

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

Comments

Simon Glass June 22, 2018, 7:28 p.m. UTC | #1
On 22 June 2018 at 06:44, Alexander Graf <agraf@suse.de> wrote:
> 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@suse.de>
>
> ---
>
> v4 -> v5:
>
>   - Replace runtime mprotect() mechanism with mmap() flag
> ---
>  arch/sandbox/cpu/os.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

That looks a lot better to me.

Reviewed-by: Simon Glass <sjg@chromium.org>
Alexander Graf Sept. 15, 2018, 1:32 p.m. UTC | #2
> 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@suse.de>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Thanks, applied to efi-next

Alex
diff mbox series

Patch

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;