From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com []) by mx.groups.io with SMTP id smtpd.web12.3085.1609903476617457257 for ; Tue, 05 Jan 2021 19:24:39 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=zjciKghq; spf=fail (domain: intel.com, ip: , mailfrom: hao.a.wu@intel.com) IronPort-SDR: v9sk8nI7Kyt2wFk0ZzBl/zz5jYWiPHeRvmn45gl0oNVbFfa7J7d/mRBavjSQ/13WCV8h0YF88O FVNM1MnPL5EQ== X-IronPort-AV: E=McAfee;i="6000,8403,9855"; a="238771559" X-IronPort-AV: E=Sophos;i="5.78,478,1599548400"; d="scan'208";a="238771559" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jan 2021 19:24:38 -0800 IronPort-SDR: pusZslKLEtZ9drGUiLrWJ7r1xpDrqR16kS9jk2rtyyMLLWnaqvXKTpBcW/RN6XZ4DtRNUPDluB 2a6I/iADEIvg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,478,1599548400"; d="scan'208";a="402551264" Received: from fmsmsx605.amr.corp.intel.com ([10.18.126.85]) by FMSMGA003.fm.intel.com with ESMTP; 05 Jan 2021 19:24:38 -0800 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 5 Jan 2021 19:24:37 -0800 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 5 Jan 2021 19:24:37 -0800 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx609.amr.corp.intel.com (10.18.126.89) 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, 5 Jan 2021 19:24:37 -0800 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (104.47.73.46) 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, 5 Jan 2021 19:24:37 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aeWwBFTMzsnmEusxkfcHW3vz1ya6Ee7Fh5ijI1EFWwtBQBbUvk8rCmk3VgabIBVJnYe4kuW4UGjjZpe9/dSvYOz4A42GXtZLDlQu0KZtmlU9FZhgVZyuFyRQ3nFngW19Ctn3t2xdzBu5xQg8251OaZp1C94G+Cbrs6iSiVBNtm7YWenjhRbR2MMLOepQthzKkhE4OZJrgmnfRjTPqt4ZtwZb5eIGJl0i6sNmkKCOLN07dqvevbv7VJE2Ew0o3ji09czx+z/TJOYRWGHcYdHc0dbGmva54huRgPINR6ilVYWLZl5Z/1B8l7gf7wLrFfXc93JLeV4vWMUB9n6jlJVijA== 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=0GQLA8F7cFehHVmxp6btBCdDT/ACetWGmYKKkb6d8h0=; b=PzYnLN/4DJZlWTcFCVsKYbNLXQ0TnwMeWkecuOsg0i2W9AeljlQFeNMJVVGHdBAx5si0KPaD68tPv6wiZW5iZ/EA+V2vMq/gIvtpyedb7/+4cHc6gilAO1bIDqca3+HMODbK8GybpByBS+JGKDyBqeR+6DeWwwcUSxFaRwJCEQowM+dr3jkqCCWYajIfgSvkbki+hMwXyeZcGNxGSYK8mcIBP7IE95E6Hu7wYpP5gCxu7rP7aCl6q2wUZsF+0VU4l8ec+Te7k4X/cMuxXa3+ElKaPtezYXjEYtRQnIFn37SknqBkdcf8zTyQ7WanF2ij2hd6rTcFFplKGtZNWWCxvw== 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=0GQLA8F7cFehHVmxp6btBCdDT/ACetWGmYKKkb6d8h0=; b=zjciKghqB6JP8d0Fv/obzuUrZ1Jbev2n3n9485l4cdZNCVOsODcJorIQF2zOrQ7YLDk5JbhoOax7qCQa//myXa5DKTCywYF4kwqjsyLnSZxLumbA0VGiEfIS1GJ0huNewzuX5R+zX8IMBQqJn0wGEJ8TH+Iaz0QN3Jgo6hPJQbY= Received: from BN8PR11MB3666.namprd11.prod.outlook.com (2603:10b6:408:8c::19) by BN7PR11MB2721.namprd11.prod.outlook.com (2603:10b6:406:ba::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Wed, 6 Jan 2021 03:24:35 +0000 Received: from BN8PR11MB3666.namprd11.prod.outlook.com ([fe80::d11e:3b2:e34f:7f0f]) by BN8PR11MB3666.namprd11.prod.outlook.com ([fe80::d11e:3b2:e34f:7f0f%5]) with mapi id 15.20.3742.006; Wed, 6 Jan 2021 03:24:35 +0000 From: "Wu, Hao A" To: Kun Qin , "devel@edk2.groups.io" CC: "Wang, Jian J" , "Bi, Dandan" , Liming Gao Subject: Re: [PATCH v2 08/16] MdeModulePkg: FirmwarePerformanceDataTable: Added StandaloneMm support Thread-Topic: [PATCH v2 08/16] MdeModulePkg: FirmwarePerformanceDataTable: Added StandaloneMm support Thread-Index: AQHW45UF+hP3MGOQRUS5ztjg5LUDpaoZ66mg Date: Wed, 6 Jan 2021 03:24:35 +0000 Message-ID: References: <20210105185935.3769-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: 2a6a4e48-3aaf-4b8c-0139-08d8b1f29783 x-ms-traffictypediagnostic: BN7PR11MB2721: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:469; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: m+WnOtsq9sLaGK0rOOJhtsrvcKHJjIIjwWcgJcvyHDc2y87hSysuE8eAjBIiKDdXPqnKVphmlTsRcUemikouZiRH+qa+e8C0wvbPT0bZvV+BIP/W9lo7L2CzYLmvRWMnNeJtZ6RzAtV80iUy2gx0WCOVUKfY8TBV56YtiGfSIvm4w6rXASxqgL3qcE94Ol65MI1VeJbgDKoSg2C/BUCAqGaYmgQxxOJDPeoU1hYGSNwz0a2O45gTyqjJYQCGwBdee0DLoU+iaBSHxfYGiu4Trz8TEsZaDWF4qi4cDNOe4NH+TMQwGB4A569kBdrkySv8HKC1FYlwdpIz9w/FYabpr7tOIf5Tw7igNHICJ/3/ZOzXtG8MzFxJsYm3x4WLgYB3qNS/vujklJdFM8cE3Gs2Bw== 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)(136003)(39860400002)(346002)(396003)(376002)(366004)(19627235002)(2906002)(316002)(76116006)(54906003)(66476007)(4326008)(52536014)(66556008)(110136005)(64756008)(33656002)(7696005)(478600001)(45080400002)(66446008)(5660300002)(71200400001)(30864003)(8676002)(8936002)(83380400001)(26005)(53546011)(6506007)(186003)(55016002)(9686003)(86362001)(66946007)(559001)(579004);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?hcLOv02fbaxIc0mSVVoMsSxiVMnZ0UkJyFtEsmP8xq1MQZzW9jmezhqse+ww?= =?us-ascii?Q?R4VWJzd3UlaqGewEMc7lesHwEDPDUKDEbnYkD5YtCCA4N/p2AVdVxoJtrEIY?= =?us-ascii?Q?7tD9zP9IJCvCh5XItP2hnp/IUaa2vafONv3ikHtbI/oL19F3eg4Am40SN6RU?= =?us-ascii?Q?1R0Y9DtcyLIV/EVgPDBZgBHYgLO6g/mnxvgT8N9MdOZcxpkhgFCrF6lg1atm?= =?us-ascii?Q?XzMzL4MjaNm4BAhrNo6v0th9HWdZCyjVH7f6jANnZKX7YSIbgUPRjrgLV6Kz?= =?us-ascii?Q?tPUNKAqWT5JMqAWhym6CIgkF6wIQIa3YsTmUqRW7gudYMXlLXO/6Fz4BorjT?= =?us-ascii?Q?6/HsJL34ay7IUJde332C0UL8xsL8gHHKsEdTLvoeV6mSP+YYCJ4RMh1Ekxva?= =?us-ascii?Q?+h5FjFDnCbkEx7OQh8tj+UHYCUyJiapV0Jxfe3uui/YTVY3XSAIJaOQ6Mz1Y?= =?us-ascii?Q?iUBy72BpQqhZpbIonSs2Va0T7BK3FbvLN5cPPl0ZsN9lZbe4ogQlASFGIR32?= =?us-ascii?Q?V//CUiv+wgGwwDif1DpklplgF9eJpE8YGxn4DSccPrpaIuyqwSisvidWoz6j?= =?us-ascii?Q?4IAoZPPd+hOzH49ngNNf3EzMPFB2Vau3uDj0Av53sC5/L2qVS0vYT7/T2g6n?= =?us-ascii?Q?vy4kUKZgwq3kebwysRUHpQ5cpZy6oLNP/hfQeEbVV20u73BIgsfIW5c/XoNb?= =?us-ascii?Q?tQ2BeZq5izHmfiDwK62NATteKPE8HpguVuUX61cQ20DlkkjdcgX3RURJ/Dic?= =?us-ascii?Q?SJ8XOZyjYwbf2vLcUL9KrEcosFonWmZHjQmICGAA4CEcPXU/Lm27qa+8qHn7?= =?us-ascii?Q?7YdGN9Eo5YBDLC1TzJdykLYbRi2p5Rydk0+F9T2pWFxsKn70NnG/L9ETXfCg?= =?us-ascii?Q?8ZirE9A+5BnqnDRBs+wX05FpSxGXzGZSdV3GVgRnC1WugGImcA2p9d4fsNGq?= =?us-ascii?Q?NGQJR3Uyfs1sll83Ka0PXh0mQqZd0QI4ARuVZu9zvhY=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: 2a6a4e48-3aaf-4b8c-0139-08d8b1f29783 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jan 2021 03:24:35.4112 (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: 2+6OG2Ozid2VPl1D/5O7NrBeKKj4YSAHn6u/Dds9adLwMbENldfKfuidxAmH2Eq7QJkP+TMm5bK3KcR52VRu7A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7PR11MB2721 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: Wednesday, January 6, 2021 2:59 AM > To: devel@edk2.groups.io > Cc: Wang, Jian J ; Wu, Hao A ; > Bi, Dandan ; Liming Gao > Subject: [PATCH v2 08/16] 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. Reviewed-by: Hao A Wu 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 > Notes: > v2: > - Removed "EFIAPI" for internally abstracted functions [Hao] > - Support driver for both IA32 and X64 in dsc file [Hao] >=20 >=20 > MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/{Firm > warePerformanceSmm.c =3D> FirmwarePerformanceCommon.c} | 76 > +++++++++----------- >=20 > MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Firm > warePerformanceStandaloneMm.c | 61 > ++++++++++++++++ >=20 > MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Firm > warePerformanceTraditional.c | 61 ++++= ++++++++++++ > MdeModulePkg/MdeModulePkg.dsc > | 2 + >=20 > MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Firm > warePerformanceCommon.h | 50 ++++= +++++++++ >=20 > MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Firm > warePerformanceSmm.inf | 11 +-- >=20 > MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/{Firm > warePerformanceSmm.inf =3D> FirmwarePerformanceStandaloneMm.inf} | 31 > ++++---- > 7 files changed, 230 insertions(+), 62 deletions(-) >=20 > diff --git > a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir > mwarePerformanceSmm.c > b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir > mwarePerformanceCommon.c > similarity index 75% > rename from > MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Firm > warePerformanceSmm.c > rename to > MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Firm > warePerformanceCommon.c > index d6c6e7693e4d..ecadef8711ed 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,20 +266,15 @@ FpdtSmiHandler ( > } >=20 > /** > - The module Entry Point of the Firmware Performance Data Table SMM > driver. > - > - @param[in] ImageHandle The firmware allocated handle for the EFI > image. > - @param[in] SystemTable A pointer to the EFI System Table. > + The module Entry Point of the Firmware Performance Data Table MM > driver. >=20 > @retval EFI_SUCCESS The entry point is executed successfully. > @retval Other Some error occurs when executing this entry poi= nt. >=20 > **/ > EFI_STATUS > -EFIAPI > -FirmwarePerformanceSmmEntryPoint ( > - IN EFI_HANDLE ImageHandle, > - IN EFI_SYSTEM_TABLE *SystemTable > +FirmwarePerformanceCommonEntryPoint ( > + VOID > ) > { > EFI_STATUS Status; > @@ -289,13 +283,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 +298,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..d7da61c98c66 > --- /dev/null > +++ > b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir > mwa > +++ rePerformanceStandaloneMm.c > @@ -0,0 +1,61 @@ > +/** @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 > +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 MM 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..43c050d6b516 > --- /dev/null > +++ > b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir > mwa > +++ rePerformanceTraditional.c > @@ -0,0 +1,61 @@ > +/** @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 > +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 098909490095..34ca571ca662 > 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 > @@ -495,6 +496,7 @@ [Components.IA32, Components.X64] > MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf > MdeModulePkg/Universal/Acpi/SmmS3SaveState/SmmS3SaveState.inf >=20 > MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Firm > warePerformanceSmm.inf > + > + > MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Firm > warePe > + rformanceStandaloneMm.inf >=20 > MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.i > nf >=20 > MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmD > xe.inf >=20 > MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf > diff --git > a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir > mwarePerformanceCommon.h > b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir > mwarePerformanceCommon.h > new file mode 100644 > index 000000000000..0fbdac02de4c > --- /dev/null > +++ > b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/Fir > mwa > +++ rePerformanceCommon.h > @@ -0,0 +1,50 @@ > +/** @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 > +IsBufferOutsideMmValid ( > + IN EFI_PHYSICAL_ADDRESS Buffer, > + IN UINT64 Length > + ); > + > +/** > + The module Entry Point of the Firmware Performance Data Table MM > driver. > + > + @retval EFI_SUCCESS The entry point is executed successfully. > + @retval Other Some error occurs when executing this entry poi= nt. > + > +**/ > +EFI_STATUS > +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.30.0.windows.1