From patchwork Fri Jun 15 12:42: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: 138685 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp804063lji; Fri, 15 Jun 2018 05:49:32 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK4mLYz3t9KyHxu7ExlFvB025jJ2nb8YLnRFST1aykx4/7yCq9MX+2B5rDlXzIDxokjJKMc X-Received: by 2002:a50:fb8f:: with SMTP id e15-v6mr1750492edq.141.1529066972240; Fri, 15 Jun 2018 05:49:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529066972; cv=none; d=google.com; s=arc-20160816; b=GZOhuJq2NzRsbbTquecQRtF9VwloWW2Q7D9b1zJZ4OyWz9BEYRo/eP4noyAoxcIsRc WueSsFmwEHikO0/XTDU6oRfk9FiDsz9urtAVuis9EUtdcmPWhjBXYqvd432VUAYs4/BZ Dei88isqNa4qO4iQWphSRUZ5YEO3L0oNkXPboDJXjxy2++Lv1pUKtwmxOZq8CZ+a5s8T JthxuhL4mDV+Do2hrhR4yT/Q+kbA4n8uZw6SP5Oo/frscG2xHP2iioUaM1N5GgQDglWg fJimlr2e5p6ek18QWv3nEoq6isOlRqto1IQtZEVFzks5TpHHzDlgLcNcLuOxxVAt+91c CrRw== 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=j1dNMTjRk+JP0molinnobjvZac9fs4Izu6DPsvg2BlgBpR2EUpbQSNd2+Z12xJPREN kTeTmiP9nPiwps/uTJ0oTIkoQFJbmMePbPBo5C3osqkpu+U0+T5smK24Rdb4Q3QYZgdp 1LN289KKb4OXk0CP3mygEKltV9I/XJRqovYaFKYdNVq1iHs+KJNRyWx0b3Hn7nOR0ycM 29pjhfS7tkGUMSDlVbue20sANoVkRG8s38HBAWrMNU3DHFn49SbroHmhNpRWQUe1JkGr QcvGu2XHo6MO6E5TxDeZ9V5nP8XBzzEVzaD2AyE8hropxpLAnkRQIJURRsa7ht15vZA6 Xy8w== 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 m9-v6si6441868edf.0.2018.06.15.05.49.31; Fri, 15 Jun 2018 05:49:32 -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 CFD8BC21EFC; Fri, 15 Jun 2018 12:45: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 AC9D4C21F38; Fri, 15 Jun 2018 12:42:40 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 8C4C0C21E29; Fri, 15 Jun 2018 12:42:33 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 96168C21E52 for ; Fri, 15 Jun 2018 12:42:31 +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 DC024AD59; Fri, 15 Jun 2018 12:42:30 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Fri, 15 Jun 2018 14:42:13 +0200 Message-Id: <20180615124229.35310-2-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180615124229.35310-1-agraf@suse.de> References: <20180615124229.35310-1-agraf@suse.de> Cc: Andy Shevchenko , Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 01/17] 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 Fri Jun 15 12:42: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: 138687 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp805256lji; Fri, 15 Jun 2018 05:50:47 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKVTxBDBBj5SKoSBIXat3XJxS5SowNg05UFLQs0HdH3pW5ORxNW22on21/aqNJpzAmzUVgF X-Received: by 2002:a50:87e6:: with SMTP id 35-v6mr1777227edz.1.1529067047361; Fri, 15 Jun 2018 05:50:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529067047; cv=none; d=google.com; s=arc-20160816; b=VGMKU0xkhidFECxhcbHj4/iKAokXgSA2UFSljc8CJQfVcDuM1XurvcUi2Vek0Nsx4u zKlXKGAF+nQ/Xh7gI5JETFdp5Er1rO4nEDi4ewmG+f3nYZ4JBjJsSlozR/4cFUUg3VeG flL7KZg6xdivRNi1/Mqb0+uVVf/zGNYXFSB7bj/XcVup3AyqDA3aQ/DSPzGVAMrr9YwO OKNhd5EjXhKY5dSasb4WBEzsmHXGZy1HqkKvvEHrZ4xV+GCBEDso+CprpC0RO8+cIw3O aTggyPzNvKrtiiWoLSdGDodbrUNLjhLf5ttpapRly4kLJhsPMEWE73dKfGblI9/mCFYq F36g== 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=XSoTdkqip5aG0wId6L5oSD1Ntxh1QWMzNhUQJzNLakopZX/R6aWy4JJtk+88pfjQsE wndDYrrqMveNdEk4SsoQkd6iSriCrvnIHA9BcY0uwyQ23Q1DwGjyWLeXyKhyBfoeXuqT slXWqMO2WfAaW1GjAlwgj/67HvK+V1Jdn3+15WMgOCeV3sAdeg3aK3hpEPcKNoOfQe/P Oj+a2Y49ktEeeaxKGfSdidswPVR6G42gKLCGV2kTYLZyDm6hgxIfYQ0gSrGJ3X9hxHJM t/S1sIu+ZkNOIHkX5AEZtIscPWaJQ+bZY6Ip7GDTgGlZaeGmYgMR5+O636m8CIxI65oR /WBA== 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 d55-v6si4920486ede.97.2018.06.15.05.50.47; Fri, 15 Jun 2018 05:50:47 -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 02F97C21EA6; Fri, 15 Jun 2018 12:44:23 +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 45C3BC21EDC; Fri, 15 Jun 2018 12:42:37 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 350CEC21E29; Fri, 15 Jun 2018 12:42:32 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 554ADC21E2B for ; Fri, 15 Jun 2018 12:42:31 +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 DD378AF0B; Fri, 15 Jun 2018 12:42:30 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Fri, 15 Jun 2018 14:42:14 +0200 Message-Id: <20180615124229.35310-3-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180615124229.35310-1-agraf@suse.de> References: <20180615124229.35310-1-agraf@suse.de> Cc: Andy Shevchenko , Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 02/17] 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 Fri Jun 15 12:42: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: 138679 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp799660lji; Fri, 15 Jun 2018 05:44:55 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIETRW/bK5Mp8v6kY0+shxzs7tTCA8YVg2qcIcCIiCXduFDcyOnJYnxW6RGeGqko20+5rY1 X-Received: by 2002:a50:b671:: with SMTP id c46-v6mr1837138ede.190.1529066695482; Fri, 15 Jun 2018 05:44:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529066695; cv=none; d=google.com; s=arc-20160816; b=pmuZrhH7/RXCXwU6NSlUK6++DOlqv/Nl1hGAF1H+Wuz8blGhwfvVAMlHQxLze3At0I hNl96v4ETHZiNjFXzWCPUV9xwRHpfTDct+llCkI78cxJTxFy42CYYuC08bAOsVgfjakV 5GA9/vyHBDDozSa5asdfxBW7Ilu6lBtaG5Hi0ai/4rLhXqK2T3R68FbSXvQS6U/n1MEf /i2FaNVuZzUhHRI+KgM1YPMaG2metu45SahaZCz++gq5JIM2v/v0ty5nXJt/E5boCTR5 rAwi34OHyFeOgmrw1hZXGvWjLvegsxEpKCoWnbMpD+hblQLBSBZ08gFG3yV628FOmnd7 fLPg== 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=eGNlucv7CbjvuFNbEfkwOyrTncOPY+5fnwsyPauiKIeJzCyYGg6+KGdRTN20+Jr5qg ns2phEshkSJ3mW+HBBSrscPE+kAYq2zChMRC2gd4uP/mayxOqB26DHyT14FQtU/eFyx0 fCf2OgCcTD8W7lLuHTJ/LqB3V0wFzgtUJkLouo+VisyotiIgE/KeZ6I8evz61RJj2OwF rcN5tPM3cjPwCuEtQFPNtraJtpVkQlVDg3Kb9q71CS1SU1a2B9UuTEuV0doRYzAT3g7V Nw6PwGFJRwAVcKtvbWYlhJmF11XnwjIALyQFjtTkkjXbh97OsBO1nCMYXIemeo9tXtRh jXMg== 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 v3-v6si2944661ede.462.2018.06.15.05.44.55; Fri, 15 Jun 2018 05:44:55 -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 17DA6C21E2B; Fri, 15 Jun 2018 12:43:47 +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 9CCFFC21EC5; Fri, 15 Jun 2018 12:42:35 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 0E110C21E2B; Fri, 15 Jun 2018 12:42:32 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 8AD0EC21E50 for ; Fri, 15 Jun 2018 12:42:31 +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 DB957AC7F; Fri, 15 Jun 2018 12:42:30 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Fri, 15 Jun 2018 14:42:15 +0200 Message-Id: <20180615124229.35310-4-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180615124229.35310-1-agraf@suse.de> References: <20180615124229.35310-1-agraf@suse.de> Cc: Andy Shevchenko , Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 03/17] 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 Fri Jun 15 12:42:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 138677 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp798268lji; Fri, 15 Jun 2018 05:43:28 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIigP+Azj2d1iuqgvofx0WyxxVPMry+lVn0AdzhsMtxhn1X4FIPJ6uLNkzqThwSHCDzbNUV X-Received: by 2002:a50:b5a3:: with SMTP id a32-v6mr1773571ede.120.1529066608625; Fri, 15 Jun 2018 05:43:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529066608; cv=none; d=google.com; s=arc-20160816; b=fTpuSzcCA6hdeYZlOpSLjWWeofDdGtvwfSWe5e/2fD5uRLjKjLz+gwYZlWBXoijaVh Q/dG/eMageA2C7WO7NAQbsndbBBPkC1TQ1G7P6nZxtqcG81Jt7SkpxlsYJKMms3pNBOW pWQz2ASEEybBwn2XPpHY57tSaHViS/TiHU49v35PgMjADXzAzElONoce4J6C1UGAOQzR Uso+jhffTEFioMCeaItyK/hz3xOOPwtRzh/xdhwU1vgy7Rn47H7sppjuogHHWSOvdjmj Am7wC7GArjMLFU2BKpU21+nygVdH1sXX1UvHKXiMIg3yQ3yGRP7urlJvmx+iHyFHpLCe zQYw== 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=rqGgrf6v3MzORs2GGqVfsIfms8TKpfCJfoTX0EWSHVP/IyoB9Z5T6Jf6/gwcY3ouvT fB6+d2HLm7ZpxGbfVlRmChpJHIh9kCr06hjmDqqEbKNczer+7KRRR+lh2+l3Wofwlnqn c/x3Ufdn+sLDlzEOsWHFpuS4xhhAVuEri2iy5TG/naFKKlkhtWCgAaJuMXrypY4b8U7U jor4bZmvqGX/Wb87bHhanm9cixjuQ0sSCPD0nSS4cBHE9woyX+MutCVhktDEMyRFJNFf 2VFa6XP8Jj525Qv+n9YKfbWmEvqj/Rxcvqs1YDE0G0FLPtp7fRsJQYs/rNRrCoOFq+Vb Z4qQ== 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-v6si2884599eda.373.2018.06.15.05.43.28; Fri, 15 Jun 2018 05:43: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 06591C21F17; Fri, 15 Jun 2018 12:43:03 +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 46C80C21E68; Fri, 15 Jun 2018 12:42:34 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C43CBC21DAF; Fri, 15 Jun 2018 12:42:32 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 527B0C21DAF for ; Fri, 15 Jun 2018 12:42:31 +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 DD355AE4F; Fri, 15 Jun 2018 12:42:30 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Fri, 15 Jun 2018 14:42:16 +0200 Message-Id: <20180615124229.35310-5-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180615124229.35310-1-agraf@suse.de> References: <20180615124229.35310-1-agraf@suse.de> Cc: Andy Shevchenko , Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 04/17] 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 Fri Jun 15 12:42:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 138684 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp803340lji; Fri, 15 Jun 2018 05:48:46 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLT6ihIkdxg7D92A9SmZvOBKGpiZrEMkz66cd4o0ub5lt+8e8QFtJTGDKRhS6xFQW1LHMND X-Received: by 2002:a50:864b:: with SMTP id 11-v6mr1743595edt.229.1529066926204; Fri, 15 Jun 2018 05:48:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529066926; cv=none; d=google.com; s=arc-20160816; b=k6OC+Vr/03hEy/XbVSn7EFCDSpI8NXN9pTSzWjEue0VugbgDrcgpED2kBKfOvgvNxj MBCE02QRhv/qZ0db31RqyKM5mE7JfFW9P+sW/kowKkW3TNsPTrkOQeB+wwhiDMEsCPxm ZHenOQrqfrXY6slldQIyC2UzOaEyv+cZKgvvCVAWn4NWpejky7X6hHBVWDxHy1wWtUNN WbuoeYaa3WqQohCimaSYLeKuOw77RBSkAtH26u+/B9hwDtFXufG312PWcTlC+pyOn1ho e193V8Ky+T3sWXNvCrjcv+M3E4kARoSec0d+vfDqSSfzYstudapj0hSHbvM73Dz7fA9A wynw== 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=fpR5ZgEwOVfe0JyIHKicwtPj9DBVlctAbnlqsYpawXHLG3nji6Z3u/FAENEhMNvMxi Oi5SHjiEZpZk1/lkFycafQmuh9Gi2H2GSnoCZ505Ph8BUa/MKV08nIYz0RFHJV1uiyYK Nb3/VknjEPRfYsqwHxoK56uuPMt7tp4EZRdB0Bx+lcJixtuyRypr9l0Kxxq+PuFkxypS mGQX5osNL4X3xUeJOkWV2zW28h4OgpeG6OHsPMlwmZSCCn9EqaO8vMMJ45pyT9bKu9ZP ktY1vaP5AD+vWklfFnjPCvMtwx2bikaad9/8yzYrAixLnnqHLNLwA/73Rp0hmluET7P3 Hd8Q== 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 u2-v6si5962438edd.23.2018.06.15.05.48.45; Fri, 15 Jun 2018 05:48:46 -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 9DC26C21F1D; Fri, 15 Jun 2018 12:44: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 7892EC21EF7; Fri, 15 Jun 2018 12:42:36 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 239FBC21DAF; Fri, 15 Jun 2018 12:42:32 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 6B27AC21E30 for ; Fri, 15 Jun 2018 12:42:31 +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 EAF35AF41; Fri, 15 Jun 2018 12:42:30 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Fri, 15 Jun 2018 14:42:17 +0200 Message-Id: <20180615124229.35310-6-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180615124229.35310-1-agraf@suse.de> References: <20180615124229.35310-1-agraf@suse.de> Cc: Andy Shevchenko , Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 05/17] 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 Fri Jun 15 12:42:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 138681 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp801524lji; Fri, 15 Jun 2018 05:46:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKWTBLFwCdz7cQrkIVPr7znz9n0VO1lnDuCIk4zu+c+MqRVnPwTveKyfeZoATUzx5i6SWCo X-Received: by 2002:a50:eb48:: with SMTP id z8-v6mr1800691edp.7.1529066810191; Fri, 15 Jun 2018 05:46:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529066810; cv=none; d=google.com; s=arc-20160816; b=Ac82FTEMoxaBwByDQGJ8lxyKcPf2pKUYV8aFUHK1QlC9Tt3oX0Z2cHn/JBrKrhtcLO srukQzPrXQSjqJOfCqgbXRxxEp5f2sbmNiDjWM6c6VgwJ+naqQGYNQtX3Q+0Bq86SO4Z BlnbVq1V1zl3j76OLQmPd4w1A8V6p3HRWH0Nl1kRYMx+U5Log5r3r1+t+i9M7gD8H1iV dKKqgTki7lBM0Q5PVXLLNrW5zlYCazP/BzEQ0Ae5NZ6Nc6+GEUPkCIF/s2sKVudZBeiy FYQ3RobKC3YaYy2jzfNfQjGEX8zGrY5H3nYpKhPXJy9JBF72UJlj1tSaYNnTz261DSQX QCJA== 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=sWRGq96AxqX2AuRxObNooWxu5dOrz8M+GHzvQTpU3TnmI9wpIlc0E/EiXd27L1J3Ld Tbvl+RdzMuWiq4eHpe+CVguAzvnxFi1p1ut3hvVC0JPYi/KmycObAaHCr68s3yXYotJo 1Ari1zn6vepfqkeczO+HOn48xBy59nJpDcRMdcADXlq6jSw5HXiHKtdRm1O47U43g1Jc /d7VfeH5Yv/qpmpkcQY47l11lBONG5Bmzd8uQkkrvsDsJnT1OoOHcv5dxCzo6vR0LBDI AmPk4dHO/Gc0IKa5BTJhv3AsMvW7W4VPPqWufbKMmS8uYxNnAZBY+z/jQs2e4ZUrEBKc f70w== 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 f38-v6si4806118edd.281.2018.06.15.05.46.49; Fri, 15 Jun 2018 05:46: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 C71BDC21EEF; Fri, 15 Jun 2018 12:44:40 +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 1DAA3C21F1C; Fri, 15 Jun 2018 12:42:38 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 4C5C6C21E30; Fri, 15 Jun 2018 12:42:32 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 9D458C21E62 for ; Fri, 15 Jun 2018 12:42:31 +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 EDBDBAF45; Fri, 15 Jun 2018 12:42:30 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Fri, 15 Jun 2018 14:42:18 +0200 Message-Id: <20180615124229.35310-7-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180615124229.35310-1-agraf@suse.de> References: <20180615124229.35310-1-agraf@suse.de> Cc: Andy Shevchenko , Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 06/17] 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 Fri Jun 15 12:42:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 138678 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp798836lji; Fri, 15 Jun 2018 05:44:01 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ/FTbod7ID8jymc0dnwOriYpS8lJuUf9Fkw/qV7pDkrwLCSHJic1ZGMk8K+h9VAxb8Lb/G X-Received: by 2002:a50:a666:: with SMTP id d93-v6mr1761271edc.294.1529066641391; Fri, 15 Jun 2018 05:44:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529066641; cv=none; d=google.com; s=arc-20160816; b=C8xPf6NfNA5C77Lk8bQZrAcNXkX3mBpn2iRLoOI3vA1pYn/2DgUEnHHPmzbvmu2T5E 9/iveQMqWgnhzNjuP55oLGGeNWtnM+H9HYejziNlpa6+UqX/5eguGqMm7/yZsoawJEdE JYcc0aEpzq5o0DgYDWZKOXjYgZemAXXQCr8SoQv1GAxotwFGwf3KplgmskdRWo28m4AH RFUBqcpiS7ShettVsz6aLg/oCRdKPc/SpDzQ1m9g32xaSiJIAynpwNDtuqDywzBBdH1S um2uTbsKPcg0FCCPWRFvTpEWHn/pGJMAupdarS6io1zSnFvZCWYcyRlEyX7iZ1HCaBuc J4NQ== 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=CvRrI0zXDXVvVSkHEV4+LyjZlR3w4oYtRsCfXoK3lWw=; b=ogGmjVwE+KFkyCFzmuN8Ee2rGWjaDe8RCLElazWxEb85ZMyYHmcI1Y81wzFUB6dr/q +UsHh52c5HiDdI7Mim+URovgjjMLHpcEcw9HMMbfaFy45ToKFVT0rIqL8ZuAeIV7I0H+ k+Iz/CDLu4G549ualMSt0uAzNfxDbowKAqRaxtelGYpNf23gZtL+kfy4xRJCNSVnvzk3 yzNw+y70E0N4HvMoo06KepCLuKAEyATb7r4bbUjIHJjQaqBc6CT4y1W82KGjeFzisaJN eskqer1AhX+BALWpAnE56ISdFcYPI7Xf/N+kqM+Je9XXAiw2FYxfEczFj5J4m89uiMT5 wXOQ== 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 19-v6si4882671edz.385.2018.06.15.05.44.01; Fri, 15 Jun 2018 05:44:01 -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 EC3D0C21E85; Fri, 15 Jun 2018 12:43:28 +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 EADD1C21EB9; Fri, 15 Jun 2018 12:42:34 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id DD239C21E29; Fri, 15 Jun 2018 12:42:32 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id A061CC21E68 for ; Fri, 15 Jun 2018 12:42:31 +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 0133CAF85; Fri, 15 Jun 2018 12:42:30 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Fri, 15 Jun 2018 14:42:19 +0200 Message-Id: <20180615124229.35310-8-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180615124229.35310-1-agraf@suse.de> References: <20180615124229.35310-1-agraf@suse.de> Cc: Andy Shevchenko , Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 07/17] 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 --- 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..23d8b70648 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) ; } + +#ifdef CONFIG_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 Fri Jun 15 12:42:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 138676 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp797567lji; Fri, 15 Jun 2018 05:42:44 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJBIK/W7rGs7O/UlRcJOvrWQ9LRQUrFbnI3KiMg5wqvisr8D7KIzXD5/TdjsZWbS98OWCvA X-Received: by 2002:a50:b4a1:: with SMTP id w30-v6mr1770604edd.254.1529066564571; Fri, 15 Jun 2018 05:42:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529066564; cv=none; d=google.com; s=arc-20160816; b=xrYbD27sohL/OXvKLk9obKW77dqW42vTrlrmBZMz41IqSx/0XHZNcNdVZhrvu+Myrc Vzv+m9hpuWGFyxFj03Y/B93KOvk8SwLUWkbu94PGrEtSzPls/9X7kr1crFAexQj5innQ 2juugIFxHO2RhXRar3uLfPhQ7avFXbScp0q9OxGudENIzVotpJxKZ0GnCUa68Qdup67C 0cDQpYRz/Sq65+dPLR3w4o18/FDFywLKgvMVpR/Kk5BFhjNrrhmY8L1q0I5rMoN2kZwy qDjq9DvKAbNl8HXx2NH5z5znKPD6nyT4agGvBtQ+ZiSUIOeaH4DDJPyy9FJxAhhvR1gv qYYQ== 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=QEvPrX66g5MwJgDHWlTRm5Qnn9ey4cOntQTKAsNU/K8algUnk57lGF+yCQelZ+4om9 /6zr7wsDigwY0NzA4rF4SNR/Halp/e1IdPV4XtTVusFLFCqTTHBPqfscHrJfhQZslCZa wpz+S+v42G30QYGxVXg3TxnLFokKYj6ueK+OmfSVsjApuUnvplST8w1n1WDEzz6sUkUp MSGBbjMRsqNo2JhlhDKAfBV9vMEm9d6Ug9X6Bd058uzFhdg5tv8eOQIU2Pb+ni2Ilm6f 0UWhHAWQZIAFZBmaRD399A3wtE35nllepkL3jgdjOCGabJv1J3wi4Caoz2ABkweXPV32 sNlw== 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 z38-v6si4743774edb.261.2018.06.15.05.42.43; Fri, 15 Jun 2018 05:42:44 -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 73B3EC21F59; Fri, 15 Jun 2018 12:42: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 A4D17C21DAF; Fri, 15 Jun 2018 12:42:33 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id BA07CC21EBA; Fri, 15 Jun 2018 12:42:32 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 54E49C21E29 for ; Fri, 15 Jun 2018 12:42:31 +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 03932AF87; Fri, 15 Jun 2018 12:42:30 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Fri, 15 Jun 2018 14:42:20 +0200 Message-Id: <20180615124229.35310-9-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180615124229.35310-1-agraf@suse.de> References: <20180615124229.35310-1-agraf@suse.de> Cc: Andy Shevchenko , Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 08/17] 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 Fri Jun 15 12:42:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 138688 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp805590lji; Fri, 15 Jun 2018 05:51:07 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIdUbALLQVqXZmzH9R4gJX28OVYrg5xEtzd3R05u37bzG2vsL790WRFe/vIfkcgYkf6PJTS X-Received: by 2002:a50:f743:: with SMTP id j3-v6mr1782849edn.37.1529067067547; Fri, 15 Jun 2018 05:51:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529067067; cv=none; d=google.com; s=arc-20160816; b=Qli5BWkeI/2cZqKJ1v/skH/qZu7yuyyMNeE6aN2ShDRvxEAGmIwG5XK61nTwelcnUb x7nTXE0EUt1AukcIHS/UN7F0gxav5B34y9kc943bG1NnrK7uWXt8gfhLx0txFcvMyb9O upK+Z46XsoO0DXU3wb4+8IXM3Sk93Z4cGnsl4ofQ62y81OM2HNuHtmt6L0JIZHHYYFWx F0kJCJ3MkcD69lAj0AeZJ72tsVFeVhuXtF5bcZkCllBGx1YNaIwA/byFZ0FkN5tzv1Y5 KYlGvk6PcSUrRCoTJf/WU3Pft6EvZ+hv8qylwTe54FrPj8Zpq+YAfN237WzyYcethjx4 BDgA== 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=vXn/YS23TUk2wMQgFznVVj6dP1eClSP4xF/DT50y8BHzNF5+1MSKgUYnhClcof9STf c+YpGNzRn7gwuLCAdbb3puRejXBEiyCyQAjp7LLi2+iWiX9AEua1BedvP13pIq4SZke/ N/ckBHhuGNuMDgRVfqdzQNKrJFjKdL3x52s8sABSd5yMf5vKXfNaRVEPo4ZuMrkv3BHI N164TWcy7CoIIUoR3J8gy04lWpQdvdTrfvXp4pwbCzf5W+gDhptc1NNgSUpFqONBf9GJ RYEnclgLoQza9OVEhZrSpF7nKDQbV0zNoTL6R/30mB9Ji935kDJNMlr6v92LNJf1F731 Gf+g== 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 v26-v6si6471545edi.290.2018.06.15.05.51.07; Fri, 15 Jun 2018 05:51:07 -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 2B400C21F1F; Fri, 15 Jun 2018 12:45: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 02653C21EFF; Fri, 15 Jun 2018 12:42:40 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 73099C21E2B; Fri, 15 Jun 2018 12:42:33 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id B4535C21E75 for ; Fri, 15 Jun 2018 12:42:31 +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 F2CF5AF81; Fri, 15 Jun 2018 12:42:30 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Fri, 15 Jun 2018 14:42:21 +0200 Message-Id: <20180615124229.35310-10-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180615124229.35310-1-agraf@suse.de> References: <20180615124229.35310-1-agraf@suse.de> Cc: Andy Shevchenko , Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 09/17] 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 Fri Jun 15 12:42:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 138682 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp803083lji; Fri, 15 Jun 2018 05:48:28 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKm4qEZ72d+31VyspsnZDv8JPu3yemepwZS41qw7tZFpSKCsjATVGoEOmFp5CpcUXg3XMM+ X-Received: by 2002:a50:94ce:: with SMTP id t14-v6mr1788266eda.146.1529066908903; Fri, 15 Jun 2018 05:48:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529066908; cv=none; d=google.com; s=arc-20160816; b=YmfZC0Htx5fDtzuysEjLjVEYUx/2UJGx1A636/q8s4uroS935AlcMUje4xoyS9L3Py MM46EuUynC70IBr0SOVmCyVcEEjI1l+wVr7QqRAXZOx8YJBjr2mufUYLbScF0ru/RG2n EvGt3c++hzZQjpA4rFNtOZe2oTNEIan3KtSRwgkWpfvANMiLDpdSvH4PV4DRAzcfMW40 iCZuWZDkn5ycfUUku53XsxensmVTk5MYGAL2xDil1yw9bvLf6icnfhVnH9AwDCtkgVn4 LMfIOh7MktWeo//ZqaIz2ILhaAtZcqNvQg51FreQ5mtXj0R9eVtMpnfXqD7NkWrcCJEc oY5g== 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=NTqjGZZanyfCWyByattmMF0ZWBht1yYS96qjKoB7+OlyL88kxEFNmbMs78jGmlI2B3 O9fW+FOXYruiKe+Krcfh5odnEHoMlZTdpHGhJ7ngTv+IrHnAzZ7XIapuuGeX0PbvNY4L CklmFYb8JA8Qcr0fT1cc4PAJyXJ/8tErl9KVvLm9zuF7PEleey6bM3B4YfymfFgMhc0Y OyzAUXf/Ds7nNOG9ZfxrJJaeFGd5tOECMEHcz0wwXxs0Z7UnczanVvQO+vkxxO8Qj4h3 k3uhJDu6B5StKBcEK/+xgLgd+Tdatoi72wxNqxF4UluFgBuAinHs4oAdVx2r8N7jNuTU 5srA== 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 w39-v6si1551218eda.109.2018.06.15.05.48.28; Fri, 15 Jun 2018 05:48: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 661FDC21EEB; Fri, 15 Jun 2018 12:45:58 +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 80775C21F41; Fri, 15 Jun 2018 12:42:41 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 5659BC21E75; Fri, 15 Jun 2018 12:42:34 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id CA986C21E8A for ; Fri, 15 Jun 2018 12:42:31 +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 301C1AF88; Fri, 15 Jun 2018 12:42:31 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Fri, 15 Jun 2018 14:42:22 +0200 Message-Id: <20180615124229.35310-11-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180615124229.35310-1-agraf@suse.de> References: <20180615124229.35310-1-agraf@suse.de> Cc: Andy Shevchenko , Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 10/17] 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 Fri Jun 15 12:42:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 138692 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp807712lji; Fri, 15 Jun 2018 05:53:17 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJqAM7dtV1F/738HLVK7v47SVxNJtx3oxZXyvVu9CdCCbGc2XrMXGqEh3YgsHUFdjkE5suo X-Received: by 2002:aa7:d6c2:: with SMTP id x2-v6mr1792556edr.196.1529067197410; Fri, 15 Jun 2018 05:53:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529067197; cv=none; d=google.com; s=arc-20160816; b=DrGKzNJRJVnZ22Z4x92v/9vhbfQS+xNcj+rOAt3I/O+zYoWEezoVOzkAy8Z1GRq/jU eRZSybHoVSCNGinS1rnEGB7p86BfsAzTk38/O4xSX3V4mSVR9565PxHW4VvdhmsaRRDR IAYurE9BfDGioQtDQKRcjvy7LJHPWlVMJulUeOim5jyF6o6nF9w4rfAzdNiNaWqL3Kup 7cptDWdtq8lzzN9pDavoyUGlWIByiFu++niieUOJYHwZZIDjfxoyw14H8bFlfpzbDVMD hiHH77onQhtN2+/XaJksNYN0dC0w79OGwxdprZZtbXSQTxB72ebYboaOUDyBHuZWDdGR WGJA== 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=lDZvxHfbVEwctRb9V4u3mspKOEwICgZX6aY2M+wtmld9S5tVLEmucf0Zwvl/TTJlIv wPgxOUBf4EOBgrsa3Io2/+Q22EUB8xZdpCVk25U8YjzWa9MuEPkVE9V7KOumyBvVSYni wWmTnFdAmjCo9dy5zNsHvC34JrN49dObzUMntgycoNe1WvH0hs2nB4W0FBAcLojxiCN7 fYUeg/DYtPuQSdsKylFgbnCEJEDhQQithCsPVlYibnMa0yDLMg1bevijVZOQR8ZfFSAb XEjaOzBvyyZ8GCOh9CxA5Iospf8ByT8Wx4lQ2A8HW0KuORzDbhanCSkmHya59DUpyZ/g nVJw== 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 5-v6si1805871edn.30.2018.06.15.05.53.17; Fri, 15 Jun 2018 05:53:17 -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 0D060C21EFC; Fri, 15 Jun 2018 12:47: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 10600C21F3E; Fri, 15 Jun 2018 12:42:46 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id BBF23C21E8A; Fri, 15 Jun 2018 12:42:34 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 2652EC21EB9 for ; Fri, 15 Jun 2018 12:42:32 +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 5C004AF95; Fri, 15 Jun 2018 12:42:31 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Fri, 15 Jun 2018 14:42:23 +0200 Message-Id: <20180615124229.35310-12-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180615124229.35310-1-agraf@suse.de> References: <20180615124229.35310-1-agraf@suse.de> Cc: Andy Shevchenko , Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 11/17] 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 Fri Jun 15 12:42:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 138680 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp800755lji; Fri, 15 Jun 2018 05:46:04 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKzn2MQXRcRjdEUm2O4tWs5pcMEz3DwFvn4awr1P1G/R54AD9kyn9Y1R7fv6IHWpC/cpLqs X-Received: by 2002:a50:a50f:: with SMTP id y15-v6mr1760839edb.105.1529066764560; Fri, 15 Jun 2018 05:46:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529066764; cv=none; d=google.com; s=arc-20160816; b=gwn8HEnuO7DZXS8Aw3JD0gtH31drZETn+F2p9Rn4iJ5GVGK+Hha9n2ivmXjLGSKlXb oFQU5Bn4ehu6oMHl0ujvIuxBgsfdCqQQfXG3X5RR5hqUBZnidhUvqCONGMTFQWIaU2LE QSBRN8Nop6IoqkIFpXtxXhmJY0WBrEZAHY8z0eC6iW+6GYy4PV4BP4b+2Wf9VoScdDH8 XXvjc9OyjbcNKINYUQkK5Y+uWUcINJSB8hScimRc9Q6sI0RZwEsu/RxdFyNE5ZqpPtpL nySnOlcSO3e4DfHX14xuJvy+ovQAJDWwHrva23zKpiVjPyFHvRwdPzW7etq2jPN6A40f /nlg== 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=QLkCB9tAoupY/xOFPY1YNFKKxLGpbPfxr/OdQ3AZhsakd25rszIrUwygIWxZA3e3n5 OFGXu0GbtnGAC/1EKu8V4plcqdPaU/FfUc2+L/Y2dgBm7RxjcDHvCvl+7I/GqdjWZZOL QoCT/xa6v5syTFdCis7LhqdlLnSvCytqy8cPR01iRkj9Z2UMB0HjfTbZKyAQRDTBSqkq VabS2hPGHB1e0XAzUh0Rr/oAQY2mew1oTqYQkPHIziG9FmQM8i1nXiewKS7LAJbjiInr GSTIC+O9UHRKRbJo/StKwDP+xP8RHx1oFjED3xWOZp26MOX0pKRFcSNjrDgGoVhKE58B v04g== 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 z38-v6si4746743edb.261.2018.06.15.05.46.04; Fri, 15 Jun 2018 05:46: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 2899DC21EF7; Fri, 15 Jun 2018 12:44:57 +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 2AD40C21F27; Fri, 15 Jun 2018 12:42:39 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 5C244C21DAF; Fri, 15 Jun 2018 12:42:33 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id C2FD2C21E88 for ; Fri, 15 Jun 2018 12:42:31 +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 36873AF8D; Fri, 15 Jun 2018 12:42:31 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Fri, 15 Jun 2018 14:42:24 +0200 Message-Id: <20180615124229.35310-13-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180615124229.35310-1-agraf@suse.de> References: <20180615124229.35310-1-agraf@suse.de> Cc: Andy Shevchenko , Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 12/17] 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 Fri Jun 15 12:42:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 138689 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp805603lji; Fri, 15 Jun 2018 05:51:08 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJvFjMeCzLh18Ko8NgomyRN1900wdE5hofgkUnNWoJH0eZyrZUDZ0X1W0JL0lmW0SLnOtMs X-Received: by 2002:a50:9434:: with SMTP id p49-v6mr1823890eda.107.1529067068884; Fri, 15 Jun 2018 05:51:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529067068; cv=none; d=google.com; s=arc-20160816; b=jKKeGkD2MAGtBHWjkoZAGSCMyU76zCXfnotgNnMfiqX3LhX/G3sMNjUx17YMB4E68E cGzruZc5WADUzXyBr6fiwjhp8xfbTL6KBqpWFKMXY5GVgWxOvosKN5c2wUJE58FkyzrI BZ3LW9esij8GC0T2gNVnqmeY0MFoI46DL5WsB5tNEb6539pj20/WF1zEjAU9funpdxL1 oDQ5y/NUuw8kOFuiXn/1fYNVsbsO9vNyAblxRRpv1qCo4eB9YpXmSZl2l4JZEKdebUAP yBGAXiwKeK573m403vHad14aNVx3Ea9xNI1LhIU9C1b3OxHI0mzpt7MN7wlOY+3WSv3K 7QeQ== 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=+hG1/KeX/0IyAn4Lbrkg05a+eBiXi4jEXJ8EyL9+cSI=; b=aogQYUvQbm/ghPAImBg76IHtRuoeo3zlq5souEuB/Jm1cgRJfwIqPxBuZEE3SfdO3s 0aGyZoxI9KX3qWRIsk0+0BuPdy2iPd4pN9Edwr7BUFlUPVGKegtek9pJ8DGEsqIg4y8Q iBsRZgwtIkqQ1fqMbiv7qYK7sKqo5nawoove7kXeeehPxlQ39i8IAok4p7fHKQljMWgl paH9/EtQYbEwtd5j2TXL7O/0z2rzlYw59nkarOQ44dJeWH/FpyLblvxLft+Brv1lUobC shGniIcbAsdcP6v323eak8xx0hB897fiWZupHKE82gTaluVl08PBq11SIpGqG2wDomnm XJnw== 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 6-v6si185005eda.96.2018.06.15.05.51.08; Fri, 15 Jun 2018 05:51:08 -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 78E2FC21EB4; Fri, 15 Jun 2018 12:46:25 +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 63A7BC21EB4; Fri, 15 Jun 2018 12:42:42 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 6ED3CC21E8A; Fri, 15 Jun 2018 12:42:34 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id D8E5CC21E96 for ; Fri, 15 Jun 2018 12:42:31 +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 3F5DCAF8E; Fri, 15 Jun 2018 12:42:31 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Fri, 15 Jun 2018 14:42:25 +0200 Message-Id: <20180615124229.35310-14-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180615124229.35310-1-agraf@suse.de> References: <20180615124229.35310-1-agraf@suse.de> Cc: Andy Shevchenko , Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 13/17] sandbox: Enable 1:1 map 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" So far we've always had a split address space situation with "U-Boot addresses" (a number space starting from 0) and "host virtual addresses" (128MB mapped randomly in address space). This meant that we had to make sure all code is properly aware that addresses and pointers are not the same thing, so they must not cast between the two. However, most real boards do actually have a 1:1 map. So it's much easier to just expose the same in sandbox. So this patch maps sandbox RAM from 0x8000000-0x10000000. This address range fits just fine on both 32bit and 64bit systems. Signed-off-by: Alexander Graf --- I don't know if this really is the best path forward, but at least it's one that gets rid of the one awkward target that does not have a 1:1 map ;) --- Makefile | 2 +- arch/sandbox/cpu/cpu.c | 35 ----------------------------------- arch/sandbox/cpu/state.c | 4 ++-- arch/sandbox/cpu/u-boot.lds | 9 +++++++++ arch/sandbox/include/asm/io.h | 17 +++++------------ common/board_f.c | 4 +++- configs/sandbox64_defconfig | 6 +++--- configs/sandbox_defconfig | 6 +++--- configs/sandbox_flattree_defconfig | 4 ++-- configs/sandbox_noblk_defconfig | 4 ++-- configs/sandbox_spl_defconfig | 4 ++-- include/configs/sandbox.h | 32 ++++++++++++++++---------------- 12 files changed, 48 insertions(+), 79 deletions(-) diff --git a/Makefile b/Makefile index 6a190e7a89..705c5b632f 100644 --- a/Makefile +++ b/Makefile @@ -867,7 +867,7 @@ endif # Normally we fill empty space with 0xff quiet_cmd_objcopy = OBJCOPY $@ -cmd_objcopy = $(OBJCOPY) --gap-fill=0xff $(OBJCOPYFLAGS) \ +cmd_objcopy = $(OBJCOPY) --gap-fill=0xff -R .ram $(OBJCOPYFLAGS) \ $(OBJCOPYFLAGS_$(@F)) $< $@ # Provide a version which does not do this, for use by EFI diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c index 23d8b70648..b20894b806 100644 --- a/arch/sandbox/cpu/cpu.c +++ b/arch/sandbox/cpu/cpu.c @@ -5,7 +5,6 @@ #define DEBUG #include #include -#include #include #include #include @@ -58,16 +57,6 @@ int cleanup_before_linux_select(int flags) return 0; } -void *phys_to_virt(phys_addr_t paddr) -{ - return (void *)(gd->arch.ram_buf + paddr); -} - -phys_addr_t virt_to_phys(void *vaddr) -{ - return (phys_addr_t)((uint8_t *)vaddr - gd->arch.ram_buf); -} - void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags) { #if defined(CONFIG_PCI) && !defined(CONFIG_SPL_BUILD) @@ -103,11 +92,6 @@ void sandbox_set_enable_pci_map(int enable) enable_pci_map = enable; } -phys_addr_t map_to_sysmem(const void *ptr) -{ - return (u8 *)ptr - gd->arch.ram_buf; -} - void flush_dcache_range(unsigned long start, unsigned long stop) { } @@ -178,22 +162,3 @@ void longjmp(jmp_buf jmp, int ret) while (1) ; } - -#ifdef CONFIG_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 diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c index cc50819ab9..75ad564274 100644 --- a/arch/sandbox/cpu/state.c +++ b/arch/sandbox/cpu/state.c @@ -12,6 +12,7 @@ /* Main state record for the sandbox */ static struct sandbox_state main_state; static struct sandbox_state *state; /* Pointer to current state record */ +static __attribute__ ((section (".ram"))) u8 sandbox_ram[CONFIG_SYS_SDRAM_SIZE]; static int state_ensure_space(int extra_size) { @@ -366,8 +367,7 @@ int state_init(void) state = &main_state; state->ram_size = CONFIG_SYS_SDRAM_SIZE; - state->ram_buf = os_malloc(state->ram_size); - assert(state->ram_buf); + state->ram_buf = sandbox_ram; state_reset_for_test(state); /* diff --git a/arch/sandbox/cpu/u-boot.lds b/arch/sandbox/cpu/u-boot.lds index 3a6cf55eb9..dd649df1f8 100644 --- a/arch/sandbox/cpu/u-boot.lds +++ b/arch/sandbox/cpu/u-boot.lds @@ -50,3 +50,12 @@ SECTIONS } INSERT BEFORE .data; + +SECTIONS +{ + .ram 0x8000000 : { + *(.ram) + } +} + +INSERT BEFORE .bss; diff --git a/arch/sandbox/include/asm/io.h b/arch/sandbox/include/asm/io.h index 81b7750628..fe792200a7 100644 --- a/arch/sandbox/include/asm/io.h +++ b/arch/sandbox/include/asm/io.h @@ -6,12 +6,6 @@ #ifndef __SANDBOX_ASM_IO_H #define __SANDBOX_ASM_IO_H -void *phys_to_virt(phys_addr_t paddr); -#define phys_to_virt phys_to_virt - -phys_addr_t virt_to_phys(void *vaddr); -#define virt_to_phys virt_to_phys - void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags); #define map_physmem map_physmem @@ -23,20 +17,19 @@ void unmap_physmem(const void *vaddr, unsigned long flags); #include -/* For sandbox, we want addresses to point into our RAM buffer */ static inline void *map_sysmem(phys_addr_t paddr, unsigned long len) { - return map_physmem(paddr, len, MAP_WRBACK); + return (void *)(unsigned long)paddr; } -/* Remove a previous mapping */ static inline void unmap_sysmem(const void *vaddr) { - unmap_physmem(vaddr, MAP_WRBACK); } -/* Map from a pointer to our RAM buffer */ -phys_addr_t map_to_sysmem(const void *ptr); +static inline phys_addr_t map_to_sysmem(const void *ptr) +{ + return (phys_addr_t)(unsigned long)ptr; +} /* Define nops for sandbox I/O access */ #define readb(addr) ((void)addr, 0) diff --git a/common/board_f.c b/common/board_f.c index e943347ce3..b06f9d30ad 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -219,7 +219,9 @@ static int setup_mon_len(void) { #if defined(__ARM__) || defined(__MICROBLAZE__) gd->mon_len = (ulong)&__bss_end - (ulong)_start; -#elif defined(CONFIG_SANDBOX) || defined(CONFIG_EFI_APP) +#elif defined(CONFIG_SANDBOX) + gd->mon_len = 0; +#elif defined(CONFIG_EFI_APP) gd->mon_len = (ulong)&_end - (ulong)_init; #elif defined(CONFIG_NIOS2) || defined(CONFIG_XTENSA) gd->mon_len = CONFIG_SYS_MONITOR_LEN; diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig index 20a2ab3ffb..5c47b651d4 100644 --- a/configs/sandbox64_defconfig +++ b/configs/sandbox64_defconfig @@ -1,4 +1,4 @@ -CONFIG_SYS_TEXT_BASE=0 +CONFIG_SYS_TEXT_BASE=0x8000000 CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_SANDBOX64=y CONFIG_DEFAULT_DEVICE_TREE="sandbox64" @@ -11,13 +11,13 @@ CONFIG_BOOTSTAGE=y CONFIG_BOOTSTAGE_REPORT=y CONFIG_BOOTSTAGE_FDT=y CONFIG_BOOTSTAGE_STASH=y -CONFIG_BOOTSTAGE_STASH_ADDR=0x0 +CONFIG_BOOTSTAGE_STASH_ADDR=0x8000000 CONFIG_BOOTSTAGE_STASH_SIZE=0x4096 CONFIG_CONSOLE_RECORD=y CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000 CONFIG_SILENT_CONSOLE=y CONFIG_PRE_CONSOLE_BUFFER=y -CONFIG_PRE_CON_BUF_ADDR=0x100000 +CONFIG_PRE_CON_BUF_ADDR=0x8100000 CONFIG_LOG_MAX_LEVEL=6 CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_CMD_CPU=y diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index 2fc84a16c9..84828c972c 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -1,4 +1,4 @@ -CONFIG_SYS_TEXT_BASE=0 +CONFIG_SYS_TEXT_BASE=0x8000000 CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_DEFAULT_DEVICE_TREE="sandbox" CONFIG_DISTRO_DEFAULTS=y @@ -10,13 +10,13 @@ CONFIG_BOOTSTAGE=y CONFIG_BOOTSTAGE_REPORT=y CONFIG_BOOTSTAGE_FDT=y CONFIG_BOOTSTAGE_STASH=y -CONFIG_BOOTSTAGE_STASH_ADDR=0x0 +CONFIG_BOOTSTAGE_STASH_ADDR=0x8000000 CONFIG_BOOTSTAGE_STASH_SIZE=0x4096 CONFIG_CONSOLE_RECORD=y CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000 CONFIG_SILENT_CONSOLE=y CONFIG_PRE_CONSOLE_BUFFER=y -CONFIG_PRE_CON_BUF_ADDR=0x100000 +CONFIG_PRE_CON_BUF_ADDR=0x8100000 CONFIG_LOG_MAX_LEVEL=6 CONFIG_LOG_ERROR_RETURN=y CONFIG_DISPLAY_BOARDINFO_LATE=y diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig index e922c4b38f..567ec15c22 100644 --- a/configs/sandbox_flattree_defconfig +++ b/configs/sandbox_flattree_defconfig @@ -1,4 +1,4 @@ -CONFIG_SYS_TEXT_BASE=0 +CONFIG_SYS_TEXT_BASE=0x8000000 CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_DEFAULT_DEVICE_TREE="sandbox" CONFIG_DISTRO_DEFAULTS=y @@ -10,7 +10,7 @@ CONFIG_BOOTSTAGE=y CONFIG_BOOTSTAGE_REPORT=y CONFIG_BOOTSTAGE_FDT=y CONFIG_BOOTSTAGE_STASH=y -CONFIG_BOOTSTAGE_STASH_ADDR=0x0 +CONFIG_BOOTSTAGE_STASH_ADDR=0x8000000 CONFIG_BOOTSTAGE_STASH_SIZE=0x4096 CONFIG_CONSOLE_RECORD=y CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000 diff --git a/configs/sandbox_noblk_defconfig b/configs/sandbox_noblk_defconfig index 8bdd4edcda..c46b0bc06c 100644 --- a/configs/sandbox_noblk_defconfig +++ b/configs/sandbox_noblk_defconfig @@ -1,4 +1,4 @@ -CONFIG_SYS_TEXT_BASE=0 +CONFIG_SYS_TEXT_BASE=0x8000000 CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_DEFAULT_DEVICE_TREE="sandbox" CONFIG_DISTRO_DEFAULTS=y @@ -10,7 +10,7 @@ CONFIG_BOOTSTAGE=y CONFIG_BOOTSTAGE_REPORT=y CONFIG_BOOTSTAGE_FDT=y CONFIG_BOOTSTAGE_STASH=y -CONFIG_BOOTSTAGE_STASH_ADDR=0x0 +CONFIG_BOOTSTAGE_STASH_ADDR=0x8000000 CONFIG_BOOTSTAGE_STASH_SIZE=0x4096 # CONFIG_USE_BOOTCOMMAND is not set CONFIG_CONSOLE_RECORD=y diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig index fb6bb4baa2..4327e3f8b6 100644 --- a/configs/sandbox_spl_defconfig +++ b/configs/sandbox_spl_defconfig @@ -1,4 +1,4 @@ -CONFIG_SYS_TEXT_BASE=0 +CONFIG_SYS_TEXT_BASE=0x8000000 CONFIG_SPL_LIBCOMMON_SUPPORT=y CONFIG_SPL_LIBGENERIC_SUPPORT=y CONFIG_SYS_MALLOC_F_LEN=0x2000 @@ -17,7 +17,7 @@ CONFIG_BOOTSTAGE=y CONFIG_BOOTSTAGE_REPORT=y CONFIG_BOOTSTAGE_FDT=y CONFIG_BOOTSTAGE_STASH=y -CONFIG_BOOTSTAGE_STASH_ADDR=0x0 +CONFIG_BOOTSTAGE_STASH_ADDR=0x8000000 CONFIG_BOOTSTAGE_STASH_SIZE=0x4096 CONFIG_CONSOLE_RECORD=y CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000 diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h index 1a49d1dab5..d0e5a5d6bf 100644 --- a/include/configs/sandbox.h +++ b/include/configs/sandbox.h @@ -6,12 +6,18 @@ #ifndef __CONFIG_H #define __CONFIG_H +/* Size of our emulated memory */ +#define CONFIG_SYS_SDRAM_BASE 0x8000000 +#define CONFIG_SYS_SDRAM_SIZE (128 << 20) +#define CONFIG_SYS_MONITOR_BASE 0 +#define CONFIG_NR_DRAM_BANKS 1 + #ifdef FTRACE #define CONFIG_TRACE #define CONFIG_TRACE_BUFFER_SIZE (16 << 20) #define CONFIG_TRACE_EARLY_SIZE (8 << 20) #define CONFIG_TRACE_EARLY -#define CONFIG_TRACE_EARLY_ADDR 0x00100000 +#define CONFIG_TRACE_EARLY_ADDR (CONFIG_SYS_SDRAM_BASE + 0x100000) #endif @@ -30,7 +36,7 @@ /* * Size of malloc() pool, before and after relocation */ -#define CONFIG_MALLOC_F_ADDR 0x0010000 +#define CONFIG_MALLOC_F_ADDR (CONFIG_SYS_SDRAM_BASE + 0x10000) #define CONFIG_SYS_MALLOC_LEN (32 << 20) /* 32MB */ #define CONFIG_SYS_CBSIZE 1024 /* Console I/O Buffer Size */ @@ -44,19 +50,13 @@ #define CONFIG_I2C_EDID /* Memory things - we don't really want a memory test */ -#define CONFIG_SYS_LOAD_ADDR 0x00000000 -#define CONFIG_SYS_MEMTEST_START 0x00100000 +#define CONFIG_SYS_LOAD_ADDR CONFIG_SYS_SDRAM_BASE +#define CONFIG_SYS_MEMTEST_START (CONFIG_SYS_SDRAM_BASE + 0x100000) #define CONFIG_SYS_MEMTEST_END (CONFIG_SYS_MEMTEST_START + 0x1000) -#define CONFIG_SYS_FDT_LOAD_ADDR 0x100 +#define CONFIG_SYS_FDT_LOAD_ADDR (CONFIG_SYS_SDRAM_BASE + 0x100) #define CONFIG_PHYSMEM -/* Size of our emulated memory */ -#define CONFIG_SYS_SDRAM_BASE 0 -#define CONFIG_SYS_SDRAM_SIZE (128 << 20) -#define CONFIG_SYS_MONITOR_BASE 0 -#define CONFIG_NR_DRAM_BANKS 1 - #define CONFIG_SYS_BAUDRATE_TABLE {4800, 9600, 19200, 38400, 57600,\ 115200} @@ -104,11 +104,11 @@ #define MEM_LAYOUT_ENV_SETTINGS \ "bootm_size=0x10000000\0" \ - "kernel_addr_r=0x1000000\0" \ - "fdt_addr_r=0xc00000\0" \ - "ramdisk_addr_r=0x2000000\0" \ - "scriptaddr=0x1000\0" \ - "pxefile_addr_r=0x2000\0" + "kernel_addr_r=0x9000000\0" \ + "fdt_addr_r=0x8c00000\0" \ + "ramdisk_addr_r=0xa000000\0" \ + "scriptaddr=0x8001000\0" \ + "pxefile_addr_r=0x8002000\0" #define CONFIG_EXTRA_ENV_SETTINGS \ SANDBOX_SERIAL_SETTINGS \ From patchwork Fri Jun 15 12:42:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 138691 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp806588lji; Fri, 15 Jun 2018 05:52:10 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKH8aibB4eVGb+DUyk7cTLi2rii9Ly2wS/bD5XwfwzPyBeLxempt6eqEjUN3yxAVBDkxNzl X-Received: by 2002:a50:bf47:: with SMTP id g7-v6mr1756401edk.283.1529067130710; Fri, 15 Jun 2018 05:52:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529067130; cv=none; d=google.com; s=arc-20160816; b=AUoomM9DJW1nvksefmW+K/EPyaMVWhc9DjMUdZnTfmB52oNsDl6M/3NrFFxTaXHRdj M/mKLvzdPcuHjOjiNcxi/SpVNIELJUcDbrebKrZtYD/PRSMpD8gNy4jIBOVmo+7Aep65 CXeqirGaWRRMtTvl/sq7+3pm5V/8wygkyAJUADcNDfKYFOhhWackeREeii7ZsSt1Lyxh u8CCdIgBlZp/aRzqz4QDkKuZkO2ut6IKFHr2LFCyoY+zHOWbbvyx9zWC746p9HUfIZkz S0DrJI2miX1qnrCgAETSD8pYOJ65hfT5siI52YSUIyoYKZ6zJ6OrNC6j9u5cver5CeyE NXlw== 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=YXNBaSp4QswcgYbaS9sFIupPjxj36xuyyMYzxN+8Sl4=; b=KcVKiUALl7Wfj8hfvvZS1VzIiyG6YLVsGCyQfnak4exGdoALZLjzGsymWWZF+xKSfZ CY/g6BD3VOzDXVJqK369QM2i88I3gmVmlWvOLXLwZ4caLALYEvYJPm+4AlTo+1xmx86O y1qd5lmmwz09zg5LLtbok7s3wJBZdVMkrg91D2COw9i0RZQ4yXlPvSg1huJ6eyeaFrD9 AnGyMf3Aw2Rricr/mgBEVZiuFdZAdsaZyTE4rBEtNCJ+QX+PohCWb3RZuvSmawH00NXD YjhgpcR2A4ie7e/eDIPgvke9nvmJ9NPQqWIclO/cDYxAk+73KuqDCQEXKZvm3Rr9k8QC A5OA== 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 k1-v6si3232805edc.350.2018.06.15.05.52.10; Fri, 15 Jun 2018 05:52:10 -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 412E7C21EFD; Fri, 15 Jun 2018 12:47:09 +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 52A32C21F2F; Fri, 15 Jun 2018 12:42:44 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A1E39C21EA6; Fri, 15 Jun 2018 12:42:34 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id DBBE2C21EA6 for ; Fri, 15 Jun 2018 12:42:31 +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 45E0DAF90; Fri, 15 Jun 2018 12:42:31 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Fri, 15 Jun 2018 14:42:26 +0200 Message-Id: <20180615124229.35310-15-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180615124229.35310-1-agraf@suse.de> References: <20180615124229.35310-1-agraf@suse.de> Cc: Andy Shevchenko , Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 14/17] 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 --- include/config_distro_bootcmd.h | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h index 1bd79ae3b8..ca6c57edbf 100644 --- a/include/config_distro_bootcmd.h +++ b/include/config_distro_bootcmd.h @@ -245,35 +245,24 @@ #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" #else #error Please specify an EFI client identifier #endif From patchwork Fri Jun 15 12:42:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 138683 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp803321lji; Fri, 15 Jun 2018 05:48:45 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK8DtCbUUyKWB87Lz8P0t/G6EAOaLRP2++P2UG6Xzgf8RLzMpOXLBxlbnzePw5Ow5mXJpD6 X-Received: by 2002:a50:9643:: with SMTP id y61-v6mr1750831eda.160.1529066925127; Fri, 15 Jun 2018 05:48:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529066925; cv=none; d=google.com; s=arc-20160816; b=sTkEJobBSlV9KWTG378G72tll+jz+09HP/DoCxygljJUMA7+Ww4ESk/zD6greO5xnW gLE2FXYj91vXxF6Get+jjhNvr00CBldnb+4bsVJ8ZwXIywc0kJoybDlKanOgdoJRZIK7 KiahIuOtchVeV9ZB7ATbrLh+UVlj4f9xmNTGSUFA/dQiTR4E+g+bxWf39IFpHSUyQFie /zEwrIV1+KW5jMfEA4N7TGQPI1c+LmIzX6FIJe9b/zh07C2Tn6GtFI3Db+3HGh7IUp7R 0zMsbsyCeTOAgooSJOxuIGzJam/LD/yavSe93bmnweFA3FPAXqwhpA90tA4RDAfnlCwH J9qw== 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=C1h24efjO3tkEL6G0cew9NtDDTlF+uw5dm7ndrLzY3DIOr2+RYOAmw5Cgwfz4wc2V9 HV1tbGsACoayPmdrbItskPF+P8KKWo0o1ZMhLkevNzwT/vm3WNRUMVsU3F7W6IY86MAc yNzOf1+8kBZIkkIi9Av8f0zFi9dn+bIxsvC6uugJyfXnQGjcMiQzTpk+rtcUjZpwKbVK CVATIO9Q4hMkqa4+KCeAMeljj1oit4dLmoyzNReyeIL6yC8CDY+QaYjFKJJkoOUVJt6e 9w6NA7o2UMn2qLWATe6G/Cr8QvjPaSACtegD+zJJiaFQmI49UumQ5Pu8sm2quypqMfTX P19w== 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 s31-v6si2007974edm.148.2018.06.15.05.48.44; Fri, 15 Jun 2018 05:48: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 B011BC21F18; Fri, 15 Jun 2018 12:46:52 +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 69A60C21F58; Fri, 15 Jun 2018 12:42:43 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 8A26EC21E96; Fri, 15 Jun 2018 12:42:34 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id CE2A7C21E90 for ; Fri, 15 Jun 2018 12:42:31 +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 3FC94AF8F; Fri, 15 Jun 2018 12:42:31 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Fri, 15 Jun 2018 14:42:27 +0200 Message-Id: <20180615124229.35310-16-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180615124229.35310-1-agraf@suse.de> References: <20180615124229.35310-1-agraf@suse.de> Cc: Andy Shevchenko , Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 15/17] 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 Fri Jun 15 12:42:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 138686 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp804474lji; Fri, 15 Jun 2018 05:50:00 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLWCCS3obbWfW5O5wPOP8cw6QwuwIb+BL+Ygthz2PR9OIeFmspfsUqECZa7rDlIHsTRscsw X-Received: by 2002:a50:b6bc:: with SMTP id d57-v6mr1825518ede.250.1529067000051; Fri, 15 Jun 2018 05:50:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529067000; cv=none; d=google.com; s=arc-20160816; b=CUpWcVMbd3oIWaGILsYCj4dDzsP54JelBwl7euX4PdqxNjIeOGuJLSOvLQ1WiIRU7/ 8RZNUd9L/tPKGPVE6kg/0Xo98gYZlrjWYqPY9XFVeektdFH5SAjSxCY/0H/90a8otVQ+ M5Kzx5oSgoFHZ+0XMkouM3MxfaCVa33Rwu+oKQ3uBEVjThj2XFX9Z6Uf6OtPy2bsdgZV VEj7vU+9thEbRi686tajSrNpfYV6jLUUmRdHRxIhF9VgM7gLQeDy8bhQFQBuONfokgMF cH3IbDvO3aiqSBYhJ14Gtjgqdkh6mjSEgCuqutimOjxREuKnXxfXSS2IS0a9LRPgqj5k FMKg== 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=NhCH80twytFmgIBZiSayc+VQzKNYQ/LlTahNS8gEchc=; b=mWcFSFkf7SKEjP8u8KRwmTw7RfFL3FUdJLUa6aTEh4KT4+hfTaMIwjsU/4E8fIRP0R xySJticWOkXW9lPbx4NBpAQCz09zJiz2XrBB9ACYH3rZ71O35P4mwhg+VaHVZpxxD68X Ymi9zUdFDzCr89rHzHBImxZOzHniROJONIYSr35GCeQt/luOhJYyZGqQx73yKksBEF+a 2XU0W5GbOA1tokWxpxzu7XD/D6TxL4dulWfsGEifmK3FIGj0TaJGTGFoT0Agfv58T1Hw 4ZWMewK/Nr+YRSpsZ4IoQAvV9P5RrxbG/VH+szBRa/7HPmdCThuk3SXWnqpfgeNKRZ5m geAw== 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-v6si5300147edi.277.2018.06.15.05.49.59; Fri, 15 Jun 2018 05:50:00 -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 97DBDC21F19; Fri, 15 Jun 2018 12:48: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 C7B22C21F7D; Fri, 15 Jun 2018 12:42:46 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id EADA3C21EA6; Fri, 15 Jun 2018 12:42:34 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id EB78CC21EB1 for ; Fri, 15 Jun 2018 12:42:31 +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 47568AF91; Fri, 15 Jun 2018 12:42:31 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Fri, 15 Jun 2018 14:42:28 +0200 Message-Id: <20180615124229.35310-17-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180615124229.35310-1-agraf@suse.de> References: <20180615124229.35310-1-agraf@suse.de> Cc: Andy Shevchenko , Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 16/17] 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 payload 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 | 10 ++++++++++ arch/sandbox/cpu/os.c | 23 +++++++++++++++++++++++ include/os.h | 19 +++++++++++++++++++ 3 files changed, 52 insertions(+) diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c index b20894b806..944f104899 100644 --- a/arch/sandbox/cpu/cpu.c +++ b/arch/sandbox/cpu/cpu.c @@ -162,3 +162,13 @@ void longjmp(jmp_buf jmp, int ret) while (1) ; } + +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); +} diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 5839932b00..81206ba0d2 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -183,6 +183,29 @@ void *os_realloc(void *ptr, size_t length) return buf; } +int os_mprotect(void *ptr, size_t length, int prot) +{ + struct os_mem_hdr *hdr = ptr; + int p = 0; + + if ((uintptr_t)ptr & sizeof(*hdr)) { + /* + * We got an unaligned pointer, probably a return value + * from os_malloc() + */ + ptr = &hdr[-1]; + } + + 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 Fri Jun 15 12:42:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 138693 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp808429lji; Fri, 15 Jun 2018 05:53:55 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJp7pa9/5f227jY6rvuw6D+kAwjCtONGX9XUBppd0rcenCPSif5Um5fiFkANt5KtwTo6v0L X-Received: by 2002:a50:ba1d:: with SMTP id g29-v6mr1775233edc.85.1529067235494; Fri, 15 Jun 2018 05:53:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529067235; cv=none; d=google.com; s=arc-20160816; b=ldQdnXNvOd7pondSbcKc44M6tEeToz2g4Hmw/2xTi4tSFzSpHea/neZIJBgLwsg1Vr UgbvmrWHJd4Eu41Ipimhr6M4yB9fQMxPMif8HZz3AFO1BZiyvMYOFiP8IMLHdJGyjCuw aJnlCTqtWP55ZlHwcF02zX80/bg/GWsKMnnnAgJTz3g8Nus9dZXqTANpv8dbD6EulnWS h4NetRCOMFRmi5ffA+3EnWDeNZWlDl6PRjc0Z+avYeDZmtb0ntUm9PLF4h0YHIMCx6+6 qeRE3oq0jRt4elemnvMMNBFUPo5F05TAQl5s+lqIWNVLgKk86IBVq/RxMKwhO9AdVbgf M2/w== 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=l1RfSfAAY2W8/Ya+juobNRpPAC13vmBsWenVP9s3uJM=; b=c9Vqqy4q6Z48djrDGJuPR0fERwqCuVS/WmP0bIgTH3he5ekmNhYMG9vG+NObsuJoNs TTLMQnIcmrfb3GbLulZ2LMgKkTkpiG8EqNaeHVUv9I9GezE0TJsH0ch+QFPUTuOEKegh GMCmJ2MBwvk6qocy9oGLmFOHzGCAKR9mS+2gcrv2At9ihmvy9lLt9s3dxRNZb1ih8Hs5 p9pS71GU4ZtwBZctjTMSLqn36BUOhCPH0PcsnER1oS69xEcbYX0bOOTp/IXNpBDivPPB wo1NnYFiEkG98IB8TyFP6vxGfEyalOuipTNNH5c3rRp3VEAmAJl9O/gYDQ6IIZnUaUm4 VgDQ== 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 j30-v6si1462407edc.86.2018.06.15.05.53.55; Fri, 15 Jun 2018 05:53:55 -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 18A3BC21E62; Fri, 15 Jun 2018 12:47:36 +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 1E955C21DAF; Fri, 15 Jun 2018 12:42:45 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D3343C21E96; Fri, 15 Jun 2018 12:42:34 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 259D2C21EB4 for ; Fri, 15 Jun 2018 12:42:32 +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 61F63AF96; Fri, 15 Jun 2018 12:42:31 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Fri, 15 Jun 2018 14:42:29 +0200 Message-Id: <20180615124229.35310-18-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180615124229.35310-1-agraf@suse.de> References: <20180615124229.35310-1-agraf@suse.de> Cc: Andy Shevchenko , Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 17/17] 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 944f104899..1d9f10df98 100644 --- a/arch/sandbox/cpu/cpu.c +++ b/arch/sandbox/cpu/cpu.c @@ -151,11 +151,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 81206ba0d2..4ef4040103 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -653,24 +653,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_ */