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.web08.42394.1609136645202321323 for ; Sun, 27 Dec 2020 22:24:05 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=AnywKFZ8; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: jiewen.yao@intel.com) IronPort-SDR: PNRyM1RZKoFsA9wxXU3kPnZt04KC1VuyudREjIPAL84P6KpI2cbN4578DrV+S1ZjWh3i+XnS7E 7lTRb9GPWDIg== X-IronPort-AV: E=McAfee;i="6000,8403,9847"; a="261096156" X-IronPort-AV: E=Sophos;i="5.78,454,1599548400"; d="scan'208,217";a="261096156" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2020 22:24:04 -0800 IronPort-SDR: Qt/2SsE14svWPhdbFfxRbAXu/J9wSp6C+quj7hhiuFzIoKo+5CMvivXVcZkRxojrp8eneVdrll W2UN/S2gtJtg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,454,1599548400"; d="scan'208,217";a="567342311" Received: from orsmsx604.amr.corp.intel.com ([10.22.229.17]) by fmsmga005.fm.intel.com with ESMTP; 27 Dec 2020 22:24:04 -0800 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX604.amr.corp.intel.com (10.22.229.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Sun, 27 Dec 2020 22:24:03 -0800 Received: from orsmsx609.amr.corp.intel.com (10.22.229.22) 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.1713.5; Sun, 27 Dec 2020 22:24:03 -0800 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx609.amr.corp.intel.com (10.22.229.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Sun, 27 Dec 2020 22:24:03 -0800 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.41) 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.1713.5; Sun, 27 Dec 2020 22:24:03 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PiH0ZWNkmyYAgrxAWrmVPpCLhd58r6Mcis+8ZXjhFM8ckTNDyFhMiK83X8z1KVJpalOBl5iEwVELIKX3aol4VNv8Zcqw27WNBqLS171mWT7YBYM99gDBFkvgdA7yst2p5aT0KtNL9Jt9m3/YmfPOVZq8gkmy29ktfx9iGuwCJaVt91gkH8TVBlpjHG/Rwa4z4IXvBs0xBoCZ8nT9gqRqSswkh7FUBKtT4gMoYBEV4jvlTcGY9chV4XVwglqQx7O6vYVwqd7Qkfb/xtqEbEv3e1J3DeMI+El1MBE+BNssf7XA+Xnmg4kEIHaCMPxw01KZqts71hgxQlcVzpmNojluOQ== 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=Qdhdnon6R/Bac2YW2+CyPT3pDmmekSUQeiVxO15dUiU=; b=b4K5V4rDU6atsqho4Xpb/GN0WgBGc/pjXhZ1pGq1DrDxmJUjAtVbIFrydScB6EHEKLR64OVVxxFNI4X57VkuqMrNisDIdYVXFwInqY8KvriVPKPcfHlPAmWY0nrLcg629tD526nEZHrtvn+WiqQ/rbfsMJ7tnLbQSRJghXf+Lbtd3+M6upFi0w5TviE1LoM6+LgNe25Py0biqfRdKJwnnwC2QYm4qm5rmAMqFQCbnX67khmV4enbZAi3rNFTEZRn9xNNMoK1SKnNhM1Q2rUChd0TZ/37Bl6iPvwbHw8+8GBbb3oamSGkWvHYDfEAoPk3b5jhGPQQffNkblsqWEDLIA== 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=Qdhdnon6R/Bac2YW2+CyPT3pDmmekSUQeiVxO15dUiU=; b=AnywKFZ8k1cv6cJFOWUpU/ynLLAyahMM7yp7qMbhBkjcfJoaGbd4tW8IFDkCH1jcOlx8/UM9aPFcpRgL2MmydiGMb0ZHuQfur91nZcWSIPU2Bsnu/F6z0uNo/4t0rvPMk1bzFN+tFo+W/rmisi2M3XjDZb713/O9ZpxD/bCi/mc= Received: from CY4PR11MB1288.namprd11.prod.outlook.com (2603:10b6:903:23::8) by CY4PR11MB1813.namprd11.prod.outlook.com (2603:10b6:903:127::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3700.30; Mon, 28 Dec 2020 06:24:02 +0000 Received: from CY4PR11MB1288.namprd11.prod.outlook.com ([fe80::e058:fd5a:28d8:2b17]) by CY4PR11MB1288.namprd11.prod.outlook.com ([fe80::e058:fd5a:28d8:2b17%12]) with mapi id 15.20.3700.031; Mon, 28 Dec 2020 06:24:02 +0000 From: "Yao, Jiewen" To: Kun Qin , "devel@edk2.groups.io" CC: Ard Biesheuvel , Sami Mujawar , Supreeth Venkatesh Subject: Re: [PATCH v1 04/15] StandaloneMmPkg: StandaloneMmMemLib: Extends support for X64 architecture Thread-Topic: [PATCH v1 04/15] StandaloneMmPkg: StandaloneMmMemLib: Extends support for X64 architecture Thread-Index: AQHW1W60Vk5xAW1fXUeG9eUbieXuqaoLsrVwgABCeoCAACNn0A== Date: Mon, 28 Dec 2020 06:24:02 +0000 Message-ID: References: <20201218185011.1366-1-kun.q@outlook.com> , In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.5.1.3 dlp-product: dlpe-windows dlp-reaction: no-action 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.102.204.37] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 2dfd2295-81e2-47e1-e7dc-08d8aaf92b7b x-ms-traffictypediagnostic: CY4PR11MB1813: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: /QJntFJvkBRs+i00hIVr6YOrVOBaK/jV+0sd5D7aLWR/M0YQdyxB/PWMvSsId6jpvZduNERaWDVgyQCOFLegrPOd1zYyhqRVN1SmhF+5nQl9ZsmojWvlUuSd32UgzGgGztT8w2iwt87VxcLka21eNchiiW746UyOxG3bUfQmMC2BVdIrePSKU+WpmiNZTKECtlvwW20WRiruC+XlMiaXbDYFBqq8JBbVbMcRHku+nKjgKj+FZzkCv03xJvWb1bMvkk6bEBF9sMhZwDSfud0dutDveXAF39hnJ5+EsshNPBLCecgFl+E6xEyPQlsKIU5pP9qniQI5mVvheywoMAOggTPFCFHe0KdB99aIG9xZoTyh0wqz5A56WdbWnf3Km2/9skrDggRyj3FrhiiEd/eSwA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY4PR11MB1288.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(6029001)(4636009)(136003)(376002)(396003)(366004)(346002)(39860400002)(478600001)(45080400002)(9686003)(55016002)(71200400001)(83380400001)(66946007)(66476007)(66446008)(52536014)(64756008)(66556008)(7696005)(8676002)(33656002)(316002)(5660300002)(86362001)(76116006)(4326008)(26005)(2906002)(110136005)(8936002)(54906003)(6506007)(53546011)(186003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?ODmZqdeUnQAU/2KAPzZ+N0//j2jiZ4gBJaYZQMxg/7VJCgNjhK532DPCrRPH?= =?us-ascii?Q?gHwMq6j7eISUJrdZHIdms9nZ9FbQWfASDzizStDuA8RM3J/2G8kVYG09PxaT?= =?us-ascii?Q?sgI1uQcg1ATVfQgNQUjM68TrVSF7wRYZbYyXTVLigoUaJKJnP2lFuESSq9uL?= =?us-ascii?Q?iVa36Zj7ZZ8ar8ojlDXoWR/YDOjnwMASj9bX0ZlwnJFfdKH/ZebEb0qFVHA7?= =?us-ascii?Q?nsNjAc7+1z4XKtWXg+7a0zKjvBt6Zi4NRqm/S60jVF8bqtfHGGQYZw2Poy+V?= =?us-ascii?Q?pk2ICyAt+DGd4pB1YikpXIaX0DeA7SW5Sccm5VoRWpx1Q+c1CO5VDU67jliA?= =?us-ascii?Q?wnZ1uiKVTeHQ2hdB+mTulOE+BjE8Uti/qiGUb+lCifvnNu7ansJ9jT3gi1Vo?= =?us-ascii?Q?C/xv6e/xwvM4A+gehMJxahmxF0DmrQp9DU0JKTn2331Q1Go+1z9iY4tVVFlx?= =?us-ascii?Q?mz55PRnc9qGre11faIKBiL0In8B0bkWKJ/vvIYGQtJ7dXo04fam5sFQBbHA4?= =?us-ascii?Q?yJb5qWsX0TMWe99/YIXwDAL5C3CTzyf1JW5dtyGE/hArEwKSIpj5vJA+oM0f?= =?us-ascii?Q?14C4F73pHgTgXg8ujsL3pqMGgAZ+TITgBByqWLUpytTmNoxs6o2lFT3vPg9f?= =?us-ascii?Q?y2H59HKEgeKS7nR+skfViUWectycXDsTcDhLG82OQ9IPfMPLjlvUUGiuSjF1?= =?us-ascii?Q?NWcePZ7ZI6iyDdtGAMjj5lfpMpYBmUyO6kpa8dXB4YuzRnoF/FdHATVzyZii?= =?us-ascii?Q?DZwBy7JpTLhMJXS5eWhlBQCz6cSVSQ/1S3VeEO3y0aOrytZMgih67hrt5H93?= =?us-ascii?Q?vjR18inglmuJoUJ95MiwPiiVnj9N1GMEW6xqfoDLtQzX357IlyPOtQble41b?= =?us-ascii?Q?V++SmYkhLQdX3XW7+DJWn+p9iWJbX1CeHkP5shd79hePZxvPtGZOJSRVtsmv?= =?us-ascii?Q?Q3BPsPZPOqdm/mnmIF+wQWntaOdljbokAeP0RaKnrvo=3D?= x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CY4PR11MB1288.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2dfd2295-81e2-47e1-e7dc-08d8aaf92b7b X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Dec 2020 06:24:02.4654 (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: cHu5IujaW45EBzWqyeV9zCvaqBMDJT0f4s67z0vscDye8TzHQYkK+gkf8Ptr/DbYBO8Jo0N2dyW5J5NM3Z96yg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR11MB1813 Return-Path: jiewen.yao@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_CY4PR11MB12884DC5C03B889A355735808CD90CY4PR11MB1288namp_" --_000_CY4PR11MB12884DC5C03B889A355735808CD90CY4PR11MB1288namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I am not familiar with AArch64. So I will let ARM people comment it. For X86, I think it is security hole, if we do not fill mMmMemLibInternalMm= ramRanges. A partial fix with known security vulnerability is not the best idea. I prefer to we give a full fix, or no fix it in V2. Thank you Yao Jiewen From: Kun Qin Sent: Monday, December 28, 2020 12:15 PM To: Yao, Jiewen ; devel@edk2.groups.io Cc: Ard Biesheuvel ; Sami Mujawar ; Supreeth Venkatesh Subject: RE: [PATCH v1 04/15] StandaloneMmPkg: StandaloneMmMemLib: Extends = support for X64 architecture Hi Jiewen, I did not fill these 2 variables for this patch because I thought to follow= up fix for this issue separately because the AARCH64 instance does not fil= l it either and I meant for this patch to solely extends the coverage to x6= 4 (and IA32). But please let me know if you think otherwise, I can add the = x64 fix in this patch as well. But I do not have fix for AARCH64 since I am= not familiar with how it should work. Thanks, Kun From: Yao, Jiewen Sent: Sunday, December 27, 2020 16:18 To: Kun Qin; devel@edk2.groups.io Cc: Ard Biesheuvel; Sami Mujawar; Supreeth Venkatesh Subject: RE: [PATCH v1 04/15] StandaloneMmPkg: StandaloneMmMemLib: Extends = support for X64 architecture May I know where is the code to fill below? EFI_MMRAM_DESCRIPTOR *mMmMemLibInternalMmramRanges; UINTN mMmMemLibInternalMmramCount; > -----Original Message----- > From: Kun Qin > > Sent: Saturday, December 19, 2020 2:50 AM > To: devel@edk2.groups.io > Cc: Ard Biesheuvel = >; Sami Mujawar > >; Yao, Jiewen >; Supreeth > Venkatesh > > Subject: [PATCH v1 04/15] StandaloneMmPkg: StandaloneMmMemLib: > Extends support for X64 architecture > > This change extends StandaloneMmMemLib library to support X64 > architecture. The implementation is ported from > MdePkg/Library/SmmMemLib. > > Cc: Ard Biesheuvel = > > Cc: Sami Mujawar > > Cc: Jiewen Yao > > Cc: Supreeth Venkatesh > > > Signed-off-by: Kun Qin > > --- > > StandaloneMmPkg/Library/StandaloneMmMemLib/X64/StandaloneMmMe > mLibInternal.c | 67 ++++++++++++++++++++ > > StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib > .inf | 6 +- > 2 files changed, 72 insertions(+), 1 deletion(-) > > diff --git > a/StandaloneMmPkg/Library/StandaloneMmMemLib/X64/StandaloneMm > MemLibInternal.c > b/StandaloneMmPkg/Library/StandaloneMmMemLib/X64/StandaloneMm > MemLibInternal.c > new file mode 100644 > index 000000000000..c5e21c583f44 > --- /dev/null > +++ > b/StandaloneMmPkg/Library/StandaloneMmMemLib/X64/StandaloneMm > MemLibInternal.c > @@ -0,0 +1,67 @@ > +/** @file > + Internal ARCH Specific file of MM memory check library. > + > + MM memory check library implementation. This library consumes > MM_ACCESS_PROTOCOL > + to get MMRAM information. In order to use this library instance, the > platform should produce > + all MMRAM range via MM_ACCESS_PROTOCOL, including the range for > firmware (like MM Core > + and MM driver) and/or specific dedicated hardware. > + > + Copyright (c) 2015, Intel Corporation. All rights reserved.
> + Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > +#include > +#include > +#include > +#include > +// > +// Maximum support address used to check input buffer > +// > +extern EFI_PHYSICAL_ADDRESS > mMmMemLibInternalMaximumSupportAddress; > + > +/** > + Calculate and save the maximum support address. > + > +**/ > +VOID > +MmMemLibInternalCalculateMaximumSupportAddress ( > + VOID > + ) > +{ > + VOID *Hob; > + UINT32 RegEax; > + UINT8 PhysicalAddressBits; > + > + // > + // Get physical address bits supported. > + // > + Hob =3D GetFirstHob (EFI_HOB_TYPE_CPU); > + if (Hob !=3D NULL) { > + PhysicalAddressBits =3D ((EFI_HOB_CPU *) Hob)->SizeOfMemorySpace; > + } else { > + AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); > + if (RegEax >=3D 0x80000008) { > + AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL); > + PhysicalAddressBits =3D (UINT8) RegEax; > + } else { > + PhysicalAddressBits =3D 36; > + } > + } > + // > + // IA-32e paging translates 48-bit linear addresses to 52-bit physical > addresses. > + // > + ASSERT (PhysicalAddressBits <=3D 52); > + if (PhysicalAddressBits > 48) { > + PhysicalAddressBits =3D 48; > + } > + > + // > + // Save the maximum support address in one global variable > + // > + mMmMemLibInternalMaximumSupportAddress =3D > (EFI_PHYSICAL_ADDRESS)(UINTN)(LShiftU64 (1, PhysicalAddressBits) - 1); > + DEBUG ((DEBUG_INFO, "mMmMemLibInternalMaximumSupportAddress > =3D 0x%lx\n", mMmMemLibInternalMaximumSupportAddress)); > +} > + > + > diff --git > a/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMem > Lib.inf > b/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMem > Lib.inf > index 49da02e54e6d..65ad0a48905c 100644 > --- > a/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMem > Lib.inf > +++ > b/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMem > Lib.inf > @@ -26,12 +26,15 @@ [Defines] > # > # The following information is for reference only and not required by th= e > build tools. > # > -# VALID_ARCHITECTURES =3D AARCH64 > +# VALID_ARCHITECTURES =3D X64 AARCH64 > # > > [Sources.Common] > StandaloneMmMemLib.c > > +[Sources.X64] > + X64/StandaloneMmMemLibInternal.c > + > [Sources.AARCH64] > AArch64/StandaloneMmMemLibInternal.c > > @@ -42,3 +45,4 @@ [Packages] > [LibraryClasses] > BaseMemoryLib > DebugLib > + HobLib > -- > 2.28.0.windows.1 --_000_CY4PR11MB12884DC5C03B889A355735808CD90CY4PR11MB1288namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

I am not familiar with AArch64. So I will let ARM pe= ople comment it.

 

For X86, I think it is security hole, if we do not f= ill mMmMemLibInternalMmramRanges.

 

A partial fix with known security vulnerability is n= ot the best idea.

 

I prefer to we give a full fix, or no fix it in V2.<= o:p>

 

Thank you

Yao Jiewen

 

 

From: Kun Qin <kun.q@outlook.com>
Sent: Monday, December 28, 2020 12:15 PM
To: Yao, Jiewen <jiewen.yao@intel.com>; devel@edk2.groups.io Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>; Sami Mujawar <= sami.mujawar@arm.com>; Supreeth Venkatesh <supreeth.venkatesh@arm.com= >
Subject: RE: [PATCH v1 04/15] StandaloneMmPkg: StandaloneMmMemLib: E= xtends support for X64 architecture

 

Hi Jiewen,

 

I did not fill these 2 variables for this patch beca= use I thought to follow up fix for this issue separately because the AARCH6= 4 instance does not fill it either and I meant for this patch to solely ext= ends the coverage to x64 (and IA32). But please let me know if you think otherwise, I can add the x64 fix in th= is patch as well. But I do not have fix for AARCH64 since I am not familiar= with how it should work.

 

Thanks,

Kun

 

From: Yao, Jiewen
Sent: Sunday, December 27, 2020 16:18
To: Kun Qin; devel@edk2.groups.io
Cc: Ard Biesheuvel; Sami Mujawar; Supreeth Ve= nkatesh
Subject: RE: [PATCH v1 04/15] StandaloneMmPkg: StandaloneMmMemLib: E= xtends support for X64 architecture

 

May I know where is t= he code to fill below?
EFI_MMRAM_DESCRIPTOR *mMmMemLibInternalMmramRanges;
UINTN           &nbs= p;    mMmMemLibInternalMmramCount;



> -----Original Message-----
> From: Kun Qin <kun.q@outlook.c= om>
> Sent: Saturday, December 19, 2020 2:50 AM
> To: devel@edk2.groups.io > Cc: Ard Biesheuvel <ard.b= iesheuvel@arm.com>; Sami Mujawar
> <sami.mujawar@arm.com&g= t;; Yao, Jiewen <jiewen.yao@inte= l.com>; Supreeth
> Venkatesh <supreeth.v= enkatesh@arm.com>
> Subject: [PATCH v1 04/15] StandaloneMmPkg: StandaloneMmMemLib:
> Extends support for X64 architecture
>
> This change extends StandaloneMmMemLib library to support X64
> architecture. The implementation is ported from
> MdePkg/Library/SmmMemLib.
>
> Cc: Ard Biesheuvel <ard.b= iesheuvel@arm.com>
> Cc: Sami Mujawar <sami.muja= war@arm.com>
> Cc: Jiewen Yao <jiewen.yao@= intel.com>
> Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
>
> Signed-off-by: Kun Qin <kun.q@= outlook.com>
> ---
>
> StandaloneMmPkg/Library/StandaloneMmMemLib/X64/StandaloneMmMe
> mLibInternal.c | 67 ++++++++++++++++++++
>
> StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib
> .inf           |&nbs= p; 6 +-
>  2 files changed, 72 insertions(+), 1 deletion(-)
>
> diff --git
> a/StandaloneMmPkg/Library/StandaloneMmMemLib/X64/StandaloneMm
> MemLibInternal.c
> b/StandaloneMmPkg/Library/StandaloneMmMemLib/X64/StandaloneMm
> MemLibInternal.c
> new file mode 100644
> index 000000000000..c5e21c583f44
> --- /dev/null
> +++
> b/StandaloneMmPkg/Library/StandaloneMmMemLib/X64/StandaloneMm
> MemLibInternal.c
> @@ -0,0 +1,67 @@
> +/** @file
> +  Internal ARCH Specific file of MM memory check library.
> +
> +  MM memory check library implementation. This library consumes<= br> > MM_ACCESS_PROTOCOL
> +  to get MMRAM information. In order to use this library instanc= e, the
> platform should produce
> +  all MMRAM range via MM_ACCESS_PROTOCOL, including the range fo= r
> firmware (like MM Core
> +  and MM driver) and/or specific dedicated hardware.
> +
> +  Copyright (c) 2015, Intel Corporation. All rights reserved.<= ;BR>
> +  Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.&l= t;BR>
> +
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +#include <Library/BaseLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/HobLib.h>
> +//
> +// Maximum support address used to check input buffer
> +//
> +extern EFI_PHYSICAL_ADDRESS
> mMmMemLibInternalMaximumSupportAddress;
> +
> +/**
> +  Calculate and save the maximum support address.
> +
> +**/
> +VOID
> +MmMemLibInternalCalculateMaximumSupportAddress (
> +  VOID
> +  )
> +{
> +  VOID         *Hob;
> +  UINT32       RegEax;
> +  UINT8        PhysicalAddres= sBits;
> +
> +  //
> +  // Get physical address bits supported.
> +  //
> +  Hob =3D GetFirstHob (EFI_HOB_TYPE_CPU);
> +  if (Hob !=3D NULL) {
> +    PhysicalAddressBits =3D ((EFI_HOB_CPU *) Hob)->= SizeOfMemorySpace;
> +  } else {
> +    AsmCpuid (0x80000000, &RegEax, NULL, NULL, NUL= L);
> +    if (RegEax >=3D 0x80000008) {
> +      AsmCpuid (0x80000008, &RegEax, NUL= L, NULL, NULL);
> +      PhysicalAddressBits =3D (UINT8) RegEax= ;
> +    } else {
> +      PhysicalAddressBits =3D 36;
> +    }
> +  }
> +  //
> +  // IA-32e paging translates 48-bit linear addresses to 52-bit = physical
> addresses.
> +  //
> +  ASSERT (PhysicalAddressBits <=3D 52);
> +  if (PhysicalAddressBits > 48) {
> +    PhysicalAddressBits =3D 48;
> +  }
> +
> +  //
> +  // Save the maximum support address in one global variable
> +  //
> +  mMmMemLibInternalMaximumSupportAddress =3D
> (EFI_PHYSICAL_ADDRESS)(UINTN)(LShiftU64 (1, PhysicalAddressBits) - 1);=
> +  DEBUG ((DEBUG_INFO, "mMmMemLibInternalMaximumSupportAddre= ss
> =3D 0x%lx\n", mMmMemLibInternalMaximumSupportAddress));
> +}
> +
> +
> diff --git
> a/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMem
> Lib.inf
> b/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMem
> Lib.inf
> index 49da02e54e6d..65ad0a48905c 100644
> ---
> a/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMem
> Lib.inf
> +++
> b/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMem
> Lib.inf
> @@ -26,12 +26,15 @@ [Defines]
>  #
>  # The following information is for reference only and not requir= ed by the
> build tools.
>  #
> -#  VALID_ARCHITECTURES       =     =3D AARCH64
> +#  VALID_ARCHITECTURES       =     =3D X64 AARCH64
>  #
>
>  [Sources.Common]
>    StandaloneMmMemLib.c
>
> +[Sources.X64]
> +  X64/StandaloneMmMemLibInternal.c
> +
>  [Sources.AARCH64]
>    AArch64/StandaloneMmMemLibInternal.c
>
> @@ -42,3 +45,4 @@ [Packages]
>  [LibraryClasses]
>    BaseMemoryLib
>    DebugLib
> +  HobLib
> --
> 2.28.0.windows.1

 

--_000_CY4PR11MB12884DC5C03B889A355735808CD90CY4PR11MB1288namp_--