From patchwork Mon Jun 18 15:22:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 138998 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4081774lji; Mon, 18 Jun 2018 08:23:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKWKRthZNPqiN0j+60Pk9KX0To5yS9JThpc4vYK2LHBcTAn577xDjS/8Fwq3Z+hhFM8bJMw X-Received: by 2002:a50:f4cf:: with SMTP id v15-v6mr11552028edm.162.1529335414618; Mon, 18 Jun 2018 08:23:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529335414; cv=none; d=google.com; s=arc-20160816; b=OZAfVMSTmqQzFsTapHyLS+vdKVULvx5MiJqkNuUoZ2pufuPu24oCfxCnTm27JDloye EuZ+f1owcCel6hr4uCqXAnQCx3BnMFGzDgFEMeYnBDwE+d4k5S+5N/8XsBhMV+neZGnK k8SVvudGILkTTkL2YVbYP6n9+19pAvDwxAARHZi4zFrldNEj56cIuf33+n1mKE5CSdQz iPaEBq0rb2s3HeHJqIT02vGR66DRzPpmjLhb/pi/kP76BXV+YGDroJiIcgANqbh6wtwG GmapEX9K+mH+kIFNSj2XOzD1B6m/xeeVo/6zXICL5AYrfjl4o2F4LTedXJlqaPI8+P5K pNJg== 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=j0UsDECa98ZO9D8rx5HlV2PNXL6+50mB7kBR/pzZJk8=; b=sB9K8Nwx1HKftgxbQqAC+ykPM1G0hMClhJ9aEqRlOlywHedmT1GhjrHRdYmZVihidJ VrIhMBTgFbGpE+atb7pdBkNADiA90NEj5mX47VBIeg9XG+7tB39KV91kACo9g+wsrBdj +pZs2wVLmSWX7DomiEcr5QhvHtgcBmojvusqTIuJrCfnH86THW/nfovraW38nWJ4Ox1e CpLWh2Yl562KEbjA+GEdOA2nyihmRevNZ/YaIFnD/aijFVj2CnBS/ccaqHsa0vBSPiDV loH9pjECJ6SBeI9qNTQxTulWbRd4OivIXjagOiNv4BDobE+o07WSt3k2Hyjtzqm6A2QR rRmA== 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 s48-v6si6491420edb.319.2018.06.18.08.23.34; Mon, 18 Jun 2018 08:23:34 -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 23EAFC21F81; Mon, 18 Jun 2018 15:23:21 +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 18DCBC21DFA; Mon, 18 Jun 2018 15:23:19 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 8F8F2C21E1D; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 2EB0EC21DED for ; Mon, 18 Jun 2018 15:23:17 +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 BC00EAF5B; Mon, 18 Jun 2018 15:23:16 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 18 Jun 2018 17:22:55 +0200 Message-Id: <20180618152315.34233-2-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180618152315.34233-1-agraf@suse.de> References: <20180618152315.34233-1-agraf@suse.de> Cc: Heinrich Schuchardt , Andy Shevchenko Subject: [U-Boot] [PATCH v4 01/21] efi: sandbox: Add distroboot support 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" From: Simon Glass With sandbox these values depend on the host system. Let's assume that it is x86_64 for now. Signed-off-by: Simon Glass Signed-off-by: Alexander Graf --- include/config_distro_bootcmd.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h index d672e8ebe6..1bd79ae3b8 100644 --- a/include/config_distro_bootcmd.h +++ b/include/config_distro_bootcmd.h @@ -251,6 +251,8 @@ #elif defined(CONFIG_ARM) #define BOOTENV_EFI_PXE_ARCH "0xa" #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00010:UNDI:003000" + +/* For sandbox we only support 64-bit x86 at present */ #elif defined(CONFIG_X86) /* Always assume we're running 64bit */ #define BOOTENV_EFI_PXE_ARCH "0x7" @@ -261,6 +263,17 @@ #elif defined(CONFIG_CPU_RISCV_64) #define BOOTENV_EFI_PXE_ARCH "0x1b" #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00027:UNDI:003000" +#elif defined(CONFIG_SANDBOX) +/* + * TODO(sjg@chromium.org): Consider providing a way to enable sandbox features + * based on the host architecture + */ +# ifndef __x86_64__ +# warning "sandbox EFI support is only tested on 64-bit x86" +# endif +/* To support other *host* architectures this should be changed */ +#define BOOTENV_EFI_PXE_ARCH "0x7" +#define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00007:UNDI:003000" #else #error Please specify an EFI client identifier #endif From patchwork Mon Jun 18 15:22:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 139005 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4085630lji; Mon, 18 Jun 2018 08:27:38 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKk/LKxRtfSi/kCD19xAw92A0wa+oJ/FoiZm0jC/k7bMOzKXow0KPwGOKpJ5NGZUpubSDnr X-Received: by 2002:a50:cb0d:: with SMTP id g13-v6mr11526170edi.81.1529335658553; Mon, 18 Jun 2018 08:27:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529335658; cv=none; d=google.com; s=arc-20160816; b=AUZ9eN1vhxocVnoOR3+3BkslkExCmHdGPNd/+Xe308kM2ekRqi7x/b7QOpgEDRZGRj oAIQcbz+x3fOzmijpLgjZKXghTUN45MflGBEWHR0xyWYXvfF/6iCX0KOXg1Nkh8x5zPF yFMjorY4Vpay2fS2TEs8hnRy+SXhdojWVZdkq7ZZkGZyimlNgizoYo77UsRsJQHDprMP EQSQN5miWort5MWfatnqmkPj5i6Y4D3tf3QBHg4RKu8QUyWS812PmptqJXooC1fPR7gV HBWpP4+5pGgTXFId/DJ6zhYR3qegt7cEu0vzBMp2SRpi8BWRsJ7O2rFyc471XKlCEfnD YOLA== 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=97sDLf9D+o4CHkrAB/PKmm4T2GTnP3HHG/6/Xqm11Qo=; b=N+Ohnnv47IVQjQkxMppRjJOEIEDSfjXSh6rSzrVntWajkJU5gknySF6hn6B5nfh8ol ewa1c3N/AdqN8IL1Pr6TA9esQaS9G4uXZUacpZjkAukRZHQ3gJlpT7n9Rr4rgI5G19C3 BIhVmf5ZiMoY7tsm8M8q1sdqsHgOTFFisJ53eVO68o9WWgaJlwgJR6fJh7utxhuPPjGP ag7/URV5uNUgTiXABuV5RtxwURZ3pxsGwCtJ0HxrVahdkpR0NZGX942fGMCx8TGMv5Z0 aDvZE5vn7Ex45+EKgByusPNTIu2cNT0JQQKxogZWegZAeSg0H9KD3YmrCmvDKeZhZA6v tQ7w== 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 a8-v6si7167746edr.122.2018.06.18.08.27.38; Mon, 18 Jun 2018 08:27:38 -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 2739AC21EFF; Mon, 18 Jun 2018 15:25:00 +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 16E74C21E63; Mon, 18 Jun 2018 15:23:23 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 4F92BC21E38; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 964E0C21DED for ; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id BC3BAAF64; Mon, 18 Jun 2018 15:23:16 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 18 Jun 2018 17:22:56 +0200 Message-Id: <20180618152315.34233-3-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180618152315.34233-1-agraf@suse.de> References: <20180618152315.34233-1-agraf@suse.de> Cc: Heinrich Schuchardt , Andy Shevchenko Subject: [U-Boot] [PATCH v4 02/21] efi: sandbox: Add relocation constants 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" From: Simon Glass Add these so that we can build the EFI loader for sandbox. The values are for x86_64 so potentially bogus. But we don't support relocation within sandbox anyway. Signed-off-by: Simon Glass Signed-off-by: Alexander Graf --- lib/efi_loader/efi_runtime.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c index 4874eb602f..388dfb9840 100644 --- a/lib/efi_loader/efi_runtime.c +++ b/lib/efi_loader/efi_runtime.c @@ -62,6 +62,18 @@ struct dyn_sym { #define R_ABSOLUTE R_RISCV_64 #define SYM_INDEX 32 #endif + +/* For sandbox we only support 64-bit x86 at present */ +#elif defined(CONFIG_SANDBOX) +/* + * TODO(sjg@chromium.org): Consider providing a way to enable sandbox features + * based on the host architecture + */ +# ifndef __x86_64__ +# warning "sandbox EFI support is only tested on 64-bit x86" +# endif +#define R_RELATIVE 8 +#define R_MASK 0xffffffffULL #else #error Need to add relocation awareness #endif From patchwork Mon Jun 18 15:22:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 139006 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4086267lji; Mon, 18 Jun 2018 08:28:20 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLk3/ArC7D2TMPjXhz4oVDY526lFLkAsGZFyNfJdZatxLFA3KdNoCthoALAsxG77NCCv1T7 X-Received: by 2002:aa7:c486:: with SMTP id m6-v6mr11853413edq.266.1529335700698; Mon, 18 Jun 2018 08:28:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529335700; cv=none; d=google.com; s=arc-20160816; b=ZYvHp5eXXExsdjdg/XKd/6o6c0nMJhg1yvHNtj+mQCab+YGMY6Tpz5zzezKR+ljLba jnw5LR3DcO9EO/wLoAuPhm6126/IcOSCDFFk/mBxapFNwRwEIlkYH5JpBHHOk1OoJ64d i94GxeM/lZyZZe76iaHU1WU1b7Q2R6yaV6H4KNZ2RMzqsnOixDUBt2FVkWdwgVxVBpvV dpyYh023tTJpuzJeaEMMDVESJNn3m7aCI0Nx0MqFT1pFYfMmo8gV0pOjw0WRpCizyGUv 3nGIn87jGBCApm/6b0yLZOxJE9/i5nmlhafQZ5A/OTtITIJAEEAODy3QW6jf7ZU4FZN5 LKCQ== 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=73m/NCdF9/Nr1lITe5I0+h+ywV5cqcdYnp+RAcAenII=; b=JE8XLqAqInuFpwGOOmrOaJ9Pg/0nhmS49xJqnAzqE1mnXjxkvN7WiUkckY6/bf8n7f LByZXnblz4nCVLa9CKV6S/mGRRkkNPpZsmSRRbrMlCR4eCQUKv/tAdL0n+cvs5lYx16t X0oSyQh+Tp2KcVEZ7WW8Yc4fqnLtEDt7jFkn/pQgRBXwkwQ7ujnTmzQcQ0dMayqJ6NxD Helw1tgYYB4hEzNQPEDmGCPYG+yl1OimLm5Zcqxm5oU4MiiVwVyCN2Z+7FAVUVTrwqDs VO69JwxXKTLf9yv6d6NTgmB95ypR5KXqDbq8S1ZRyfoRhODPXnjz3RdrKDK54P8Hoc0z 5XQg== 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 k91-v6si5858353edc.432.2018.06.18.08.28.20; Mon, 18 Jun 2018 08:28:20 -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 24ADDC21E70; Mon, 18 Jun 2018 15:24:21 +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 71C00C21EFB; Mon, 18 Jun 2018 15:23:21 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 036DCC21E63; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id ACAA8C21E52 for ; Mon, 18 Jun 2018 15:23:17 +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 BC4CEAF65; Mon, 18 Jun 2018 15:23:16 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 18 Jun 2018 17:22:57 +0200 Message-Id: <20180618152315.34233-4-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180618152315.34233-1-agraf@suse.de> References: <20180618152315.34233-1-agraf@suse.de> Cc: Heinrich Schuchardt , Andy Shevchenko Subject: [U-Boot] [PATCH v4 03/21] efi_loader: Use compiler constants for image loader 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" The EFI image loader tries to determine which target architecture we're working with to only load PE binaries that match. So far this has worked based on CONFIG defines, because the target CPU was always indicated by a config define. With sandbox however, this is not longer true as all sandbox targets only encompass a single CONFIG option and so we need to use compiler defines to determine the CPU architecture. Signed-off-by: Alexander Graf --- lib/efi_loader/efi_image_loader.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c index ecdb77e5b6..fdf40a62c8 100644 --- a/lib/efi_loader/efi_image_loader.c +++ b/lib/efi_loader/efi_image_loader.c @@ -19,25 +19,25 @@ const efi_guid_t efi_simple_file_system_protocol_guid = const efi_guid_t efi_file_info_guid = EFI_FILE_INFO_GUID; static int machines[] = { -#if defined(CONFIG_ARM64) +#if defined(__aarch64__) IMAGE_FILE_MACHINE_ARM64, -#elif defined(CONFIG_ARM) +#elif defined(__arm__) IMAGE_FILE_MACHINE_ARM, IMAGE_FILE_MACHINE_THUMB, IMAGE_FILE_MACHINE_ARMNT, #endif -#if defined(CONFIG_X86_64) +#if defined(__x86_64__) IMAGE_FILE_MACHINE_AMD64, -#elif defined(CONFIG_X86) +#elif defined(__i386__) IMAGE_FILE_MACHINE_I386, #endif -#if defined(CONFIG_CPU_RISCV_32) +#if defined(__riscv) && (__riscv_xlen == 32) IMAGE_FILE_MACHINE_RISCV32, #endif -#if defined(CONFIG_CPU_RISCV_64) +#if defined(__riscv) && (__riscv_xlen == 64) IMAGE_FILE_MACHINE_RISCV64, #endif 0 }; From patchwork Mon Jun 18 15:22:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 139000 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4082546lji; Mon, 18 Jun 2018 08:24:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJUh1HraqFnL1fgzDmmIjyjnL/6EEJCKaABt2SU5vspHiilhKU7tm0URuUUFqKoJGPQov7j X-Received: by 2002:a50:b223:: with SMTP id o32-v6mr11523252edd.184.1529335462000; Mon, 18 Jun 2018 08:24:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529335461; cv=none; d=google.com; s=arc-20160816; b=HtcFijPjTyNuH+xR0mquIpLx8969gI8Js1V9SyqaQoWXrNFFnAU4iDZCk5aXkjWWUe aY2Ja/muBKfStbs4dyY89M5ckiIUNEIHmLxZBz4o7zTRLMQHWGxSnuYWU58/b9mMEgf2 FvF87pS0RI2tnm4GgWuIvQh9CsqNJwp+hPfh69wFw2CKflp3ufY3Z96QTxt/3qgtgA9j kN3YppAzQjGC+DcqGR+BbdI6Ng7/WwanumJhNgobGaicGSQDn61Ll+qhOp08n4BV1cV0 +P25W/fSTFKgPdFjsWeTsO5NSpPF/wE6F7pj6xzbk/ekCkAB4mWCWORkZCtKMavQ1UUG qUFQ== 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=SRmsmaViDrXjl6X+DN9hRh/SyhsyZnJHzzIQQJiJgps=; b=fA8j5HjwUACxouqYxiu7mZj2mJDWFR/c6xLTmgE1Uf2FdzBvRUUFHjqcAsXuaUiqZ7 5zaabDoVq2xFGwhBDQ19iCF7MPlbUGx9p68TMtIbJK8Vkxb3nkjrqwKFDVSS6HBVm6i2 Eq7tKQTyKwZGHHnGkOtpny8kdTNu60FSMORzrhaO/gsd6djtDjkk0lEirtsXJ0a0OJ39 ju08sKpZgyyOZiofuYpQaBMsaO3MFv7V4iBC3WzR+AkH/D6Orydp+d9oZ+jILDK2t9/M 5PR8hs7JwkTzuJdl/lcgfD3aVpTp3gsMGVBcWM0+Zmt+3PDEht1B76le4HeFak2ULewi lqIg== 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 x21-v6si9559324edx.74.2018.06.18.08.24.21; Mon, 18 Jun 2018 08:24:21 -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 7E6E5C21EF7; Mon, 18 Jun 2018 15:24:02 +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 9EA4BC21ECC; Mon, 18 Jun 2018 15:23:20 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D46B9C21E6C; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 6ADE2C21DFD for ; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id C3C3CAF68; Mon, 18 Jun 2018 15:23:16 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 18 Jun 2018 17:22:58 +0200 Message-Id: <20180618152315.34233-5-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180618152315.34233-1-agraf@suse.de> References: <20180618152315.34233-1-agraf@suse.de> Cc: Heinrich Schuchardt , Andy Shevchenko Subject: [U-Boot] [PATCH v4 04/21] efi_loader: Use map_sysmem() in bootefi command 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" The bootefi command gets a few addresses as values passed in. In sandbox, these values are in U-Boot address space, so we need to make sure we explicitly call map_sysmem() on them to be able to access them. Signed-off-by: Alexander Graf Reviewed-by: Simon Glass --- cmd/bootefi.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index f55a40dc84..a86a2bd4a9 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -389,7 +390,8 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) unsigned long addr; char *saddr; efi_status_t r; - void *fdt_addr; + unsigned long fdt_addr; + void *fdt; /* Allow unaligned memory access */ allow_unaligned(); @@ -406,11 +408,12 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return CMD_RET_USAGE; if (argc > 2) { - fdt_addr = (void *)simple_strtoul(argv[2], NULL, 16); + fdt_addr = simple_strtoul(argv[2], NULL, 16); if (!fdt_addr && *argv[2] != '0') return CMD_RET_USAGE; /* Install device tree */ - r = efi_install_fdt(fdt_addr); + fdt = map_sysmem(fdt_addr, 0); + r = efi_install_fdt(fdt); if (r != EFI_SUCCESS) { printf("ERROR: failed to install device tree\n"); return CMD_RET_FAILURE; @@ -429,7 +432,7 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) addr = simple_strtoul(saddr, NULL, 16); else addr = CONFIG_SYS_LOAD_ADDR; - memcpy((char *)addr, __efi_helloworld_begin, size); + memcpy(map_sysmem(addr, size), __efi_helloworld_begin, size); } else #endif #ifdef CONFIG_CMD_BOOTEFI_SELFTEST @@ -475,7 +478,7 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } printf("## Starting EFI application at %08lx ...\n", addr); - r = do_bootefi_exec((void *)addr, bootefi_device_path, + r = do_bootefi_exec(map_sysmem(addr, 0), bootefi_device_path, bootefi_image_path); printf("## Application terminated, r = %lu\n", r & ~EFI_ERROR_MASK); From patchwork Mon Jun 18 15:22:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 139016 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4090240lji; Mon, 18 Jun 2018 08:32:02 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIfCe2ziNva5GP2q+cdzN0jYCjqaZ0+pd6SQhAMGAFpcsKBGiy/WtBrvizHXwaGoNMNnpH1 X-Received: by 2002:a50:dd84:: with SMTP id w4-v6mr11770633edk.221.1529335922793; Mon, 18 Jun 2018 08:32:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529335922; cv=none; d=google.com; s=arc-20160816; b=oxXm9451eX1kuRepdsMcbDcamW8L4OySQ+GdqfIX07tqdSvxGD15TisX8paBSaiXNH ykfUNoCssS8oTIfjuOM3MlhluzOxJT1GfTh/AqpW4aV6zVi7599A6PrGTfD0lNqKHL0O +22E7d+BBQtu0LGq1T6HSHK+/OqxXk8rUASn4Il4AB5kI8et6HMmhzjzMkGQOn4LBqef cKyr5ybsNYGkvgRwebuUqhYDAyT7ildASMoahavkd89OqJL03sLah/rSvcFTPZxXpIlb +Lz6EayQTORCfP7pxvDT5CpfDTWdoI+Uuiud7IKthWEWOcZFV7Z+Yr0wZTwhNJbsVIu9 SSWg== 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=4yVe3Qhep2FECKHeBfXJoPFMHyd1p29AD7UN+bxkh04=; b=ZIMYRTIBtFVDR+bJkw2L1I+jHn8jjbcXMf0NGk28pLq8hxaN7kYebI21DBwuApC5Kf 0vuFE65/8X+XjwIUiZrVU6q4xw4OT4wvbG42cwNydb+/B/v09VqCNONSodGUSJsIf7w5 aRzN2EmFxBzQCXNqbqirwiYKoC7dNHgC8JuS6JeS4TwzgDrjKmk4fC0MzF6eoRR2PEp4 irXQqZ+FpZuhNIhHuq9nHz7QC7V+UUWKFEtJAQAJVMtMowbXp4vybDqO4g2ztDOhe322 yIRkRCJKzdWnJMen6uv9E8RX3CdCFv0HHDDHks/ygw7atkimUV9J4hldqRLfvssDKdta N17w== 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 x47-v6si8816170edm.401.2018.06.18.08.32.02; Mon, 18 Jun 2018 08:32:02 -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 6A4E5C21F1A; Mon, 18 Jun 2018 15:25:35 +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 ADEA3C21F27; Mon, 18 Jun 2018 15:23:24 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 6D253C21DED; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 984C7C21E38 for ; Mon, 18 Jun 2018 15:23:17 +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 CC033AF6D; Mon, 18 Jun 2018 15:23:16 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 18 Jun 2018 17:22:59 +0200 Message-Id: <20180618152315.34233-6-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180618152315.34233-1-agraf@suse.de> References: <20180618152315.34233-1-agraf@suse.de> Cc: Heinrich Schuchardt , Andy Shevchenko Subject: [U-Boot] [PATCH v4 05/21] efi.h: Do not use config options 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" Currently efi.h determines a few bits of its environment according to config options. This falls apart with the efi stub support which may result in efi.h getting pulled into the stub as well as real U-Boot code. In that case, one may be 32bit while the other one is 64bit. This patch changes the conditionals to use compiler provided defines instead. That way we always adhere to the build environment we're in and the definitions adjust automatically. Signed-off-by: Alexander Graf Reviewed-by: Bin Meng Tested-by: Bin Meng Signed-off-by: Bin Meng --- include/efi.h | 17 ++++------------- lib/efi/Makefile | 4 ++-- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/include/efi.h b/include/efi.h index e30a3c51c6..826d484977 100644 --- a/include/efi.h +++ b/include/efi.h @@ -19,12 +19,12 @@ #include #include -#if CONFIG_EFI_STUB_64BIT || (!defined(CONFIG_EFI_STUB) && defined(__x86_64__)) -/* EFI uses the Microsoft ABI which is not the default for GCC */ +/* EFI on x86_64 uses the Microsoft ABI which is not the default for GCC */ +#ifdef __x86_64__ #define EFIAPI __attribute__((ms_abi)) #else #define EFIAPI asmlinkage -#endif +#endif /* __x86_64__ */ struct efi_device_path; @@ -32,16 +32,7 @@ typedef struct { u8 b[16]; } efi_guid_t; -#define EFI_BITS_PER_LONG BITS_PER_LONG - -/* - * With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64. EFI_STUB is set - * in lib/efi/Makefile, when building the stub. - */ -#if defined(CONFIG_EFI_STUB_64BIT) && defined(EFI_STUB) -#undef EFI_BITS_PER_LONG -#define EFI_BITS_PER_LONG 64 -#endif +#define EFI_BITS_PER_LONG (sizeof(long) * 8) /* Bit mask for EFI status code with error */ #define EFI_ERROR_MASK (1UL << (EFI_BITS_PER_LONG - 1)) diff --git a/lib/efi/Makefile b/lib/efi/Makefile index 18d081ac46..ece7907227 100644 --- a/lib/efi/Makefile +++ b/lib/efi/Makefile @@ -7,9 +7,9 @@ obj-$(CONFIG_EFI_STUB) += efi_info.o CFLAGS_REMOVE_efi_stub.o := -mregparm=3 \ $(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32) -CFLAGS_efi_stub.o := -fpic -fshort-wchar -DEFI_STUB +CFLAGS_efi_stub.o := -fpic -fshort-wchar CFLAGS_REMOVE_efi.o := -mregparm=3 \ $(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32) -CFLAGS_efi.o := -fpic -fshort-wchar -DEFI_STUB +CFLAGS_efi.o := -fpic -fshort-wchar extra-$(CONFIG_EFI_STUB) += efi_stub.o efi.o From patchwork Mon Jun 18 15:23:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 139001 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4083378lji; Mon, 18 Jun 2018 08:25:11 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLrzvJHUoNDQ06OWu86LhXVQ+KippD4ihRJMmIMbNtn5ajVhWSPhHY5POl55Vtbx3bowLNS X-Received: by 2002:a50:dac9:: with SMTP id s9-v6mr11578624edj.241.1529335511520; Mon, 18 Jun 2018 08:25:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529335511; cv=none; d=google.com; s=arc-20160816; b=RrECXh90emCWQg2EbBrPSmECHNnVp0jypLktJ7lb25nSo0Qx3vPH6WogaZ4ODyXfsL T8vgKWGYqyqV5NgAVivMRuNyBMFFyKK8cyKk2krAXgdB3B02ZahAIsYeVExsXyw0Wm+s wjVuQ1P7ZJe9iMZ+xsowoBd+uC+52xMPxhna3aM/7wXtlDbjmVLwRJCYLJJIuWzVxu8w Q5/ShQ+I/z/bmK4tt1HpyYyj7dqR7XJbo9R89wXmRUqrcQCy1gIWWZD8beHaJzsgV2Ue JqoGTfX4Jf9fAN8IQAXCebd1zNgYo6bBKG82fxYH1mwLX4eoExYUKvNbfV5kIRHS3eZ8 lNbA== 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=YdXjBEeCo2jVBjedPIAZnNd95MPouVnNFn/qHEnIfnQ=; b=fN6+6R5CbPCznLTUaaGsMx5JTio6TQc5Kb0eLHcmpOBTy/Gu7US6Uo1j13JyDMaj9S SohnLqHgAF7vP82XNmWvvoGpLdkuo1deVj17Eeol5ExkeQapK0j0cLLVZELWrYwQFMFj DJNVhXrtn81JYRV6hCrSwjf1z9e5ydk22aB/WI7Vd69LApB48cPDOQQ/Wcyyb+zmvtBh Hv5f8NwKQzUQVCkZKxyC+G8TM5sfM3NyS9lOr83lP0vjyfffFwbZsOkR35O6lmaOx5nD JwR45jwtF/dOBf0OyTvJhjeLtIxz0WXCzuqAtAUBfjellnG6fRbHIFb1pwCohqg7k9O1 u4SQ== 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 z20-v6si7366581edr.56.2018.06.18.08.25.11; Mon, 18 Jun 2018 08:25:11 -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 2BDF1C21EC9; Mon, 18 Jun 2018 15:23:41 +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 CFF01C21E9F; Mon, 18 Jun 2018 15:23:19 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id BA6E6C21E63; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 60494C21DFA for ; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id C9A49AF69; Mon, 18 Jun 2018 15:23:16 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 18 Jun 2018 17:23:00 +0200 Message-Id: <20180618152315.34233-7-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180618152315.34233-1-agraf@suse.de> References: <20180618152315.34233-1-agraf@suse.de> Cc: Heinrich Schuchardt , Andy Shevchenko Subject: [U-Boot] [PATCH v4 06/21] efi_loader: Allow SMBIOS tables in highmem 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" We try hard to make sure that SMBIOS tables live in the lower 32bit. However, when we can not find any space at all there, we should not error out but instead just fall back to map them in the full address space instead. Signed-off-by: Alexander Graf --- lib/efi_loader/efi_smbios.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/efi_loader/efi_smbios.c b/lib/efi_loader/efi_smbios.c index 7c3fc8af0b..932f7582ec 100644 --- a/lib/efi_loader/efi_smbios.c +++ b/lib/efi_loader/efi_smbios.c @@ -26,8 +26,15 @@ efi_status_t efi_smbios_register(void) /* Reserve 4kiB page for SMBIOS */ ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS, EFI_RUNTIME_SERVICES_DATA, 1, &dmi); - if (ret != EFI_SUCCESS) - return ret; + + if (ret != EFI_SUCCESS) { + /* Could not find space in lowmem, use highmem instead */ + ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES, + EFI_RUNTIME_SERVICES_DATA, 1, &dmi); + + if (ret != EFI_SUCCESS) + return ret; + } /* * Generate SMBIOS tables - we know that efi_allocate_pages() returns From patchwork Mon Jun 18 15:23:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 139008 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4087242lji; Mon, 18 Jun 2018 08:29:20 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJC34niHNaWYfc4djVxkfQWSkC3fFb4/yFVeBEA8wSHhYsf2btAJKFQGHzWvRcedPuaUhVY X-Received: by 2002:a50:9dc3:: with SMTP id l3-v6mr11583524edk.234.1529335760712; Mon, 18 Jun 2018 08:29:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529335760; cv=none; d=google.com; s=arc-20160816; b=SwXPeqvnuyfCn9vjQXGCavMM5EEAU2KiJCqoOEgjV8DGjfKIoYNtztYm0SyRoYs4vi JSZStEh/Ctgmp0WjMN5ZIbCBm+CO4N4HsujUKRmCPtvMX67O8IiXwDT4BaQmasjFjs+v 9A7AniT8Hh0z6rmdze0bVbZeHroQxozhLsIhObkmCzZb+zQptt3sYbihfPpHq2YkhmBq jehVbYSfne0sE9KdEH0+AEkgTPwzr7lAlPbs5NH7HoS92EJxvCnHnKyHeHbf973YjCo5 ZuW14sRQNPHtkR9nAXXPKzCnfiYQNmOpz1oVtoww7D8+92wazrxiIzG7vX0ldtdsLftT Y6Yg== 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=hJTepjo+VifVHoq9iCQB+KP7VG8wdfvOW45L96lMNNg=; b=RfVBermfIBdhVTwZeJD8obPZU8ivEL0TpA+WE2zJL2N8HkGLw9B33Vrof0/p6t+MVe /oXjSYG+DxIA/9WUCqqy8OHBjBJhXyRe+tpfZyGQsRomGTzgd2oimv/wlaIfV9wf5SP1 XJ7qlfDvj7UHhHmlmmu2AlMAgeLaV98fCXlJEMF5xzROdE+pvk4fW4NOQ9CsdmAYrUUu 6oHOdbHraBuFH3CkVU3yrEaP6RS4s62Z9qnugG2gtQHNg0xW8OTYdpJg7vqq2xDU1VKr Wqd0qOEKEjF8lPIaLdflBtjBfTpZkAARIOm+CJ2hCk5I8GT4QxfgZEQYeC6yd8tRuaqm +7UQ== 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 32-v6si8272477edr.363.2018.06.18.08.29.20; Mon, 18 Jun 2018 08:29:20 -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 4013FC21EDE; Mon, 18 Jun 2018 15:25:17 +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 D4573C21F21; Mon, 18 Jun 2018 15:23:23 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 62D20C21E63; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id BE130C21DFD for ; Mon, 18 Jun 2018 15:23:17 +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 D103FAF6E; Mon, 18 Jun 2018 15:23:16 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 18 Jun 2018 17:23:01 +0200 Message-Id: <20180618152315.34233-8-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180618152315.34233-1-agraf@suse.de> References: <20180618152315.34233-1-agraf@suse.de> Cc: Heinrich Schuchardt , Andy Shevchenko Subject: [U-Boot] [PATCH v4 07/21] sandbox: Map host memory for efi_loader 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 do not control payload applications, so we can not teach them about the difference between virtual and physical addresses. Instead, let's just always map host virtual addresses in the efi memory map. That way we can be sure that all memory allocation functions always return consumable pointers. Signed-off-by: Alexander Graf --- v1 -> v2: - only compile efi_add_known_memory if efi_loader is enabled v3 -> v4: - don't compile efi mapping code in for spl --- arch/sandbox/cpu/cpu.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c index cde0b055a6..29dac8dfda 100644 --- a/arch/sandbox/cpu/cpu.c +++ b/arch/sandbox/cpu/cpu.c @@ -5,6 +5,7 @@ #define DEBUG #include #include +#include #include #include #include @@ -177,3 +178,22 @@ void longjmp(jmp_buf jmp, int ret) while (1) ; } + +#if CONFIG_IS_ENABLED(EFI_LOADER) + +/* + * In sandbox, we don't have a 1:1 map, so we need to expose + * process addresses instead of U-Boot addresses + */ +void efi_add_known_memory(void) +{ + u64 ram_start = (uintptr_t)map_sysmem(0, gd->ram_size); + u64 ram_size = gd->ram_size; + u64 start = (ram_start + EFI_PAGE_MASK) & ~EFI_PAGE_MASK; + u64 pages = (ram_size + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT; + + efi_add_memory_map(start, pages, EFI_CONVENTIONAL_MEMORY, + false); +} + +#endif From patchwork Mon Jun 18 15:23:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 139003 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4085059lji; Mon, 18 Jun 2018 08:27:05 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJRZdelIw+6So3qFa1cMAQDYolNmTc7wgvUiaqtq42oFknDsAl7Pi+99iA1YQeEAA6cdE4q X-Received: by 2002:aa7:c6c3:: with SMTP id b3-v6mr11513675eds.302.1529335625075; Mon, 18 Jun 2018 08:27:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529335625; cv=none; d=google.com; s=arc-20160816; b=d4vwh1eDdNvyfZNfewVPRClN5DCRSHKl6oe2/2qA9JtMVai52Emts9e60fGiJTSAHT JVwy7u8KwUWl1rIGC9/JOsNVSz0JD2pulDO4TscEfu/+SgkfjgxCLpjrxBTNVkJrWdCh NWM9W//p4s1ZOsYubVZEe2JXbdYeepuXaKW6nlHzU94yNpuy1oghJ77dKpOvmBzidXuM Vsman2g8pQEn1y2K2exALHr5l6s8rgXP3pyMy0ayDfb1zh7kyV5zHwZbfN5xpTqXhzl4 uvFnLR3JN4v4q0+PRb6BwK1oUX3ncOJ+7q50x9620WXydOu15qJeEZkDmjIkWHYN4alh 7emw== 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=lUY8nhYnWYnF4GKFYcy3Jz6Bm3iI6YSxpZIPv61qQtM=; b=apsSZSNMU5YFeUUQwFHQOLQDwzE+Iy662cTqH5dn5Kt4q/P2WOVJZo3Cfi7qvBd/ke 8jiE9Ft1U2kwMHGQzQc6xw2ToNl3umfBCmI2AIradmXCEDr6E88hDnB1BOaudkwUzFzQ StvBSpiP0x3NPrYecQB0Ah6NJ7UKr3y8+b8ScRCugpNbJ7JTzXmMe0k9jwyxIN/hfIFH vY2XfNmzjWUOhBCRA7la3AxoPDUC/lP29gy5tUrrNYjRvzpQ5rkfFhQMqoyAJXM9ucoy iGgkf5K+7cDqLql89ItLFlNqDIIA1y0ZyMZa3ObwyBniPHWs9/A3BLXXaYYyZXhddTJh Z8Dg== 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 50-v6si5522002edz.449.2018.06.18.08.27.04; Mon, 18 Jun 2018 08:27:05 -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 A04F8C21EF2; Mon, 18 Jun 2018 15:24:39 +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 40F56C21F16; Mon, 18 Jun 2018 15:23:22 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 3538DC21E1D; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id C20D3C21DFA for ; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E74AEAF71; Mon, 18 Jun 2018 15:23:16 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 18 Jun 2018 17:23:02 +0200 Message-Id: <20180618152315.34233-9-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180618152315.34233-1-agraf@suse.de> References: <20180618152315.34233-1-agraf@suse.de> Cc: Heinrich Schuchardt , Andy Shevchenko Subject: [U-Boot] [PATCH v4 08/21] efi_loader: efi_allocate_pages is too restrictive 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" From: Heinrich Schuchardt When running on the sandbox the stack is not necessarily at a higher memory address than the highest free memory. There is no reason why the checking of the highest memory address should be more restrictive for EFI_ALLOCATE_ANY_PAGES than for EFI_ALLOCATE_MAX_ADDRESS. Signed-off-by: Heinrich Schuchardt [agraf: use -1ULL instead] Signed-off-by: Alexander Graf --- lib/efi_loader/efi_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index ec66af98ea..ce29bcc6a3 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -295,7 +295,7 @@ efi_status_t efi_allocate_pages(int type, int memory_type, switch (type) { case EFI_ALLOCATE_ANY_PAGES: /* Any page */ - addr = efi_find_free_memory(len, gd->start_addr_sp); + addr = efi_find_free_memory(len, -1ULL); if (!addr) { r = EFI_NOT_FOUND; break; From patchwork Mon Jun 18 15:23:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 139013 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4089137lji; Mon, 18 Jun 2018 08:31:06 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJeSDBNwzAE2WRwRj508zdY89XD/1AtsXtKvbineGjPI8eN6VyIWRCAtVKMaloiEC9LBRyi X-Received: by 2002:a50:d303:: with SMTP id g3-v6mr12010082edh.208.1529335866176; Mon, 18 Jun 2018 08:31:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529335866; cv=none; d=google.com; s=arc-20160816; b=TKuMJ8sKsDrjm4ZTMiGVzbfGYxsGGn8s4GI0tyKuEco2ikVhymApfHM6zsKHw6pf4q zniOwwpFb/gznQNdG3sIrMPmCy3PEbssg3HU8//ZMcz8KwSQpt4W91amhgTswdED/Zir vuhCu3gulbH+ngXAwYY+neWL7KYSrTdRiFvipNDHfF47ynmTawSmmMetcgc94rMclTfT z+IUZTfMXbOOJXNGwpOhHupTyDB0YK+LvhXL2GC+zDobHFfebVCNPbwxWOlNnH7VdNTV mclkCnT6ZMkoEqAkfHn4LJiDfvw2FA0SjdzumxiJCgmrjN+v6b7Aq3C67txTRSKNtFB3 i1RQ== 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=hwenLHKpXAqwv4Ou0CIiMSc2vEL3aRO1DA5KzG/55gM=; b=mzBXu73tZrVeqfVMlVNS2kv49xeAKC90ogRHOgdJaGCt+g+Z/CRhByRAwRB2Al4ywX yDkNHu4MPG0Oy/mdaSzSWQCG6FkrvL3JJEgVOq+M1eQ+M1b5L5ODyC2wn4UXdlaAAWe0 x3ezUS/5Kk7G3mj3uDi+jWNpXVppU0YIDdrUgVUjFDI8pi0vwooIfSge6FY+totdYwre MkBiTHCI5nfxNtGiFk7oMenvVbFFH5pM1JMzJa09seXt5viK5UOF6PyEHhc3jzkG06DS 6pS41vQ5m2RB1zYlFgmc93uxnWK0ETd0sVs9Cm22+ges7qKm/cHlK2u2AOM0Cpbcw+CJ HD3w== 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 b42-v6si9695180edf.140.2018.06.18.08.31.05; Mon, 18 Jun 2018 08:31:06 -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 C56F6C21F19; Mon, 18 Jun 2018 15:25:51 +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 98D1FC21F0F; Mon, 18 Jun 2018 15:23:25 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 788F9C21E1D; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id CE6CFC21E1D for ; Mon, 18 Jun 2018 15:23:17 +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 EE1DEAF72; Mon, 18 Jun 2018 15:23:16 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 18 Jun 2018 17:23:03 +0200 Message-Id: <20180618152315.34233-10-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180618152315.34233-1-agraf@suse.de> References: <20180618152315.34233-1-agraf@suse.de> Cc: Heinrich Schuchardt , Andy Shevchenko Subject: [U-Boot] [PATCH v4 09/21] efi_loader: Disable miniapps on sandbox 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" In the sandbox environment we can not easily build efi stub binaries right now, so let's disable the respective test cases for the efi selftest suite. Signed-off-by: Alexander Graf Reviewed-by: Simon Glass --- lib/efi_selftest/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile index 4fe404d88d..bf5c8199cb 100644 --- a/lib/efi_selftest/Makefile +++ b/lib/efi_selftest/Makefile @@ -41,7 +41,7 @@ endif # TODO: As of v2018.01 the relocation code for the EFI application cannot # be built on x86_64. -ifeq ($(CONFIG_X86_64),) +ifeq ($(CONFIG_X86_64)$(CONFIG_SANDBOX),) ifneq ($(CONFIG_CMD_BOOTEFI_SELFTEST),) From patchwork Mon Jun 18 15:23:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 139009 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4087485lji; Mon, 18 Jun 2018 08:29:37 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKgzHwPoqqThhIqmcpu55bVebbqbsbgGDwPeaVNpinJKnhSODi2IwHIWZbw2dJM8os84zqG X-Received: by 2002:a50:a806:: with SMTP id j6-v6mr11657883edc.138.1529335777509; Mon, 18 Jun 2018 08:29:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529335777; cv=none; d=google.com; s=arc-20160816; b=C7RETK72wMZvgSz2gnfHG3eQJU0Q2lYhjENfEbposfqJ9JruYBb76HbBkkNYcrdSxF 0RvBP5bnNmP3UIkVEsFsEBw4NhHfrqu+7ekXmyLTlVz47/hzfEuZ2pUHbKbwnBkM/8vZ fWqysczMZSJ5vf3haSFeew1BSpKwbmgszs/OgTAJ8aNPHM/yXBFrhx4LqdtcjZxKQGKe sseBZQGhHyC4siWoSGyftn9GhFx1eN5wgaRwt99HdlYtY/F7wh52+cl3WHwpFvnCI4Xm e+8LS5ffW3aAvHX+VIupXVcz/zGPdXwGwt19gCB5sdHKThaOnczG6SPXnA/zeiu/h+4S f7vA== 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=9EeXjOHWqG9DQ+lA2E4BWKxf1xn3xAq/sFSdyHfnSJE=; b=YBDnOz/a+SEqDxmjPoOSdnnlFOcmDNezy+lJT/Buk6qlcDhujRlAvVo7PRRHb9rKeG xoS5UaYA8USOUIaF7jlAdBYR6rBclfV18wakt3ftGRKMVrNQy5YQLOOoYC4ern+SfEFW +r3aZKrpH2feLrYqb0Bydu189sm++lc/QlAb8Q7IBykSCytRZUhbavWm52mIEcZzcPVn fHYFu9sooHgFF72u+HSc5OSaTMtGfm7Vh3vB2L5E2Q2o16hcEbcOQyrhIqb1LoOkubx/ 3tsePXXGJLcbTDibRMbnAsV6e1BgFZbt0zqotDPKCwIr6ayAqOLe2bxrGmVe7Evpturn NIqg== 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 t14-v6si7202894edh.210.2018.06.18.08.29.37; Mon, 18 Jun 2018 08:29:37 -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 17E81C21E38; Mon, 18 Jun 2018 15:27:33 +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 B70ACC21F5E; Mon, 18 Jun 2018 15:23:30 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 0EA36C21E38; Mon, 18 Jun 2018 15:23:18 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id D96E3C21E7E for ; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 0BCCCAF73; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 18 Jun 2018 17:23:04 +0200 Message-Id: <20180618152315.34233-11-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180618152315.34233-1-agraf@suse.de> References: <20180618152315.34233-1-agraf@suse.de> Cc: Heinrich Schuchardt , Andy Shevchenko Subject: [U-Boot] [PATCH v4 10/21] fs: Convert fs_read/write to take buffer instead of address 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" The fs_read() and fs_write() functions are internal interfaces that naturally want to get pointers as arguments. Most users so far even have pointers and explicitly cast them into integers just to be able to pass them into the function. Convert them over to instead take a pointer argument for the buffer. That way any sandbox mapping gets greatly simplified and users of the API intuitively know what to do. Signed-off-by: Alexander Graf --- board/BuR/common/common.c | 2 +- board/gdsys/p1022/controlcenterd-id.c | 10 +++++----- cmd/mvebu/bubt.c | 4 ++-- common/splash_source.c | 4 +++- drivers/bootcount/bootcount_ext.c | 12 ++++++------ drivers/fpga/zynqpl.c | 8 +++++--- fs/fs.c | 20 ++++++++++---------- include/fs.h | 12 ++++++------ lib/efi_loader/efi_file.c | 6 ++---- 9 files changed, 40 insertions(+), 38 deletions(-) diff --git a/board/BuR/common/common.c b/board/BuR/common/common.c index 9df19791c2..ab9d9c51cf 100644 --- a/board/BuR/common/common.c +++ b/board/BuR/common/common.c @@ -269,7 +269,7 @@ static int load_devicetree(void) puts("load_devicetree: set_blk_dev failed.\n"); return -1; } - rc = fs_read(dtbname, (u32)dtbaddr, 0, 0, &dtbsize); + rc = fs_read(dtbname, (u_char *)dtbaddr, 0, 0, &dtbsize); #endif if (rc == 0) { gd->fdt_blob = (void *)dtbaddr; diff --git a/board/gdsys/p1022/controlcenterd-id.c b/board/gdsys/p1022/controlcenterd-id.c index 7e082dff05..2f01f7b7eb 100644 --- a/board/gdsys/p1022/controlcenterd-id.c +++ b/board/gdsys/p1022/controlcenterd-id.c @@ -874,7 +874,7 @@ static struct key_program *load_key_chunk(const char *ifname, if (fs_set_blk_dev(ifname, dev_part_str, fs_type)) goto failure; - if (fs_read(path, (ulong)buf, 0, 12, &i) < 0) + if (fs_read(path, buf, 0, 12, &i) < 0) goto failure; if (i < 12) goto failure; @@ -890,7 +890,7 @@ static struct key_program *load_key_chunk(const char *ifname, goto failure; if (fs_set_blk_dev(ifname, dev_part_str, fs_type)) goto failure; - if (fs_read(path, (ulong)result, 0, + if (fs_read(path, result, 0, sizeof(struct key_program) + header.code_size, &i) < 0) goto failure; if (i <= 0) @@ -1019,7 +1019,7 @@ static int second_stage_init(void) struct key_program *hmac_blob = NULL; const char *image_path = "/ccdm.itb"; char *mac_path = NULL; - ulong image_addr; + u8 *image_addr; loff_t image_size; uint32_t err; @@ -1059,7 +1059,7 @@ static int second_stage_init(void) strcat(mac_path, mac_suffix); /* read image from mmcdev (ccdm.itb) */ - image_addr = (ulong)get_image_location(); + image_addr = get_image_location(); if (fs_set_blk_dev("mmc", mmcdev, FS_TYPE_EXT)) goto failure; if (fs_read(image_path, image_addr, 0, 0, &image_size) < 0) @@ -1077,7 +1077,7 @@ static int second_stage_init(void) puts("corrupted mac file\n"); goto failure; } - if (check_hmac(hmac_blob, (u8 *)image_addr, image_size)) { + if (check_hmac(hmac_blob, image_addr, image_size)) { puts("image integrity could not be verified\n"); goto failure; } diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c index b4d371f305..29fff898fa 100644 --- a/cmd/mvebu/bubt.c +++ b/cmd/mvebu/bubt.c @@ -209,7 +209,7 @@ static size_t mmc_read_file(const char *file_name) } /* Perfrom file read */ - rc = fs_read(file_name, get_load_addr(), 0, 0, &act_read); + rc = fs_read(file_name, (void *)get_load_addr(), 0, 0, &act_read); if (rc) return 0; @@ -392,7 +392,7 @@ static size_t usb_read_file(const char *file_name) } /* Perfrom file read */ - rc = fs_read(file_name, get_load_addr(), 0, 0, &act_read); + rc = fs_read(file_name, (void *)get_load_addr(), 0, 0, &act_read); if (rc) return 0; diff --git a/common/splash_source.c b/common/splash_source.c index 62763b9ebd..79dbea12fc 100644 --- a/common/splash_source.c +++ b/common/splash_source.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -252,7 +253,8 @@ static int splash_load_fs(struct splash_location *location, u32 bmp_load_addr) } splash_select_fs_dev(location); - res = fs_read(splash_file, bmp_load_addr, 0, 0, &actread); + res = fs_read(splash_file, map_sysmem(bmp_load_addr, bmp_size), + 0, 0, &actread); out: if (location->ubivol != NULL) diff --git a/drivers/bootcount/bootcount_ext.c b/drivers/bootcount/bootcount_ext.c index 075e590896..4a46f17c15 100644 --- a/drivers/bootcount/bootcount_ext.c +++ b/drivers/bootcount/bootcount_ext.c @@ -24,10 +24,10 @@ void bootcount_store(ulong a) buf = map_sysmem(CONFIG_SYS_BOOTCOUNT_ADDR, 2); buf[0] = BC_MAGIC; buf[1] = (a & 0xff); - unmap_sysmem(buf); - ret = fs_write(CONFIG_SYS_BOOTCOUNT_EXT_NAME, - CONFIG_SYS_BOOTCOUNT_ADDR, 0, 2, &len); + ret = fs_write(CONFIG_SYS_BOOTCOUNT_EXT_NAME, buf, 0, 2, &len); + + unmap_sysmem(buf); if (ret != 0) puts("Error storing bootcount\n"); } @@ -44,14 +44,14 @@ ulong bootcount_load(void) return 0; } - ret = fs_read(CONFIG_SYS_BOOTCOUNT_EXT_NAME, CONFIG_SYS_BOOTCOUNT_ADDR, - 0, 2, &len_read); + buf = map_sysmem(CONFIG_SYS_BOOTCOUNT_ADDR, 2); + + ret = fs_read(CONFIG_SYS_BOOTCOUNT_EXT_NAME, buf, 0, 2, &len_read); if (ret != 0 || len_read != 2) { puts("Error loading bootcount\n"); return 0; } - buf = map_sysmem(CONFIG_SYS_BOOTCOUNT_ADDR, 2); if (buf[0] == BC_MAGIC) ret = buf[1]; diff --git a/drivers/fpga/zynqpl.c b/drivers/fpga/zynqpl.c index fd37d18c7f..2fba77d45f 100644 --- a/drivers/fpga/zynqpl.c +++ b/drivers/fpga/zynqpl.c @@ -431,7 +431,7 @@ static int zynq_loadfs(xilinx_desc *desc, const void *buf, size_t bsize, if (fs_set_blk_dev(interface, dev_part, fstype)) return FPGA_FAIL; - if (fs_read(filename, (u32) buf, pos, blocksize, &actread) < 0) + if (fs_read(filename, (void *)buf, pos, blocksize, &actread) < 0) return FPGA_FAIL; if (zynq_validate_bitstream(desc, buf, bsize, blocksize, &swap, @@ -454,10 +454,12 @@ static int zynq_loadfs(xilinx_desc *desc, const void *buf, size_t bsize, return FPGA_FAIL; if (bsize > blocksize) { - if (fs_read(filename, (u32) buf, pos, blocksize, &actread) < 0) + if (fs_read(filename, (void *)buf, pos, blocksize, + &actread) < 0) return FPGA_FAIL; } else { - if (fs_read(filename, (u32) buf, pos, bsize, &actread) < 0) + if (fs_read(filename, (void *)buf, pos, bsize, + &actread) < 0) return FPGA_FAIL; } } while (bsize > blocksize); diff --git a/fs/fs.c b/fs/fs.c index 33808d549e..27ce9259d2 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -402,20 +402,17 @@ int fs_size(const char *filename, loff_t *size) return ret; } -int fs_read(const char *filename, ulong addr, loff_t offset, loff_t len, +int fs_read(const char *filename, void *buf, loff_t offset, loff_t len, loff_t *actread) { struct fstype_info *info = fs_get_info(fs_type); - void *buf; int ret; /* * We don't actually know how many bytes are being read, since len==0 * means read the whole file. */ - buf = map_sysmem(addr, len); ret = info->read(filename, buf, offset, len, actread); - unmap_sysmem(buf); /* If we requested a specific number of bytes, check we got it */ if (ret == 0 && len && *actread != len) @@ -425,16 +422,13 @@ int fs_read(const char *filename, ulong addr, loff_t offset, loff_t len, return ret; } -int fs_write(const char *filename, ulong addr, loff_t offset, loff_t len, +int fs_write(const char *filename, void *buf, loff_t offset, loff_t len, loff_t *actwrite) { struct fstype_info *info = fs_get_info(fs_type); - void *buf; int ret; - buf = map_sysmem(addr, len); ret = info->write(filename, buf, offset, len, actwrite); - unmap_sysmem(buf); if (ret < 0 && len != *actwrite) { printf("** Unable to write file %s **\n", filename); @@ -529,6 +523,7 @@ int do_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[], int ret; unsigned long time; char *ep; + void *buf; if (argc < 2) return CMD_RET_USAGE; @@ -567,9 +562,11 @@ int do_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[], else pos = 0; + buf = map_sysmem(addr, bytes); time = get_timer(0); - ret = fs_read(filename, addr, pos, bytes, &len_read); + ret = fs_read(filename, buf, pos, bytes, &len_read); time = get_timer(time); + unmap_sysmem(buf); if (ret < 0) return 1; @@ -623,6 +620,7 @@ int do_save(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[], loff_t len; int ret; unsigned long time; + void *buf; if (argc < 6 || argc > 7) return CMD_RET_USAGE; @@ -638,9 +636,11 @@ int do_save(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[], else pos = 0; + buf = map_sysmem(addr, bytes); time = get_timer(0); - ret = fs_write(filename, addr, pos, bytes, &len); + ret = fs_write(filename, buf, pos, bytes, &len); time = get_timer(time); + unmap_sysmem(buf); if (ret < 0) return 1; diff --git a/include/fs.h b/include/fs.h index 163da103b4..647b0c2ed2 100644 --- a/include/fs.h +++ b/include/fs.h @@ -76,27 +76,27 @@ int fs_size(const char *filename, loff_t *size); * Note that not all filesystem types support either/both offset!=0 or len!=0. * * @filename: Name of file to read from - * @addr: The address to read into + * @buf: The buffer to read into * @offset: The offset in file to read from * @len: The number of bytes to read. Maybe 0 to read entire file * @actread: Returns the actual number of bytes read * @return 0 if ok with valid *actread, -1 on error conditions */ -int fs_read(const char *filename, ulong addr, loff_t offset, loff_t len, +int fs_read(const char *filename, void *buf, loff_t offset, loff_t len, loff_t *actread); /* * fs_write - Write file to the partition previously set by fs_set_blk_dev() * Note that not all filesystem types support offset!=0. * - * @filename: Name of file to read from - * @addr: The address to read into - * @offset: The offset in file to read from. Maybe 0 to write to start of file + * @filename: Name of file to write to + * @buf: The buffer to read from + * @offset: The offset in file to write to. Maybe 0 to write to start of file * @len: The number of bytes to write * @actwrite: Returns the actual number of bytes written * @return 0 if ok with valid *actwrite, -1 on error conditions */ -int fs_write(const char *filename, ulong addr, loff_t offset, loff_t len, +int fs_write(const char *filename, void *buf, loff_t offset, loff_t len, loff_t *actwrite); /* diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c index e6a15bcb52..7bd061f395 100644 --- a/lib/efi_loader/efi_file.c +++ b/lib/efi_loader/efi_file.c @@ -233,8 +233,7 @@ static efi_status_t file_read(struct file_handle *fh, u64 *buffer_size, { loff_t actread; - if (fs_read(fh->path, (ulong)buffer, fh->offset, - *buffer_size, &actread)) + if (fs_read(fh->path, buffer, fh->offset, *buffer_size, &actread)) return EFI_DEVICE_ERROR; *buffer_size = actread; @@ -363,8 +362,7 @@ static efi_status_t EFIAPI efi_file_write(struct efi_file_handle *file, goto error; } - if (fs_write(fh->path, (ulong)buffer, fh->offset, *buffer_size, - &actwrite)) { + if (fs_write(fh->path, buffer, fh->offset, *buffer_size, &actwrite)) { ret = EFI_DEVICE_ERROR; goto error; } From patchwork Mon Jun 18 15:23:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 139011 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4088415lji; Mon, 18 Jun 2018 08:30:28 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLYWJbVAQeaHN3g80S1Kpl8sA8KhH8Znv1IubPeMhFL1yUCpJpyFvU7bAnSi44cvt+ARVX1 X-Received: by 2002:a50:88a6:: with SMTP id d35-v6mr11761158edd.239.1529335828157; Mon, 18 Jun 2018 08:30:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529335828; cv=none; d=google.com; s=arc-20160816; b=Dji/nMP3IxUMQWS69B4zTQRfZnVHYd8JIGGtbjNYAVS7hNlq501DX4UpqOwhtap4uJ kQ9JOiNa2aFscebzgWzOyBYuIb4ODGgzAGUMSM8mjM62tLZCqcMabtgzfBudcg1K07yR uzVrKyRisdW8mljYulVFfn/W0SP+xwpBl0Wa7ggYCJlHn73iOokjJYXsOPRj1Fg4rp6J K5PIg7mxASYws3BmozRsvNnNVMLtdTR6sKSp/ue09ohM5Zfe4vurEtDX9sRO9m8jtZVr CUX2xllcZFbURoL32WD7dqYg2pWQdzTJNJGAhNip7yDjesm5IvfpKzD9pAM2AazL+d// Gmhw== 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=ykFbBNIUHVqqCbHh88+DnXqWVAWZMEu4ZzI62PZL2JM=; b=BPMs38dOR6DS48mo6IXUl2t1mVuosY2XhWl0euHxkGb4FzkImqskCAEdYmXvh3h5jo tCMuSF0puWRza91DCr1jiqu7Y2wqgCEr4yVnRTqJwCYR/a3cBoqFSUaKJ3dk3gvSfSuz CG9prMFQASOvxl6TXrpCimYY6RsuX6GFfcszpFOWw90hoTwnt08EX8hGpUpbLhlkBwxB totXo5DUEJWBslYMETm4Ox7SKUH9YJXmsv6E3y+hdiVPae+y46k8IEbnI9ldAY+dWyBR 0Fw7cobkZrDrDv2ljg3LA3AiCjEZw4+PaIB0sIyClz/hACtGvy/xDsYCbYm9FiDnNGTm gK0g== 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 g33-v6si9402743edd.382.2018.06.18.08.30.27; Mon, 18 Jun 2018 08:30:28 -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 C6649C21F1F; Mon, 18 Jun 2018 15:28:00 +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 B7FBDC21F7D; Mon, 18 Jun 2018 15:23:31 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 25934C21DFD; Mon, 18 Jun 2018 15:23:18 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id D56CEC21E70 for ; Mon, 18 Jun 2018 15:23:17 +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 211B7AF75; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 18 Jun 2018 17:23:05 +0200 Message-Id: <20180618152315.34233-12-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180618152315.34233-1-agraf@suse.de> References: <20180618152315.34233-1-agraf@suse.de> Cc: Heinrich Schuchardt , Andy Shevchenko Subject: [U-Boot] [PATCH v4 11/21] efi_loader: Introduce ms abi vararg helpers 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" Varargs differ between sysv and ms abi. On x86_64 we have to follow the ms abi though, so we also need to make sure we use x86_64 varargs helpers. This patch introduces generic efi vararg helpers that adhere to the respective EFI ABI. That way we can deal with them properly from efi loader code and properly interpret variable arguments. This fixes the InstallMultipleProtocolInterfaces tests in the efi selftests on x86_64 for me. Signed-off-by: Alexander Graf --- include/efi.h | 8 ++++++++ lib/efi_loader/efi_boottime.c | 36 ++++++++++++++++++------------------ 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/include/efi.h b/include/efi.h index 826d484977..7be7798d8d 100644 --- a/include/efi.h +++ b/include/efi.h @@ -22,8 +22,16 @@ /* EFI on x86_64 uses the Microsoft ABI which is not the default for GCC */ #ifdef __x86_64__ #define EFIAPI __attribute__((ms_abi)) +#define efi_va_list __builtin_ms_va_list +#define efi_va_start __builtin_ms_va_start +#define efi_va_arg __builtin_va_arg +#define efi_va_end __builtin_ms_va_end #else #define EFIAPI asmlinkage +#define efi_va_list va_list +#define efi_va_start va_start +#define efi_va_arg va_arg +#define efi_va_end va_end #endif /* __x86_64__ */ struct efi_device_path; diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 50d311548e..404743fe01 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -2273,7 +2273,7 @@ static efi_status_t EFIAPI efi_install_multiple_protocol_interfaces( { EFI_ENTRY("%p", handle); - va_list argptr; + efi_va_list argptr; const efi_guid_t *protocol; void *protocol_interface; efi_status_t r = EFI_SUCCESS; @@ -2282,12 +2282,12 @@ static efi_status_t EFIAPI efi_install_multiple_protocol_interfaces( if (!handle) return EFI_EXIT(EFI_INVALID_PARAMETER); - va_start(argptr, handle); + efi_va_start(argptr, handle); for (;;) { - protocol = va_arg(argptr, efi_guid_t*); + protocol = efi_va_arg(argptr, efi_guid_t*); if (!protocol) break; - protocol_interface = va_arg(argptr, void*); + protocol_interface = efi_va_arg(argptr, void*); r = EFI_CALL(efi_install_protocol_interface( handle, protocol, EFI_NATIVE_INTERFACE, @@ -2296,19 +2296,19 @@ static efi_status_t EFIAPI efi_install_multiple_protocol_interfaces( break; i++; } - va_end(argptr); + efi_va_end(argptr); if (r == EFI_SUCCESS) return EFI_EXIT(r); /* If an error occurred undo all changes. */ - va_start(argptr, handle); + efi_va_start(argptr, handle); for (; i; --i) { - protocol = va_arg(argptr, efi_guid_t*); - protocol_interface = va_arg(argptr, void*); + protocol = efi_va_arg(argptr, efi_guid_t*); + protocol_interface = efi_va_arg(argptr, void*); EFI_CALL(efi_uninstall_protocol_interface(handle, protocol, protocol_interface)); } - va_end(argptr); + efi_va_end(argptr); return EFI_EXIT(r); } @@ -2332,7 +2332,7 @@ static efi_status_t EFIAPI efi_uninstall_multiple_protocol_interfaces( { EFI_ENTRY("%p", handle); - va_list argptr; + efi_va_list argptr; const efi_guid_t *protocol; void *protocol_interface; efi_status_t r = EFI_SUCCESS; @@ -2341,12 +2341,12 @@ static efi_status_t EFIAPI efi_uninstall_multiple_protocol_interfaces( if (!handle) return EFI_EXIT(EFI_INVALID_PARAMETER); - va_start(argptr, handle); + efi_va_start(argptr, handle); for (;;) { - protocol = va_arg(argptr, efi_guid_t*); + protocol = efi_va_arg(argptr, efi_guid_t*); if (!protocol) break; - protocol_interface = va_arg(argptr, void*); + protocol_interface = efi_va_arg(argptr, void*); r = EFI_CALL(efi_uninstall_protocol_interface( handle, protocol, protocol_interface)); @@ -2354,20 +2354,20 @@ static efi_status_t EFIAPI efi_uninstall_multiple_protocol_interfaces( break; i++; } - va_end(argptr); + efi_va_end(argptr); if (r == EFI_SUCCESS) return EFI_EXIT(r); /* If an error occurred undo all changes. */ - va_start(argptr, handle); + efi_va_start(argptr, handle); for (; i; --i) { - protocol = va_arg(argptr, efi_guid_t*); - protocol_interface = va_arg(argptr, void*); + protocol = efi_va_arg(argptr, efi_guid_t*); + protocol_interface = efi_va_arg(argptr, void*); EFI_CALL(efi_install_protocol_interface(&handle, protocol, EFI_NATIVE_INTERFACE, protocol_interface)); } - va_end(argptr); + efi_va_end(argptr); return EFI_EXIT(r); } From patchwork Mon Jun 18 15:23:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 139012 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4088846lji; Mon, 18 Jun 2018 08:30:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKEi1m3JRHB1bO6HkxM+PR/iezdCammy8RzPpNSddYZG8eLsme+mJwFTK+/XBqpNeOofdbO X-Received: by 2002:aa7:c588:: with SMTP id g8-v6mr11343173edq.200.1529335850775; Mon, 18 Jun 2018 08:30:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529335850; cv=none; d=google.com; s=arc-20160816; b=gvVFAGmVivzVTXK4ayE1MdIwcp+eSrcJOSjmGgtQwShg6fnMunXTZjLQUK5Sr8ew89 PVgHw15D+4zeAM2dZyGp8ZL/evaKTraT8faI0vVRvAfN0HXS1eLo9JCuenONqdZEiLjq F2M77tpFi+T2OmnFBVndVK4Q1410PCanM7J1E+70KWDt327zGmAPB6HQ+DXjpLP4+TnI 4DdGQEDL/60aV09kcdTJaPCw++IETNocLli3UPay+ubtkVIM0cCKLCSr9E65rAi7PuoL shF04BRrw51XMOpEc3zC2hGb/RiJJAxlg2cNdiw00ZlU4mUTQqd9f1Bhk8R/NcQOw0Pc 92PQ== 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=irZnT1nzMA/NDgFCc8DHOr3IeSnoIbqTeA61sLv2B+Q=; b=fCNWa8cNb+zDFtvL2Mp7qiHi0JA5jtSEGJgxAKv1msXQp98d1H52/ptu+4R0xgsWtK faY7JhY8aD2WzYIrOsw+mmCudEvjKXHGJjlLXQv31nfjwSrYryZ7GNlE9eUOM/Jjq9rX DCsNt7sWQTq4Yh+VCKuvGVPj65qrtNSzx3MR/PxhR9us2ZuZ8buCrtjX7xqI9Y/wRbNO pcw+VrG5ltNQ9+KoOqNxDpJZf5vha/TdPKUJCiUL5NI6ikwRplj8jfADPvhFNHByuAsd Ci7q5rNs7efSi9pshTWyhuhri7mrei1NhNGvsSucDxYHhfhkRRAdzEocPTzgpqET5C/S vZTg== 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 u13-v6si5300660edq.297.2018.06.18.08.30.50; Mon, 18 Jun 2018 08:30:50 -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 6612EC21F02; Mon, 18 Jun 2018 15:27:00 +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 0080DC21F68; Mon, 18 Jun 2018 15:23:28 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D78E8C21DFD; Mon, 18 Jun 2018 15:23:18 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id E18A0C21E88 for ; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 2898FAF76; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 18 Jun 2018 17:23:06 +0200 Message-Id: <20180618152315.34233-13-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180618152315.34233-1-agraf@suse.de> References: <20180618152315.34233-1-agraf@suse.de> Cc: Heinrich Schuchardt , Andy Shevchenko Subject: [U-Boot] [PATCH v4 12/21] efi: sandbox: Enable EFI loader for sandbox 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" From: Simon Glass This allows this feature to build within sandbox. This is for testing purposes only since it is not possible for sandbox to load native code. Signed-off-by: Simon Glass Signed-off-by: Alexander Graf --- lib/efi_loader/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index df58e633d1..d471e6f4a4 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -1,6 +1,6 @@ config EFI_LOADER bool "Support running EFI Applications in U-Boot" - depends on (ARM || X86 || RISCV) && OF_LIBFDT + depends on (ARM || X86 || RISCV || SANDBOX) && OF_LIBFDT # We do not support bootefi booting ARMv7 in non-secure mode depends on !ARMV7_NONSEC # We need EFI_STUB_64BIT to be set on x86_64 with EFI_STUB From patchwork Mon Jun 18 15:23:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 139014 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4089272lji; Mon, 18 Jun 2018 08:31:13 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJWmdwCLlMZVIFlHh5e37RKAt3iY22XiGhfVsurW/SJUsGCxftueUaONXZY32WCQlNDa4NG X-Received: by 2002:a50:ec94:: with SMTP id e20-v6mr11655101edr.119.1529335873032; Mon, 18 Jun 2018 08:31:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529335873; cv=none; d=google.com; s=arc-20160816; b=l7RJ+miAmwNbtQFGsgqc47DfFTXFL0COOgcKQLHBDS4DYovm6WSd138ImFL1Mk9gcG 8G9eG/j2mngP+EarPw4BOAsAY4AJPMFoMLYxPahd04UWIFy50A27Cd6PV/zedoPpSjPe g/sBBOVGsPR7YAStOGSwosOQZlfATkPw/AW36ar2h0mnQo/ZjQHvQKANPY3jyHbLPa+D wLQWNDPYJ3XEBfqJvwBiDGjry173efIoAr95HdNXM9xwL+QoXyxgzNxdXuUbNij4Z7+Z wR28sodQ2NguYGD8OZcr+6CHPMd0WlmwnIlXuMLVcwBwHve15MMel1LXFNVEFVsx6GTC ZZKA== 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=AW7Al+gkyqpwpIYH/N8u5mlS4FXvJ+xIo3O9/dUbmnY=; b=C5cdAwdSsc7fWA/J63by0KJer3zbch6shC3NLi4WJGzAzUqIOiAcs5rXXaCwQmzvxV UfoDFWWL7Vtu6X7kRATa/SsPJdaDbN34O2y2lkRSFSHlQSDGkNnpmtvnxvrInJHV7XwE eE+tKd6zHieIrPLvmz5TKZ10K66jwdA3w8UV3ktDTpLPl0OmsB/oAOYfdQ3/Q1Auj+y2 GwrKEvePyNzjvWn2A2T7NRl8dkndEZRuwc/qHQTEEQbn0DMvVxj4KJWIzwCc9smwEsth 1LMJB5hmdRmypXWcQtNHdChGHPOenbQKDv92WjIKNp+tGhkXRf2XiL/Cs81lTSmRE8DL Tsjw== 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 t38-v6si5624382edd.288.2018.06.18.08.31.12; Mon, 18 Jun 2018 08:31:13 -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 920C0C21F0F; Mon, 18 Jun 2018 15:29:37 +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 1111EC21F84; Mon, 18 Jun 2018 15:23:44 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 268BFC21F2F; Mon, 18 Jun 2018 15:23:20 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id EFAF9C21E52 for ; Mon, 18 Jun 2018 15:23:17 +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 440F1AF79; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 18 Jun 2018 17:23:07 +0200 Message-Id: <20180618152315.34233-14-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180618152315.34233-1-agraf@suse.de> References: <20180618152315.34233-1-agraf@suse.de> Cc: Heinrich Schuchardt , Andy Shevchenko Subject: [U-Boot] [PATCH v4 13/21] distro: Move to compiler based target architecture determination 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" Thanks to CONFIG_SANDBOX, we can not rely on config options to tell us what CPU architecture we're running on. The compiler however does know that, so let's just move the ifdefs over to compiler based defines rather than kconfig based options. Signed-off-by: Alexander Graf --- v3 -> v4: - Compile fix for dts --- include/config_distro_bootcmd.h | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h index 1bd79ae3b8..c35a42f6c5 100644 --- a/include/config_distro_bootcmd.h +++ b/include/config_distro_bootcmd.h @@ -245,35 +245,27 @@ #if defined(CONFIG_CMD_DHCP) #if defined(CONFIG_EFI_LOADER) /* http://www.iana.org/assignments/dhcpv6-parameters/dhcpv6-parameters.xml */ -#if defined(CONFIG_ARM64) +#if defined(__aarch64__) #define BOOTENV_EFI_PXE_ARCH "0xb" #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00011:UNDI:003000" -#elif defined(CONFIG_ARM) +#elif defined(__arm__) #define BOOTENV_EFI_PXE_ARCH "0xa" #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00010:UNDI:003000" - -/* For sandbox we only support 64-bit x86 at present */ -#elif defined(CONFIG_X86) -/* Always assume we're running 64bit */ +#elif defined(__x86_64__) #define BOOTENV_EFI_PXE_ARCH "0x7" #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00007:UNDI:003000" -#elif defined(CONFIG_CPU_RISCV_32) +#elif defined(__i386__) +#define BOOTENV_EFI_PXE_ARCH "0x0" +#define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00000:UNDI:003000" +#elif defined(__riscv) && (__riscv_xlen == 32) #define BOOTENV_EFI_PXE_ARCH "0x19" #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00025:UNDI:003000" -#elif defined(CONFIG_CPU_RISCV_64) +#elif defined(__riscv) && (__riscv_xlen == 64) #define BOOTENV_EFI_PXE_ARCH "0x1b" #define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00027:UNDI:003000" -#elif defined(CONFIG_SANDBOX) -/* - * TODO(sjg@chromium.org): Consider providing a way to enable sandbox features - * based on the host architecture - */ -# ifndef __x86_64__ -# warning "sandbox EFI support is only tested on 64-bit x86" -# endif -/* To support other *host* architectures this should be changed */ -#define BOOTENV_EFI_PXE_ARCH "0x7" -#define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00007:UNDI:003000" +#elif defined(__ASSEMBLY__) +#define BOOTENV_EFI_PXE_ARCH "0xff" +#define BOOTENV_EFI_PXE_VCI "PXEClient:Arch:00255:UNDI:003000" #else #error Please specify an EFI client identifier #endif From patchwork Mon Jun 18 15:23:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 139017 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4090262lji; Mon, 18 Jun 2018 08:32:04 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKoejF50eJBmV89HjXe4uUbNZMx5/c3nEfo33ZXV2Shd3wGHexDKWmkNtV4GVSLAo4bAvKe X-Received: by 2002:a50:8810:: with SMTP id b16-v6mr11992561edb.274.1529335924094; Mon, 18 Jun 2018 08:32:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529335924; cv=none; d=google.com; s=arc-20160816; b=TUVvrVdkUFm2Et6rQfZ6dXh9I7NS8u2UjdPljW+3Xt85bCTrqpGCUXjfj7GBCv7Nhn 465P99tH1UpGMHDhm/4ZlDJtq7ac7J4Ua8+jR9yr2HO50097DdTBn4/NogDrYJDj+lmQ ortFWUfGJJKTfZoVfeyvmReZg/RXq8z0KV3gPXxspqi0W0sZQeeZzS46j7HzueLbKIkk Av+bdkzuSxeM/QoUm6doijR2Dk+uVlFaya4WpnxTYyieNuUzryNbi9NtU48mZ68GnoA4 8+2p0dfTwfiRoqc5cgC9nmmq8bwYoXGYFV3CACsx+yVaA53U+PE7XAikY+jHoc+dB76M y1aw== 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=b3hX+Y4Nvz+OE0v6ddPN9TqJMhE1hyURr2d/9amr21c=; b=G/06vvgMC8U1s8fqVbIErn00Bmcu7oJKPlwFBs0tdjTzW9uHf3RQV8TUjpWU1IIQk1 VAJw5wnIXUeB5bQlLrHAsZs3gKidcb/LuErP66Fk60losfIwCNoAy3FMocK/Lei3j9sg MNRKhxzrKYygGTMW0qoWr+D2gpQ/4+EWHEnhNW6KUxBRZ92Hh/0xFVRAD4+XtRZLTQkI TSoFajNYb6J+ocBJsLuuurbNksgm9Tb8C0GqUH+YfXIjfxnSXfkKOEqUPti3oKMhQMf+ sIUGIPklhIc0wpbWmbwsFXOt+BAc4xOLuN5vzozQCqDtJn9FYV+ESQQe0XofbWy+RyqH KuWQ== 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 z42-v6si5590063edd.118.2018.06.18.08.32.03; Mon, 18 Jun 2018 08:32:04 -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 B0CE4C21F03; Mon, 18 Jun 2018 15:27:16 +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 C9A9DC21F45; Mon, 18 Jun 2018 15:23:29 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id EA8DAC21E1D; Mon, 18 Jun 2018 15:23:18 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id EB323C21E38 for ; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 442B1AF7A; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 18 Jun 2018 17:23:08 +0200 Message-Id: <20180618152315.34233-15-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180618152315.34233-1-agraf@suse.de> References: <20180618152315.34233-1-agraf@suse.de> Cc: Heinrich Schuchardt , Andy Shevchenko Subject: [U-Boot] [PATCH v4 14/21] efi_loader: Move to compiler based target architecture determination 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" Thanks to CONFIG_SANDBOX, we can not rely on config options to tell us what CPU architecture we're running on. The compiler however does know that, so let's just move the ifdefs over to compiler based defines rather than kconfig based options. Signed-off-by: Alexander Graf --- lib/efi_loader/efi_runtime.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c index 388dfb9840..bc44e43745 100644 --- a/lib/efi_loader/efi_runtime.c +++ b/lib/efi_loader/efi_runtime.c @@ -32,18 +32,18 @@ static efi_status_t __efi_runtime EFIAPI efi_invalid_parameter(void); * TODO(sjg@chromium.org): These defines and structs should come from the elf * header for each arch (or a generic header) rather than being repeated here. */ -#if defined(CONFIG_ARM64) +#if defined(__aarch64__) #define R_RELATIVE 1027 #define R_MASK 0xffffffffULL #define IS_RELA 1 -#elif defined(CONFIG_ARM) +#elif defined(__arm__) #define R_RELATIVE 23 #define R_MASK 0xffULL -#elif defined(CONFIG_X86) +#elif defined(__x86_64__) || defined(__i386__) #include #define R_RELATIVE R_386_RELATIVE #define R_MASK 0xffULL -#elif defined(CONFIG_RISCV) +#elif defined(__riscv) #include #define R_RELATIVE R_RISCV_RELATIVE #define R_MASK 0xffULL @@ -55,25 +55,15 @@ struct dyn_sym { u32 foo2; u32 foo3; }; -#ifdef CONFIG_CPU_RISCV_32 +#if (__riscv_xlen == 32) #define R_ABSOLUTE R_RISCV_32 #define SYM_INDEX 8 -#else +#elif (__riscv_xlen == 64) #define R_ABSOLUTE R_RISCV_64 #define SYM_INDEX 32 +#else +#error unknown riscv target #endif - -/* For sandbox we only support 64-bit x86 at present */ -#elif defined(CONFIG_SANDBOX) -/* - * TODO(sjg@chromium.org): Consider providing a way to enable sandbox features - * based on the host architecture - */ -# ifndef __x86_64__ -# warning "sandbox EFI support is only tested on 64-bit x86" -# endif -#define R_RELATIVE 8 -#define R_MASK 0xffffffffULL #else #error Need to add relocation awareness #endif From patchwork Mon Jun 18 15:23:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 139004 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4085381lji; Mon, 18 Jun 2018 08:27:24 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKgEWb4jH2C8e6DTIZsrAH4ySyvuv+VjDgs/9l0UpxRjHOWRhLOezWOjT4GRYMslkzIAmC7 X-Received: by 2002:a50:9385:: with SMTP id o5-v6mr11346752eda.291.1529335644770; Mon, 18 Jun 2018 08:27:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529335644; cv=none; d=google.com; s=arc-20160816; b=n2CtTx5Y9ucWZJmjSTHV1hdV5WAy5uWbSyp9Tn5W7GTMAs9PDtDhLlJRSiYvm8vlyl k9P1g3lTaRsm7ThWlHrVHmMYZ9c0atmjVkkJmxGk8Ing4mTFtxwgoEOVi2lVigVe+Ojs 2LSYQ5UfGe6dV/xX6aN8lEYHJEBRXWRYmAX12sNbBi9cxm0lWE91fvhiew7UCrYnY0U5 Ao2rkbHiq0msGc+uNm+MtOGKSuOZmFqvnKig9blEkLbhKNfc6SWuj4sdmN8GlkTRcoH4 l1H7Q5nKWxs7yMHisLqK5PucgBlry/GFuVv4KvWhyKUFJSjSfL/c8iz/vlbsnXOHN52n 1lRw== 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=L0ihwtCF/3NORMewIdNCs5UfSNERzRsZ7h9rYNOh56Y=; b=TaoUOWP4g4VHQjp1lI3QJvX2nxZr3f14DYP/oDdqhDUyngUMevwjY3UV/zDA+aL7sZ 4DKtsB5yidSBxrloFYxbNj70CT4jMLNOsZvWlMUCY2SXfRDYHlrTipe7ImhX1R7c3pSB nIPLBUNX9+gVgYN1MDOCyHygjsdSeBY5JXSxzz3izdvDwNTOJ3cwWZxBR3xg6XCCm+hJ eXM8EJwsPNSC1uvhYWCqhvAKk+X2cVJRfSsyzOTlAEVwfY8xKYEH1FeLRcHEkpbjlagy XaU14nDfWBuwjWX6BuEyiAzUC9MQ61Tu7RxFLKPQ8ch0bMyu7qtoAysrFtRkZydQskqc OYTA== 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 b11-v6si5399929edd.235.2018.06.18.08.27.24; Mon, 18 Jun 2018 08:27:24 -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 4766DC21E63; Mon, 18 Jun 2018 15:26:43 +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 4671AC21F5B; Mon, 18 Jun 2018 15:23:28 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C9A4DC21DFA; Mon, 18 Jun 2018 15:23:18 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id E7001C21DED for ; Mon, 18 Jun 2018 15:23:17 +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 4D1C1AF7D; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 18 Jun 2018 17:23:09 +0200 Message-Id: <20180618152315.34233-16-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180618152315.34233-1-agraf@suse.de> References: <20180618152315.34233-1-agraf@suse.de> Cc: Heinrich Schuchardt , Andy Shevchenko Subject: [U-Boot] [PATCH v4 15/21] sandbox: Fix setjmp/longjmp 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" In sandbox, longjmp returns to itself in an endless loop. Cut this through by calling the real OS function. Setjmp on the other hand must not return. So here we have to call the OS setjmp function straight from the code where the setjmp call happens. Signed-off-by: Alexander Graf --- arch/sandbox/cpu/cpu.c | 5 ----- arch/sandbox/cpu/os.c | 20 ++------------------ arch/sandbox/include/asm/setjmp.h | 4 +++- 3 files changed, 5 insertions(+), 24 deletions(-) diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c index 29dac8dfda..9087026d71 100644 --- a/arch/sandbox/cpu/cpu.c +++ b/arch/sandbox/cpu/cpu.c @@ -167,11 +167,6 @@ ulong timer_get_boot_us(void) return (count - base_count) / 1000; } -int setjmp(jmp_buf jmp) -{ - return os_setjmp((ulong *)jmp, sizeof(*jmp)); -} - void longjmp(jmp_buf jmp, int ret) { os_longjmp((ulong *)jmp, ret); diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 5839932b00..9cfdc9f31f 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -630,24 +630,8 @@ void os_localtime(struct rtc_time *rt) rt->tm_isdst = tm->tm_isdst; } -int os_setjmp(ulong *jmp, int size) -{ - jmp_buf dummy; - - /* - * We cannot rely on the struct name that jmp_buf uses, so use a - * local variable here - */ - if (size < sizeof(dummy)) { - printf("setjmp: jmpbuf is too small (%d bytes, need %d)\n", - size, sizeof(jmp_buf)); - return -ENOSPC; - } - - return setjmp((struct __jmp_buf_tag *)jmp); -} - void os_longjmp(ulong *jmp, int ret) { - longjmp((struct __jmp_buf_tag *)jmp, ret); + /* Call the OS longjmp function directly */ + _longjmp((struct __jmp_buf_tag *)jmp, ret); } diff --git a/arch/sandbox/include/asm/setjmp.h b/arch/sandbox/include/asm/setjmp.h index 1fe37c91cc..e103d170e0 100644 --- a/arch/sandbox/include/asm/setjmp.h +++ b/arch/sandbox/include/asm/setjmp.h @@ -24,7 +24,9 @@ struct jmp_buf_data { typedef struct jmp_buf_data jmp_buf[1]; -int setjmp(jmp_buf jmp); +/* Call the OS setjmp function directly, so that we don't introduce returns */ +#define setjmp _setjmp +int _setjmp(jmp_buf jmp); __noreturn void longjmp(jmp_buf jmp, int ret); #endif /* _SETJMP_H_ */ From patchwork Mon Jun 18 15:23:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 139015 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4089860lji; Mon, 18 Jun 2018 08:31:42 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKpa6Q5oEgaZ8jO/Z587nlHHhZdIcvJQZ1DwYy+OkZO1as/FYGzVWmRlojFxA3qR6uwpowA X-Received: by 2002:aa7:c756:: with SMTP id c22-v6mr11804274eds.144.1529335902441; Mon, 18 Jun 2018 08:31:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529335902; cv=none; d=google.com; s=arc-20160816; b=l10nWfE1LPEJ9yg+hi4vqjc0rN69TAqwAEA8C3B4gvIU1mieouWIlTSf5T+urr+SUJ kN5lm8SOekeRXf4QPZDvd6Q5SmFscg1zTxD75n+wFdcxuVPN2WfbvaM/JExChrGtwWX0 A5iWRHtIJbRbjPnRupXJPhhs3R8tiaRXeTmYMmxPB/lv63YigoSOGdqYPsOSd6xcAEA+ 3+4+1HKXzRWFXHuGht4TOT9Tuo8xfTHawaqUbtQ6X6/ckHpcEV3zXonznc/H94CDPQy1 iX6OTH9SK9RqD72COHWUR5dQkEQwph5TashSdsO61GoJQtJ0W4fz9MQ0rYlLtcOGe7A0 AyxQ== 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=XfeCzv3ZWJuxGCetv0oSnLKqIdJ1fboGMpab2cECnKw=; b=TrHWx+Wn+FxeBHf2w71T+egfxaxoX++i19YvBOCJ9EykMwde0QJxT6mvCilM0bv8iq HVhZ8vmORCDmYG3FvZjzTnv/aRlebUCK24css+aiNuoDBi+iTFh//vmR01g4ef70ZKGA Mcf0jGwKJIQfY1mVUxo2r1umddMbQHJhSlnEgBSackHmzETyxLDrNslavJzQ/ywF9NyB hZsD30zd7T6pfFFWjZkHr2oF/LhPACpZNjmRgq4eXqMY9S9ORV8PxrgFXO8nQ814BJ+c 9QYX4tUoa/nBR32EVphinPOaZGysQAq+z8AeRyamm/K3Gk2YGwhyJcIWUTGKdNvo21px nFGQ== 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 o4-v6si6675843edd.398.2018.06.18.08.31.42; Mon, 18 Jun 2018 08:31:42 -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 09096C21F1C; Mon, 18 Jun 2018 15:26:24 +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 72C0EC21EC5; Mon, 18 Jun 2018 15:23:27 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A7768C21DED; Mon, 18 Jun 2018 15:23:18 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 0AE14C21EAE for ; Mon, 18 Jun 2018 15:23:18 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 59399AF7F; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 18 Jun 2018 17:23:10 +0200 Message-Id: <20180618152315.34233-17-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180618152315.34233-1-agraf@suse.de> References: <20180618152315.34233-1-agraf@suse.de> Cc: Heinrich Schuchardt , Andy Shevchenko Subject: [U-Boot] [PATCH v4 16/21] elf: Move x86 reloc defines to common elf.h 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" We need to know about x86 relocation definitions even in cases where we don't officially build against the x86 target, such as with sandbox. So let's move the x86 definitions into the common elf header, where all other architectures already have them. Signed-off-by: Alexander Graf --- arch/x86/include/asm/elf.h | 45 ----------------------------------------- arch/x86/lib/reloc_ia32_efi.c | 1 - arch/x86/lib/reloc_x86_64_efi.c | 1 - include/elf.h | 35 ++++++++++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 47 deletions(-) delete mode 100644 arch/x86/include/asm/elf.h diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h deleted file mode 100644 index 7ae9c7d6da..0000000000 --- a/arch/x86/include/asm/elf.h +++ /dev/null @@ -1,45 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* - * Brought in from Linux 4.1, removed things not useful to U-Boot. - * The definitions perhaps came from the GNU Library which is GPL. - */ - -#ifndef _ASM_X86_ELF_H -#define _ASM_X86_ELF_H - -/* ELF register definitions */ -#define R_386_NONE 0 -#define R_386_32 1 -#define R_386_PC32 2 -#define R_386_GOT32 3 -#define R_386_PLT32 4 -#define R_386_COPY 5 -#define R_386_GLOB_DAT 6 -#define R_386_JMP_SLOT 7 -#define R_386_RELATIVE 8 -#define R_386_GOTOFF 9 -#define R_386_GOTPC 10 -#define R_386_NUM 11 - -/* x86-64 relocation types */ -#define R_X86_64_NONE 0 /* No reloc */ -#define R_X86_64_64 1 /* Direct 64 bit */ -#define R_X86_64_PC32 2 /* PC relative 32 bit signed */ -#define R_X86_64_GOT32 3 /* 32 bit GOT entry */ -#define R_X86_64_PLT32 4 /* 32 bit PLT address */ -#define R_X86_64_COPY 5 /* Copy symbol at runtime */ -#define R_X86_64_GLOB_DAT 6 /* Create GOT entry */ -#define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */ -#define R_X86_64_RELATIVE 8 /* Adjust by program base */ -/* 32 bit signed pc relative offset to GOT */ -#define R_X86_64_GOTPCREL 9 -#define R_X86_64_32 10 /* Direct 32 bit zero extended */ -#define R_X86_64_32S 11 /* Direct 32 bit sign extended */ -#define R_X86_64_16 12 /* Direct 16 bit zero extended */ -#define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */ -#define R_X86_64_8 14 /* Direct 8 bit sign extended */ -#define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */ - -#define R_X86_64_NUM 16 - -#endif diff --git a/arch/x86/lib/reloc_ia32_efi.c b/arch/x86/lib/reloc_ia32_efi.c index e838af3b70..f0bd2dbd57 100644 --- a/arch/x86/lib/reloc_ia32_efi.c +++ b/arch/x86/lib/reloc_ia32_efi.c @@ -10,7 +10,6 @@ #include #include #include -#include efi_status_t _relocate(long ldbase, Elf32_Dyn *dyn, efi_handle_t image, struct efi_system_table *systab) diff --git a/arch/x86/lib/reloc_x86_64_efi.c b/arch/x86/lib/reloc_x86_64_efi.c index 34c5b2ed3f..adc80ea82a 100644 --- a/arch/x86/lib/reloc_x86_64_efi.c +++ b/arch/x86/lib/reloc_x86_64_efi.c @@ -12,7 +12,6 @@ #include #include #include -#include efi_status_t _relocate(long ldbase, Elf64_Dyn *dyn, efi_handle_t image, struct efi_system_table *systab) diff --git a/include/elf.h b/include/elf.h index 0d3845e063..6802428ac4 100644 --- a/include/elf.h +++ b/include/elf.h @@ -550,6 +550,41 @@ unsigned long elf_hash(const unsigned char *name); #endif /* __ASSEMBLER */ +/* ELF register definitions */ +#define R_386_NONE 0 +#define R_386_32 1 +#define R_386_PC32 2 +#define R_386_GOT32 3 +#define R_386_PLT32 4 +#define R_386_COPY 5 +#define R_386_GLOB_DAT 6 +#define R_386_JMP_SLOT 7 +#define R_386_RELATIVE 8 +#define R_386_GOTOFF 9 +#define R_386_GOTPC 10 +#define R_386_NUM 11 + +/* x86-64 relocation types */ +#define R_X86_64_NONE 0 /* No reloc */ +#define R_X86_64_64 1 /* Direct 64 bit */ +#define R_X86_64_PC32 2 /* PC relative 32 bit signed */ +#define R_X86_64_GOT32 3 /* 32 bit GOT entry */ +#define R_X86_64_PLT32 4 /* 32 bit PLT address */ +#define R_X86_64_COPY 5 /* Copy symbol at runtime */ +#define R_X86_64_GLOB_DAT 6 /* Create GOT entry */ +#define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */ +#define R_X86_64_RELATIVE 8 /* Adjust by program base */ +/* 32 bit signed pc relative offset to GOT */ +#define R_X86_64_GOTPCREL 9 +#define R_X86_64_32 10 /* Direct 32 bit zero extended */ +#define R_X86_64_32S 11 /* Direct 32 bit sign extended */ +#define R_X86_64_16 12 /* Direct 16 bit zero extended */ +#define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */ +#define R_X86_64_8 14 /* Direct 8 bit sign extended */ +#define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */ + +#define R_X86_64_NUM 16 + /* * XXX - PowerPC defines really don't belong in here, * but we'll put them in for simplicity. From patchwork Mon Jun 18 15:23:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 139019 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4091229lji; Mon, 18 Jun 2018 08:32:58 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLCVwLj/AdTXl0+pRFTe1M8WAsq97b9tb/5fA5MO9fvCcv/XvXUuyYGVFHDkfM07qfrTawE X-Received: by 2002:a50:d490:: with SMTP id s16-v6mr11915234edi.127.1529335978473; Mon, 18 Jun 2018 08:32:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529335978; cv=none; d=google.com; s=arc-20160816; b=zZHBP08S3LJTeV7cDPj+djnmvrDlgOWohvFv1wTk6SGlZwQJW4KRUd1Oo63/QXm+2Y mCuL7w4R77jZUR4wfORxqQPu4QYh/EIam2Cl59dCXsAZJCUXHLtZ3OyH/TGM1CR2LAF8 vb5FlvwbBMWUgVEfoXgY/amY0EG+PbrkVo537uUef10jF07qxXzWZya7SlwtmNOxq/7D SEnPu1Kja86W7cdL+dCpOkQrsjXqSu4vVobHfbeMqlSRDfJy0duOrKgQBM1E0yqLE9Gn 0w6h9kvzjE6Kzp42n+X0tYeBT02wwN6TsVVkOVfOTWGB+/CsnmR58SlLWC9+5Cv0QwmQ QyIg== 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=L4b5VZnGoywya+omM7gAO3t+n6ryqfv0jNyZPE0qiTU=; b=GX6wbGi4FPhgjK+a2pYHTeMlkjONdioLDM8WvM+w3H7JfPBNqogSVsrcupkx/cCk+p h0ejEieH0r4gPZwMF3ZLcYBRG/l4miRn4F/p3S27bBaAWnSoRKJtxifXYed7PLDccfrI 3vQEi4KTEBfe2wcmfmhx6UR0OndFnrIMLcIa9IKnzpF9OoOCgj4n4VGyRwrpa3/Xy+tc GGXLTKJpievsiT7m3wsIih+dRDYjuPUGUgG1y0yp7yJkkOs0Xu+Rstd+8Xlc0ayqcxMS isCAbeqiZ6xhjzB2w2SU7/nzZkNktAjhSn/KpB2qV4Olbzhl3C8VdWQK2vQXGKCiFpyI 2Riw== 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 s11-v6si6411418edh.359.2018.06.18.08.32.58; Mon, 18 Jun 2018 08:32:58 -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 0BDFDC21EF2; Mon, 18 Jun 2018 15:28:19 +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 9D65AC21F87; Mon, 18 Jun 2018 15:23:32 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 3E083C21E1D; Mon, 18 Jun 2018 15:23:18 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id F14D7C21E9F for ; Mon, 18 Jun 2018 15:23:17 +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 53680AF7E; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 18 Jun 2018 17:23:11 +0200 Message-Id: <20180618152315.34233-18-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180618152315.34233-1-agraf@suse.de> References: <20180618152315.34233-1-agraf@suse.de> Cc: Heinrich Schuchardt , Andy Shevchenko Subject: [U-Boot] [PATCH v4 17/21] efi_loader: Use common elf.h reloc defines 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" Now that elf.h contains relocation defines for all architectures we care about, let's just include it unconditionally and refer to the defines. Signed-off-by: Alexander Graf --- lib/efi_loader/efi_runtime.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c index bc44e43745..dd3ff8ad23 100644 --- a/lib/efi_loader/efi_runtime.c +++ b/lib/efi_loader/efi_runtime.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -33,18 +34,16 @@ static efi_status_t __efi_runtime EFIAPI efi_invalid_parameter(void); * header for each arch (or a generic header) rather than being repeated here. */ #if defined(__aarch64__) -#define R_RELATIVE 1027 +#define R_RELATIVE R_AARCH64_RELATIVE #define R_MASK 0xffffffffULL #define IS_RELA 1 #elif defined(__arm__) -#define R_RELATIVE 23 +#define R_RELATIVE R_ARM_RELATIVE #define R_MASK 0xffULL #elif defined(__x86_64__) || defined(__i386__) -#include #define R_RELATIVE R_386_RELATIVE #define R_MASK 0xffULL #elif defined(__riscv) -#include #define R_RELATIVE R_RISCV_RELATIVE #define R_MASK 0xffULL #define IS_RELA 1 From patchwork Mon Jun 18 15:23:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 139026 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4094170lji; Mon, 18 Jun 2018 08:35:45 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJuePOGOxihoolpTUcv98KbfVMn5ej2KG5lAm5f1zAWA3swui2qbpBhYXnQgfYQt2eMCFb6 X-Received: by 2002:a50:82c1:: with SMTP id 59-v6mr11499674edg.114.1529336145884; Mon, 18 Jun 2018 08:35:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529336145; cv=none; d=google.com; s=arc-20160816; b=bZSPorzMAhZSbJ96psi+p6P6vkpJrFVN4fjZJdT+b4N4b0faT0cdVgls4L4W9lsuDM mIEfP58vo91FzDh8ch154tFApDUdUl/qmHZoIn393zcbAJyZzTXpEEFEALrqGrK+TOOf 1MfknN4PK9dacW9on79x4hfkb2oOmuegLeEyEbrfgMZmlLHsklxM8eYAOyu1QIBZpU58 lwysa3MXmPt38z05FxaNhRRweneAlzXYmZsiov8iUeiXBGQEFi/obhd+qc6reYYHrOhs vQmI5kx3aIKelSAB0+RichqMcb3fW2Gxw+pNmx5/Wx1NCdm06RhYwD9laTO4yNR1G3tb NJfQ== 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=Mj9oXgbKcliaJ0F1h0IyrkwNPQESdPzi9Sj9X7+HQZw=; b=gGolZwdGqBvogIrMLwH8P+xOszxGKA/QteQPLcU4FxinuI5uN4EDHyJTI8B3CP/Vom wMJlMremVbWS1j5j588ecadK0qv79j8sprkpAAJ2d+UmXAWAwwlJgzqntcqy29Zt7w2m 1GFKMKoIniQS0aL9pfcCf0kaBl+QUmnaj8PkRqx3nJAzhVCmrK5CU9Qnqsi2ORpc0nTy ducnwdNNjFuvfnh34LaPmL6JrxXKkwxwPnP7zKZWVD2j3WY36QWH8VAW1QyEs8Zv7Pq+ W2WKFWko4vyzSRT8i4M3RkBZXjgmBqJtseDaPr0/UEX6Jwm/Zzpti28EZtPETxv/VEiR mu7A== 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 z17-v6si8166372edc.424.2018.06.18.08.35.45; Mon, 18 Jun 2018 08:35:45 -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 621FDC21F06; Mon, 18 Jun 2018 15:26:08 +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 8B301C21EDE; Mon, 18 Jun 2018 15:23:26 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 92033C21E38; Mon, 18 Jun 2018 15:23:18 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 0361EC21EA2 for ; Mon, 18 Jun 2018 15:23:18 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 5F3A5AF80; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 18 Jun 2018 17:23:12 +0200 Message-Id: <20180618152315.34233-19-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180618152315.34233-1-agraf@suse.de> References: <20180618152315.34233-1-agraf@suse.de> Cc: Heinrich Schuchardt , Andy Shevchenko Subject: [U-Boot] [PATCH v4 18/21] efi: sandbox: Adjust memory usage for sandbox 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" From: Simon Glass With sandbox the U-Boot code is not mapped into the sandbox memory range so does not need to be excluded when allocating EFI memory. Update the EFI memory init code to take account of that. Signed-off-by: Simon Glass [agraf: Remove map_sysmem() call] Signed-off-by: Alexander Graf --- lib/efi_loader/efi_memory.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index ce29bcc6a3..19492df518 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -496,14 +497,13 @@ __weak void efi_add_known_memory(void) } } -int efi_memory_init(void) +/* Add memory regions for U-Boot's memory and for the runtime services code */ +static void add_u_boot_and_runtime(void) { unsigned long runtime_start, runtime_end, runtime_pages; unsigned long uboot_start, uboot_pages; unsigned long uboot_stack_size = 16 * 1024 * 1024; - efi_add_known_memory(); - /* Add U-Boot */ uboot_start = (gd->start_addr_sp - uboot_stack_size) & ~EFI_PAGE_MASK; uboot_pages = (gd->ram_top - uboot_start) >> EFI_PAGE_SHIFT; @@ -516,6 +516,14 @@ int efi_memory_init(void) runtime_pages = (runtime_end - runtime_start) >> EFI_PAGE_SHIFT; efi_add_memory_map(runtime_start, runtime_pages, EFI_RUNTIME_SERVICES_CODE, false); +} + +int efi_memory_init(void) +{ + efi_add_known_memory(); + + if (!IS_ENABLED(CONFIG_SANDBOX)) + add_u_boot_and_runtime(); #ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER /* Request a 32bit 64MB bounce buffer region */ From patchwork Mon Jun 18 15:23: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: 139023 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4092408lji; Mon, 18 Jun 2018 08:34:07 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJAHFdV36faG9of5sLfsOkKOT3qj1xOhECvFDIjVCW5ojxgynw4DnDnIWei8XQ96XldYiUG X-Received: by 2002:a50:94ce:: with SMTP id t14-v6mr11592001eda.146.1529336046976; Mon, 18 Jun 2018 08:34:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529336046; cv=none; d=google.com; s=arc-20160816; b=roV63Uft9uEN2HUPsgE6b8iqsxlr6tcZvfxiWR5OvvYZmvkz5+RXJNJzjC1EPWT7Gi ilGDV5di50d+JV74DqOFlEqJo0PsMOnRCv6KkJA+bRnAsoCJRNLwTH8zgomEBZqD5EhC +opShIpSSfhPHJOssUVweA3CsADaSujKOLHCsoNW8YEhHaHTHIUuksOw5QweDyyM91Kv 6ssfg3GCMNwuIxg3FiDcBmybZtySACvs9teLzwCdi8B66OV0sEylJ4zE1p8gFKL1B1Qh R8zmaaSmdOxy/Si/wGCsfSgko+650dk+VPLaSmtlSGLREn1ZXpw/FEfAvvWGAo44l73x UdNw== 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=WRRAKHlnRGoDQe4f68ax5XyV4+kUFKEeuavOw+O6bkg=; b=ok2pZqb0KqpaIitfv11F8plgzuHzqU/ht8kopUkbjJ9O7FrCkQfIWHxJLyGCQEpnlf jyvFmJSr48jm0PgEZTohqALP5uylX7/WGJ9KZ1YGT8QNbjMQ9SOQ3MDkiww0mFSaGBK+ FPjKIV/GtuctBguPqaEM1uCtqLHNuksbg+LdSX7gsWW4Wb/RXEDtlSpnFPQHjq16IFuE ssEFITKzKfCRSgzsaFyIiHwwEpW6r1AEWaO8j/7BGkbbT72j14t9BfIiYFKAQzhkANqw +0WWnsadrBQFi2OHVgsGOwt7GKsegD7L2z/ngclmxJsdyf+ZVvUKG8iC8oIPTUwaleRi jlQA== 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 q8-v6si6483002edg.352.2018.06.18.08.34.06; Mon, 18 Jun 2018 08:34:06 -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 99419C21F2B; Mon, 18 Jun 2018 15:28:49 +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 83B85C21F94; Mon, 18 Jun 2018 15:23:34 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7C829C21DFD; Mon, 18 Jun 2018 15:23:18 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 1C0B1C21DFA for ; Mon, 18 Jun 2018 15:23:18 +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 7964AAF82; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 18 Jun 2018 17:23:13 +0200 Message-Id: <20180618152315.34233-20-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180618152315.34233-1-agraf@suse.de> References: <20180618152315.34233-1-agraf@suse.de> Cc: Heinrich Schuchardt , Andy Shevchenko Subject: [U-Boot] [PATCH v4 19/21] 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 whenever we get into the efi_loader case, let's mark RAM as executable. That way we still protect normal cases, but allow for efi binaries to directly get executed from within RAM. For this, we hook into the already existing allow_unaligned() call which also transitions the system over into semantics required by the UEFI specification. Signed-off-by: Alexander Graf --- arch/sandbox/cpu/cpu.c | 14 ++++++++++++++ arch/sandbox/cpu/os.c | 14 ++++++++++++++ include/os.h | 19 +++++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c index 9087026d71..641b66a0a7 100644 --- a/arch/sandbox/cpu/cpu.c +++ b/arch/sandbox/cpu/cpu.c @@ -192,3 +192,17 @@ void efi_add_known_memory(void) } #endif + +#if CONFIG_IS_ENABLED(EFI_LOADER) + +void allow_unaligned(void) +{ + int r; + + r = os_mprotect(gd->arch.ram_buf, gd->ram_size, + OS_PROT_READ | OS_PROT_WRITE | OS_PROT_EXEC); + + assert(!r); +} + +#endif diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 9cfdc9f31f..9fa79a8843 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -183,6 +183,20 @@ void *os_realloc(void *ptr, size_t length) return buf; } +int os_mprotect(void *ptr, size_t length, int prot) +{ + int p = 0; + + if (prot & OS_PROT_READ) + p |= PROT_READ; + if (prot & OS_PROT_WRITE) + p |= PROT_WRITE; + if (prot & OS_PROT_EXEC) + p |= PROT_EXEC; + + return mprotect(ptr, length, p); +} + void os_usleep(unsigned long usec) { usleep(usec); diff --git a/include/os.h b/include/os.h index c8e0f52d30..d451e12064 100644 --- a/include/os.h +++ b/include/os.h @@ -157,6 +157,25 @@ void os_free(void *ptr); void *os_realloc(void *ptr, size_t length); /** + * Modify protection of a memory region + * + * This function changes the memory protection scheme of a given memory + * region. Using it you can for example allow execution of memory that + * would otherwise prohibit it. + * + * \param ptr Pointer to memory region to modify + * \param length New length for memory block + * \param prot New protection scheme (ORed OS_PROT_ values) + * \return 0 on success, -1 otherwise. + */ +int os_mprotect(void *ptr, size_t length, int prot); + +/* Defines for "prot" in os_mprotect() */ +#define OS_PROT_READ 0x1 +#define OS_PROT_WRITE 0x2 +#define OS_PROT_EXEC 0x4 + +/** * Access to the usleep function of the os * * \param usec Time to sleep in micro seconds From patchwork Mon Jun 18 15:23:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 139021 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4091728lji; Mon, 18 Jun 2018 08:33:26 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIzu8fH6sDf6oaPim+7BYKncbbXN78Age7hdX09rGeqlqXlJAr7a0NnciPNHGOfJ48Gvwqk X-Received: by 2002:aa7:d299:: with SMTP id w25-v6mr11479491edq.13.1529336006850; Mon, 18 Jun 2018 08:33:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529336006; cv=none; d=google.com; s=arc-20160816; b=XdyyS0LMljqyJlC5J+p0xm2yqByhVnuvWifhyb7DsYXHUcxEAojJns1A7dYCJtExcS DUzGF7ujQD3+Wp8Nwj2VaLOifVNKJGb/+9DmuxcI849kSEh4E2zI8AhAMfTAKEyYoZwz 6yNKcqodJdAUoOATDtjiGwNtQSA4VhPECB8G6Lx3WSmQIGPkhBWBDBj5UpXRkm1MGRjV VxfkwuBMEaY9tbeJaWS/LHyOiv86sjuaqWP2vqArb3Bm7j3t0kMk7Bng1J8cdKEECbOR qUOQQdEAt7eu4e4Lnxzt9A0isPPM3u2VL3tJWq6wRd92/ip5OmEr8p+BrVXFco0BEh/i Z1Wg== 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=bDHdEMkPPh9PPgrQg4wWBVK2ZLTkrsdQGlRWEaiRVFY=; b=Ekos0LAUXnr1YaB4is6Emdocqr/cAaHoMAGa/GZYpq8FqPgg7LC0XLyz3TIyPMf3cN MnaWZhHRlqpwwoeis93QjpxHgrGky3fnVxL6aO8Rk+EEfY1MeikKzOwzPlAW6JyNzDnf iMm7c09rVzHLA8RIF57p8PUvIhL/9SarGBgWG35INac3mr1KxvBcBpewB0M98jfrBBt8 bBHmw5KCeTci1trErLPDEvFyXfkIM9EB/rWQcor/sUecDeQ+K09lWoEqPrKZbNGJWa40 hrrHner/TmdP4CtqNL02Y+zK6Fug3ystYp6kfbhJIE6HT4+XW9B7u9+BrXzN0Ykdmjw1 TcXg== 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 f24-v6si8850356edm.12.2018.06.18.08.33.26; Mon, 18 Jun 2018 08:33:26 -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 7F93AC21F2B; Mon, 18 Jun 2018 15:28:33 +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 A143DC21F71; Mon, 18 Jun 2018 15:23:33 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 5BC72C21E70; Mon, 18 Jun 2018 15:23:18 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 14AF1C21EB1 for ; Mon, 18 Jun 2018 15:23:18 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 7CF4DAF85; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 18 Jun 2018 17:23:14 +0200 Message-Id: <20180618152315.34233-21-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180618152315.34233-1-agraf@suse.de> References: <20180618152315.34233-1-agraf@suse.de> Cc: Heinrich Schuchardt , Andy Shevchenko Subject: [U-Boot] [PATCH v4 20/21] sandbox: Always allocate aligned buffers 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" In some code paths we check whether host virtual addresses are sane. That only works if at least alignments between host and U-Boot address spaces match. So let's always map U-Boot addresses with 64kb alignment. That should be enough to ensure that the actual RAM ends up in a different page from the header on all architectures. Signed-off-by: Alexander Graf --- arch/sandbox/cpu/os.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 9fa79a8843..4dc6483922 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -143,14 +143,15 @@ void os_tty_raw(int fd, bool allow_sigs) void *os_malloc(size_t length) { struct os_mem_hdr *hdr; + size_t alloc_length = length + (64 * 1024); - hdr = mmap(NULL, length + sizeof(*hdr), PROT_READ | PROT_WRITE, + hdr = mmap(NULL, alloc_length, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (hdr == MAP_FAILED) return NULL; hdr->length = length; - return hdr + 1; + return (void*)hdr + (64 * 1024); } void os_free(void *ptr) From patchwork Mon Jun 18 15:23:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 139024 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4092932lji; Mon, 18 Jun 2018 08:34:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJrl1QP1wLwUw8xbpsaej0Q2JCayXGQAgcKPqCGBbzdmQej0MZj9P/Pwk9PsuB3EzFWaaqt X-Received: by 2002:a50:fb13:: with SMTP id d19-v6mr10664871edq.41.1529336074451; Mon, 18 Jun 2018 08:34:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529336074; cv=none; d=google.com; s=arc-20160816; b=RBKpPT05sNPj94VZCX3FPCmp0HFVdbWlpqpSfdBE+/QnvjkAE8iq7k1oSWdWvw6Y06 trodw0peagHKQtiDRiDJY0gikQ4hLtcSbeFLhQ1A76ZOqqxdDeeIwLmJ5VI0hf9HJDh9 fGJf/jGPwY9SjQFSDbRk+T4KKDq3rH6s3cmc/aMatwnm6hTX9WP1LKuFsOQtq1AyWgz1 bQsJv5uwEvVJa9cPSZzIgbZ+7OcLXI2Mb2iKxEOifSnJt65Rr8w5piS14dyIAePNqOe+ coq+xnjZAdm4WRBSD/HuNZd2HGgZR8kG8CxgHf/e3KRhOe8OHzYSw8XwSPhDmRT4pXvB vEpw== 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=4U8+tp83zU7OCHR76G8PvGU2l7v2I+b57lPgzQhsZZE=; b=lnuWsikLOqFoOSymRicvDAdn/V3JNclJTklxtKve+Nirkb+rnRxLwDSiO873NU7AuH J/wedwsKMeCXVDi8Ks7jH3N19bqfdteKf6F7SjagAciHeY242JVDhyWMnrZ1x6GrIGbd xpNapodIVB518aLVwCXLVSH2cHklVl2SDn62K19p96UaF/Ps5u/tH65eApbyHLgASaNh oE5Uos7WNv6vw+DDkxcMb+7WFpit2ifwwZHLLIaZUc5/i/S9YFqu5gZD3sBddQE7fLgm m3d45zyKj2I7vqjVtISNNUd5R10A8q80DXgM4bXz5IRldADg3GH5zAlB6mtwkst8o/bY UuNA== 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 o90-v6si9734072edb.241.2018.06.18.08.34.34; Mon, 18 Jun 2018 08:34:34 -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 13DBAC21F02; Mon, 18 Jun 2018 15:29:05 +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 556E6C21F98; Mon, 18 Jun 2018 15:23:35 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C4478C21E70; Mon, 18 Jun 2018 15:23:18 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 25E0FC21DFD for ; Mon, 18 Jun 2018 15:23:18 +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 8ABFDAF87; Mon, 18 Jun 2018 15:23:17 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Mon, 18 Jun 2018 17:23:15 +0200 Message-Id: <20180618152315.34233-22-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180618152315.34233-1-agraf@suse.de> References: <20180618152315.34233-1-agraf@suse.de> Cc: Heinrich Schuchardt , Andy Shevchenko Subject: [U-Boot] [PATCH v4 21/21] efi_loader: Expose U-Boot addresses in memory map for sandbox 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" We currently expose host addresses in the EFI memory map. That can be bad if we ever want to use sandbox to boot strap a real kernel, because then the kernel would fetch its memory table from our host virtual address map. But to make that use case work, we would need to have full control over the address space the EFI application sees. So let's expose only U-Boot addresses to the guest until we get to the point of allocation. EFI's allocation functions are fun - they can take U-Boot addresses as input values for hints and return host addresses as allocation results through the same uint64_t * parameter. So we need to be extra careful on what to pass in when. With this patch I am successfully able to run the efi selftest suite as well as grub.efi on aarch64. Signed-off-by: Alexander Graf --- arch/sandbox/cpu/cpu.c | 19 ------------------- lib/efi_loader/efi_memory.c | 12 ++++++------ 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c index 641b66a0a7..be88ab2f1c 100644 --- a/arch/sandbox/cpu/cpu.c +++ b/arch/sandbox/cpu/cpu.c @@ -176,25 +176,6 @@ void longjmp(jmp_buf jmp, int ret) #if CONFIG_IS_ENABLED(EFI_LOADER) -/* - * In sandbox, we don't have a 1:1 map, so we need to expose - * process addresses instead of U-Boot addresses - */ -void efi_add_known_memory(void) -{ - u64 ram_start = (uintptr_t)map_sysmem(0, gd->ram_size); - u64 ram_size = gd->ram_size; - u64 start = (ram_start + EFI_PAGE_MASK) & ~EFI_PAGE_MASK; - u64 pages = (ram_size + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT; - - efi_add_memory_map(start, pages, EFI_CONVENTIONAL_MEMORY, - false); -} - -#endif - -#if CONFIG_IS_ENABLED(EFI_LOADER) - void allow_unaligned(void) { int r; diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index 19492df518..64d2b8f7fa 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -326,7 +326,7 @@ efi_status_t efi_allocate_pages(int type, int memory_type, /* Reserve that map in our memory maps */ ret = efi_add_memory_map(addr, pages, memory_type, true); if (ret == addr) { - *memory = addr; + *memory = (uintptr_t)map_sysmem(addr, pages * EFI_PAGE_SIZE); } else { /* Map would overlap, bail out */ r = EFI_OUT_OF_RESOURCES; @@ -360,11 +360,12 @@ void *efi_alloc(uint64_t len, int memory_type) efi_status_t efi_free_pages(uint64_t memory, efi_uintn_t pages) { uint64_t r = 0; + uint64_t addr = map_to_sysmem((void*)(uintptr_t)memory); - r = efi_add_memory_map(memory, pages, EFI_CONVENTIONAL_MEMORY, false); + r = efi_add_memory_map(addr, pages, EFI_CONVENTIONAL_MEMORY, false); /* Merging of adjacent free regions is missing */ - if (r == memory) + if (r == addr) return EFI_SUCCESS; return EFI_NOT_FOUND; @@ -381,9 +382,9 @@ efi_status_t efi_free_pages(uint64_t memory, efi_uintn_t pages) efi_status_t efi_allocate_pool(int pool_type, efi_uintn_t size, void **buffer) { efi_status_t r; - efi_physical_addr_t t; u64 num_pages = (size + sizeof(struct efi_pool_allocation) + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT; + struct efi_pool_allocation *alloc; if (size == 0) { *buffer = NULL; @@ -391,10 +392,9 @@ efi_status_t efi_allocate_pool(int pool_type, efi_uintn_t size, void **buffer) } r = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES, pool_type, num_pages, - &t); + (uint64_t*)&alloc); if (r == EFI_SUCCESS) { - struct efi_pool_allocation *alloc = (void *)(uintptr_t)t; alloc->num_pages = num_pages; *buffer = alloc->data; }