From patchwork Mon Jul 3 20:41:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 783639 X-Patchwork-Delegate: agraf@suse.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3x1fHz001Bz9s9Y for ; Tue, 4 Jul 2017 06:44:14 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id B6BABC21DDF; Mon, 3 Jul 2017 20:42:56 +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=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2 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 6A16BC21DB6; Mon, 3 Jul 2017 20:42:03 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 2C3DEC21DA3; Mon, 3 Jul 2017 20:42:00 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lists.denx.de (Postfix) with ESMTPS id 75A8AC21C62 for ; Mon, 3 Jul 2017 20:41:59 +0000 (UTC) Received: from workstation4.fritz.box ([88.152.145.149]) by mail.gmx.com (mrgmx002 [212.227.17.184]) with ESMTPSA (Nemesis) id 0LynHb-1dorsy3HFf-0169KS; Mon, 03 Jul 2017 22:41:55 +0200 From: Heinrich Schuchardt To: Alexander Graf Date: Mon, 3 Jul 2017 22:41:24 +0200 Message-Id: <20170703204126.11992-2-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170703204126.11992-1-xypron.glpk@gmx.de> References: <20170703204126.11992-1-xypron.glpk@gmx.de> X-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mgPDdFlDOlodY= Cc: u-boot@lists.denx.de, Heinrich Schuchardt Subject: [U-Boot] [PATCH v2 1/3] bootefi: allow return without EFI_BOOT_SERVICES.Exit 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 Unified Extensible Firmware Interface Specification, version 2.7, defines in chapter 2.1.2 - UEFI Application that an EFI application may either directly return or call EFI_BOOT_SERVICES.Exit(). Unfortunately U-Boot makes the incorrect assumption that EFI_BOOT_SERVICES.Exit() is always called. So the following application leads to a memory exception on the aarch64 architecture when returning: EFI_STATUS efi_main( EFI_HANDLE handle, EFI_SYSTEM_TABlE systable) { return EFI_SUCCESS; } With this patch the entry point is stored in the image handle. The new wrapper function do_enter is used to call the EFI entry point. Cc: Alexander Graf Signed-off-by: Heinrich Schuchardt --- v2: do not store entry in loaded_image_info but use additonal function parameter as suggested by Alexander --- cmd/bootefi.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 771300ee94..f52da205c9 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -147,15 +147,27 @@ static void *copy_fdt(void *fdt) return new_fdt; } +static asmlinkage ulong efi_do_enter(asmlinkage ulong (*entry)( + void *image_handle, struct efi_system_table *st), + void *image_handle, struct efi_system_table *st) +{ + efi_status_t ret = EFI_LOAD_ERROR; + + if (entry) + ret = entry(image_handle, st); + st->boottime->exit(image_handle, ret, 0 , NULL); + return ret; +} + #ifdef CONFIG_ARM64 -static unsigned long efi_run_in_el2(ulong (*entry)(void *image_handle, - struct efi_system_table *st), void *image_handle, - struct efi_system_table *st) +static unsigned long efi_run_in_el2(asmlinkage ulong (*entry)( + void *image_handle, struct efi_system_table *st), + void *image_handle, struct efi_system_table *st) { /* Enable caches again */ dcache_enable(); - return entry(image_handle, st); + return efi_do_enter(entry, image_handle, st); } #endif @@ -260,7 +272,7 @@ static unsigned long do_bootefi_exec(void *efi, void *fdt) } #endif - return entry(&loaded_image_info, &systab); + return efi_do_enter(entry, &loaded_image_info, &systab); }