From patchwork Tue May 13 00:06:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olivier Martin X-Patchwork-Id: 30000 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f199.google.com (mail-ie0-f199.google.com [209.85.223.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 012ED203F3 for ; Tue, 13 May 2014 00:24:15 +0000 (UTC) Received: by mail-ie0-f199.google.com with SMTP id to1sf3702438ieb.2 for ; Mon, 12 May 2014 17:24:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:thread-topic :thread-index:message-id:accept-language:acceptlanguage:mime-version :cc:subject:precedence:reply-to:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:errors-to :x-original-sender:x-original-authentication-results:mailing-list :content-language:content-type; bh=9ToDFQsyVidpbpjvAnIRG9+2xvhPxkkek/oFElfj90k=; b=mhdLZQz2G0TthEqksaY3YV7V1LVj4IrM/yvTJF8YvuzAjt/Lr3NIj/EQgqyeJUWoHA u7U4PV5AScvtA856lbvFK7I/L2bIaukT4FqiAwAlyoE8Gr4YLjVp0VpBgUZYwIfboslG uAiwiLhZXLGQOmvJu2ZJRTyjtV9gKV9o97rVW2m3QsGz8vDqYs0uwoObK7g7FvsxSzM8 E54XzX15VIBAc+MXBmVrWkKclQb9j7OcwEqwX4lwvB/gm2gQar38XSVaB6MA81joyhVQ bVYbkFlDHuSgUXtJgbPbBDHweihytg3+vOjN+M3VwPwFbrkfdow21P6UI4NwdfxiyS2z 5nMA== X-Gm-Message-State: ALoCoQlWfI/NG667c8I3jfAo+efkhx9Ox+7YMqBBTnBAvCLb4igG44UlWOudtZxTdUF6xTVuW8HC X-Received: by 10.182.241.9 with SMTP id we9mr15850161obc.22.1399940655256; Mon, 12 May 2014 17:24:15 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.40.74 with SMTP id w68ls1673273qgw.53.gmail; Mon, 12 May 2014 17:24:15 -0700 (PDT) X-Received: by 10.221.37.1 with SMTP id tc1mr3916768vcb.32.1399940655156; Mon, 12 May 2014 17:24:15 -0700 (PDT) Received: from mail-ve0-f169.google.com (mail-ve0-f169.google.com [209.85.128.169]) by mx.google.com with ESMTPS id kp14si2346153vcb.110.2014.05.12.17.24.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 12 May 2014 17:24:15 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.169 as permitted sender) client-ip=209.85.128.169; Received: by mail-ve0-f169.google.com with SMTP id jx11so9755675veb.14 for ; Mon, 12 May 2014 17:24:15 -0700 (PDT) X-Received: by 10.221.37.1 with SMTP id tc1mr3916749vcb.32.1399940654963; Mon, 12 May 2014 17:24:14 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp108693vcb; Mon, 12 May 2014 17:24:14 -0700 (PDT) X-Received: by 10.50.83.6 with SMTP id m6mr49061569igy.30.1399940653551; Mon, 12 May 2014 17:24:13 -0700 (PDT) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id m2si13708860igx.24.2014.05.12.17.24.12 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 12 May 2014 17:24:13 -0700 (PDT) Received-SPF: pass (google.com: domain of edk2-devel-bounces@lists.sourceforge.net designates 216.34.181.88 as permitted sender) client-ip=216.34.181.88; Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Wk0Vj-0003fc-6g; Tue, 13 May 2014 00:23:59 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1Wk0Vh-0003fV-M4 for edk2-devel@lists.sourceforge.net; Tue, 13 May 2014 00:23:57 +0000 Received-SPF: pass (sog-mx-3.v43.ch3.sourceforge.com: domain of arm.com designates 195.130.217.12 as permitted sender) client-ip=195.130.217.12; envelope-from=olivier.martin@arm.com; helo=service88.mimecast.com; Received: from service88.mimecast.com ([195.130.217.12]) by sog-mx-3.v43.ch3.sourceforge.com with esmtp (Exim 4.76) id 1Wk0Vg-0004Sa-3Y for edk2-devel@lists.sourceforge.net; Tue, 13 May 2014 00:23:57 +0000 Received: from emea-cam-gw2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) (Using TLS) by service88.mimecast.com; Tue, 13 May 2014 01:07:27 +0100 Received: from george.Emea.Arm.com ([fe80::4c19:a8f:5c9a:76df]) by emea-cam-gw2.Emea.Arm.com ([::1]) with mapi; Tue, 13 May 2014 01:07:34 +0100 From: Olivier Martin To: "jaben.carsey@intel.com" Date: Tue, 13 May 2014 01:06:05 +0100 Thread-Topic: [PATCH] ShellPkg/Shell: Do not mix status when executing a command Thread-Index: AQHPbj87g/LD1Fj7UUiiS/rOq6bEmA== Message-ID: <0877601216922E4B83A7129715B5DA2BA7B7583D27@GEORGE.Emea.Arm.com> Accept-Language: en-US, en-GB X-MS-Has-Attach: yes X-MS-TNEF-Correlator: acceptlanguage: en-US, en-GB MIME-Version: 1.0 X-MC-Unique: 114051301072700302 X-Spam-Score: -1.5 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1Wk0Vg-0004Sa-3Y Cc: "edk2-devel@lists.sourceforge.net" Subject: [edk2] [PATCH] ShellPkg/Shell: Do not mix status when executing a command X-BeenThere: edk2-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list Reply-To: edk2-devel@lists.sourceforge.net List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: edk2-devel-bounces@lists.sourceforge.net X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: olivier.martin@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.169 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Content-Language: en-GB Dear ShellPkg maintainer, please find the attached patch that fixes the following error. The function InternalShellExecuteDevicePath() did not differentiate an error occuring during the preparation of an image and an error occuring during its execution. A use case of the issue was when a EFI application was called in a EFI Shell script. If the EFI application was returning an error then the NSH script stopped its execution. While the EFI Shell specification says the script should continue its execution (see 4.2 Error Handling). Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin Best Regards, Olivier -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. ARM Limited, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered in England & Wales, Company No: 2557590 ARM Holdings plc, Registered office 110 Fulbourn Road, Cambridge CB1 9NJ, Registered in England & Wales, Company No: 2548782 ------------------------------------------------------------------------------ "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE Instantly run your Selenium tests across 300+ browser/OS combos. Get unparalleled scalability from the best Selenium testing platform available Simple to use. Nothing to install. Get started now for free." http://p.sf.net/sfu/SauceLabs >From 5969a3758bbed8642b4c308279c99ba94994eece Mon Sep 17 00:00:00 2001 From: Olivier Martin Date: Tue, 13 May 2014 00:40:00 +0100 Subject: [PATCH] ShellPkg/Shell: Do not mix status when executing a command The function InternalShellExecuteDevicePath() did not differentiate an error occuring during the preparation of an image and an error occuring during its execution. A use case of the issue was when a EFI application was called in a EFI Shell script. If the EFI application was returning an error then the NSH script stopped its execution. While the EFI Shell specification says the script should continue its execution (see 4.2 Error Handling). Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin --- ShellPkg/Application/Shell/Shell.c | 4 +++- ShellPkg/Application/Shell/ShellProtocol.c | 10 +++++++--- ShellPkg/Application/Shell/ShellProtocol.h | 7 ++++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/ShellPkg/Application/Shell/Shell.c b/ShellPkg/Application/Shell/Shell.c index 056d66d..951d31e 100644 --- a/ShellPkg/Application/Shell/Shell.c +++ b/ShellPkg/Application/Shell/Shell.c @@ -2231,6 +2231,7 @@ RunCommandOrFile( ) { EFI_STATUS Status; + EFI_STATUS StartStatus; CHAR16 *CommandWithPath; EFI_DEVICE_PATH_PROTOCOL *DevPath; SHELL_STATUS CalleeExitStatus; @@ -2308,6 +2309,7 @@ RunCommandOrFile( DevPath, CmdLine, NULL, + &StartStatus, NULL, NULL ); @@ -2317,7 +2319,7 @@ RunCommandOrFile( if(EFI_ERROR (Status)) { CalleeExitStatus = (SHELL_STATUS) (Status & (~MAX_BIT)); } else { - CalleeExitStatus = SHELL_SUCCESS; + CalleeExitStatus = (SHELL_STATUS) StartStatus; } // diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c index ec45594..cfe2f40 100644 --- a/ShellPkg/Application/Shell/ShellProtocol.c +++ b/ShellPkg/Application/Shell/ShellProtocol.c @@ -1386,11 +1386,13 @@ InternalShellExecuteDevicePath( IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN CONST CHAR16 *CommandLine OPTIONAL, IN CONST CHAR16 **Environment OPTIONAL, + OUT EFI_STATUS *StartImageStatus OPTIONAL, OUT UINTN *ExitDataSize OPTIONAL, OUT CHAR16 **ExitData OPTIONAL ) { EFI_STATUS Status; + EFI_STATUS StartStatus; EFI_STATUS CleanupStatus; EFI_HANDLE NewHandle; EFI_LOADED_IMAGE_PROTOCOL *LoadedImage; @@ -1504,11 +1506,14 @@ InternalShellExecuteDevicePath( // now start the image, passing up exit data if the caller requested it // if (!EFI_ERROR(Status)) { - Status = gBS->StartImage( + StartStatus = gBS->StartImage( NewHandle, ExitDataSizePtr, ExitData ); + if (StartImageStatus != NULL) { + *StartImageStatus = StartStatus; + } CleanupStatus = gBS->UninstallProtocolInterface( NewHandle, @@ -1620,6 +1625,7 @@ EfiShellExecute( DevPath, Temp, (CONST CHAR16**)Environment, + StatusCode, &ExitDataSize, &ExitData); @@ -1644,8 +1650,6 @@ EfiShellExecute( } FreePool (ExitData); Status = EFI_SUCCESS; - } else if ((StatusCode != NULL) && !EFI_ERROR(Status)) { - *StatusCode = EFI_SUCCESS; } // diff --git a/ShellPkg/Application/Shell/ShellProtocol.h b/ShellPkg/Application/Shell/ShellProtocol.h index ff12327..7cc1b01 100644 --- a/ShellPkg/Application/Shell/ShellProtocol.h +++ b/ShellPkg/Application/Shell/ShellProtocol.h @@ -455,10 +455,11 @@ EfiShellEnablePageBreak ( EFI_STATUS EFIAPI InternalShellExecuteDevicePath( - IN CONST EFI_HANDLE *ParentImageHandle, + IN CONST EFI_HANDLE *ParentImageHandle, IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, - IN CONST CHAR16 *CommandLine OPTIONAL, - IN CONST CHAR16 **Environment OPTIONAL, + IN CONST CHAR16 *CommandLine OPTIONAL, + IN CONST CHAR16 **Environment OPTIONAL, + OUT EFI_STATUS *StartImageStatus OPTIONAL, OUT UINTN *ExitDataSize OPTIONAL, OUT CHAR16 **ExitData OPTIONAL ); -- 1.7.5.4