[edk2-devel] [PATCH v1 4/7] StandaloneMmPkg: Invoke GetPhysicalAddressBits() and remove the duplicated code

Yu Pu posted 7 patches 3 years, 11 months ago
There is a newer version of this series
[edk2-devel] [PATCH v1 4/7] StandaloneMmPkg: Invoke GetPhysicalAddressBits() and remove the duplicated code
Posted by Yu Pu 3 years, 11 months ago
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3394

Invoke GetPhysicalAddressBits() defined in UefiCpuPkg for CPU physical address
mask calculation and remove the duplicated code in
StandaloneMmPkg\Library\StandaloneMmMemLib\X86StandaloneMmMemLibInternal.c

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>

Signed-off-by: Yu Pu <yu.pu@intel.com>
---
 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/X86StandaloneMmMemLibInternal.c b/StandaloneMmPkg/Library/StandaloneMmMemLib/X86StandaloneMmMemLibInternal.c
index c309d1bc6a56..4afd9b938934 100644
--- a/StandaloneMmPkg/Library/StandaloneMmMemLib/X86StandaloneMmMemLibInternal.c
+++ b/StandaloneMmPkg/Library/StandaloneMmMemLib/X86StandaloneMmMemLibInternal.c
@@ -19,6 +19,7 @@
 #include <Library/MemoryAllocationLib.h>
 #include <Library/DebugLib.h>
 #include <Library/HobLib.h>
+#include <Library/UefiCpuLib.h>
 
 #include <Guid/MmCoreData.h>
 #include <Guid/MmramMemoryReserve.h>
@@ -40,7 +41,6 @@ MmMemLibInternalCalculateMaximumSupportAddress (
   )
 {
   VOID    *Hob;
-  UINT32  RegEax;
   UINT8   PhysicalAddressBits;
 
   //
@@ -50,13 +50,7 @@ MmMemLibInternalCalculateMaximumSupportAddress (
   if (Hob != NULL) {
     PhysicalAddressBits = ((EFI_HOB_CPU *)Hob)->SizeOfMemorySpace;
   } else {
-    AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);
-    if (RegEax >= 0x80000008) {
-      AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);
-      PhysicalAddressBits = (UINT8)RegEax;
-    } else {
-      PhysicalAddressBits = 36;
-    }
+    PhysicalAddressBits = GetPhysicalAddressBits (NULL, NULL);
   }
 
   //
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]
   MdePkg/MdePkg.dec
   StandaloneMmPkg/StandaloneMmPkg.dec
+  UefiCpuPkg/UefiCpuPkg.dec
 
 [LibraryClasses]
   BaseMemoryLib
   DebugLib
   HobLib
   MemoryAllocationLib
+  UefiCpuLib
 
 [Guids]
   gMmCoreDataHobGuid                  ## SOMETIMES_CONSUMES ## HOB
diff --git a/StandaloneMmPkg/StandaloneMmPkg.dsc b/StandaloneMmPkg/StandaloneMmPkg.dsc
index 8012f93b7dcc..41449046799f 100644
--- a/StandaloneMmPkg/StandaloneMmPkg.dsc
+++ b/StandaloneMmPkg/StandaloneMmPkg.dsc
@@ -59,6 +59,7 @@
   StandaloneMmCoreEntryPoint|StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
   StandaloneMmDriverEntryPoint|MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf
   VariableMmDependency|StandaloneMmPkg/Library/VariableMmDependency/VariableMmDependency.inf
+  UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf
 
 [LibraryClasses.AARCH64, LibraryClasses.ARM]
   ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
-- 
2.30.0.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#87237): https://edk2.groups.io/g/devel/message/87237
Mute This Topic: https://groups.io/mt/89503327/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v1 4/7] StandaloneMmPkg: Invoke GetPhysicalAddressBits() and remove the duplicated code
Posted by Ard Biesheuvel 3 years, 11 months ago
On Wed, 2 Mar 2022 at 09:20, Yu Pu <yu.pu@intel.com> wrote:
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3394
>
> Invoke GetPhysicalAddressBits() defined in UefiCpuPkg for CPU physical address
> mask calculation and remove the duplicated code in
> StandaloneMmPkg\Library\StandaloneMmMemLib\X86StandaloneMmMemLibInternal.c
>
> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> Cc: Sami Mujawar <sami.mujawar@arm.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
>
> Signed-off-by: Yu Pu <yu.pu@intel.com>
> ---
>  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/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]
>    MdePkg/MdePkg.dec
>    StandaloneMmPkg/StandaloneMmPkg.dec
> +  UefiCpuPkg/UefiCpuPkg.dec
>
>  [LibraryClasses]
>    BaseMemoryLib
>    DebugLib
>    HobLib
>    MemoryAllocationLib
> +  UefiCpuLib
>

Isn't this dependency X86 only?


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#87258): https://edk2.groups.io/g/devel/message/87258
Mute This Topic: https://groups.io/mt/89503327/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v1 4/7] StandaloneMmPkg: Invoke GetPhysicalAddressBits() and remove the duplicated code
Posted by Ni, Ray 3 years, 11 months ago
Agree.
Yu,
can you please add the UefiCpuLib in [LibraryClasses.IA32, LibraryClasses.X64] instead of [LibraryClasses]?

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Ard Biesheuvel
Sent: Thursday, March 3, 2022 5:58 PM
To: Pu, Yu <yu.pu@intel.com>
Cc: edk2-devel-groups-io <devel@edk2.groups.io>; Ard Biesheuvel <ardb+tianocore@kernel.org>; Sami Mujawar <sami.mujawar@arm.com>; Yao, Jiewen <jiewen.yao@intel.com>
Subject: Re: [edk2-devel] [PATCH v1 4/7] StandaloneMmPkg: Invoke GetPhysicalAddressBits() and remove the duplicated code

On Wed, 2 Mar 2022 at 09:20, Yu Pu <yu.pu@intel.com> wrote:
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3394
>
> Invoke GetPhysicalAddressBits() defined in UefiCpuPkg for CPU physical 
> address mask calculation and remove the duplicated code in 
> StandaloneMmPkg\Library\StandaloneMmMemLib\X86StandaloneMmMemLibIntern
> al.c
>
> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> Cc: Sami Mujawar <sami.mujawar@arm.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
>
> Signed-off-by: Yu Pu <yu.pu@intel.com>
> ---
>  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/StandaloneMmMemLib.inf 
> b/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf
> index b29d97a74607..94f7fbb1c4f7 100644
> --- 
> a/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf
> +++ b/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.in
> +++ f
> @@ -43,12 +43,14 @@
>  [Packages]
>    MdePkg/MdePkg.dec
>    StandaloneMmPkg/StandaloneMmPkg.dec
> +  UefiCpuPkg/UefiCpuPkg.dec
>
>  [LibraryClasses]
>    BaseMemoryLib
>    DebugLib
>    HobLib
>    MemoryAllocationLib
> +  UefiCpuLib
>

Isn't this dependency X86 only?







-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#87280): https://edk2.groups.io/g/devel/message/87280
Mute This Topic: https://groups.io/mt/89503327/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-