From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web10.9271.1608626169725624004 for ; Tue, 22 Dec 2020 00:36:09 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=ywh9Wh6p; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: hao.a.wu@intel.com) IronPort-SDR: ol8R9rjYsSjgsEGu2xC6X9+z2Y0iz29pGiD8pibg5KpDiX/x4BSFLbFz/jFKkbcUOy06RqaID0 dXPV1m79Mxgw== X-IronPort-AV: E=McAfee;i="6000,8403,9842"; a="260570539" X-IronPort-AV: E=Sophos;i="5.78,438,1599548400"; d="scan'208";a="260570539" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Dec 2020 00:36:07 -0800 IronPort-SDR: z2+RZLCHR8n+H9VeipChol0kqrcZaZQZg6iuGr+EAxbdQCEeVcIJXPXFYWvXs2oVfywayBjgE6 gFHRhENOt9ow== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,438,1599548400"; d="scan'208";a="457255330" Received: from fmsmsx604.amr.corp.intel.com ([10.18.126.84]) by fmsmga001.fm.intel.com with ESMTP; 22 Dec 2020 00:36:06 -0800 Received: from fmsmsx604.amr.corp.intel.com (10.18.126.84) by fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 22 Dec 2020 00:36:05 -0800 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 22 Dec 2020 00:36:05 -0800 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (104.47.74.40) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Tue, 22 Dec 2020 00:36:05 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hofRIKP58jIq2LdB8pJsATnEHkzNsp/ApG2o4U11t10Zg2kxNGNi6wSEgbulJ/L86zmKA5zmDFnFeRIroWKlM3xMJsEX+1JkrlBMY19tBLXrnEdYuX7DL+uALYfYYMHLcNOCOjsjuahIqvRoVSyegbSBW1KCd+tjjD/YnJ2Z0ntWGUFIIYeFSqnTg4P5RFnBB4dH1aEL+Is6nuQ81nxK5YgEf6f9TmgKrt3gqkunmXBfw9tM95Aw+0l3lO3Dbi3wnIMzXGFE0um2R71iQnCHNbZ105M8uDn9MxQlbYG4FNPVbwITA8xQ+L5IZK/qYFguBxog9OB4Q8lw8CyI+6pzmQ== 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-SenderADCheck; bh=KIo1Afw7e/DhR9QD2yy8yxleQF9+oHs+RA4JymD/CRM=; b=TOmeX/sMpKLL8TVsXlbLz6Yude4sJj56QdTjHzmAWVwO078gV+ocQRPVyFMkZNolt4uMkjOjSFcIMHAbik2z+ozmiGrPMUS3/cQ8T6kP7q5tDciFA8tWIKHfdq5gO34iW5RHUpbO5fVidtSf1Si8N8+VRDP8GmVIODWN+nu7GHNzFRYuCOnIm6+6c/R2Zy2dW5akbBUUHWIMGLgYJpGh8hkk0EW0gHOm7P+7nAtKITA6sGE182M+xtXXPgcOn/P33dOyiVik+XiCy1Bm5woshchBAf2DGRFV4hkKRfVlaKpBYXR5lvmjHqSNpn9fLrSz/uQorE5q31BnIrWfEqkXtA== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KIo1Afw7e/DhR9QD2yy8yxleQF9+oHs+RA4JymD/CRM=; b=ywh9Wh6pun1+d+QpPgxkgckQRFRslTkUviYKUT5ozK08ROFonT+Nj5mnJJ37pZTIRrQInOqhaZrM4jGrQnDVAkwD1zQYNL+p75jXaEfiyqmbgnV8M5crRR8KKLuLIRPY+6gbjqt1/PANvMXdnE6JP9a+lEn8AP/ukUpYL0erfw8= Received: from BN8PR11MB3666.namprd11.prod.outlook.com (2603:10b6:408:8c::19) by BN6PR1101MB2354.namprd11.prod.outlook.com (2603:10b6:404:9b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3676.25; Tue, 22 Dec 2020 08:36:04 +0000 Received: from BN8PR11MB3666.namprd11.prod.outlook.com ([fe80::4cda:993f:ffc1:f169]) by BN8PR11MB3666.namprd11.prod.outlook.com ([fe80::4cda:993f:ffc1:f169%6]) with mapi id 15.20.3676.033; Tue, 22 Dec 2020 08:36:04 +0000 From: "Wu, Hao A" To: Kun Qin , "devel@edk2.groups.io" CC: "Wang, Jian J" , "Bi, Dandan" , Liming Gao , "Yao, Jiewen" Subject: Re: [PATCH v1 07/15] MdeModulePkg: FirmwarePerformanceDataTable: Added StandaloneMm support Thread-Topic: [PATCH v1 07/15] MdeModulePkg: FirmwarePerformanceDataTable: Added StandaloneMm support Thread-Index: AQHW1W6+YjCWkCYk8kudGiegsqonB6oClWBw Date: Tue, 22 Dec 2020 08:36:03 +0000 Message-ID: References: <20201218185011.1366-1-kun.q@outlook.com> In-Reply-To: Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.5.1.3 authentication-results: outlook.com; dkim=none (message not signed) header.d=none;outlook.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.198.147.218] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 98bce452-3f40-4fae-c9b7-08d8a6549e95 x-ms-traffictypediagnostic: BN6PR1101MB2354: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:534; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: b016YIhwPbm9ypgn9HEvkBHfr2FRgrncDp5oouqeYbMvM2k/n9Bsgqtp37Y9Zm3zmOntGkd3kOWW4B+3Br3nv50rEVyFII2nCYZGwT2OBMBUUt/DEcwfNUCVV4lDhJIks3k1i82pdRzbb09IF3CqD4ldaFfMYcJhzpXtNZYmcvyU6KAU341ZujR3MRSJawdY78UaETnEzM8k/SYxgGJsoEDys/iM9EJt6X+66lh9zZ2XtfmOnHBfnidsQ6xJ+tR/nEfW0nnCjsTAfMva0zbp42cPMEPYZ534v98k/eK91I4BSlBO0LiIaXRZnFX5Y1J41mt3j/7l9xco618BebP3tWYkD92Z7CWp6LrE0EP+NzYf96HJsLFpuG3htrv9dmNN0so23dZyMOy9XbYQKlxN4Q== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR11MB3666.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(136003)(376002)(39860400002)(366004)(396003)(110136005)(76116006)(9686003)(186003)(66946007)(54906003)(55016002)(30864003)(83380400001)(107886003)(53546011)(5660300002)(316002)(478600001)(4326008)(8676002)(52536014)(45080400002)(2906002)(8936002)(86362001)(7696005)(6506007)(71200400001)(26005)(19627235002)(66556008)(66446008)(66476007)(33656002)(64756008)(559001)(579004);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?y5WGZFcG/NAE/4UD3ASsE3roAkEL4VTmBosXtRodpecjaLe+djBQ0frHAfMF?= =?us-ascii?Q?+SZuDrWcSWtxAyR8RYrCOe7p7I3XRMz8H7FsM80JLcv5Tk2rxlAX5beNPm/A?= =?us-ascii?Q?lTk9KpMMkgEQVtyg+K7xixwNn15CeRV0qwKA9TkVTCwSQ/Rgx53n4HCVL/wG?= =?us-ascii?Q?tTgbTpIvtSJI8E4KDwzDYkb3is9+r/CwCmU+BnXzMwHKskPDNuTL+0aNDhZ5?= =?us-ascii?Q?8wgH6cAGnan0XQ8SvSZdLyby9zxQ/NQWLviwT9xLczF8dxi0NT+RzFhNB+rK?= =?us-ascii?Q?kkV68gYjr09IJtYXNO4z0LRsCz8nmwvmd+2jNWbagoAPstAx+Bw4DRieAOu7?= =?us-ascii?Q?76KVHahCG3Ubf9rDLe/oOxPzEkdJ55n8f+RKCVPNJeJWeKYw8h+omVtrnueI?= =?us-ascii?Q?JvvIz9ycMEtBhhGvJ1S9mNhebnjYen9u95c73LRCbQifLwy6b/aeg23PFkVr?= =?us-ascii?Q?5dOt5akcbRnxJ8M9AsQ9dMnCRj+0hDkGow9YIdUclEL3IinbTZwFPOZFvORt?= =?us-ascii?Q?zcdn2gaUe0IZW+UViIZ1NiFxAK2Pu2J2pKm1Egxnk+XWPEcSsquNbPB4Q1CD?= =?us-ascii?Q?X0JpPU+peAJ3KC2YEzP/AXoqtQXfTkRgI2DtUc+69oC+w6rjSUMDPbONZGXj?= =?us-ascii?Q?qLXKi239dGYq6DkiMwvD/l3YspXL3zQ1HzCgBTTY9KQrjZLOhlCYBNeAcA2s?= =?us-ascii?Q?StRP9dffRe1YPA98GRRknRRAay4xe0o8DAgPqlvGyUimXfGL0BS1VvahzH7k?= =?us-ascii?Q?IrTJsA8dz8esKGl2pB6Fc7B+h9XfHccu5h2MEppFLrXNyIFQYmYQ68gI+r+x?= =?us-ascii?Q?99DxHut4k0LUexp23VAC3PKIp1Jsn73/HV1pqPV2KWzqlgKjtNSuQwyKgLDm?= =?us-ascii?Q?aq+cy9nICXQ8R685iD3T64xyaOq8ATWjHfZL2zcBeQkwD6Qj5eLnsotFJFLB?= =?us-ascii?Q?jYqrqBoBpnQntr60Kp6o7CWXANdxBNbRCEz2WT7eYiU=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN8PR11MB3666.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 98bce452-3f40-4fae-c9b7-08d8a6549e95 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Dec 2020 08:36:03.8936 (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: X44qvBk3WBgBavEpU3kKHEAM7nP7mB42eTgC37R9xNoE043YxNxd5OGNZEsaWzQgkgrfkUQyFAKnJXLaooy7Zw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR1101MB2354 Return-Path: hao.a.wu@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: Kun Qin > Sent: Saturday, December 19, 2020 2:50 AM > To: devel@edk2.groups.io > Cc: Wang, Jian J ; Wu, Hao A ; > Bi, Dandan ; Liming Gao > Subject: [PATCH v1 07/15] MdeModulePkg: FirmwarePerformanceDataTable: > Added StandaloneMm support >=20 > This change added support of FPDT driver under StandaloneMm. It replaces > SMM version ReportStatusCode protocol with MM version. This patch also > abstracts standalone and traditional MM interfaces into separate files to > support each corresponding function prototypes and implementations. Could you help to remove the 'EFIAPI' for functions: FirmwarePerformanceCommonEntryPoint() IsBufferOutsideMmValid() I found that they are internal functions. Another question I have is that is there any special consideration to list = FirmwarePerformanceStandaloneMm.inf under the [Components.X64] section in the DSC file? Best Regards, Hao Wu >=20 > Cc: Jian J Wang > Cc: Hao A Wu > Cc: Dandan Bi > Cc: Liming Gao >=20 > Signed-off-by: Kun Qin > --- >=20 > MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/{Firm > warePerformanceSmm.c =3D> FirmwarePerformanceCommon.c} | 72 > ++++++++++---------- >=20 > MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Firm > warePerformanceStandaloneMm.c | 62 > +++++++++++++++++ >=20 > MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Firm > warePerformanceTraditional.c | 62 ++++= +++++++++++++ > MdeModulePkg/MdeModulePkg.dsc > | 2 + >=20 > MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Firm > warePerformanceCommon.h | 55 ++++= +++++++++++ >=20 > MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Firm > warePerformanceSmm.inf | 11 +-- >=20 > MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/{Firm > warePerformanceSmm.inf =3D> FirmwarePerformanceStandaloneMm.inf} | 31 > ++++----- > 7 files changed, 237 insertions(+), 58 deletions(-) >=20 > diff --git > a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir > mwarePerformanceSmm.c > b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir > mwarePerformanceCommon.c > similarity index 77% > rename from > MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Firm > warePerformanceSmm.c > rename to > MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Firm > warePerformanceCommon.c > index d6c6e7693e4d..c2aa9455f9c4 100644 > --- > a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir > mwarePerformanceSmm.c > +++ > b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir > mwa > +++ rePerformanceCommon.c > @@ -1,11 +1,11 @@ > /** @file > - This module collects performance data for SMM driver boot records and = S3 > Suspend Performance Record. > + This module collects performance data for MM driver boot records and S= 3 > Suspend Performance Record. >=20 > This module registers report status code listener to collect performan= ce > data > - for SMM driver boot records and S3 Suspend Performance Record. > + for MM driver boot records and S3 Suspend Performance Record. >=20 > Caution: This module requires additional review when modified. > - This driver will have external input - communicate buffer in SMM mode. > + This driver will have external input - communicate buffer in MM mode. > This external input must be validated carefully to avoid security issu= e like > buffer overflow, integer overflow. >=20 > @@ -16,13 +16,13 @@ >=20 > **/ >=20 > -#include > +#include >=20 > -#include > +#include >=20 > #include >=20 > -#include > +#include > #include > #include > #include > @@ -30,23 +30,22 @@ > #include > #include > #include -#include > > #include -#include > +#include "FirmwarePerformanceCommon.h" >=20 > -SMM_BOOT_PERFORMANCE_TABLE *mSmmBootPerformanceTable =3D > NULL; > +SMM_BOOT_PERFORMANCE_TABLE *mMmBootPerformanceTable =3D > NULL; >=20 > -EFI_SMM_RSC_HANDLER_PROTOCOL *mRscHandlerProtocol =3D NULL; > +EFI_MM_RSC_HANDLER_PROTOCOL *mRscHandlerProtocol =3D NULL; > UINT64 mSuspendStartTime =3D 0; > BOOLEAN mS3SuspendLockBoxSaved =3D FALSE; > UINT32 mBootRecordSize =3D 0; > UINT8 *mBootRecordBuffer =3D NULL; >=20 > -SPIN_LOCK mSmmFpdtLock; > -BOOLEAN mSmramIsOutOfResource =3D FALSE; > +SPIN_LOCK mMmFpdtLock; > +BOOLEAN mMmramIsOutOfResource =3D FALSE; >=20 > /** > - Report status code listener for SMM. This is used to record the > performance > + Report status code listener for MM. This is used to record the > + performance > data for S3 Suspend Start and S3 Suspend End in FPDT. >=20 > @param[in] CodeType Indicates the type of status code bein= g > reported. > @@ -66,7 +65,7 @@ BOOLEAN mSmramIsOutOfResource =3D= FALSE; > **/ > EFI_STATUS > EFIAPI > -FpdtStatusCodeListenerSmm ( > +FpdtStatusCodeListenerMm ( > IN EFI_STATUS_CODE_TYPE CodeType, > IN EFI_STATUS_CODE_VALUE Value, > IN UINT32 Instance, > @@ -89,19 +88,19 @@ FpdtStatusCodeListenerSmm ( > // Collect one or more Boot records in boot time > // > if (Data !=3D NULL && CompareGuid (&Data->Type, > &gEdkiiFpdtExtendedFirmwarePerformanceGuid)) { > - AcquireSpinLock (&mSmmFpdtLock); > + AcquireSpinLock (&mMmFpdtLock); > // > // Get the boot performance data. > // > - CopyMem (&mSmmBootPerformanceTable, Data + 1, Data->Size); > - mBootRecordBuffer =3D ((UINT8 *) (mSmmBootPerformanceTable)) + > sizeof (SMM_BOOT_PERFORMANCE_TABLE); > + CopyMem (&mMmBootPerformanceTable, Data + 1, Data->Size); > + mBootRecordBuffer =3D ((UINT8 *) (mMmBootPerformanceTable)) + sizeof > + (SMM_BOOT_PERFORMANCE_TABLE); >=20 > - ReleaseSpinLock (&mSmmFpdtLock); > + ReleaseSpinLock (&mMmFpdtLock); > return EFI_SUCCESS; > } >=20 > if (Data !=3D NULL && CompareGuid (&Data->Type, > &gEfiFirmwarePerformanceGuid)) { > - DEBUG ((DEBUG_ERROR, "FpdtStatusCodeListenerSmm: Performance > data reported through gEfiFirmwarePerformanceGuid will not be collected > by FirmwarePerformanceDataTableSmm\n")); > + DEBUG ((DEBUG_ERROR, "FpdtStatusCodeListenerMm: Performance > data > + reported through gEfiFirmwarePerformanceGuid will not be collected by > + FirmwarePerformanceDataTableMm\n")); > return EFI_UNSUPPORTED; > } >=20 > @@ -157,7 +156,7 @@ FpdtStatusCodeListenerSmm ( > /** > Communication service SMI Handler entry. >=20 > - This SMI handler provides services for report SMM boot records. > + This SMI handler provides services for report MM boot records. >=20 > Caution: This function may receive untrusted input. > Communicate buffer and buffer size are external input, so this functio= n will > do basic validation. > @@ -166,7 +165,7 @@ FpdtStatusCodeListenerSmm ( > @param[in] RegisterContext Points to an optional handler context w= hich > was specified when the > handler was registered. > @param[in, out] CommBuffer A pointer to a collection of data in me= mory > that will > - be conveyed from a non-SMM environment = into an SMM > environment. > + be conveyed from a non-MM environment i= nto an MM > environment. > @param[in, out] CommBufferSize The size of the CommBuffer. >=20 > @retval EFI_SUCCESS The interrupt was handled = and quiesced. > No other handlers > @@ -207,8 +206,8 @@ FpdtSmiHandler ( > return EFI_SUCCESS; > } >=20 > - if (!SmmIsBufferOutsideSmmValid ((UINTN)CommBuffer, > TempCommBufferSize)) { > - DEBUG ((EFI_D_ERROR, "FpdtSmiHandler: SMM communication data > buffer in SMRAM or overflow!\n")); > + if (!IsBufferOutsideMmValid ((UINTN)CommBuffer, > TempCommBufferSize)) { > + DEBUG ((DEBUG_ERROR, "FpdtSmiHandler: MM communication data > buffer > + in MMRAM or overflow!\n")); > return EFI_SUCCESS; > } >=20 > @@ -218,8 +217,8 @@ FpdtSmiHandler ( >=20 > switch (SmmCommData->Function) { > case SMM_FPDT_FUNCTION_GET_BOOT_RECORD_SIZE : > - if (mSmmBootPerformanceTable !=3D NULL) { > - mBootRecordSize =3D mSmmBootPerformanceTable->Header.Length - > sizeof (SMM_BOOT_PERFORMANCE_TABLE); > + if (mMmBootPerformanceTable !=3D NULL) { > + mBootRecordSize =3D mMmBootPerformanceTable->Header.Length - > + sizeof (SMM_BOOT_PERFORMANCE_TABLE); > } > SmmCommData->BootRecordSize =3D mBootRecordSize; > break; > @@ -244,8 +243,8 @@ FpdtSmiHandler ( > BootRecordSize =3D mBootRecordSize - BootRecordOffset; > } > SmmCommData->BootRecordSize =3D BootRecordSize; > - if (!SmmIsBufferOutsideSmmValid ((UINTN)BootRecordData, > BootRecordSize)) { > - DEBUG ((EFI_D_ERROR, "FpdtSmiHandler: SMM Data buffer in SMRAM > or overflow!\n")); > + if (!IsBufferOutsideMmValid ((UINTN)BootRecordData, BootRecordSize= )) > { > + DEBUG ((DEBUG_ERROR, "FpdtSmiHandler: MM Data buffer in > MMRAM > + or overflow!\n")); > Status =3D EFI_ACCESS_DENIED; > break; > } > @@ -267,7 +266,7 @@ FpdtSmiHandler ( > } >=20 > /** > - The module Entry Point of the Firmware Performance Data Table SMM > driver. > + The module Entry Point of the Firmware Performance Data Table MM > driver. >=20 > @param[in] ImageHandle The firmware allocated handle for the EFI > image. > @param[in] SystemTable A pointer to the EFI System Table. > @@ -278,9 +277,8 @@ FpdtSmiHandler ( > **/ > EFI_STATUS > EFIAPI > -FirmwarePerformanceSmmEntryPoint ( > - IN EFI_HANDLE ImageHandle, > - IN EFI_SYSTEM_TABLE *SystemTable > +FirmwarePerformanceCommonEntryPoint ( > + VOID > ) > { > EFI_STATUS Status; > @@ -289,13 +287,13 @@ FirmwarePerformanceSmmEntryPoint ( > // > // Initialize spin lock > // > - InitializeSpinLock (&mSmmFpdtLock); > + InitializeSpinLock (&mMmFpdtLock); >=20 > // > - // Get SMM Report Status Code Handler Protocol. > + // Get MM Report Status Code Handler Protocol. > // > - Status =3D gSmst->SmmLocateProtocol ( > - &gEfiSmmRscHandlerProtocolGuid, > + Status =3D gMmst->MmLocateProtocol ( > + &gEfiMmRscHandlerProtocolGuid, > NULL, > (VOID **) &mRscHandlerProtocol > ); > @@ -304,14 +302,14 @@ FirmwarePerformanceSmmEntryPoint ( > // > // Register report status code listener for BootRecords and S3 Suspend > Start and End. > // > - Status =3D mRscHandlerProtocol->Register (FpdtStatusCodeListenerSmm); > + Status =3D mRscHandlerProtocol->Register (FpdtStatusCodeListenerMm); > ASSERT_EFI_ERROR (Status); >=20 > // > // Register SMI handler. > // > Handle =3D NULL; > - Status =3D gSmst->SmiHandlerRegister (FpdtSmiHandler, > &gEfiFirmwarePerformanceGuid, &Handle); > + Status =3D gMmst->MmiHandlerRegister (FpdtSmiHandler, > + &gEfiFirmwarePerformanceGuid, &Handle); > ASSERT_EFI_ERROR (Status); >=20 > return Status; > diff --git > a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir > mwarePerformanceStandaloneMm.c > b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir > mwarePerformanceStandaloneMm.c > new file mode 100644 > index 000000000000..2c4f40eceaea > --- /dev/null > +++ > b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir > mwa > +++ rePerformanceStandaloneMm.c > @@ -0,0 +1,62 @@ > +/** @file > + This module collects performance data for MM driver boot records and S= 3 > Suspend Performance Record. > + > + This module registers report status code listener to collect > + performance data for MM driver boot records and S3 Suspend > Performance Record. > + > + Caution: This module requires additional review when modified. > + This driver will have external input - communicate buffer in MM mode. > + This external input must be validated carefully to avoid security > + issue like buffer overflow, integer overflow. > + > + FpdtSmiHandler() will receive untrusted input and do basic validation. > + > + Copyright (c) 2011 - 2018, Intel Corporation. All rights > + reserved.
Copyright (c), Microsoft Corporation. > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > + > +#include #include > +"FirmwarePerformanceCommon.h" > + > +/** > + This function is an abstraction layer for implementation specific Mm b= uffer > validation routine. > + > + @param Buffer The buffer start address to be checked. > + @param Length The buffer length to be checked. > + > + @retval TRUE This buffer is valid per processor architecture and not > overlap with SMRAM. > + @retval FALSE This buffer is not valid per processor architecture or o= verlap > with SMRAM. > +**/ > +BOOLEAN > +EFIAPI > +IsBufferOutsideMmValid ( > + IN EFI_PHYSICAL_ADDRESS Buffer, > + IN UINT64 Length > + ) > +{ > + return MmIsBufferOutsideMmValid (Buffer, Length); } > + > +/** > + The module Entry Point of the Firmware Performance Data Table MM > driver. > + > + @param[in] ImageHandle The firmware allocated handle for the EFI > image. > + @param[in] SystemTable A pointer to the EFI System Table. > + > + @retval EFI_SUCCESS The entry point is executed successfully. > + @retval Other Some error occurs when executing this entry poi= nt. > + > +**/ > +EFI_STATUS > +EFIAPI > +FirmwarePerformanceStandaloneMmEntryPoint ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_MM_SYSTEM_TABLE *SystemTable > + ) > +{ > + return FirmwarePerformanceCommonEntryPoint (); } > diff --git > a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir > mwarePerformanceTraditional.c > b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir > mwarePerformanceTraditional.c > new file mode 100644 > index 000000000000..507aabcb4e88 > --- /dev/null > +++ > b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir > mwa > +++ rePerformanceTraditional.c > @@ -0,0 +1,62 @@ > +/** @file > + This module collects performance data for MM driver boot records and S= 3 > Suspend Performance Record. > + > + This module registers report status code listener to collect > + performance data for MM driver boot records and S3 Suspend > Performance Record. > + > + Caution: This module requires additional review when modified. > + This driver will have external input - communicate buffer in MM mode. > + This external input must be validated carefully to avoid security > + issue like buffer overflow, integer overflow. > + > + FpdtSmiHandler() will receive untrusted input and do basic validation. > + > + Copyright (c) 2011 - 2018, Intel Corporation. All rights > + reserved.
Copyright (c), Microsoft Corporation. > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > + > +#include > +#include "FirmwarePerformanceCommon.h" > + > +/** > + This function is an abstraction layer for implementation specific Mm b= uffer > validation routine. > + > + @param Buffer The buffer start address to be checked. > + @param Length The buffer length to be checked. > + > + @retval TRUE This buffer is valid per processor architecture and not > overlap with SMRAM. > + @retval FALSE This buffer is not valid per processor architecture or o= verlap > with SMRAM. > +**/ > +BOOLEAN > +EFIAPI > +IsBufferOutsideMmValid ( > + IN EFI_PHYSICAL_ADDRESS Buffer, > + IN UINT64 Length > + ) > +{ > + return SmmIsBufferOutsideSmmValid (Buffer, Length); } > + > +/** > + The module Entry Point of the Firmware Performance Data Table MM > driver. > + > + @param[in] ImageHandle The firmware allocated handle for the EFI > image. > + @param[in] SystemTable A pointer to the EFI System Table. > + > + @retval EFI_SUCCESS The entry point is executed successfully. > + @retval Other Some error occurs when executing this entry poi= nt. > + > +**/ > +EFI_STATUS > +EFIAPI > +FirmwarePerformanceSmmEntryPoint ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + return FirmwarePerformanceCommonEntryPoint (); } > diff --git a/MdeModulePkg/MdeModulePkg.dsc > b/MdeModulePkg/MdeModulePkg.dsc index 05bf5fe08094..dc85d108d958 > 100644 > --- a/MdeModulePkg/MdeModulePkg.dsc > +++ b/MdeModulePkg/MdeModulePkg.dsc > @@ -168,6 +168,7 @@ [LibraryClasses.common.MM_STANDALONE] >=20 > StandaloneMmDriverEntryPoint|MdePkg/Library/StandaloneMmDriverEntry > Point/StandaloneMmDriverEntryPoint.inf >=20 > MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/Stan > daloneMmServicesTableLib.inf >=20 > LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxStandalo > neMmLib.inf > + > + > MemLib|StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMm > MemLib.i > + nf >=20 > [LibraryClasses.ARM, LibraryClasses.AARCH64] > ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf > @@ -501,6 +502,7 @@ [Components.IA32, Components.X64] >=20 > [Components.X64] > MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf > + > + > MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Firm > warePe > + rformanceStandaloneMm.inf >=20 > [BuildOptions] >=20 > diff --git > a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir > mwarePerformanceCommon.h > b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir > mwarePerformanceCommon.h > new file mode 100644 > index 000000000000..ba01e28f2493 > --- /dev/null > +++ > b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir > mwa > +++ rePerformanceCommon.h > @@ -0,0 +1,55 @@ > +/** @file > + This module collects performance data for SMM driver boot records and = S3 > Suspend Performance Record. > + > + This module registers report status code listener to collect > + performance data for SMM driver boot records and S3 Suspend > Performance Record. > + > + Caution: This module requires additional review when modified. > + This driver will have external input - communicate buffer in SMM mode. > + This external input must be validated carefully to avoid security > + issue like buffer overflow, integer overflow. > + > + FpdtSmiHandler() will receive untrusted input and do basic validation. > + > + Copyright (c) 2011 - 2018, Intel Corporation. All rights > + reserved.
Copyright (c), Microsoft Corporation. > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#ifndef _FW_PERF_COMMON_H_ > +#define _FW_PERF_COMMON_H_ > + > +/** > + This function is an abstraction layer for implementation specific Mm b= uffer > validation routine. > + > + @param Buffer The buffer start address to be checked. > + @param Length The buffer length to be checked. > + > + @retval TRUE This buffer is valid per processor architecture and not > overlap with SMRAM. > + @retval FALSE This buffer is not valid per processor architecture or o= verlap > with SMRAM. > +**/ > +BOOLEAN > +EFIAPI > +IsBufferOutsideMmValid ( > + IN EFI_PHYSICAL_ADDRESS Buffer, > + IN UINT64 Length > + ); > + > +/** > + The module Entry Point of the Firmware Performance Data Table MM > driver. > + > + @param[in] ImageHandle The firmware allocated handle for the EFI > image. > + @param[in] SystemTable A pointer to the EFI System Table. > + > + @retval EFI_SUCCESS The entry point is executed successfully. > + @retval Other Some error occurs when executing this entry poi= nt. > + > +**/ > +EFI_STATUS > +EFIAPI > +FirmwarePerformanceCommonEntryPoint ( > + VOID > + ); > + > +#endif // _FW_PERF_COMMON_H_ > diff --git > a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir > mwarePerformanceSmm.inf > b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir > mwarePerformanceSmm.inf > index 618cbd56ca59..b7194bd899dd 100644 > --- > a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir > mwarePerformanceSmm.inf > +++ > b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir > mwa > +++ rePerformanceSmm.inf > @@ -26,7 +26,9 @@ [Defines] > # >=20 > [Sources] > - FirmwarePerformanceSmm.c > + FirmwarePerformanceCommon.c > + FirmwarePerformanceCommon.h > + FirmwarePerformanceTraditional.c >=20 > [Packages] > MdePkg/MdePkg.dec > @@ -34,7 +36,7 @@ [Packages] >=20 > [LibraryClasses] > UefiDriverEntryPoint > - SmmServicesTableLib > + MmServicesTableLib > BaseLib > DebugLib > TimerLib > @@ -42,12 +44,11 @@ [LibraryClasses] > PcdLib > BaseMemoryLib > MemoryAllocationLib > - UefiBootServicesTableLib > SynchronizationLib > SmmMemLib >=20 > [Protocols] > - gEfiSmmRscHandlerProtocolGuid ## CONSUMES > + gEfiMmRscHandlerProtocolGuid ## CONSUMES >=20 > [Guids] > ## SOMETIMES_PRODUCES ## UNDEFINED # SaveLockBox > @@ -61,7 +62,7 @@ [Pcd] > gEfiMdeModulePkgTokenSpaceGuid.PcdProgressCodeS3SuspendEnd ## > CONSUMES >=20 > [Depex] > - gEfiSmmRscHandlerProtocolGuid > + gEfiMmRscHandlerProtocolGuid >=20 > [UserExtensions.TianoCore."ExtraFiles"] > FirmwarePerformanceSmmExtra.uni > diff --git > a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir > mwarePerformanceSmm.inf > b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir > mwarePerformanceStandaloneMm.inf > similarity index 65% > copy from > MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Firm > warePerformanceSmm.inf > copy to > MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Firm > warePerformanceStandaloneMm.inf > index 618cbd56ca59..e6aad88be0ef 100644 > --- > a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir > mwarePerformanceSmm.inf > +++ > b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir > mwa > +++ rePerformanceStandaloneMm.inf > @@ -5,19 +5,19 @@ > # for SMM boot performance records and S3 Suspend Performance Record. > # > # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved. > +# Copyright (c) Microsoft Corporation. > # SPDX-License-Identifier: BSD-2-Clause-Patent # ## >=20 > [Defines] > INF_VERSION =3D 0x00010005 > - BASE_NAME =3D FirmwarePerformanceSmm > - MODULE_UNI_FILE =3D FirmwarePerformanceSmm.uni > - FILE_GUID =3D 044310AB-77FD-402a-AF1A-87D4120E732= 9 > - MODULE_TYPE =3D DXE_SMM_DRIVER > + BASE_NAME =3D FirmwarePerformanceStandaloneMm > + FILE_GUID =3D 827AC29D-E52D-4B1A-874A-C6577E0699C= F > + MODULE_TYPE =3D MM_STANDALONE > VERSION_STRING =3D 1.0 > - PI_SPECIFICATION_VERSION =3D 0x0001000A > - ENTRY_POINT =3D FirmwarePerformanceSmmEntryPoint > + PI_SPECIFICATION_VERSION =3D 0x00010032 > + ENTRY_POINT =3D FirmwarePerformanceStandaloneMmEntr= yPoint >=20 > # > # The following information is for reference only and not required by th= e > build tools. > @@ -26,15 +26,18 @@ [Defines] > # >=20 > [Sources] > - FirmwarePerformanceSmm.c > + FirmwarePerformanceCommon.c > + FirmwarePerformanceCommon.h > + FirmwarePerformanceStandaloneMm.c >=20 > [Packages] > MdePkg/MdePkg.dec > MdeModulePkg/MdeModulePkg.dec > + StandaloneMmPkg/StandaloneMmPkg.dec >=20 > [LibraryClasses] > - UefiDriverEntryPoint > - SmmServicesTableLib > + StandaloneMmDriverEntryPoint > + MmServicesTableLib > BaseLib > DebugLib > TimerLib > @@ -42,12 +45,11 @@ [LibraryClasses] > PcdLib > BaseMemoryLib > MemoryAllocationLib > - UefiBootServicesTableLib > SynchronizationLib > - SmmMemLib > + MemLib >=20 > [Protocols] > - gEfiSmmRscHandlerProtocolGuid ## CONSUMES > + gEfiMmRscHandlerProtocolGuid ## CONSUMES >=20 > [Guids] > ## SOMETIMES_PRODUCES ## UNDEFINED # SaveLockBox > @@ -61,7 +63,4 @@ [Pcd] > gEfiMdeModulePkgTokenSpaceGuid.PcdProgressCodeS3SuspendEnd ## > CONSUMES >=20 > [Depex] > - gEfiSmmRscHandlerProtocolGuid > - > -[UserExtensions.TianoCore."ExtraFiles"] > - FirmwarePerformanceSmmExtra.uni > + gEfiMmRscHandlerProtocolGuid > -- > 2.28.0.windows.1