{"id":809262,"url":"http://patchwork.ozlabs.org/api/patches/809262/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20170903121719.12743-1-agraf@suse.de/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170903121719.12743-1-agraf@suse.de>","list_archive_url":null,"date":"2017-09-03T12:17:19","name":"[U-Boot] efi_loader: Fix efi_exit gd clobbering","commit_ref":"a148920e12cb9aa09589634966737c0fe88de2cc","pull_url":null,"state":"accepted","archived":false,"hash":"391d24595e12fe44692f034bc20498cade7e8eda","submitter":{"id":1212,"url":"http://patchwork.ozlabs.org/api/people/1212/?format=json","name":"Alexander Graf","email":"agraf@suse.de"},"delegate":{"id":3400,"url":"http://patchwork.ozlabs.org/api/users/3400/?format=json","username":"agraf","first_name":"Alexander","last_name":"Graf","email":"agraf@suse.de"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20170903121719.12743-1-agraf@suse.de/mbox/","series":[{"id":1219,"url":"http://patchwork.ozlabs.org/api/series/1219/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=1219","date":"2017-09-03T12:17:19","name":"[U-Boot] efi_loader: Fix efi_exit gd clobbering","version":1,"mbox":"http://patchwork.ozlabs.org/series/1219/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/809262/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/809262/checks/","tags":{},"related":[],"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xlX6j2Czfz9s7v\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSun,  3 Sep 2017 22:17:31 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 910F9C21DCF; Sun,  3 Sep 2017 12:17:24 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id A98A0C21D65;\n\tSun,  3 Sep 2017 12:17:21 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 11D95C21D04; Sun,  3 Sep 2017 12:17:21 +0000 (UTC)","from mx1.suse.de (mx2.suse.de [195.135.220.15])\n\tby lists.denx.de (Postfix) with ESMTPS id 54DE5C21C35\n\tfor <u-boot@lists.denx.de>; Sun,  3 Sep 2017 12:17:20 +0000 (UTC)","from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254])\n\tby mx1.suse.de (Postfix) with ESMTP id D1D2FAAD0;\n\tSun,  3 Sep 2017 12:17:19 +0000 (UTC)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED\n\tautolearn=unavailable autolearn_force=no version=3.4.0","X-Virus-Scanned":"by amavisd-new at test-mx.suse.de","From":"Alexander Graf <agraf@suse.de>","To":"u-boot@lists.denx.de","Date":"Sun,  3 Sep 2017 14:17:19 +0200","Message-Id":"<20170903121719.12743-1-agraf@suse.de>","X-Mailer":"git-send-email 2.12.3","Cc":"Heinrich Schuchardt <xypron.glpk@gmx.de>","Subject":"[U-Boot] [PATCH] efi_loader: Fix efi_exit gd clobbering","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"},"content":"Commit f494950b (efi_loader: call __efi_exit_check in efi_exit) added a call\nto __efi_exit_check inside efi_exit to account for the fact that we're exiting\nthe efi_exit function via a longjmp call.\n\nHowever, __efi_exit_check also swizzles gd to the application gd while the\nlongjmp will put us back into EFI context, so we need the efi (u-boot) gd.\n\nThis patch fixes that up by explicitly setting gd back to efi_gd before\ndoing the longjmp. It also adds a few comments on why it does that.\n\nSigned-off-by: Alexander Graf <agraf@suse.de>\n---\n lib/efi_loader/efi_boottime.c | 7 +++++++\n 1 file changed, 7 insertions(+)","diff":"diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c\nindex 99c5a6ee0c..90e9ead7b2 100644\n--- a/lib/efi_loader/efi_boottime.c\n+++ b/lib/efi_loader/efi_boottime.c\n@@ -798,8 +798,15 @@ static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle,\n \tEFI_ENTRY(\"%p, %ld, %ld, %p\", image_handle, exit_status,\n \t\t  exit_data_size, exit_data);\n \n+\t/* Make sure entry/exit counts for EFI world cross-overs match */\n \t__efi_exit_check();\n \n+\t/*\n+\t * But longjmp out with the U-Boot gd, not the application's, as\n+\t * the other end is a setjmp call inside EFI context.\n+\t */\n+\tefi_restore_gd();\n+\n \tloaded_image_info->exit_status = exit_status;\n \tlongjmp(&loaded_image_info->exit_jmp, 1);\n \n","prefixes":["U-Boot"]}