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 DAAC6941004 for ; Wed, 31 Jan 2024 02:22:08 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=ofz2lv5/RFDmos0uB7VUG4ZoCgciYHCJ00bYdDkLGGg=; 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=1706667727; v=1; b=ZGNa7CZVSzwwtPVAzcIr2nm+vsJfGlizLN8mJ8+N0ARmzVHOFMZYH9KSFUk2av7/eI5mZM2q tT+PGg7mdcUqOytFJG7EVWz/E3YVn14yQVVGM87knXKvyXIpUUKTsyfclrRU3yQjXc4IN2Z7y5V L/zsAeEs+/PFqBRD9dWOZXwo= X-Received: by 127.0.0.2 with SMTP id fOLgYY7687511xiyxJe3iOvO; Tue, 30 Jan 2024 18:22:07 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) by mx.groups.io with SMTP id smtpd.web10.5497.1706667726997575741 for ; Tue, 30 Jan 2024 18:22:07 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10969"; a="16992665" X-IronPort-AV: E=Sophos;i="6.05,231,1701158400"; d="scan'208";a="16992665" X-Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jan 2024 18:22:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10969"; a="961461686" X-IronPort-AV: E=Sophos;i="6.05,231,1701158400"; d="scan'208";a="961461686" X-Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by orsmga005.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 30 Jan 2024 18:22:05 -0800 X-Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx602.amr.corp.intel.com (10.18.126.82) 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 18:22:05 -0800 X-Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx610.amr.corp.intel.com (10.18.126.90) 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 18:22:04 -0800 X-Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) 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 18:22:04 -0800 X-Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.100) by edgegateway.intel.com (192.55.55.68) 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 18:22:04 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aZUn8IwRiSPLTd1aZ5wjQuLCPmuQN52UKpa1pzY6DzTt7IfKYx0sQ/m7i26/oXWAMsSaasIUH2EZX3syGTXCuvCxSWSagkIhP4OKMSVpNdcRikfFia4CdDMzH37f1Luq9QSPsIQMwZVF3Ww3WqdUdi8fSRy2Gk7cKZM97NUk2QbS/pNNNWkZuWrHmNMCRDUOLXLk6kRIe3Vmne+oohDuCqj3z7rkjlFlRW9FkMjNikb0cgNYMWVe/cCEDH9SsPu6J1qFsFHHn/blQtl8sf326ibQ044UJAndv/79FkFXcYe+4NXtJMdH1HfXyqxaOsGkwc96RYTgsjOo9Gbhfa3lUQ== 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=bCkqfvAu43Ff6qK/o3bsVE1XG7D9jB4u3B3Qt3+tL3k=; b=RkLvADgV5Bk9IxzWlFeUv9jmgR2fHciaAAIy8xDxqHv+B9+D3JnZ+25eWv7vQrK2+15jlpN5cYajAVlzGcM7tpEKzORl9OrTl7VxZkGL+3VPSCinStryaFxVPTu1UeYMdUMb25Y4PHps1Xo9HWsXoAPnsD5NKJlWn13+JePwChWI28AAfjrsNKqRVODy8HvOUHp2o1T2eYAVey0vTqbCBAJ01kGs7pgz4cJ0id1lrJsD2wWPNhqXHQjFVmaV0kr/3FncIqv1EbMERaR64fKzzRAT59MjPM15X0HsIILLdFXh2OeN79L11olZBIOc6n3SzG3kr4mzhMj6eqtIkNze0g== 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 CO1PR11MB5185.namprd11.prod.outlook.com (2603:10b6:303:6e::11) by SA2PR11MB5130.namprd11.prod.outlook.com (2603:10b6:806:11d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.34; Wed, 31 Jan 2024 02:22:02 +0000 X-Received: from CO1PR11MB5185.namprd11.prod.outlook.com ([fe80::4e82:ea54:a498:575a]) by CO1PR11MB5185.namprd11.prod.outlook.com ([fe80::4e82:ea54:a498:575a%6]) with mapi id 15.20.7228.029; Wed, 31 Jan 2024 02:22:02 +0000 From: "Zhi Jin" To: "Kinney, Michael D" , "devel@edk2.groups.io" CC: Liming Gao , "Ni, Ray" 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: AQHaTRjKGgBAkf/DOUuxg2YuHVou+LDn+wcAgAof55CAAJYeAIAAiz4w Date: Wed, 31 Jan 2024 02:22:02 +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: CO1PR11MB5185:EE_|SA2PR11MB5130:EE_ x-ms-office365-filtering-correlation-id: 24f6b49b-474b-4e7c-bb83-08dc2203692b x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: kfn+4UTpSudaWn+wEusjrYumrTZRC6EtOyAM2GU0hKNky7knaK9HneRu0jdoH5NrhEAB4wcgghXB4+zJA0QwF0L0hJGh/K1ddUNwxE6bpqsOxjBIPN/CLsygt8acUJ5BKs658lOZueoJCREbPi9e0ubixWJYRJWy2zkd63v1Ld5cmCzi/e2CAYwn+42oGJEw7CeufKzPGurmhZ0jgmUNBR0XPHZoX97/D68CAYp7OOwaVcvLTvDY/UM7JpfbQTOCCLQo+2kggP7m1ESEgAPEs0WEx1yTULC0UW+GyiOASBrxcONtKBp7YJGoI4S5rFXc0V0yP2OSWsbSRacVTH+TIBfKDWHuWSpLIzhPBqZoMD+xE3BRqXeBowpBiyueZd85sa5J9PqfiIVcz4BHyXn3+UzA23mZuChlcA/Z4lvw5lOZWvvA4qHR0Qm/vyn2ycRBb1yQlf/rcZD5MwJdVauxinTpWogrPCzTF4TwxwK20WhhgufXKNNFO5zdECN0U3C8MqXPvAPi1jQC5LwQECAJ9ao/y9WHCttH2aRyFU/uLoe6kXAAENdxqr3L2XIWLR70oZhdO/nVOSrae73GcDrXWz5/3lveZWxYMIqo5z2G5Bk= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?JbDjOmj5Kr4+Bi5QxjwZ5xmANvx73jTX5go77ZtJos0NwOqLfPXZAviRCwOY?= =?us-ascii?Q?p0orRRwhTyQ9cGHoM/HSyjR0YR5BbTX3yVlBmWdDriFjAjO7wY1Ir0DoAzoU?= =?us-ascii?Q?I6nBGVPaFmgVZMXORPPupd3hMjLV0dNro3iR/U+1U57VH4ACk/2eDuBzjCbv?= =?us-ascii?Q?/MGJj2zCLzY8M8crvsctB3cUITtVNOd1e7qWJC9JWAaeMyt6Iww4DSX+Ex6O?= =?us-ascii?Q?SeXX24AzWYIn49X+eFtFOwxfdUorYwltSy+hsFZzHZz/NuriLHG7jtiip1Gs?= =?us-ascii?Q?H/P936S1Vi1+b1snthTHnERzEM0kwjEhCNeuwWHFWQQFed8CqYv7YeaKeWYe?= =?us-ascii?Q?qLz3xIe65PVi3c7gv+Xnh45cOxrsN84n5WM7qY+sKtNbRk1MTvAEY6iE7hOT?= =?us-ascii?Q?ydbPm8R/kIRYqtYuV/xgQvRpA577TKxBWy84uhi578QIqHi+J1327Cp5Eu/j?= =?us-ascii?Q?q7gR+F4CQXH9rk5a+B7cRO8Uhg1pKuBdC0wOiBics4IyAIiuUNIVvFsgebBB?= =?us-ascii?Q?jwuF0inea+oqvqgqfBovsx7EiS4XAFrIn6i/ICRveMEvnKlHpnHOk0EsTgbk?= =?us-ascii?Q?RED2RYFG/Z8Wf6zK4XMrFsBcocut07pDgtbOrc3EUFxGVHvCw9jsgOi8qiIT?= =?us-ascii?Q?4wHV31ggIFgpIpaxCkUup2XuTLGmnC24lAs3lpJlwJwqnezCT/H7ziDX/RDK?= =?us-ascii?Q?O40mb0Yp3XkUetMbxYHOPH3BOFpsKPFStxNoXwnYZhjuaJLzalNZ+NMKxxWg?= =?us-ascii?Q?RHmT4bt9YkcrnVNUMH2j0VmssUVFsKtI17HBKbQfgWwEZXhizGOEHb71vw5E?= =?us-ascii?Q?/kHkBJiGsueyq3T5SF3dnfv1sF3USkZdrRowwxXECGlHQn/nTtGm1nKPs4q6?= =?us-ascii?Q?b3bBWJYWYonRJoFsFc9Kojd4DlqSVNNfijvisIrn3NaRB7sEZd6OPqQEghTd?= =?us-ascii?Q?IDYWofcjzXdwAsm+3Al5t6pOf7whs8PXV1QJIY8/UP7yCgILqSZEondHG9ub?= =?us-ascii?Q?9dHIScQNJU/liS059yo9yrr1iMELjjbbUNYEqivs9So1L8dbSt0lekpqRu4i?= =?us-ascii?Q?/7ARgSFXvg43v9VJAHwhuJ4wPxK6FkmacfKAxBS8esvq1lrX317ThTQs00nq?= =?us-ascii?Q?iPGb5z6Caq0w77wDUxpdLfG0BC0QK03M0h/YZEmgFusTBh9LJvdKj8utZlnH?= =?us-ascii?Q?c9w8t2frnCof+1C500O8HEFO0Eth7r+aJq8YBkyoFOlJKn8wVCWwyc4nXtEL?= =?us-ascii?Q?1SOnw8zrwIdKgINXv9m1YXbwPiCrd1D64RmNTTv03jFShL2/KMqQ941GH6nK?= =?us-ascii?Q?pys+TqOoBCPqWZEht9/nVsUKkHuIZbqmaOCS35Elu8LfuAavweeuwvhu/gIr?= =?us-ascii?Q?zqAxOXO68YRfiaL/czma+sSMu4ggpUo90gvQUxX13/qo90XPbEl16bG11VVa?= =?us-ascii?Q?P2p6bbDtfoO9dZsXpxwg4joRLSiSJf0GHFNMC6dRAwdCGcEh3nZ4cfqtx0f7?= =?us-ascii?Q?tC0lzdZe1/W1nLmO5vgdPmP6EZ/cpmRPJp7WzloKuGh1KpI3olhgtdBE9MAu?= =?us-ascii?Q?UEBEPzeSRz12QcywiEA=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB5185.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 24f6b49b-474b-4e7c-bb83-08dc2203692b X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Jan 2024 02:22:02.4387 (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: g4a9++FJF0nHqCEMSV+Aildjk53OAftg2AmkPiE1SiZUl4ykHXn/rDAgic5EGpHJ4mFDabJxr6Gteqox0CFQCg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR11MB5130 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,zhi.jin@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: l9eWfasSjVfjb1uyFr8ybPusx7686176AA= 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=ZGNa7CZV; 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 Thanks, Mike. PR (https://github.com/tianocore/edk2/pull/5321) has passed CI. BRs Zhi Jin -----Original Message----- From: Kinney, Michael D =20 Sent: Wednesday, January 31, 2024 1:56 AM To: Jin, Zhi ; devel@edk2.groups.io Cc: Liming Gao ; Ni, Ray ; Kinn= ey, Michael D Subject: RE: [PATCH v2 1/2] MdeModulePkg: Remove the handle validation chec= k in CoreGetProtocolInterface 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 (#114845): https://edk2.groups.io/g/devel/message/114845 Mute This Topic: https://groups.io/mt/103883257/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-