From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web10.5530.1646212796036188164 for ; Wed, 02 Mar 2022 01:20:04 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=AXp1UOyS; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: yu.pu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646212804; x=1677748804; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ynNjr3U9eW7SQy8F2mbfrUbecrzpaJ+vHESqi5tYfSI=; b=AXp1UOySNryBY5Bk9qrUNGZgGPcwHIK31h2byfd8HEIlIwKlGPtg6HtF ll7MG2all+He0PUVsY12c1OvEfSc4yUio8M5lk5tPjayOYTYn1z4pNGG1 Bd13IrR01E5URoFmf0kyFHj92gQophT65PsjSkwFC0O/e6XCRmwLu9HJq bB/f90uFTEmUCPAl/IkI3CFuDKGRCVdlwuKeMs6WzFQ044b8OvvPBGXNA i5LfeldBMZLQmBcH2Wtbh0Ina4xrbFIdyqyq+cPgpzYmJkOB/4p8blU00 OEreLULSzFibqP9lX7BodbSYK0L0XgHMd2661VHHBinbHkK/PHuHQKZJy Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10273"; a="233324211" X-IronPort-AV: E=Sophos;i="5.90,148,1643702400"; d="scan'208";a="233324211" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2022 01:20:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,148,1643702400"; d="scan'208";a="641630364" Received: from shwdeopenlab704.ccr.corp.intel.com ([10.239.182.239]) by orsmga004.jf.intel.com with ESMTP; 02 Mar 2022 01:20:02 -0800 From: Yu Pu To: devel@edk2.groups.io Cc: Yu Pu , Ard Biesheuvel , Sami Mujawar , Jiewen Yao Subject: [PATCH v1 4/7] StandaloneMmPkg: Invoke GetPhysicalAddressBits() and remove the duplicated code Date: Wed, 2 Mar 2022 17:18:56 +0800 Message-Id: <20220302091859.2783-5-yu.pu@intel.com> X-Mailer: git-send-email 2.30.0.windows.2 In-Reply-To: <20220302091859.2783-1-yu.pu@intel.com> References: <20220302091859.2783-1-yu.pu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3394 Invoke GetPhysicalAddressBits() defined in UefiCpuPkg for CPU physical addr= ess mask calculation and remove the duplicated code in StandaloneMmPkg\Library\StandaloneMmMemLib\X86StandaloneMmMemLibInternal.c Cc: Ard Biesheuvel Cc: Sami Mujawar Cc: Jiewen Yao Signed-off-by: Yu Pu --- StandaloneMmPkg/Library/StandaloneMmMemLib/X86StandaloneMmMemLibInternal.c= | 10 ++-------- StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf = | 2 ++ StandaloneMmPkg/StandaloneMmPkg.dsc = | 1 + 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/StandaloneMmPkg/Library/StandaloneMmMemLib/X86StandaloneMmMemL= ibInternal.c b/StandaloneMmPkg/Library/StandaloneMmMemLib/X86StandaloneMmMe= mLibInternal.c index c309d1bc6a56..4afd9b938934 100644 --- a/StandaloneMmPkg/Library/StandaloneMmMemLib/X86StandaloneMmMemLibInter= nal.c +++ b/StandaloneMmPkg/Library/StandaloneMmMemLib/X86StandaloneMmMemLibInter= nal.c @@ -19,6 +19,7 @@ #include =0D #include =0D #include =0D +#include =0D =0D #include =0D #include =0D @@ -40,7 +41,6 @@ MmMemLibInternalCalculateMaximumSupportAddress ( )=0D {=0D VOID *Hob;=0D - UINT32 RegEax;=0D UINT8 PhysicalAddressBits;=0D =0D //=0D @@ -50,13 +50,7 @@ MmMemLibInternalCalculateMaximumSupportAddress ( if (Hob !=3D NULL) {=0D PhysicalAddressBits =3D ((EFI_HOB_CPU *)Hob)->SizeOfMemorySpace;=0D } else {=0D - AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);=0D - if (RegEax >=3D 0x80000008) {=0D - AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);=0D - PhysicalAddressBits =3D (UINT8)RegEax;=0D - } else {=0D - PhysicalAddressBits =3D 36;=0D - }=0D + PhysicalAddressBits =3D GetPhysicalAddressBits (NULL, NULL);=0D }=0D =0D //=0D diff --git a/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.= inf b/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf index b29d97a74607..94f7fbb1c4f7 100644 --- a/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf +++ b/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf @@ -43,12 +43,14 @@ [Packages]=0D MdePkg/MdePkg.dec=0D StandaloneMmPkg/StandaloneMmPkg.dec=0D + UefiCpuPkg/UefiCpuPkg.dec=0D =0D [LibraryClasses]=0D BaseMemoryLib=0D DebugLib=0D HobLib=0D MemoryAllocationLib=0D + UefiCpuLib=0D =0D [Guids]=0D gMmCoreDataHobGuid ## SOMETIMES_CONSUMES ## HOB=0D diff --git a/StandaloneMmPkg/StandaloneMmPkg.dsc b/StandaloneMmPkg/Standalo= neMmPkg.dsc index 8012f93b7dcc..41449046799f 100644 --- a/StandaloneMmPkg/StandaloneMmPkg.dsc +++ b/StandaloneMmPkg/StandaloneMmPkg.dsc @@ -59,6 +59,7 @@ StandaloneMmCoreEntryPoint|StandaloneMmPkg/Library/StandaloneMmCoreEntry= Point/StandaloneMmCoreEntryPoint.inf=0D StandaloneMmDriverEntryPoint|MdePkg/Library/StandaloneMmDriverEntryPoint= /StandaloneMmDriverEntryPoint.inf=0D VariableMmDependency|StandaloneMmPkg/Library/VariableMmDependency/Variab= leMmDependency.inf=0D + UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf=0D =0D [LibraryClasses.AARCH64, LibraryClasses.ARM]=0D ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf=0D --=20 2.30.0.windows.2