From patchwork Fri Jun 22 12:44:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 139613 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp832180lji; Fri, 22 Jun 2018 05:47:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLvs3x4ZPXxXH8Uz2P7b8jjvFsN+cUw+Lp4/1/dApE252YkazffrUzbpb2fHmu8hYpnBE8n X-Received: by 2002:a50:a944:: with SMTP id m4-v6mr1761223edc.180.1529671645213; Fri, 22 Jun 2018 05:47:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529671645; cv=none; d=google.com; s=arc-20160816; b=zQ3DyR5MDyHJrE/fCaJqq4bWBWkvnYTeUUqw/uhYfNtJpP96z9YjcN7baej7dAuSu2 c6cHoR0bM+H9qroR42aeyWYTLsCx3/J1g7jwWwwBgQdPPwwEDws95poUDSu16RqDK0iZ OoOJ4cypIj+Fb4+Z8acncbQn4c5x1R4hn7LPcEGZkiE8bdlVqJd/UUOHcVYbzSnrikZY Luxu9IXbbDGxqtS14hnSiEa6n5/ZKqTu1s3kEBHWOOFznF/IpEbNimsjMu1RzHM2UI+2 olaQzfj4e2wz6EGL0wSn99gNJqbX2gDJf/j/qyWwp1s4EUfje65/szm/5GAxLtyOvV5O nNgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:arc-authentication-results; bh=FnJPQaAHpVZeCF6/bqJttlGBeEK5aMlwkug53Ls3xHU=; b=g6I/3Nol5JJIgFCxVxsIdjTgwaKyVdbT6uH8pGY9fII7rRbRlq+rs/Sw2QtJvyr1WY 4WwviKhXiuvUtbYcfmP4tDlkg7lZ1lR6KFZANZq+YkgE0VDeegLkiRyhKk+cbw2G/2yz WuaHEo4wIYujz3hxh5l9tNDtEaxhJBKpToUEusAiyHMj0HavaQ7kbMaa/Qb8dHcKBVd8 6Ncj9qZXMI+vhMC37LwGi4pQLplSIYvWT3zYpexEZMBW1ZxncJbnrM1ct3W/iRUmKxuK DH8vHd1afSJQRM6PQD/1kinBVfx37xgl137QejP896PHi+GFxOJooF6X6uyDYHtQT8fy G/ug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id d90-v6si3678245edc.242.2018.06.22.05.47.24; Fri, 22 Jun 2018 05:47:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id D80D8C21F99; Fri, 22 Jun 2018 12:45:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id AB5C3C21F92; Fri, 22 Jun 2018 12:44:23 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 17F0EC21C2F; Fri, 22 Jun 2018 12:44:20 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 9B168C21C50 for ; Fri, 22 Jun 2018 12:44:20 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id ED79DAF38; Fri, 22 Jun 2018 12:44:19 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Fri, 22 Jun 2018 14:44:13 +0200 Message-Id: <20180622124418.52892-6-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180622124418.52892-1-agraf@suse.de> References: <20180622124418.52892-1-agraf@suse.de> Cc: Heinrich Schuchardt , Andy Shevchenko Subject: [U-Boot] [PATCH v5 05/10] sandbox: Allow to execute from RAM X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 Reviewed-by: Simon Glass --- 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;