From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk0-x235.google.com (mail-qk0-x235.google.com [IPv6:2607:f8b0:400d:c09::235]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3ADEC21BBC41F for ; Wed, 28 Jun 2017 07:03:21 -0700 (PDT) Received: by mail-qk0-x235.google.com with SMTP id p21so51487420qke.3 for ; Wed, 28 Jun 2017 07:04:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ZSka5H2biXlXsjh0u8+sOwBbUozSS1RWBj+VkvOquGI=; b=o25tMnrNQIK5I3lqOwtLuA462L0/MQ+K3L/j+FGne/xQdNSo525Zw+/US32lyuuTGl l9lzqHPcDYWo52zQoHr0JlGMdzbEFdgg/YBjfg4nOqbYPoVRUrGbA9sWjqNs8q9PrRyR Sj5kspSfCqq80EfiI1F5Vgx1QdUElnAFXByYgmgEkhqxBBsX7DvIS72HH6oIgtK2unOp Qz7rDoISOFxBOhyBeMrNmhvqKdqN9m6dxe9H0WxbT1DGMv0wAHpj2CJLwhwyx1oOcPel YSJ2DI7XtbUPTADh4iP1onOLCdZUouGvFSkvSC5QUVY3o1SL1LvJgpGKIqCVXflWfwtL BAvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ZSka5H2biXlXsjh0u8+sOwBbUozSS1RWBj+VkvOquGI=; b=ggmUIAYvi4junZxrGoAhHtq40fBHKIFKDXa1vwrjvaebtBshdDEmzNNmIoicwoMS3d dVqhYmJuy1ReXc8nyh/osnikNIQ1nyS0X+Z9169rqjcwXTWFsIqwFGEjNnNjJhn/GZKZ BoLJ6uA9xe+Ns6bQisQPDL+Y1Yt94uoX3fh81YMmpEC1nW84MD/EBqShQAlXdmZ7UGcL AiFo+fi5egYY+90UDhA2xKPWc5VO4j1n3w7kQeeVAZ4IbSkMQVFCDaGxxBd5d1NwSe9+ aAcG9hwg+d5o3CQkuyNAvpWMXfJCP3TfgFAdU+kfHr+PFl96GIBL6gMqL1sAzeI9DM6J I1EA== X-Gm-Message-State: AKS2vOyrtOs1srZE5TrT88jlGLhNyLsPAEOJDpDe7HVRwvf37BGFEY/1 LUv5wuduNAL7QA== X-Received: by 10.55.159.22 with SMTP id i22mr12129487qke.150.1498658691811; Wed, 28 Jun 2017 07:04:51 -0700 (PDT) Received: from HEDWIG.INI.CMU.EDU (HEDWIG.INI.CMU.EDU. [128.2.16.51]) by smtp.gmail.com with ESMTPSA id l12sm1852262qtl.24.2017.06.28.07.04.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Jun 2017 07:04:50 -0700 (PDT) Date: Wed, 28 Jun 2017 10:04:48 -0400 From: "Gabriel L. Somlo" To: Star Zeng Cc: edk2-devel@lists.01.org, Amit Kumar , Laszlo Ersek , Michael D Kinney , Liming Gao Message-ID: <20170628140447.GH18617@HEDWIG.INI.CMU.EDU> References: <1498656170-184428-1-git-send-email-star.zeng@intel.com> MIME-Version: 1.0 In-Reply-To: <1498656170-184428-1-git-send-email-star.zeng@intel.com> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.8.0 (2017-02-23) Subject: Re: [PATCH V5] MdeModulePkg/DxeCore: Fixed Interface returned by CoreOpenProtocol X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Jun 2017 14:03:21 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Jun 28, 2017 at 09:22:50PM +0800, Star Zeng wrote: > From: Amit Kumar > > Change since v4: Revise the patch based on V4 sent by Amit Kumar > 1) Only return the corresponding protocol interface in *Interface > if the return status is EFI_SUCCESS or EFI_ALREADY_STARTED. > 2) Interface is returned unmodified for all error conditions except > EFI_UNSUPPORTED and EFI_ALREADY_STARTED, NULL will be returned in > *Interface when EFI_UNSUPPORTED and Attributes is not > EFI_OPEN_PROTOCOL_TEST_PROTOCOL, the protocol interface will be > returned in *Interface when EFI_ALREADY_STARTED. Tested-by: Gabriel Somlo With this patch applied, OVMF works fine for me now. Thanks much, --Gabriel > Change since v3: > 1) Fixed issue when Attributes = EFI_OPEN_PROTOCOL_TEST_PROTOCOL > and Inteface = NULL case. [Reported by:star.zeng at intel.com] > > Change Since v2: > 1) Modified to use EFI_ERROR to get status code > > Change since v1: > 1) Fixed typo protocal to protocol > 2) Fixed coding style > > Cc: Laszlo Ersek > Cc: Amit Kumar > Cc: Michael D Kinney > Cc: Liming Gao > Cc: Gabriel Somlo > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Amit Kumar > Signed-off-by: Star Zeng > --- > MdeModulePkg/Core/Dxe/Hand/Handle.c | 36 +++++++++++++++++++++++------------- > 1 file changed, 23 insertions(+), 13 deletions(-) > > diff --git a/MdeModulePkg/Core/Dxe/Hand/Handle.c b/MdeModulePkg/Core/Dxe/Hand/Handle.c > index 59b89148c8f0..3862a3876f4a 100644 > --- a/MdeModulePkg/Core/Dxe/Hand/Handle.c > +++ b/MdeModulePkg/Core/Dxe/Hand/Handle.c > @@ -1006,12 +1006,8 @@ CoreOpenProtocol ( > // > // Check for invalid Interface > // > - if (Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) { > - if (Interface == NULL) { > - return EFI_INVALID_PARAMETER; > - } else { > - *Interface = NULL; > - } > + if ((Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) && (Interface == NULL)) { > + return EFI_INVALID_PARAMETER; > } > > // > @@ -1078,12 +1074,6 @@ CoreOpenProtocol ( > goto Done; > } > > - // > - // This is the protocol interface entry for this protocol > - // > - if (Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) { > - *Interface = Prot->Interface; > - } > Status = EFI_SUCCESS; > > ByDriver = FALSE; > @@ -1177,8 +1167,28 @@ CoreOpenProtocol ( > } > > Done: > + > + if (Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) { > + // > + // Keep Interface unmodified in case of any Error > + // except EFI_ALREADY_STARTED and EFI_UNSUPPORTED. > + // > + if (!EFI_ERROR (Status) || Status == EFI_ALREADY_STARTED) { > + // > + // EFI_ALREADY_STARTED is not an error for bus driver. > + // Return the corresponding protocol interface. > + // > + *Interface = Prot->Interface; > + } else if (Status == EFI_UNSUPPORTED) { > + // > + // Return NULL Interface if Unsupported Protocol. > + // > + *Interface = NULL; > + } > + } > + > // > - // Done. Release the database lock are return > + // Done. Release the database lock and return > // > CoreReleaseProtocolLock (); > return Status; > -- > 2.7.0.windows.1 >