From patchwork Wed May 27 18:04:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1299148 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.a=rsa-sha256 header.s=badeba3b8450 header.b=Ie/9emLk; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49XJdR72CGz9sSW for ; Thu, 28 May 2020 04:04:59 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D35448168B; Wed, 27 May 2020 20:04:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="Ie/9emLk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EC9A08168B; Wed, 27 May 2020 20:04:42 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 22F60815FB for ; Wed, 27 May 2020 20:04:40 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1590602677; bh=nRM44huyZ0O6lHx2bX0xKk73luZtWYlfYGKT3BbGCiY=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=Ie/9emLkiy3ms/D6QAkzlUeqA9zHwVm6+Oq9eyz4mPDF+jtNLL7YdcemIulODGUXB uvOXIg32FObn8Kv48t6lSSzxXApIbMWUdzIBfiSfznUPe7ElGAt8l39HzKO+9B6aAt WechdsJxHcrpXCF4zwFrBQXUQ9YA5GVRyLxLMSDM= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from workstation4.fritz.box ([88.152.145.75]) by mail.gmx.com (mrgmx005 [212.227.17.184]) with ESMTPSA (Nemesis) id 1N8GQs-1j0K171O6a-01492j; Wed, 27 May 2020 20:04:37 +0200 From: Heinrich Schuchardt To: Tom Rini Cc: Alexander Graf , Simon Glass , u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH 1/4] efi_loader: allow compiling with clang Date: Wed, 27 May 2020 20:04:21 +0200 Message-Id: <20200527180424.39395-2-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200527180424.39395-1-xypron.glpk@gmx.de> References: <20200527180424.39395-1-xypron.glpk@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:fPs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cnVoSo8ntn0 mPLp4+1Oef2mvRPRWnRqkr/ZWrmic4EY92YEsfybXujNDWV/CZ2MT2u8ldALy89+cdbF6OD6Y 21FijBR8VsRPvd5WNaCNsOkcsYvk4EN7+B7x4DxjDOC1gxcTpxdKi//KfPQ5IeTXnXXmj/4tK wRcTlJ69B6U9O8166rgWdgFucNDb2GXvRjfPbFwRIH1TKuRTEBCr0cMOY0LPSdQpYFk1RK90E K+hWlodrxVUrNZLtPg8QnVICWAHrtr4qAexa12AUk8r8pFNS92/zdZdNIwFMlX+8Fhmz/tBE5 /S1nMy0fPhQpywRueNS+IKjy+9GNoI/cI5OBzwzvx8g2JSlgPN2jiqZAsJsM+FUqdhJ01sz1y zg2Pf+8wwAjaWFpkrp/cU/2whQwnateXNUjLdC4oPzpU0czY9HJ0ky+QS9rKbmk2/I5hfrcWR EVZ4OlAUjObgNuqvv X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean On ARM systems gd is stored in register r9 or x18. When compiling with clang gd is defined as a macro calling function gd_ptr(). So we can not make assignments to gd. In the UEFI sub-system we need to save gd when leaving to UEFI binaries and have to restore gd when reentering U-Boot. Define a new function set_gd() for setting gd and use it in the UEFI sub-system. Signed-off-by: Heinrich Schuchardt Tested-by: Tom Rini Reviewed-by: Simon Glass --- Resent. --- arch/arm/include/asm/global_data.h | 9 +++++++++ lib/efi_loader/efi_boottime.c | 10 +++++----- 2 files changed, 14 insertions(+), 5 deletions(-) -- 2.26.2 diff --git a/arch/arm/include/asm/global_data.h b/arch/arm/include/asm/global_data.h index f23b6bfb75..7c0905d240 100644 --- a/arch/arm/include/asm/global_data.h +++ b/arch/arm/include/asm/global_data.h @@ -117,4 +117,13 @@ static inline gd_t *get_gd(void) #endif #endif +static inline void set_gd(volatile gd_t *gd_ptr) +{ +#ifdef CONFIG_ARM64 + __asm__ volatile("ldr x18, %0\n" : : "m"(gd_ptr)); +#else + __asm__ volatile("ldr r9, %0\n" : : "m"(gd_ptr)); +#endif +} + #endif /* __ASM_GBL_DATA_H */ diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index db34938196..1591ad8300 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -49,7 +49,7 @@ static efi_handle_t current_image; * restriction so we need to manually swap its and our view of that register on * EFI callback entry/exit. */ -static volatile void *efi_gd, *app_gd; +static volatile gd_t *efi_gd, *app_gd; #endif /* 1 if inside U-Boot code, 0 if inside EFI payload code */ @@ -89,7 +89,7 @@ int __efi_entry_check(void) #ifdef CONFIG_ARM assert(efi_gd); app_gd = gd; - gd = efi_gd; + set_gd(efi_gd); #endif return ret; } @@ -99,7 +99,7 @@ int __efi_exit_check(void) { int ret = --entry_count == 0; #ifdef CONFIG_ARM - gd = app_gd; + set_gd(app_gd); #endif return ret; } @@ -123,7 +123,7 @@ void efi_restore_gd(void) /* Only restore if we're already in EFI context */ if (!efi_gd) return; - gd = efi_gd; + set_gd(efi_gd); #endif } @@ -2920,7 +2920,7 @@ efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle, * otherwise __efi_entry_check() will put the wrong value into * app_gd. */ - gd = app_gd; + set_gd(app_gd); #endif /* * To get ready to call EFI_EXIT below we have to execute the