From patchwork Wed Jan 24 14:04:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 125664 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp437141ljf; Wed, 24 Jan 2018 06:05:02 -0800 (PST) X-Google-Smtp-Source: AH8x226U1DaBWt5mxlpnjlg8EaQAM7pbaQJ4j8f1wJ/hsJrt3zdeu7sxJp7krgyOjXn0wq7Q4Qs9 X-Received: by 10.80.142.194 with SMTP id x2mr25387519edx.274.1516802702898; Wed, 24 Jan 2018 06:05:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516802702; cv=none; d=google.com; s=arc-20160816; b=pg0pWtYzj1Yg4FEJykbeL+PkLhjpwYlPAUrDI/VuPaW5qDNNwYuwb0n6ZOxxQ0KG1a LBTUe16op4752d+c6VgTcmk5tsmqkzJoTc9XKHprNGjlYkoPTDCgXvPTMwRE6+0ei+Aj q1Q+/cZuMHMDGyWgg+tOP8CVYIrtzFOB5qYTkxnVsTCz9s0VcszXlRAitJ0hS2Yxhu1G i1jz3pLagGvXMHUimsp9dM1V/bLBlKb91ewU9vqlc8O850rAtd3Krer+zPKo75KNQG2S sV5Ir5jeNaKjOdO37+AxQVpDBQv85GjIClmmbavxh0nG32QLAfthcHf7KIsuE87Vy2gD yJ5A== 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:message-id:date:to:from :arc-authentication-results; bh=r7ocR81vsVPwZBNYzyhcXo5w3Qgz/2xAcfGm7i+PGTw=; b=KAfYEJLa5ZEGfPNF0X+qIeFacALAsJeT2vivkl8Dl1OJve3IaEj59xM1Ev2vIoIMcS yoP3IQkkRausvePcFfR+xiqGLd2gsx8pVzaEuH5/ag75U2EdBpdFQK/rtn3M+4m5OEhP cB4mZl7k4zjuvONyJ0/KtpgMQN11+9lfj7J8MxBW7MkBbjHQ3zbsikrJPMfooL6usYBF +6Y+WPFfNpdeFxax2wii+AjO6uTtVukKspMwxyK73S/6P8a2w5fSjg26H+3kl4ZmX7Mr fEPxGEumdFOlSw43S+NDEH/0gd4L5IU5B+IOF4wlE4LrbkJNG2ohEKXqcouboKkFiZF2 /0Ow== 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 l13si306245edj.196.2018.01.24.06.05.02; Wed, 24 Jan 2018 06:05:02 -0800 (PST) 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 1FB70C2221F; Wed, 24 Jan 2018 14:04: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 AB428C21F5B; Wed, 24 Jan 2018 14:04:56 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7F1A1C221EB; Wed, 24 Jan 2018 14:04:55 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 15DAFC21F2B for ; Wed, 24 Jan 2018 14:04:55 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 9EE0CAD00; Wed, 24 Jan 2018 14:04:54 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Wed, 24 Jan 2018 15:04:53 +0100 Message-Id: <20180124140454.82768-1-agraf@suse.de> X-Mailer: git-send-email 2.12.3 Cc: Heinrich Schuchardt Subject: [U-Boot] [PATCH 1/2] efi: Conflict efi_loader with different stub bitness 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 have 2 users of the EFI headers: efi_loader and the EFI stub. Efi_loader always expects that the bitness of the definitions it uses is identical to the execution. The EFI stub however allows to run x86_64 U-Boot on 32bit EFI and the other way around, so it allows for different bitness of EFI definitions and U-Boot environment. This patch explicitly requests via Kconfig that efi_loader can only be enabled if the bitness is identical. Because we can run efi_loader on x86_64 without EFI stub enabled, it also ensures that this case propagates the correct ABI constraints. Signed-off-by: Alexander Graf --- include/efi.h | 2 +- lib/efi_loader/Kconfig | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/efi.h b/include/efi.h index 2f0be9c86c..98bddbac1a 100644 --- a/include/efi.h +++ b/include/efi.h @@ -19,7 +19,7 @@ #include #include -#ifdef CONFIG_EFI_STUB_64BIT +#if CONFIG_EFI_STUB_64BIT || (!defined(CONFIG_EFI_STUB) && defined(__x86_64__)) /* EFI uses the Microsoft ABI which is not the default for GCC */ #define EFIAPI __attribute__((ms_abi)) #else diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index d2b6327119..827c267b60 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -1,6 +1,10 @@ config EFI_LOADER bool "Support running EFI Applications in U-Boot" depends on (ARM || X86) && OF_LIBFDT + # We need EFI_STUB_64BIT to be set on x86_64 with EFI_STUB + depends on !EFI_STUB || !X86_64 || EFI_STUB_64BIT + # We need EFI_STUB_32BIT to be set on x86_32 with EFI_STUB + depends on !EFI_STUB || !X86 || X86_64 || EFI_STUB_32BIT default y help Select this option if you want to run EFI applications (like grub2) From patchwork Wed Jan 24 14:04:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 125665 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp437482ljf; Wed, 24 Jan 2018 06:05:33 -0800 (PST) X-Google-Smtp-Source: AH8x225EerGcDss83V8Mwy3BOGoVZLghCQCXHbHZR/mMFPPs55brWukRAtSsEkRJKmiXbS5RQlHr X-Received: by 10.80.158.238 with SMTP id a101mr23836795edf.166.1516802733612; Wed, 24 Jan 2018 06:05:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516802733; cv=none; d=google.com; s=arc-20160816; b=rG8m+f5sAo+SjHmPx4bqInygK6YC4py1X7vCSeq74MhMUv5YSZ9jpaUiJYF34Zwrw9 GTnxynvk6J6ZvqOb6+KOprsdss8HVzayZuu4lLXHF4IY3UfWwBc46D5w+V84K3W+QVVt BIdSEIt9WcDrQ8URpEQK7L8p0IvGR7dXFFXWVJX4DA8ItXj+7v3HEhacTO8Gqu4vmqsJ UzsFylMkbEG3sAWfFwMBXZSLYq1UK3NEPaF1xxqCbu5YwxibJWRicPpzAN47PbgWgZRA IW2XGKqMKwmQHAzyEgI46+J3n62lgj2z+WaK4dISf0MjxHwOU8i1ClkXH5eD68DTSnpC okXQ== 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=gsmFIM0PEpGLjKduGx/RtCfW6yl7i8QruQDuaD72Y2k=; b=ynnqQjqEGdZMsNYewrv8WTMWqo1Wq9IejhFFf25wHKcGosQOhe9iDveXU22ENYrsHE kEuU2iEA5BzwsLvFGXO6egZ2bSmfv2+GUYqORRUPLIa/j0yoj9Z15x4FF65fubW3iuXQ PJ1MA0BNxOkllYmWJgYpEq0JsvLUUZbkRjCAjSzLzSuk2lKGYzZHp5V1rwSf0HhFaCtf dL3Jzf7CVKegNqso50ybz27oBuMTugLjio4wB0A0W+NGlzWURTHy/zWcK5ZbYnWpydNv Y6FPvhajzsieSerOP/O7on/qXE3uqaabqlop4Jqt/MJxUatP4zskMOOC5qfytmBMJ6T2 +sZA== 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 m59si216225ede.46.2018.01.24.06.05.33; Wed, 24 Jan 2018 06:05:33 -0800 (PST) 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 3CFCBC2224F; Wed, 24 Jan 2018 14:05: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 6310AC22227; Wed, 24 Jan 2018 14:04:57 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 89AB8C21F2B; Wed, 24 Jan 2018 14:04:55 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 16F8CC21F5B for ; Wed, 24 Jan 2018 14:04:55 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 9F470ADF6; Wed, 24 Jan 2018 14:04:54 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Wed, 24 Jan 2018 15:04:54 +0100 Message-Id: <20180124140454.82768-2-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180124140454.82768-1-agraf@suse.de> References: <20180124140454.82768-1-agraf@suse.de> Cc: Heinrich Schuchardt Subject: [U-Boot] [PATCH 2/2] efi_loader: Always use EFIAPI instead of asmlinkage 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" EFI calls are usually defined as asmlinkage. That means we pass all parameters to functions via the stack x86_32. On x86_64 however, we need to also stick to the MS ABI calling conventions, which the EFIAPI define conveniently handles for us. Most EFI functions were also marked with EFIAPI, except for the entry call. So this patch adjusts all entry calls to use EFIAPI instead of the manual asmlinkage attribute. While at it, we also change the prototype of the entry point to return efi_status_t instead of ulong, as this is the correct prototype definition. Signed-off-by: Alexander Graf --- cmd/bootefi.c | 11 ++++++----- lib/efi_loader/efi_boottime.c | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 51213c0293..545cfecc12 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -126,8 +126,9 @@ static void *copy_fdt(void *fdt) static efi_status_t efi_do_enter( efi_handle_t image_handle, struct efi_system_table *st, - asmlinkage ulong (*entry)(efi_handle_t image_handle, - struct efi_system_table *st)) + EFIAPI efi_status_t (*entry)( + efi_handle_t image_handle, + struct efi_system_table *st)) { efi_status_t ret = EFI_LOAD_ERROR; @@ -138,7 +139,7 @@ static efi_status_t efi_do_enter( } #ifdef CONFIG_ARM64 -static efi_status_t efi_run_in_el2(asmlinkage ulong (*entry)( +static efi_status_t efi_run_in_el2(EFIAPI efi_status_t (*entry)( efi_handle_t image_handle, struct efi_system_table *st), efi_handle_t image_handle, struct efi_system_table *st) { @@ -162,8 +163,8 @@ static efi_status_t do_bootefi_exec(void *efi, void *fdt, struct efi_device_path *memdp = NULL; ulong ret; - ulong (*entry)(efi_handle_t image_handle, struct efi_system_table *st) - asmlinkage; + EFIAPI efi_status_t (*entry)(efi_handle_t image_handle, + struct efi_system_table *st); ulong fdt_pages, fdt_size, fdt_start, fdt_end; const efi_guid_t fdt_guid = EFI_FDT_GUID; bootm_headers_t img = { 0 }; diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 39d8511fe3..5b78740bff 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -1534,8 +1534,8 @@ static efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle, unsigned long *exit_data_size, s16 **exit_data) { - asmlinkage ulong (*entry)(efi_handle_t image_handle, - struct efi_system_table *st); + EFIAPI ulong (*entry)(efi_handle_t image_handle, + struct efi_system_table *st); struct efi_loaded_image *info = image_handle; efi_status_t ret;