From patchwork Wed Apr 30 14:11:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Salter X-Patchwork-Id: 29427 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f197.google.com (mail-ve0-f197.google.com [209.85.128.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A2AEE202FE for ; Wed, 30 Apr 2014 14:11:47 +0000 (UTC) Received: by mail-ve0-f197.google.com with SMTP id sa20sf6028971veb.0 for ; Wed, 30 Apr 2014 07:11:47 -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:message-id:subject :precedence:reply-to:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:errors-to:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=AbEtysGMMXqDDGdDlR2lYJ1fLp1p45TAm10EHTcnjQc=; b=FWAGh+ecF5Q6IRkxUL6p535J0EA0VdGfBY669mBnguuf6pk9ctwIiLVCQCI+1T/an/ SIu7FD36+CL+6f3ZkbsbhRXxU6qCxM4J0menuf2RLyqr1vHhH1oIjTmc+VRI+FkTivJ+ IVCJwrvEZFwE1BhGHcCYjoACEE+LJ2AVoyIRMCgs5C3sMYLxKAoD2PDT+8HS/dWvnjoB b1EgNWwKuPijGhN+9HVC32p7zh66kEMbPN5cv1JB49J541WC+nnXeQ/NlRCWaDp8+F4G Lg/5cICr0GIcwMyhRMqemtDaSQsd3of4GkSjfOxvdeFh+04zrYzZrk4Vvvf65StYKS0p mMiA== X-Gm-Message-State: ALoCoQnyw1hXD2tnVf3ZhFV8X65EHw256a9Hh+Shm2X71JbkYwfBPrehmHatQtbKCj7OF8f9Kn43 X-Received: by 10.58.43.170 with SMTP id x10mr2387247vel.36.1398867107382; Wed, 30 Apr 2014 07:11:47 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.31.225 with SMTP id f88ls619680qgf.65.gmail; Wed, 30 Apr 2014 07:11:47 -0700 (PDT) X-Received: by 10.220.113.11 with SMTP id y11mr406073vcp.40.1398867107287; Wed, 30 Apr 2014 07:11:47 -0700 (PDT) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id fa16si5340580veb.136.2014.04.30.07.11.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 30 Apr 2014 07:11:47 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.128.173; Received: by mail-ve0-f173.google.com with SMTP id pa12so1224317veb.4 for ; Wed, 30 Apr 2014 07:11:47 -0700 (PDT) X-Received: by 10.52.51.197 with SMTP id m5mr3430832vdo.9.1398867107192; Wed, 30 Apr 2014 07:11:47 -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 ib8csp282330vcb; Wed, 30 Apr 2014 07:11:46 -0700 (PDT) X-Received: by 10.43.178.197 with SMTP id ox5mr4223887icc.22.1398867106260; Wed, 30 Apr 2014 07:11:46 -0700 (PDT) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id ce9si19082797icc.67.2014.04.30.07.11.43 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 30 Apr 2014 07:11:44 -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 1WfVES-0006Yp-Jx; Wed, 30 Apr 2014 14:11:32 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1WfVER-0006Yh-8l for edk2-devel@lists.sourceforge.net; Wed, 30 Apr 2014 14:11:31 +0000 Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=msalter@redhat.com; helo=mx1.redhat.com; Received: from mx1.redhat.com ([209.132.183.28]) by sog-mx-2.v43.ch3.sourceforge.com with esmtp (Exim 4.76) id 1WfVEP-0002Im-MC for edk2-devel@lists.sourceforge.net; Wed, 30 Apr 2014 14:11:31 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s3UEBNa0007562 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 30 Apr 2014 10:11:23 -0400 Received: from deneb.redhat.com (ovpn-113-49.phx2.redhat.com [10.3.113.49]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s3UEBMPw010548 for ; Wed, 30 Apr 2014 10:11:23 -0400 From: Mark Salter To: edk2-devel@lists.sourceforge.net Date: Wed, 30 Apr 2014 10:11:19 -0400 Message-Id: <1398867079-4684-1-git-send-email-msalter@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Spam-Score: -2.2 (--) 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_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain X-Headers-End: 1WfVEP-0002Im-MC Subject: [edk2] [PATCH] ArmPkg: fix booting with partial paths 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: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.sourceforge.net X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: msalter@redhat.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) 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 Boot entries created by efibootmgr may contain a partial device path to the EFI application to boot. These entries begin with a partition device path whereas entries created via ARM Boot Manager contain a full path to the EFI application. The ARM BDS code will fill in the missing parts of this partial device path as it does for removeable device paths. This allows the application to be loaded and started. However, the current code passes the original partial device path to gBS->LoadImage() and thus LoadImage is unable to find a DeviceHandle for the path. This means the application being booted cannot find the boot device from the Loaded Image Protocol structure. In the case of grub, this prevents the grub config file from being found. This patch fixes this by making sure the full path is propagated back to the caller of gBS->LoadImage() so that a proper DeviceHandle gets passed to the application being booted. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Mark Salter --- ArmPkg/Library/BdsLib/BdsFilePath.c | 77 ++++++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 27 deletions(-) diff --git a/ArmPkg/Library/BdsLib/BdsFilePath.c b/ArmPkg/Library/BdsLib/BdsFilePath.c index 25f9272..2b65d01 100644 --- a/ArmPkg/Library/BdsLib/BdsFilePath.c +++ b/ArmPkg/Library/BdsLib/BdsFilePath.c @@ -300,35 +300,24 @@ TryRemovableDevice ( return Status; } -/** - Connect a Device Path and return the handle of the driver that support this DevicePath - - @param DevicePath Device Path of the File to connect - @param Handle Handle of the driver that support this DevicePath - @param RemainingDevicePath Remaining DevicePath nodes that do not match the driver DevicePath - - @retval EFI_SUCCESS A driver that matches the Device Path has been found - @retval EFI_NOT_FOUND No handles match the search. - @retval EFI_INVALID_PARAMETER DevicePath or Handle is NULL - -**/ +STATIC EFI_STATUS -BdsConnectDevicePath ( - IN EFI_DEVICE_PATH_PROTOCOL* DevicePath, - OUT EFI_HANDLE *Handle, - OUT EFI_DEVICE_PATH_PROTOCOL **RemainingDevicePath +BdsConnectAndUpdateDevicePath ( + IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, + OUT EFI_HANDLE *Handle, + OUT EFI_DEVICE_PATH_PROTOCOL **RemainingDevicePath ) { EFI_DEVICE_PATH* Remaining; EFI_DEVICE_PATH* NewDevicePath; EFI_STATUS Status; - if ((DevicePath == NULL) || (Handle == NULL)) { + if ((DevicePath == NULL) || (*DevicePath == NULL) || (Handle == NULL)) { return EFI_INVALID_PARAMETER; } do { - Remaining = DevicePath; + Remaining = *DevicePath; // The LocateDevicePath() function locates all devices on DevicePath that support Protocol and returns // the handle to the device that is closest to DevicePath. On output, the device path pointer is modified // to point to the remaining part of the device path @@ -348,7 +337,7 @@ BdsConnectDevicePath ( if (!EFI_ERROR (Status)) { // Now, we have got the whole Device Path connected, call again ConnectController to ensure all the supported Driver // Binding Protocol are connected (such as DiskIo and SimpleFileSystem) - Remaining = DevicePath; + Remaining = *DevicePath; Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &Remaining, Handle); if (!EFI_ERROR (Status)) { Status = gBS->ConnectController (*Handle, NULL, Remaining, FALSE); @@ -371,9 +360,11 @@ BdsConnectDevicePath ( //TODO: Should we just return success and leave the caller decide if it is the expected RemainingPath Status = EFI_SUCCESS; } else { - Status = TryRemovableDevice (DevicePath, Handle, &NewDevicePath); + Status = TryRemovableDevice (*DevicePath, Handle, &NewDevicePath); if (!EFI_ERROR (Status)) { - return BdsConnectDevicePath (NewDevicePath, Handle, RemainingDevicePath); + Status = BdsConnectAndUpdateDevicePath (&NewDevicePath, Handle, RemainingDevicePath); + *DevicePath = NewDevicePath; + return Status; } } @@ -384,6 +375,27 @@ BdsConnectDevicePath ( return Status; } +/** + Connect a Device Path and return the handle of the driver that support this DevicePath + + @param DevicePath Device Path of the File to connect + @param Handle Handle of the driver that support this DevicePath + @param RemainingDevicePath Remaining DevicePath nodes that do not match the driver DevicePath + + @retval EFI_SUCCESS A driver that matches the Device Path has been found + @retval EFI_NOT_FOUND No handles match the search. + @retval EFI_INVALID_PARAMETER DevicePath or Handle is NULL + +**/ +BdsConnectDevicePath ( + IN EFI_DEVICE_PATH_PROTOCOL* DevicePath, + OUT EFI_HANDLE *Handle, + OUT EFI_DEVICE_PATH_PROTOCOL **RemainingDevicePath + ) +{ + return BdsConnectAndUpdateDevicePath(&DevicePath, Handle, RemainingDevicePath); +} + BOOLEAN BdsFileSystemSupport ( IN EFI_DEVICE_PATH *DevicePath, @@ -866,8 +878,8 @@ BDS_FILE_LOADER FileLoaders[] = { }; EFI_STATUS -BdsLoadImage ( - IN EFI_DEVICE_PATH *DevicePath, +BdsLoadImageAndUpdateDevicePath ( + IN OUT EFI_DEVICE_PATH **DevicePath, IN EFI_ALLOCATE_TYPE Type, IN OUT EFI_PHYSICAL_ADDRESS* Image, OUT UINTN *FileSize @@ -878,15 +890,15 @@ BdsLoadImage ( EFI_DEVICE_PATH *RemainingDevicePath; BDS_FILE_LOADER* FileLoader; - Status = BdsConnectDevicePath (DevicePath, &Handle, &RemainingDevicePath); + Status = BdsConnectAndUpdateDevicePath (DevicePath, &Handle, &RemainingDevicePath); if (EFI_ERROR (Status)) { return Status; } FileLoader = FileLoaders; while (FileLoader->Support != NULL) { - if (FileLoader->Support (DevicePath, Handle, RemainingDevicePath)) { - return FileLoader->LoadImage (DevicePath, Handle, RemainingDevicePath, Type, Image, FileSize); + if (FileLoader->Support (*DevicePath, Handle, RemainingDevicePath)) { + return FileLoader->LoadImage (*DevicePath, Handle, RemainingDevicePath, Type, Image, FileSize); } FileLoader++; } @@ -894,6 +906,17 @@ BdsLoadImage ( return EFI_UNSUPPORTED; } +BdsLoadImage ( + IN EFI_DEVICE_PATH *DevicePath, + IN EFI_DEVICE_PATH *DevicePath, + IN EFI_ALLOCATE_TYPE Type, + IN OUT EFI_PHYSICAL_ADDRESS* Image, + OUT UINTN *FileSize + ) +{ + return BdsLoadImageAndUpdateDevicePath (&DevicePath, Type, Image, FileSize); +} + /** Start an EFI Application from a Device Path @@ -920,7 +943,7 @@ BdsStartEfiApplication ( EFI_LOADED_IMAGE_PROTOCOL* LoadedImage; // Find the nearest supported file loader - Status = BdsLoadImage (DevicePath, AllocateAnyPages, &BinaryBuffer, &BinarySize); + Status = BdsLoadImageAndUpdateDevicePath (&DevicePath, AllocateAnyPages, &BinaryBuffer, &BinarySize); if (EFI_ERROR (Status)) { return Status; }