From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 58799AC17A7 for ; Tue, 30 Jan 2024 17:56:23 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=DqTC7dSgHhaVDg0GCHEnhtFhx+Se3GQH4lsruWsOsKE=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1706637381; v=1; b=GB2sYqAaX3Doz17KRHRF1hDAdEUEULBJrPiIo2Ek7TbRG7GJCFoE27gLPXwf41IQCJAvUgFf F0cANAId2gNeZxvziJ6ZCtWM4d8TZODlITw9UbEJwIh74uaWcRxONnzmrNdPuFajdjvEWm1Tw7U OK7klpGS8ZHS68x3h2BAQS/8= X-Received: by 127.0.0.2 with SMTP id qHzdYY7687511xjtmLpdsxzL; Tue, 30 Jan 2024 09:56:21 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by mx.groups.io with SMTP id smtpd.web11.3025.1706637381271797193 for ; Tue, 30 Jan 2024 09:56:21 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10969"; a="16739054" X-IronPort-AV: E=Sophos;i="6.05,230,1701158400"; d="scan'208";a="16739054" X-Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jan 2024 09:56:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,230,1701158400"; d="scan'208";a="3833830" X-Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by fmviesa004.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 30 Jan 2024 09:56:20 -0800 X-Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 30 Jan 2024 09:56:19 -0800 X-Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 30 Jan 2024 09:56:19 -0800 X-Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Tue, 30 Jan 2024 09:56:19 -0800 X-Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.100) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Tue, 30 Jan 2024 09:56:18 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l1sCtOZi3bVC7wnOJxo679ff8bV2yogsUSCfJhdqVrkxGYKvqgfA3up2alYTaoQauvF8ZNx/EDaL7rHxc5MLykmwbyMsAfcExJlapne+UA0o2y6n4QHGcQ51G0Gf8jWN5aKqi9Hnainrq0XGYDNRXFBrn1PKUGYXhq9poPS8IeHriaofNMt5z08g4yv/GfG3239w3+82nURwCO52TI5kwrpBs64HGtWf/O5sJkdhvdbqrfOaD80wHDeWglp+qQAjUAi7ffTZ7tqxUM2XEGHFr7pQ1JvGeM4imOPuC0Mqb44VzuC32wAyhRDQe/mqXpQRfGqL0H9iBWMKe9YtyQ1fRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vN1jGfQRuHFpaSYDw7W/iQMgZ2NJv5iPCoOxQWiyZW0=; b=EJdWoeL7h07Uf0Ow6f7Hn2u9K5+jCXOVYooxE/T7ekAfXbQf6NmiEhq+k2jnsFuZjz4vM72L6QNLYoFeweksWWYO5GShk1L0/0pihvcg9FWXtQmyOYNg9PZiJO7qgAjd3NIPyETkuYh3XbZ6L+lECR78PyLkh38KAw1XrJAFT+p3QF06IFfYUt+JFJ07kCTus+C0WVcWAsBLy+nAXuXuiHP9MqVlJlaQe+K4jdz+kSoNc+PbP3upSFbdcRw4jGqKIY9+1HZF3j0x1W9uMwAJFv+UCMp0nfmTCbxipbkeBTKOdpq5ax/CHs+ib5zj3EXp8py3YgZtIrqd2ohkAUyTPA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none X-Received: from CO1PR11MB4929.namprd11.prod.outlook.com (2603:10b6:303:6d::19) by PH0PR11MB5659.namprd11.prod.outlook.com (2603:10b6:510:ea::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.34; Tue, 30 Jan 2024 17:56:16 +0000 X-Received: from CO1PR11MB4929.namprd11.prod.outlook.com ([fe80::7e42:1633:d0a6:9c00]) by CO1PR11MB4929.namprd11.prod.outlook.com ([fe80::7e42:1633:d0a6:9c00%6]) with mapi id 15.20.7228.029; Tue, 30 Jan 2024 17:56:16 +0000 From: "Michael D Kinney" To: "Jin, Zhi" , "devel@edk2.groups.io" CC: Liming Gao , "Ni, Ray" , "Kinney, Michael D" Subject: Re: [edk2-devel] [PATCH v2 1/2] MdeModulePkg: Remove the handle validation check in CoreGetProtocolInterface Thread-Topic: [PATCH v2 1/2] MdeModulePkg: Remove the handle validation check in CoreGetProtocolInterface Thread-Index: AQHaTRjKvadqeszZ8k6+yCs8aJ4y+rDn+qAggAokaACAAJFcoA== Date: Tue, 30 Jan 2024 17:56:16 +0000 Message-ID: References: <20240122095323.1824627-1-zhi.jin@intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: CO1PR11MB4929:EE_|PH0PR11MB5659:EE_ x-ms-office365-filtering-correlation-id: f10b3dc4-962a-4ea2-74f5-08dc21bcc1ac x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: GpIkssLr1n7b/LcXUDRCQZu1kqssiL6vbcNUQroicdsMtHRdbk9LuZ0GVfXNyzavHTHzTlHSDR9PoCRi4Y8AF8k3JfZrExrIEJnHSxlJl0pKPcSWRo1RAYhyI+9nOegYZh9TxJP5ENkN44LsH2O2RQykbxa04+A8qTM8VEd9HK1VNAkJM0OZG1/0dLlICQqn04l9/YFLwhw29kID5ex257n5oMpYoQX0VjvO9vvrIGYHryF0NvlhDAPQiVwoqXRl5C9qQNQw4gi8P5y7wzEhaAa2KJg13hUDq0ZL5ZTG46kRYdaEGP1duBiVQ89ucs6RXRWlUJh8owZSTr1wv68eze4838SzzG4rFPl7fWGb0O9g67AN8+R1ALYSJKwHtQ4MfIQbH912+JW71YXhA+ORGlkb/+KEwVEHbg5d/VTnBBbzmGdXtq3zJ5DnnmXlQpHE2HyBO/0LXuv7co3orfWy2ccVQkMOlvNMBNX9hxnsR4+vLUm3k6PbwG43ZyyVHcUmx+VgtSBbpIhuq8+fV8hV8/95zEo6GunZ0aFq4fzKXhngPfnfGXeg5Df5+llTkk3Iv+CpqPpWn9ga8cx652a+6WtisX1DojOEcsrQ7c2xWM7QZKgz4QaIeohJLCo062OM x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?CxO462KNb5xFJmbxo5HTrzTTOsvHsjPVWTYag/vJcLJKhZIan8sHWjn+uKCR?= =?us-ascii?Q?nGfVE52mageyzDFtJ0TthvywDT9B/iHFUGc5nngnnHSowDhO2ProRNmJJ2mJ?= =?us-ascii?Q?GWpfeXF8puw9QZeVjohMVqB/mZt3yE3x6a95Cq+TPy2+cv3ipGZrAoqPm/s7?= =?us-ascii?Q?8vzjFSLTELA4/vGBXzulghuyyod9hBPXMISsALS0BDNkRShVs1ruj7Ez3+OR?= =?us-ascii?Q?HSkoPAeJdMCuNzHRCZW2h8IYTuQg4XLwcVMOPMavCqBlhavuyby2ymnyeSwd?= =?us-ascii?Q?wrNWWkZ2xBMUssXHYCM87nKjxwKKcpS/5Zrz/TsfIW2LLBOSkTMf2xcaV9Yy?= =?us-ascii?Q?HA34sQI03Nk4hNa1L5EhFz0iQmwvb55K3a5C2DfjZPBIGsxUX0Ep35PqfeXX?= =?us-ascii?Q?HsZZvi2Wv3I1XtZsRmOnFsbsYOq7u2398FllFGtmtQVM8/lGhYUljIFJPEjs?= =?us-ascii?Q?OKTeVYGu67zK/gyFDZ2Q6wmaTKfv4py3RoybAKNymZmIhxb/dHqsGDOfKEX4?= =?us-ascii?Q?rNbVZUMxexnboUa6u7xJQcu9wmNJ0mZ4kCOlLOidniaW9jGghhgFNrdvQugG?= =?us-ascii?Q?KlbCKOscfH36DUmqweZnveVnxGg2WamlC6YkV/QOXcNVUD+WDI9SArA7tlus?= =?us-ascii?Q?eiPYvy3H1ilUOoD2rW1sIiAFbf/wNDj8mkCdMc7bHcEhR5uRvZSqMiYoCioI?= =?us-ascii?Q?svR0/BmqSDMBpSUdMGuqwh6OPqpnUBSBvvm66UBXroSd+ZoAIZyeZRIlF0/V?= =?us-ascii?Q?JDsBwLAlL410/5u6lgj6TL4/JZ8WG7jpVVeLynQIvRr8+p4LJPSndCDhdD7D?= =?us-ascii?Q?/IinOVSLmrxLQ4huZ/UmKgHbBMQa5F0LEQ67IfaSW66knhUwZeDMCgAomyu5?= =?us-ascii?Q?H49cKgsPTnd87mTr+VI4Wx+84Ps8Bb5Ox1JaWtNFse83Ak9Jz2aSVzjWe3I7?= =?us-ascii?Q?vlGnJSxxKhYRKR7m7dg402r9E3FxsDk0H7FAcFGLDxSvigXlQw3W3A4hjpdb?= =?us-ascii?Q?BPZFHZCEWwkDLa8527X9PGhfXIhPDj7L8D1s79O1paOF0Ivv8Bl1cTP5peSN?= =?us-ascii?Q?MvCTsxVjmD5CDtu3nBBUKrVCEYxZEr38Xw0/id1H8NX4OvuXPaYPmEGB/M4y?= =?us-ascii?Q?9wcUjFQ2ivgZLpbVCPblHjLWYX5WlT84gar47Lxs8RMRAMnNdrm58j+EALjN?= =?us-ascii?Q?5f4xOi/nrCoJQ8Ku26xK384UKJxmzbES2flJpGsrlZN+P/v3hI3cPAWbiiNd?= =?us-ascii?Q?x/TlNfT+M49MUOgqyFBHoByK1TCrtxLKaaSTf4NKyJGcvEYRC6a/lvJ8XijI?= =?us-ascii?Q?Rtoc9nU0+hrwhmH7ycd4xqlLwNx9bpEkIEc+9kcgB3GiyJkVSSO9Xwg3mowV?= =?us-ascii?Q?K/BbgzF0GLzIG5qlIj2snOYiZNGIJduOrc9Kn783TG4lXpPE+2i9nlmDUFSN?= =?us-ascii?Q?OIB3a7pSGJi2H/w00Eselu8Kd76jt7H3xbtn6aYreJLYdjKjzlDmuPoudWKQ?= =?us-ascii?Q?1xtZPYkH1oHkV9LMibYG/4XLfJFndtk9y3jwnN02vD3RNfH1883nRWkPz/G4?= =?us-ascii?Q?ZIBYgKfuD8yWa2inM8g80+ZnZy5VrdxeNK8RR8a9I8d5cfkWEnKqtEpi5DlD?= =?us-ascii?Q?1w=3D=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB4929.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f10b3dc4-962a-4ea2-74f5-08dc21bcc1ac X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Jan 2024 17:56:16.6368 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: EeqJkjQmQNdEh7QASSBwnmyHOEiGAEPruy1r9Pb3NvH0EuPoIso3LqPU5mwDQ2Tz0Ptu6u6begPoDrB/do3YOb2L/Omq0NBiue4PejaJXZ4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB5659 X-OriginatorOrg: intel.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,michael.d.kinney@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: TrfJ4f4G2sp0neVoqhMCHcOhx7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=GB2sYqAa; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Hi Zhi, Thanks for pointing this out. For your patch, use 'STATIC'. I do see that 'STATIC' is use consistently today. If we want to move to co= nsistent use of 'static', that should be its own task to make that update across all= the files and update ECC to support both 'static' and 'STATIC' temporarily and later = only support 'static'. Mike > -----Original Message----- > From: Jin, Zhi > Sent: Tuesday, January 30, 2024 1:14 AM > To: Kinney, Michael D ; devel@edk2.groups.io > Cc: Liming Gao ; Ni, Ray > Subject: RE: [PATCH v2 1/2] MdeModulePkg: Remove the handle validation > check in CoreGetProtocolInterface >=20 > Hi Mike, >=20 > After changing 'STATIC' to 'static', I hit an error from the > EccCheck Test as below: > ERROR - EFI coding style error > ERROR - *Error code: 5001 > ERROR - *Return type of a function should exist and in the > first line > ERROR - *file: > /.../Build/.pytool/Plugin/EccCheck/MdeModulePkg/Core/Dxe/Hand/Handle.c > ERROR - *Line number: 928 > ERROR - *[CoreGetProtocolInterface] Return Type should appear > at the start of line >=20 > Looks like 'STATIC' is treated as a modifier by EccCheck, while > 'static' is not. > In BaseTools/Source/Python/Ecc/config.ini: > ModifierList =3D IN, OUT, OPTIONAL, UNALIGNED, > EFI_RUNTIMESERVICE, EFI_BOOTSERVICE, EFIAPI, TPMINTERNALAPI, STATIC >=20 > Should we add 'static' to ModifierList to fix this? >=20 > BRs > Zhi Jin >=20 > -----Original Message----- > From: Kinney, Michael D > Sent: Wednesday, January 24, 2024 6:22 AM > To: Jin, Zhi ; devel@edk2.groups.io > Cc: Liming Gao ; Ni, Ray ; > Kinney, Michael D > Subject: RE: [PATCH v2 1/2] MdeModulePkg: Remove the handle validation > check in CoreGetProtocolInterface >=20 > Hi Zhi, >=20 > Thanks for the update. One minor comment on 'STATIC' should be > 'static'. >=20 > We no longer depend on macros to redefine 'STATIC' and it is better to > just used the standard C 'static' form. >=20 > With that change: >=20 > Reviewed-by: Michael D Kinney >=20 >=20 > Mike >=20 > > -----Original Message----- > > From: Jin, Zhi > > Sent: Monday, January 22, 2024 1:53 AM > > To: devel@edk2.groups.io > > Cc: Jin, Zhi ; Liming Gao > ; > > Ni, Ray ; Kinney, Michael D > > > > Subject: [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 > > Cc: Ray Ni > > Cc: Michael D Kinney > > Signed-off-by: Zhi Jin > > --- > > 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 =3D CoreValidateHandle (UserHandle); > > - if (EFI_ERROR (Status)) { > > - return NULL; > > - } > > - > > Handle =3D (IHANDLE *)UserHandle; > > > > // > > @@ -1392,6 +1389,15 @@ CoreOpenProtocolInformation ( > > // > > CoreAcquireProtocolLock (); > > > > + // > > + // Check for invalid UserHandle > > + // > > + Status =3D CoreValidateHandle (UserHandle); > > + if (EFI_ERROR (Status)) { > > + Status =3D EFI_NOT_FOUND; > > + goto Done; > > + } > > + > > // > > // Look at each protocol interface for a match > > // > > -- > > 2.39.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#114810): https://edk2.groups.io/g/devel/message/114810 Mute This Topic: https://groups.io/mt/103883257/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/19134562= 12/xyzzy [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-