From patchwork Sun Sep 3 12:17:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 111517 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp321725qge; Sun, 3 Sep 2017 05:17:26 -0700 (PDT) X-Google-Smtp-Source: ADKCNb7DlNRu1WKbIupl0xmkpxNvtLzSoVRI2rlqQIyF6TTxoSil9Ywgs/BDgnlMMhQDk7dbJgmB X-Received: by 10.80.214.196 with SMTP id l4mr6258739edj.263.1504441046327; Sun, 03 Sep 2017 05:17:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504441046; cv=none; d=google.com; s=arc-20160816; b=bdRLlE4tYIbOCaHMtyb9f0Hr/vh+eTfp5YPO5fuG6ZSCyJxvO/92Ro0PV6PwzFH9ud D5kCGQrgyrp75QEBlV58afdnKJt4WEYhqUicm48xTJS6EeH9MC7vZbiBrZhBJSBiu3O7 WtuvSc+kfIHIJ0kdCMAHvz9p/zp7ZwnwAEllJyAxcZMMUO2Rq9bq6Efkr8h4scdhw9Zs KtPxasMi6bN54YuMoNBrEjNSSejqQTTolRiHE2Q8ORaiEBm76fK23cMNaWxrtYieLYFA W+oS3mDKXoowCNRArsmBF8zFYbqfX423n2AUk7Up3K2x6lf7wGbmQ1BL+TZu4RjtEMb1 +e+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:message-id:date:to:from :arc-authentication-results; bh=18N91vjoQkYCzdJA4WgqFJBy9KO999wJYKFqixbnW+Y=; b=n5vCpCb55BI7M8CP7mlfHwsxN9sR22dvFUBK7KlPoOAfR3xGyUiHDqNr0SsAcReDDh RqqzxNRWzJKgdfcTPq335XawMjed2XVUZKvNFfSYBfZtXxgDd9SxBNhDRQumNdXiOocF WTk7KEzXhAwl79jaQJSw5sRC1guKUPoSb+geo5oGtCUm9Q/a1W8QQ7/FC3NbUch5rRUH 3s2boR/loDCrYtBo0qr/9jp1GQM7PGgSKLUTRroazIhV3qD97a31d7bu8+0EoQ1pESON Tdy1LM2/zsCjowL4yW2TneWWx1ScEfIl0OmpNdMUFL0iuRhPBpyGoPX6e4yKCnZbJCnV oN1w== 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 q21si2753847edg.236.2017.09.03.05.17.25; Sun, 03 Sep 2017 05:17:26 -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 31518C21DBD; Sun, 3 Sep 2017 12:17: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=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED 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 A98A0C21D65; Sun, 3 Sep 2017 12:17:21 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 11D95C21D04; Sun, 3 Sep 2017 12:17:21 +0000 (UTC) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id 54DE5C21C35 for ; Sun, 3 Sep 2017 12:17:20 +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 mx1.suse.de (Postfix) with ESMTP id D1D2FAAD0; Sun, 3 Sep 2017 12:17:19 +0000 (UTC) From: Alexander Graf 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 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 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" Commit f494950b (efi_loader: call __efi_exit_check in efi_exit) added a call to __efi_exit_check inside efi_exit to account for the fact that we're exiting the efi_exit function via a longjmp call. However, __efi_exit_check also swizzles gd to the application gd while the longjmp will put us back into EFI context, so we need the efi (u-boot) gd. This patch fixes that up by explicitly setting gd back to efi_gd before doing the longjmp. It also adds a few comments on why it does that. Signed-off-by: Alexander Graf --- lib/efi_loader/efi_boottime.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 99c5a6ee0c..90e9ead7b2 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -798,8 +798,15 @@ static efi_status_t EFIAPI efi_exit(efi_handle_t image_handle, EFI_ENTRY("%p, %ld, %ld, %p", image_handle, exit_status, exit_data_size, exit_data); + /* Make sure entry/exit counts for EFI world cross-overs match */ __efi_exit_check(); + /* + * But longjmp out with the U-Boot gd, not the application's, as + * the other end is a setjmp call inside EFI context. + */ + efi_restore_gd(); + loaded_image_info->exit_status = exit_status; longjmp(&loaded_image_info->exit_jmp, 1);