From patchwork Tue Jul 22 00:43:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Franz X-Patchwork-Id: 34014 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f197.google.com (mail-ie0-f197.google.com [209.85.223.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D5FA720492 for ; Tue, 22 Jul 2014 00:46:17 +0000 (UTC) Received: by mail-ie0-f197.google.com with SMTP id rp18sf65413497iec.8 for ; Mon, 21 Jul 2014 17:46:17 -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:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :list-archive:content-type:content-transfer-encoding; bh=3GBnxiOPPYIpscHOPFP9bT3o3MeaCRegnaD0uLK2C5E=; b=Tz+EHpRVuDYnU9fVRLYa7n8kFxD2yPiZt7Ty6wQPiqCMAPmDdCcrmuQlZqCrW+qy/n iOPvqreQ7ga7uGzBtdkTv42P+LxOa3eskvbxRNY4XZdvxEYSTYowob3TMtuPfBLi444c g+gSK0c2R9CFeH6LmWB6+/Z/jPW5/aPuCxvg6bIhsGQoPvJQvpKAL56HZv3JDuS8Chgj 2ON6V6Uq5EOLOsQdZFMrUwF9ow9DNQPJd04HCnoykyfpY3xkPAgWyXkE6MqYRtx5Z9i4 1jLupLygqD6FeuI3qwzbuaWGXZOkQdk+ibF4OBTK1Ko09oGIYlmNppdHxpFNYYfpKFsA QNPw== X-Gm-Message-State: ALoCoQmOKyzfFV3rm0sxN2ny+yFdqQHOGJqfPfLjhwgqagLmq+16j/5QPX0HE0HGa8WWfSFVHmO7 X-Received: by 10.42.94.69 with SMTP id a5mr5798822icn.29.1405989977397; Mon, 21 Jul 2014 17:46:17 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.93.101 with SMTP id c92ls2144672qge.90.gmail; Mon, 21 Jul 2014 17:46:17 -0700 (PDT) X-Received: by 10.220.179.197 with SMTP id br5mr7164169vcb.80.1405989977251; Mon, 21 Jul 2014 17:46:17 -0700 (PDT) Received: from mail-vc0-f172.google.com (mail-vc0-f172.google.com [209.85.220.172]) by mx.google.com with ESMTPS id r6si12872701vei.7.2014.07.21.17.46.17 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 21 Jul 2014 17:46:17 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.172 as permitted sender) client-ip=209.85.220.172; Received: by mail-vc0-f172.google.com with SMTP id im17so13786075vcb.17 for ; Mon, 21 Jul 2014 17:46:17 -0700 (PDT) X-Received: by 10.220.118.136 with SMTP id v8mr16939414vcq.50.1405989977175; Mon, 21 Jul 2014 17:46:17 -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.221.37.5 with SMTP id tc5csp154155vcb; Mon, 21 Jul 2014 17:46:16 -0700 (PDT) X-Received: by 10.220.3.79 with SMTP id 15mr9357374vcm.63.1405989976859; Mon, 21 Jul 2014 17:46:16 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id t6si12856233vcr.86.2014.07.21.17.46.16 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 21 Jul 2014 17:46:16 -0700 (PDT) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X9OBe-000085-Ru; Tue, 22 Jul 2014 00:44:10 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X9OBd-00007g-Jg for xen-devel@lists.xen.org; Tue, 22 Jul 2014 00:44:09 +0000 Received: from [193.109.254.147:16931] by server-12.bemta-14.messagelabs.com id 76/67-23840-8D3BDC35; Tue, 22 Jul 2014 00:44:08 +0000 X-Env-Sender: roy.franz@linaro.org X-Msg-Ref: server-15.tower-27.messagelabs.com!1405989846!18774497!1 X-Originating-IP: [209.85.220.47] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 10953 invoked from network); 22 Jul 2014 00:44:08 -0000 Received: from mail-pa0-f47.google.com (HELO mail-pa0-f47.google.com) (209.85.220.47) by server-15.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 22 Jul 2014 00:44:08 -0000 Received: by mail-pa0-f47.google.com with SMTP id kx10so10632882pab.20 for ; Mon, 21 Jul 2014 17:44:06 -0700 (PDT) X-Received: by 10.68.104.66 with SMTP id gc2mr29197498pbb.17.1405989846169; Mon, 21 Jul 2014 17:44:06 -0700 (PDT) Received: from rfranz-t520.local (c-24-10-97-91.hsd1.ca.comcast.net. [24.10.97.91]) by mx.google.com with ESMTPSA id fl3sm15417298pbc.35.2014.07.21.17.44.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 21 Jul 2014 17:44:05 -0700 (PDT) From: Roy Franz To: xen-devel@lists.xen.org, ian.campbell@citrix.com, stefano.stabellini@citrix.com, tim@xen.org, jbeulich@suse.com, keir@xen.org Date: Mon, 21 Jul 2014 17:43:26 -0700 Message-Id: <1405989815-25236-4-git-send-email-roy.franz@linaro.org> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1405989815-25236-1-git-send-email-roy.franz@linaro.org> References: <1405989815-25236-1-git-send-email-roy.franz@linaro.org> Cc: Roy Franz , fu.wei@linaro.org, linaro-uefi@lists.linaro.org Subject: [Xen-devel] [PATCH V2 03/12] Refactor get_parent_handle for sharing X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: roy.franz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.172 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 List-Archive: Refactor get_parent_handle() to return NULL on error rather than directly exiting, as the exit cleanup code is arch specific. Having the common code reference the architecture specific code causes pre-linking to fail. Signed-off-by: Roy Franz --- xen/arch/x86/efi/boot.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/efi/boot.c b/xen/arch/x86/efi/boot.c index 849dc2d..c0546ec 100644 --- a/xen/arch/x86/efi/boot.c +++ b/xen/arch/x86/efi/boot.c @@ -237,12 +237,18 @@ static EFI_FILE_HANDLE __init get_parent_handle(EFI_LOADED_IMAGE *loaded_image, ret = efi_bs->HandleProtocol(loaded_image->DeviceHandle, &fs_protocol, (void **)&fio); if ( EFI_ERROR(ret) ) - PrintErrMesgExit(L"Couldn't obtain the File System Protocol Interface", + { + PrintErrMesg(L"Couldn't obtain the File System Protocol Interface", ret); + return NULL; + } ret = fio->OpenVolume(fio, &dir_handle); } while ( ret == EFI_MEDIA_CHANGED ); if ( ret != EFI_SUCCESS ) - PrintErrMesgExit(L"OpenVolume failure", ret); + { + PrintErrMesg(L"OpenVolume failure", ret); + return NULL; + } #define buffer ((CHAR16 *)keyhandler_scratch) #define BUFFERSIZE sizeof(keyhandler_scratch) @@ -254,7 +260,10 @@ static EFI_FILE_HANDLE __init get_parent_handle(EFI_LOADED_IMAGE *loaded_image, if ( DevicePathType(dp) != MEDIA_DEVICE_PATH || DevicePathSubType(dp) != MEDIA_FILEPATH_DP ) - blexit(L"Unsupported device path component"); + { + PrintErr(L"Unsupported device path component"); + return NULL; + } if ( *buffer ) { @@ -265,7 +274,8 @@ static EFI_FILE_HANDLE __init get_parent_handle(EFI_LOADED_IMAGE *loaded_image, if ( ret != EFI_SUCCESS ) { PrintErr(L"Open failed for "); - PrintErrMesgExit(buffer, ret); + PrintErrMesg(buffer, ret); + return NULL; } dir_handle->Close(dir_handle); dir_handle = new_handle; @@ -273,7 +283,10 @@ static EFI_FILE_HANDLE __init get_parent_handle(EFI_LOADED_IMAGE *loaded_image, fp = (void *)dp; if ( BUFFERSIZE < DevicePathNodeLength(dp) - sizeof(*dp) + sizeof(*buffer) ) - blexit(L"Increase BUFFERSIZE"); + { + PrintErr(L"Increase BUFFERSIZE"); + return NULL; + } memcpy(buffer, fp->PathName, DevicePathNodeLength(dp) - sizeof(*dp)); buffer[(DevicePathNodeLength(dp) - sizeof(*dp)) / sizeof(*buffer)] = 0; } @@ -292,7 +305,8 @@ static EFI_FILE_HANDLE __init get_parent_handle(EFI_LOADED_IMAGE *loaded_image, EFI_FILE_MODE_READ, 0); if ( ret != EFI_SUCCESS ) { PrintErr(L"Open failed for "); - PrintErrMesgExit(buffer, ret); + PrintErrMesg(buffer, ret); + return NULL; } dir_handle->Close(dir_handle); dir_handle = new_handle; @@ -706,6 +720,9 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) /* Get the file system interface. */ dir_handle = get_parent_handle(loaded_image, &file_name); + if ( !dir_handle ) + blexit(L"EFI get_parent_handle failed."); + argc = get_argv(0, NULL, loaded_image->LoadOptions, loaded_image->LoadOptionsSize); if ( argc > 0 &&