public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ni, Ray" <ray.ni@intel.com>
To: gaoliming <gaoliming@byosoft.com.cn>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>,
	"Jin, Zhi" <zhi.jin@intel.com>
Cc: "Kinney, Michael D" <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [PATCH v2 1/2] MdeModulePkg: Remove the handle validation check in CoreGetProtocolInterface
Date: Fri, 2 Feb 2024 06:04:16 +0000	[thread overview]
Message-ID: <MN6PR11MB8244521F7CF89B0E407676538C422@MN6PR11MB8244.namprd11.prod.outlook.com> (raw)
In-Reply-To: <021301da5403$328fc950$97af5bf0$@byosoft.com.cn>

Reviewed-by: Ray Ni <ray.ni@intel.com>

Thanks,
Ray
> -----Original Message-----
> From: gaoliming <gaoliming@byosoft.com.cn>
> Sent: Wednesday, January 31, 2024 1:06 PM
> To: devel@edk2.groups.io; Jin, Zhi <zhi.jin@intel.com>
> Cc: Ni, Ray <ray.ni@intel.com>; Kinney, Michael D
> <michael.d.kinney@intel.com>
> Subject: 回复: [edk2-devel] [PATCH v2 1/2] MdeModulePkg: Remove the
> handle validation check in CoreGetProtocolInterface
> 
> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
> 
> > -----邮件原件-----
> > 发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Zhi Jin
> > 发送时间: 2024年1月22日 17:53
> > 收件人: devel@edk2.groups.io
> > 抄送: Zhi Jin <zhi.jin@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>;
> > Ray Ni <ray.ni@intel.com>; Michael D Kinney <michael.d.kinney@intel.com>
> > 主题: [edk2-devel] [PATCH v2 1/2] MdeModulePkg: Remove the handle
> > validation check in CoreGetProtocolInterface
> >
> > CoreGetProtocolInterface() is called by CoreOpenProtocol(),
> > CoreCloseProtocol() and CoreOpenProtocolInformation().
> > Before CoreOpenProtocol() calls CoreGetProtocolInterface(), the input
> > parameter UserHandle has been already checked for validation. So does
> > CoreCloseProtocol().
> > Removing the handle validation check in CoreGetProtocolInterface()
> > could improve the performance, as CoreOpenProtocol() is called very
> > frequently.
> > To ensure the assumption that the caller of CoreGetProtocolInterface()
> > must pass in a valid UserHandle that is checked with CoreValidateHandle(),
> > add the parameter check in CoreOpenProtocolInformation(), and declare
> > CoreGetProtocolInterface() as static.
> >
> > v1 -> v2:
> >   1. Update the description of UserHandle to state that the caller
> >      must pass in a valid UserHandle that is checked with
> >      CoreValidateHandle().
> >   2. Declare CoreGetProtocolInterface() as static.
> >
> > Cc: Liming Gao <gaoliming@byosoft.com.cn>
> > Cc: Ray Ni <ray.ni@intel.com>
> > Cc: Michael D Kinney <michael.d.kinney@intel.com>
> > Signed-off-by: Zhi Jin <zhi.jin@intel.com>
> > ---
> >  MdeModulePkg/Core/Dxe/Hand/Handle.c | 18 ++++++++++++------
> >  1 file changed, 12 insertions(+), 6 deletions(-)
> >
> > diff --git a/MdeModulePkg/Core/Dxe/Hand/Handle.c
> > b/MdeModulePkg/Core/Dxe/Hand/Handle.c
> > index 51e5b5d3b3..24e4fbf5f3 100644
> > --- a/MdeModulePkg/Core/Dxe/Hand/Handle.c
> > +++ b/MdeModulePkg/Core/Dxe/Hand/Handle.c
> > @@ -918,28 +918,25 @@ CoreUninstallMultipleProtocolInterfaces (
> >    Locate a certain GUID protocol interface in a Handle's protocols.
> >
> >    @param  UserHandle             The handle to obtain the protocol
> > interface on
> > +                                 The caller must pass in a valid
> > UserHandle that
> > +                                 is checked with
> > CoreValidateHandle().
> >    @param  Protocol               The GUID of the protocol
> >
> >    @return The requested protocol interface for the handle
> >
> >  **/
> > +STATIC
> >  PROTOCOL_INTERFACE  *
> >  CoreGetProtocolInterface (
> >    IN  EFI_HANDLE  UserHandle,
> >    IN  EFI_GUID    *Protocol
> >    )
> >  {
> > -  EFI_STATUS          Status;
> >    PROTOCOL_ENTRY      *ProtEntry;
> >    PROTOCOL_INTERFACE  *Prot;
> >    IHANDLE             *Handle;
> >    LIST_ENTRY          *Link;
> >
> > -  Status = CoreValidateHandle (UserHandle);
> > -  if (EFI_ERROR (Status)) {
> > -    return NULL;
> > -  }
> > -
> >    Handle = (IHANDLE *)UserHandle;
> >
> >    //
> > @@ -1392,6 +1389,15 @@ CoreOpenProtocolInformation (
> >    //
> >    CoreAcquireProtocolLock ();
> >
> > +  //
> > +  // Check for invalid UserHandle
> > +  //
> > +  Status = CoreValidateHandle (UserHandle);
> > +  if (EFI_ERROR (Status)) {
> > +    Status = EFI_NOT_FOUND;
> > +    goto Done;
> > +  }
> > +
> >    //
> >    // Look at each protocol interface for a match
> >    //
> > --
> > 2.39.2
> >
> >
> >
> > 
> >
> 
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#115018): https://edk2.groups.io/g/devel/message/115018
Mute This Topic: https://groups.io/mt/104114721/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



      reply	other threads:[~2024-02-02  6:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-22  9:53 [edk2-devel] [PATCH v2 1/2] MdeModulePkg: Remove the handle validation check in CoreGetProtocolInterface Zhi Jin
2024-01-22  9:53 ` [edk2-devel] [PATCH v2 2/2] MdeModulePkg: Optimize CoreConnectSingleController Zhi Jin
2024-01-31  1:27   ` 回复: " gaoliming via groups.io
2024-01-23 22:22 ` [edk2-devel] [PATCH v2 1/2] MdeModulePkg: Remove the handle validation check in CoreGetProtocolInterface Michael D Kinney
2024-01-30  9:13   ` Zhi Jin
2024-01-30 17:56     ` Michael D Kinney
2024-01-31  2:22       ` Zhi Jin
2024-01-31  5:06 ` 回复: " gaoliming via groups.io
2024-02-02  6:04   ` Ni, Ray [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=MN6PR11MB8244521F7CF89B0E407676538C422@MN6PR11MB8244.namprd11.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox