* [PATCH v1 1/7] UefiCpuPackage: Add APIs for CPU physical address mask calculation
2022-03-02 9:18 [PATCH v1 0/7] *** SUBJECT HERE *** Yu Pu
@ 2022-03-02 9:18 ` Yu Pu
2022-03-02 9:18 ` [PATCH v1 2/7] MdeModulePkg: Invoke GetPhysicalAddressBits() and remove the duplicated code Yu Pu
` (5 subsequent siblings)
6 siblings, 0 replies; 16+ messages in thread
From: Yu Pu @ 2022-03-02 9:18 UTC (permalink / raw)
To: devel; +Cc: Yu Pu, Eric Dong, Ray Ni
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3394
Add API named GetPhysicalAddressBits() for CPU physical address mask
calculation, and remove the duplicated code in UefiCpuPackage.
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Yu Pu <yu.pu@intel.com>
---
UefiCpuPkg/CpuDxe/CpuDxe.c | 16 +------
UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c | 47 ++++++++++++++++++++
UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c | 9 +---
UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c | 9 +---
UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 9 +---
UefiCpuPkg/Include/Library/UefiCpuLib.h | 17 +++++++
6 files changed, 70 insertions(+), 37 deletions(-)
diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.c b/UefiCpuPkg/CpuDxe/CpuDxe.c
index 00f3cb09572c..8aca1bf72b4c 100644
--- a/UefiCpuPkg/CpuDxe/CpuDxe.c
+++ b/UefiCpuPkg/CpuDxe/CpuDxe.c
@@ -503,21 +503,7 @@ InitializeMtrrMask (
VOID
)
{
- UINT32 RegEax;
- UINT8 PhysicalAddressBits;
-
- AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);
-
- if (RegEax >= 0x80000008) {
- AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);
-
- PhysicalAddressBits = (UINT8)RegEax;
- } else {
- PhysicalAddressBits = 36;
- }
-
- mValidMtrrBitsMask = LShiftU64 (1, PhysicalAddressBits) - 1;
- mValidMtrrAddressMask = mValidMtrrBitsMask & 0xfffffffffffff000ULL;
+ GetPhysicalAddressBits(&mValidMtrrBitsMask, &mValidMtrrAddressMask);
}
/**
diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c b/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c
index 5d925bc273f8..bb1343f3cd21 100644
--- a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c
+++ b/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c
@@ -79,3 +79,50 @@ GetCpuSteppingId (
return (UINT8)Eax.Bits.SteppingId;
}
+
+/**
+ Get the physical address width supported by the processor.
+ @param[out] ValidAddressMask Bitmask with valid address bits set to
+ one; other bits are clear. Optional
+ parameter.
+ @param[out] ValidPageBaseAddressMask Bitmask with valid page base address
+ bits set to one; other bits are clear.
+ Optional parameter.
+ @return The physical address width supported by the processor.
+**/
+UINT8
+EFIAPI
+GetPhysicalAddressBits (
+ OUT UINT64 *ValidAddressMask OPTIONAL,
+ OUT UINT64 *ValidPageBaseAddressMask OPTIONAL
+ )
+{
+ UINT32 MaxExtendedFunction;
+ CPUID_VIR_PHY_ADDRESS_SIZE_EAX VirPhyAddressSize;
+ UINT64 AddressMask;
+ UINT64 PageBaseAddressMask;
+
+ AsmCpuid (CPUID_EXTENDED_FUNCTION, &MaxExtendedFunction, NULL, NULL, NULL);
+ if (MaxExtendedFunction >= CPUID_VIR_PHY_ADDRESS_SIZE) {
+ AsmCpuid (
+ CPUID_VIR_PHY_ADDRESS_SIZE,
+ &VirPhyAddressSize.Uint32,
+ NULL,
+ NULL,
+ NULL
+ );
+ } else {
+ VirPhyAddressSize.Bits.PhysicalAddressBits = 36;
+ }
+
+ AddressMask = LShiftU64 (1, VirPhyAddressSize.Bits.PhysicalAddressBits) - 1;
+ PageBaseAddressMask = AddressMask & ~(UINT64)0xFFF;
+
+ if (ValidAddressMask != NULL) {
+ *ValidAddressMask = AddressMask;
+ }
+ if (ValidPageBaseAddressMask != NULL) {
+ *ValidPageBaseAddressMask = PageBaseAddressMask;
+ }
+ return (UINT8)VirPhyAddressSize.Bits.PhysicalAddressBits;
+}
diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c
index 4e8f897f5e9c..ec7cd4013132 100644
--- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c
@@ -15,6 +15,7 @@
#include <Library/UefiBootServicesTableLib.h>
#include <Library/SmmServicesTableLib.h>
#include <Library/TpmMeasurementLib.h>
+#include <Library/UefiCpuLib.h>
#include <Register/Intel/Cpuid.h>
#include <Register/Intel/ArchitecturalMsr.h>
#include <Register/Intel/SmramSaveStateMap.h>
@@ -330,13 +331,7 @@ SmmCpuFeaturesInstallSmiHandler (
if (Hob != NULL) {
Psd->PhysicalAddressBits = ((EFI_HOB_CPU *)Hob)->SizeOfMemorySpace;
} else {
- AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);
- if (RegEax >= 0x80000008) {
- AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);
- Psd->PhysicalAddressBits = (UINT8)RegEax;
- } else {
- Psd->PhysicalAddressBits = 36;
- }
+ Psd->PhysicalAddressBits = GetPhysicalAddressBits (NULL, NULL);
}
if (!mStmConfigurationTableInitialized) {
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
index 538394f23910..de1385a86948 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
@@ -194,7 +194,6 @@ CalculateMaximumSupportAddress (
VOID
)
{
- UINT32 RegEax;
UINT8 PhysicalAddressBits;
VOID *Hob;
@@ -205,13 +204,7 @@ CalculateMaximumSupportAddress (
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);
}
return PhysicalAddressBits;
diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
index 8419a4e32acb..1017f0316093 100644
--- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
+++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
@@ -42,6 +42,7 @@
#include <Library/HobLib.h>
#include <Library/LockBoxLib.h>
#include <IndustryStandard/Acpi.h>
+#include <Library/UefiCpuLib.h>
/**
This macro aligns the address of a variable with auto storage
@@ -646,13 +647,7 @@ RestoreS3PageTables (
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/UefiCpuPkg/Include/Library/UefiCpuLib.h b/UefiCpuPkg/Include/Library/UefiCpuLib.h
index 0ff4a35774c1..dabed95ab38a 100644
--- a/UefiCpuPkg/Include/Library/UefiCpuLib.h
+++ b/UefiCpuPkg/Include/Library/UefiCpuLib.h
@@ -62,4 +62,21 @@ GetCpuSteppingId (
VOID
);
+/**
+ Get the physical address width supported by the processor.
+ @param[out] ValidAddressMask Bitmask with valid address bits set to
+ one; other bits are clear. Optional
+ parameter.
+ @param[out] ValidPageBaseAddressMask Bitmask with valid page base address
+ bits set to one; other bits are clear.
+ Optional parameter.
+ @return The physical address width supported by the processor.
+**/
+UINT8
+EFIAPI
+GetPhysicalAddressBits (
+ OUT UINT64 *ValidAddressMask OPTIONAL,
+ OUT UINT64 *ValidPageBaseAddressMask OPTIONAL
+ );
+
#endif
--
2.30.0.windows.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v1 2/7] MdeModulePkg: Invoke GetPhysicalAddressBits() and remove the duplicated code
2022-03-02 9:18 [PATCH v1 0/7] *** SUBJECT HERE *** Yu Pu
2022-03-02 9:18 ` [PATCH v1 1/7] UefiCpuPackage: Add APIs for CPU physical address mask calculation Yu Pu
@ 2022-03-02 9:18 ` Yu Pu
2022-03-07 3:54 ` [edk2-devel] " Ni, Ray
2022-03-02 9:18 ` [PATCH v1 3/7] IntelFsp2Pkg: " Yu Pu
` (4 subsequent siblings)
6 siblings, 1 reply; 16+ messages in thread
From: Yu Pu @ 2022-03-02 9:18 UTC (permalink / raw)
To: devel; +Cc: Yu Pu, Jian J Wang, Liming Gao
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 MdeModulePkg.
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Yu Pu <yu.pu@intel.com>
---
MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c | 9 ++-------
MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c | 14 ++------------
MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c | 14 ++------------
MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf | 2 ++
MdeModulePkg/MdeModulePkg.dsc | 1 +
MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf | 2 ++
MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf | 2 ++
7 files changed, 13 insertions(+), 31 deletions(-)
diff --git a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
index 0700f310b203..78e91e6e9024 100644
--- a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
+++ b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
@@ -22,6 +22,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
+#include <Library/UefiCpuLib.h>
#include <Register/Intel/Cpuid.h>
#include "DxeIpl.h"
#include "VirtualMemory.h"
@@ -733,13 +734,7 @@ CreateIdentityMappingPageTables (
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);
}
Page5LevelSupport = FALSE;
diff --git a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c
index 6b44f50bac70..367bf8cdd1e6 100644
--- a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c
+++ b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c
@@ -10,6 +10,7 @@ Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
+#include <Library/UefiCpuLib.h>
#include "ScriptExecute.h"
//
@@ -51,20 +52,9 @@ HookPageFaultHandler (
IN IA32_IDT_GATE_DESCRIPTOR *IdtEntry
)
{
- UINT32 RegEax;
- UINT8 PhysicalAddressBits;
UINTN PageFaultHandlerHookAddress;
- AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);
- if (RegEax >= 0x80000008) {
- AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);
- PhysicalAddressBits = (UINT8)RegEax;
- } else {
- PhysicalAddressBits = 36;
- }
-
- mPhyMask = LShiftU64 (1, PhysicalAddressBits) - 1;
- mPhyMask &= (1ull << 48) - SIZE_4KB;
+ GetPhysicalAddressBits(NULL, &mPhyMask);
//
// Set Page Fault entry to catch >4G access
diff --git a/MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c b/MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c
index 05941f9f8d56..06d6129c5e6d 100644
--- a/MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c
+++ b/MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c
@@ -12,6 +12,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/BaseMemoryLib.h>
#include <Library/CpuExceptionHandlerLib.h>
#include <Library/DebugAgentLib.h>
+#include <Library/UefiCpuLib.h>
#include "CommonHeader.h"
#define EXCEPTION_VECTOR_NUMBER 0x22
@@ -61,20 +62,9 @@ HookPageFaultHandler (
IN OUT PAGE_FAULT_CONTEXT *PageFaultContext
)
{
- UINT32 RegEax;
- UINT8 PhysicalAddressBits;
UINTN PageFaultHandlerHookAddress;
- AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);
- if (RegEax >= 0x80000008) {
- AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);
- PhysicalAddressBits = (UINT8)RegEax;
- } else {
- PhysicalAddressBits = 36;
- }
-
- PageFaultContext->PhyMask = LShiftU64 (1, PhysicalAddressBits) - 1;
- PageFaultContext->PhyMask &= (1ull << 48) - SIZE_4KB;
+ GetPhysicalAddressBits(NULL, &(PageFaultContext->PhyMask));
//
// Set Page Fault entry to catch >4G access
diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
index 19b8a4c8aefa..45808bcdcd6c 100644
--- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
+++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
@@ -55,6 +55,7 @@
[Packages]
MdePkg/MdePkg.dec
+ UefiCpuPkg/UefiCpuPkg.dec
MdeModulePkg/MdeModulePkg.dec
[Packages.ARM, Packages.AARCH64]
@@ -75,6 +76,7 @@
DebugAgentLib
PeiServicesTablePointerLib
PerformanceLib
+ UefiCpuLib
[LibraryClasses.ARM, LibraryClasses.AARCH64]
ArmMmuLib
diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index b1d83461865e..da6213c02da0 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -62,6 +62,7 @@
DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf
UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
+ UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf
#
# Generic Modules
#
diff --git a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf
index fb149c2f0271..dd3dd2fc8c10 100644
--- a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf
+++ b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf
@@ -41,6 +41,7 @@
[Packages]
MdePkg/MdePkg.dec
+ UefiCpuPkg/UefiCpuPkg.dec
MdeModulePkg/MdeModulePkg.dec
[LibraryClasses]
@@ -54,6 +55,7 @@
UefiBootServicesTableLib
CacheMaintenanceLib
UefiLib
+ UefiCpuLib
DebugAgentLib
LockBoxLib
CpuExceptionHandlerLib
diff --git a/MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf b/MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf
index 35d2535a5b48..75813b1e5481 100644
--- a/MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf
+++ b/MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf
@@ -38,12 +38,14 @@
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
+ UefiCpuPkg/UefiCpuPkg.dec
[LibraryClasses]
BaseLib
DebugLib
CpuExceptionHandlerLib
DebugAgentLib
+ UefiCpuLib
[Depex]
FALSE
--
2.30.0.windows.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [PATCH v1 2/7] MdeModulePkg: Invoke GetPhysicalAddressBits() and remove the duplicated code
2022-03-02 9:18 ` [PATCH v1 2/7] MdeModulePkg: Invoke GetPhysicalAddressBits() and remove the duplicated code Yu Pu
@ 2022-03-07 3:54 ` Ni, Ray
2022-03-10 8:47 ` Pu, Yu
0 siblings, 1 reply; 16+ messages in thread
From: Ni, Ray @ 2022-03-07 3:54 UTC (permalink / raw)
To: Kinney, Michael D, Gao, Liming
Cc: Wang, Jian J, Gao, Liming, devel@edk2.groups.io, Pu, Yu
Mike, Liming,
This patch makes MdeModulePkg depend on UefiCpuPkg.
But according to https://github.com/tianocore/edk2/blob/master/MdeModulePkg/MdeModulePkg.ci.yaml#L49, such dependency is not allowed.
Do you agree to move the UefiCpuLib from UefiCpuPkg to MdePkg? The library header and instance are in following paths:
https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/Include/Library/UefiCpuLib.h
https://github.com/tianocore/edk2/tree/master/UefiCpuPkg/Library/BaseUefiCpuLib
Thanks,
Ray
-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Yu Pu
Sent: Wednesday, March 2, 2022 5:19 PM
To: devel@edk2.groups.io
Cc: Pu, Yu <yu.pu@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>
Subject: [edk2-devel] [PATCH v1 2/7] MdeModulePkg: Invoke GetPhysicalAddressBits() and remove the duplicated code
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 MdeModulePkg.
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Yu Pu <yu.pu@intel.com>
---
MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c | 9 ++-------
MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c | 14 ++------------
MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c | 14 ++------------
MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf | 2 ++
MdeModulePkg/MdeModulePkg.dsc | 1 +
MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf | 2 ++
MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf | 2 ++
7 files changed, 13 insertions(+), 31 deletions(-)
diff --git a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
index 0700f310b203..78e91e6e9024 100644
--- a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
+++ b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
@@ -22,6 +22,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
+#include <Library/UefiCpuLib.h>
#include <Register/Intel/Cpuid.h>
#include "DxeIpl.h"
#include "VirtualMemory.h"
@@ -733,13 +734,7 @@ CreateIdentityMappingPageTables (
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);
}
Page5LevelSupport = FALSE;
diff --git a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c
index 6b44f50bac70..367bf8cdd1e6 100644
--- a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c
+++ b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c
@@ -10,6 +10,7 @@ Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
+#include <Library/UefiCpuLib.h>
#include "ScriptExecute.h"
//
@@ -51,20 +52,9 @@ HookPageFaultHandler (
IN IA32_IDT_GATE_DESCRIPTOR *IdtEntry
)
{
- UINT32 RegEax;
- UINT8 PhysicalAddressBits;
UINTN PageFaultHandlerHookAddress;
- AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);
- if (RegEax >= 0x80000008) {
- AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);
- PhysicalAddressBits = (UINT8)RegEax;
- } else {
- PhysicalAddressBits = 36;
- }
-
- mPhyMask = LShiftU64 (1, PhysicalAddressBits) - 1;
- mPhyMask &= (1ull << 48) - SIZE_4KB;
+ GetPhysicalAddressBits(NULL, &mPhyMask);
//
// Set Page Fault entry to catch >4G access
diff --git a/MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c b/MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c
index 05941f9f8d56..06d6129c5e6d 100644
--- a/MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c
+++ b/MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c
@@ -12,6 +12,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/BaseMemoryLib.h>
#include <Library/CpuExceptionHandlerLib.h>
#include <Library/DebugAgentLib.h>
+#include <Library/UefiCpuLib.h>
#include "CommonHeader.h"
#define EXCEPTION_VECTOR_NUMBER 0x22
@@ -61,20 +62,9 @@ HookPageFaultHandler (
IN OUT PAGE_FAULT_CONTEXT *PageFaultContext
)
{
- UINT32 RegEax;
- UINT8 PhysicalAddressBits;
UINTN PageFaultHandlerHookAddress;
- AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);
- if (RegEax >= 0x80000008) {
- AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);
- PhysicalAddressBits = (UINT8)RegEax;
- } else {
- PhysicalAddressBits = 36;
- }
-
- PageFaultContext->PhyMask = LShiftU64 (1, PhysicalAddressBits) - 1;
- PageFaultContext->PhyMask &= (1ull << 48) - SIZE_4KB;
+ GetPhysicalAddressBits(NULL, &(PageFaultContext->PhyMask));
//
// Set Page Fault entry to catch >4G access
diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
index 19b8a4c8aefa..45808bcdcd6c 100644
--- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
+++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
@@ -55,6 +55,7 @@
[Packages]
MdePkg/MdePkg.dec
+ UefiCpuPkg/UefiCpuPkg.dec
MdeModulePkg/MdeModulePkg.dec
[Packages.ARM, Packages.AARCH64]
@@ -75,6 +76,7 @@
DebugAgentLib
PeiServicesTablePointerLib
PerformanceLib
+ UefiCpuLib
[LibraryClasses.ARM, LibraryClasses.AARCH64]
ArmMmuLib
diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index b1d83461865e..da6213c02da0 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -62,6 +62,7 @@
DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf
UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
+ UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf
#
# Generic Modules
#
diff --git a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf
index fb149c2f0271..dd3dd2fc8c10 100644
--- a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf
+++ b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf
@@ -41,6 +41,7 @@
[Packages]
MdePkg/MdePkg.dec
+ UefiCpuPkg/UefiCpuPkg.dec
MdeModulePkg/MdeModulePkg.dec
[LibraryClasses]
@@ -54,6 +55,7 @@
UefiBootServicesTableLib
CacheMaintenanceLib
UefiLib
+ UefiCpuLib
DebugAgentLib
LockBoxLib
CpuExceptionHandlerLib
diff --git a/MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf b/MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf
index 35d2535a5b48..75813b1e5481 100644
--- a/MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf
+++ b/MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf
@@ -38,12 +38,14 @@
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
+ UefiCpuPkg/UefiCpuPkg.dec
[LibraryClasses]
BaseLib
DebugLib
CpuExceptionHandlerLib
DebugAgentLib
+ UefiCpuLib
[Depex]
FALSE
--
2.30.0.windows.2
-=-=-=-=-=-=
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#87235): https://edk2.groups.io/g/devel/message/87235
Mute This Topic: https://groups.io/mt/89503325/1712937
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [ray.ni@intel.com]
-=-=-=-=-=-=
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [PATCH v1 2/7] MdeModulePkg: Invoke GetPhysicalAddressBits() and remove the duplicated code
2022-03-07 3:54 ` [edk2-devel] " Ni, Ray
@ 2022-03-10 8:47 ` Pu, Yu
2022-03-11 1:02 ` 回复: " gaoliming
0 siblings, 1 reply; 16+ messages in thread
From: Pu, Yu @ 2022-03-10 8:47 UTC (permalink / raw)
To: Ni, Ray, Kinney, Michael D, Gao, Liming
Cc: Wang, Jian J, Gao, Liming, devel@edk2.groups.io
Hi, Mike, Liming,
This patch makes MdeModulePkg depend on UefiCpuPkg.
Ray and me would like to move the UefiCpuLib from UefiCpuPkg to MdePkg, do you agree with it ?
Thanks,
Yu
-----Original Message-----
From: Ni, Ray <ray.ni@intel.com>
Sent: Monday, March 7, 2022 11:55 AM
To: Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>
Cc: Wang, Jian J <jian.j.wang@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>; devel@edk2.groups.io; Pu, Yu <yu.pu@intel.com>
Subject: RE: [edk2-devel] [PATCH v1 2/7] MdeModulePkg: Invoke GetPhysicalAddressBits() and remove the duplicated code
Mike, Liming,
This patch makes MdeModulePkg depend on UefiCpuPkg.
But according to https://github.com/tianocore/edk2/blob/master/MdeModulePkg/MdeModulePkg.ci.yaml#L49, such dependency is not allowed.
Do you agree to move the UefiCpuLib from UefiCpuPkg to MdePkg? The library header and instance are in following paths:
https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/Include/Library/UefiCpuLib.h
https://github.com/tianocore/edk2/tree/master/UefiCpuPkg/Library/BaseUefiCpuLib
Thanks,
Ray
-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Yu Pu
Sent: Wednesday, March 2, 2022 5:19 PM
To: devel@edk2.groups.io
Cc: Pu, Yu <yu.pu@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>
Subject: [edk2-devel] [PATCH v1 2/7] MdeModulePkg: Invoke GetPhysicalAddressBits() and remove the duplicated code
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 MdeModulePkg.
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Yu Pu <yu.pu@intel.com>
---
MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c | 9 ++-------
MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c | 14 ++------------
MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c | 14 ++------------
MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf | 2 ++
MdeModulePkg/MdeModulePkg.dsc | 1 +
MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf | 2 ++
MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf | 2 ++
7 files changed, 13 insertions(+), 31 deletions(-)
diff --git a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
index 0700f310b203..78e91e6e9024 100644
--- a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
+++ b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
@@ -22,6 +22,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
+#include <Library/UefiCpuLib.h>
#include <Register/Intel/Cpuid.h>
#include "DxeIpl.h"
#include "VirtualMemory.h"
@@ -733,13 +734,7 @@ CreateIdentityMappingPageTables (
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);
}
Page5LevelSupport = FALSE;
diff --git a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c
index 6b44f50bac70..367bf8cdd1e6 100644
--- a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c
+++ b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.
+++ c
@@ -10,6 +10,7 @@ Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
+#include <Library/UefiCpuLib.h>
#include "ScriptExecute.h"
//
@@ -51,20 +52,9 @@ HookPageFaultHandler (
IN IA32_IDT_GATE_DESCRIPTOR *IdtEntry
)
{
- UINT32 RegEax;
- UINT8 PhysicalAddressBits;
UINTN PageFaultHandlerHookAddress;
- AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);
- if (RegEax >= 0x80000008) {
- AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);
- PhysicalAddressBits = (UINT8)RegEax;
- } else {
- PhysicalAddressBits = 36;
- }
-
- mPhyMask = LShiftU64 (1, PhysicalAddressBits) - 1;
- mPhyMask &= (1ull << 48) - SIZE_4KB;
+ GetPhysicalAddressBits(NULL, &mPhyMask);
//
// Set Page Fault entry to catch >4G access
diff --git a/MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c b/MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c
index 05941f9f8d56..06d6129c5e6d 100644
--- a/MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c
+++ b/MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c
@@ -12,6 +12,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include <Library/BaseMemoryLib.h>
#include <Library/CpuExceptionHandlerLib.h>
#include <Library/DebugAgentLib.h>
+#include <Library/UefiCpuLib.h>
#include "CommonHeader.h"
#define EXCEPTION_VECTOR_NUMBER 0x22
@@ -61,20 +62,9 @@ HookPageFaultHandler (
IN OUT PAGE_FAULT_CONTEXT *PageFaultContext
)
{
- UINT32 RegEax;
- UINT8 PhysicalAddressBits;
UINTN PageFaultHandlerHookAddress;
- AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);
- if (RegEax >= 0x80000008) {
- AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);
- PhysicalAddressBits = (UINT8)RegEax;
- } else {
- PhysicalAddressBits = 36;
- }
-
- PageFaultContext->PhyMask = LShiftU64 (1, PhysicalAddressBits) - 1;
- PageFaultContext->PhyMask &= (1ull << 48) - SIZE_4KB;
+ GetPhysicalAddressBits(NULL, &(PageFaultContext->PhyMask));
//
// Set Page Fault entry to catch >4G access
diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
index 19b8a4c8aefa..45808bcdcd6c 100644
--- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
+++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
@@ -55,6 +55,7 @@
[Packages]
MdePkg/MdePkg.dec
+ UefiCpuPkg/UefiCpuPkg.dec
MdeModulePkg/MdeModulePkg.dec
[Packages.ARM, Packages.AARCH64]
@@ -75,6 +76,7 @@
DebugAgentLib
PeiServicesTablePointerLib
PerformanceLib
+ UefiCpuLib
[LibraryClasses.ARM, LibraryClasses.AARCH64]
ArmMmuLib
diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc index b1d83461865e..da6213c02da0 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -62,6 +62,7 @@
DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf
UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
+ UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf
#
# Generic Modules
#
diff --git a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf
index fb149c2f0271..dd3dd2fc8c10 100644
--- a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf
+++ b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecut
+++ orDxe.inf
@@ -41,6 +41,7 @@
[Packages]
MdePkg/MdePkg.dec
+ UefiCpuPkg/UefiCpuPkg.dec
MdeModulePkg/MdeModulePkg.dec
[LibraryClasses]
@@ -54,6 +55,7 @@
UefiBootServicesTableLib
CacheMaintenanceLib
UefiLib
+ UefiCpuLib
DebugAgentLib
LockBoxLib
CpuExceptionHandlerLib
diff --git a/MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf b/MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf
index 35d2535a5b48..75813b1e5481 100644
--- a/MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf
+++ b/MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf
@@ -38,12 +38,14 @@
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
+ UefiCpuPkg/UefiCpuPkg.dec
[LibraryClasses]
BaseLib
DebugLib
CpuExceptionHandlerLib
DebugAgentLib
+ UefiCpuLib
[Depex]
FALSE
--
2.30.0.windows.2
-=-=-=-=-=-=
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#87235): https://edk2.groups.io/g/devel/message/87235
Mute This Topic: https://groups.io/mt/89503325/1712937
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [ray.ni@intel.com]
-=-=-=-=-=-=
^ permalink raw reply related [flat|nested] 16+ messages in thread
* 回复: [edk2-devel] [PATCH v1 2/7] MdeModulePkg: Invoke GetPhysicalAddressBits() and remove the duplicated code
2022-03-10 8:47 ` Pu, Yu
@ 2022-03-11 1:02 ` gaoliming
0 siblings, 0 replies; 16+ messages in thread
From: gaoliming @ 2022-03-11 1:02 UTC (permalink / raw)
To: devel, yu.pu, 'Ni, Ray', 'Kinney, Michael D'
Cc: 'Wang, Jian J', gaoliming
Yu and Ray:
I review UefiCpuLib. I think they are generic enough (X86 arch) to be
placed in MdePkg.
Mike:
What's your comments for this proposal?
Thanks
Liming
> -----邮件原件-----
> 发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Pu, Yu
> 发送时间: 2022年3月10日 16:47
> 收件人: Ni, Ray <ray.ni@intel.com>; Kinney, Michael D
> <michael.d.kinney@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>
> 抄送: Wang, Jian J <jian.j.wang@intel.com>; Gao, Liming
> <gaoliming@byosoft.com.cn>; devel@edk2.groups.io
> 主题: Re: [edk2-devel] [PATCH v1 2/7] MdeModulePkg: Invoke
> GetPhysicalAddressBits() and remove the duplicated code
>
> Hi, Mike, Liming,
>
> This patch makes MdeModulePkg depend on UefiCpuPkg.
> Ray and me would like to move the UefiCpuLib from UefiCpuPkg to MdePkg,
> do you agree with it ?
>
> Thanks,
> Yu
>
> -----Original Message-----
> From: Ni, Ray <ray.ni@intel.com>
> Sent: Monday, March 7, 2022 11:55 AM
> To: Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming
> <gaoliming@byosoft.com.cn>
> Cc: Wang, Jian J <jian.j.wang@intel.com>; Gao, Liming
> <gaoliming@byosoft.com.cn>; devel@edk2.groups.io; Pu, Yu
> <yu.pu@intel.com>
> Subject: RE: [edk2-devel] [PATCH v1 2/7] MdeModulePkg: Invoke
> GetPhysicalAddressBits() and remove the duplicated code
>
> Mike, Liming,
> This patch makes MdeModulePkg depend on UefiCpuPkg.
> But according to
> https://github.com/tianocore/edk2/blob/master/MdeModulePkg/MdeModul
> ePkg.ci.yaml#L49, such dependency is not allowed.
>
> Do you agree to move the UefiCpuLib from UefiCpuPkg to MdePkg? The
> library header and instance are in following paths:
>
> https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/Include/Library
> /UefiCpuLib.h
>
> https://github.com/tianocore/edk2/tree/master/UefiCpuPkg/Library/BaseUe
> fiCpuLib
>
> Thanks,
> Ray
>
>
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Yu Pu
> Sent: Wednesday, March 2, 2022 5:19 PM
> To: devel@edk2.groups.io
> Cc: Pu, Yu <yu.pu@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Gao,
> Liming <gaoliming@byosoft.com.cn>
> Subject: [edk2-devel] [PATCH v1 2/7] MdeModulePkg: Invoke
> GetPhysicalAddressBits() and remove the duplicated code
>
> 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 MdeModulePkg.
>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
>
> Signed-off-by: Yu Pu <yu.pu@intel.com>
> ---
> MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
> | 9 ++-------
> MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c
> | 14 ++------------
> MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c
> | 14 ++------------
> MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
> | 2 ++
> MdeModulePkg/MdeModulePkg.dsc
> | 1 +
>
> MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDx
> e.inf | 2 ++
> MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf
> | 2 ++
> 7 files changed, 13 insertions(+), 31 deletions(-)
>
> diff --git a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
> b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
> index 0700f310b203..78e91e6e9024 100644
> --- a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
> +++ b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
> @@ -22,6 +22,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
>
>
> **/
>
>
>
> +#include <Library/UefiCpuLib.h>
>
> #include <Register/Intel/Cpuid.h>
>
> #include "DxeIpl.h"
>
> #include "VirtualMemory.h"
>
> @@ -733,13 +734,7 @@ CreateIdentityMappingPageTables (
> 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);
>
> }
>
>
>
> Page5LevelSupport = FALSE;
>
> diff --git
> a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c
> b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c
> index 6b44f50bac70..367bf8cdd1e6 100644
> ---
> a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c
> +++
> b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.
> +++ c
> @@ -10,6 +10,7 @@ Copyright (c) 2017, AMD Incorporated. All rights
> reserved.<BR>
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
>
>
> **/
>
> +#include <Library/UefiCpuLib.h>
>
> #include "ScriptExecute.h"
>
>
>
> //
>
> @@ -51,20 +52,9 @@ HookPageFaultHandler (
> IN IA32_IDT_GATE_DESCRIPTOR *IdtEntry
>
> )
>
> {
>
> - UINT32 RegEax;
>
> - UINT8 PhysicalAddressBits;
>
> UINTN PageFaultHandlerHookAddress;
>
>
>
> - AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);
>
> - if (RegEax >= 0x80000008) {
>
> - AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);
>
> - PhysicalAddressBits = (UINT8)RegEax;
>
> - } else {
>
> - PhysicalAddressBits = 36;
>
> - }
>
> -
>
> - mPhyMask = LShiftU64 (1, PhysicalAddressBits) - 1;
>
> - mPhyMask &= (1ull << 48) - SIZE_4KB;
>
> + GetPhysicalAddressBits(NULL, &mPhyMask);
>
>
>
> //
>
> // Set Page Fault entry to catch >4G access
>
> diff --git a/MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c
> b/MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c
> index 05941f9f8d56..06d6129c5e6d 100644
> --- a/MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c
> +++ b/MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c
> @@ -12,6 +12,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> #include <Library/BaseMemoryLib.h>
>
> #include <Library/CpuExceptionHandlerLib.h>
>
> #include <Library/DebugAgentLib.h>
>
> +#include <Library/UefiCpuLib.h>
>
> #include "CommonHeader.h"
>
>
>
> #define EXCEPTION_VECTOR_NUMBER 0x22
>
> @@ -61,20 +62,9 @@ HookPageFaultHandler (
> IN OUT PAGE_FAULT_CONTEXT *PageFaultContext
>
> )
>
> {
>
> - UINT32 RegEax;
>
> - UINT8 PhysicalAddressBits;
>
> UINTN PageFaultHandlerHookAddress;
>
>
>
> - AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);
>
> - if (RegEax >= 0x80000008) {
>
> - AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);
>
> - PhysicalAddressBits = (UINT8)RegEax;
>
> - } else {
>
> - PhysicalAddressBits = 36;
>
> - }
>
> -
>
> - PageFaultContext->PhyMask = LShiftU64 (1, PhysicalAddressBits) - 1;
>
> - PageFaultContext->PhyMask &= (1ull << 48) - SIZE_4KB;
>
> + GetPhysicalAddressBits(NULL, &(PageFaultContext->PhyMask));
>
>
>
> //
>
> // Set Page Fault entry to catch >4G access
>
> diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
> b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
> index 19b8a4c8aefa..45808bcdcd6c 100644
> --- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
> +++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
> @@ -55,6 +55,7 @@
>
>
> [Packages]
>
> MdePkg/MdePkg.dec
>
> + UefiCpuPkg/UefiCpuPkg.dec
>
> MdeModulePkg/MdeModulePkg.dec
>
>
>
> [Packages.ARM, Packages.AARCH64]
>
> @@ -75,6 +76,7 @@
> DebugAgentLib
>
> PeiServicesTablePointerLib
>
> PerformanceLib
>
> + UefiCpuLib
>
>
>
> [LibraryClasses.ARM, LibraryClasses.AARCH64]
>
> ArmMmuLib
>
> diff --git a/MdeModulePkg/MdeModulePkg.dsc
> b/MdeModulePkg/MdeModulePkg.dsc index b1d83461865e..da6213c02da0
> 100644
> --- a/MdeModulePkg/MdeModulePkg.dsc
> +++ b/MdeModulePkg/MdeModulePkg.dsc
> @@ -62,6 +62,7 @@
>
> DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableL
> ib.inf
>
>
> UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBoot
> ManagerLib.inf
>
>
> VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib
> .inf
>
> + UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf
>
> #
>
> # Generic Modules
>
> #
>
> diff --git
> a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutor
> Dxe.inf
> b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutor
> Dxe.inf
> index fb149c2f0271..dd3dd2fc8c10 100644
> ---
> a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutor
> Dxe.inf
> +++
> b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecut
> +++ orDxe.inf
> @@ -41,6 +41,7 @@
>
>
> [Packages]
>
> MdePkg/MdePkg.dec
>
> + UefiCpuPkg/UefiCpuPkg.dec
>
> MdeModulePkg/MdeModulePkg.dec
>
>
>
> [LibraryClasses]
>
> @@ -54,6 +55,7 @@
> UefiBootServicesTableLib
>
> CacheMaintenanceLib
>
> UefiLib
>
> + UefiCpuLib
>
> DebugAgentLib
>
> LockBoxLib
>
> CpuExceptionHandlerLib
>
> diff --git a/MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf
> b/MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf
> index 35d2535a5b48..75813b1e5481 100644
> --- a/MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf
> +++ b/MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf
> @@ -38,12 +38,14 @@
> [Packages]
>
> MdePkg/MdePkg.dec
>
> MdeModulePkg/MdeModulePkg.dec
>
> + UefiCpuPkg/UefiCpuPkg.dec
>
>
>
> [LibraryClasses]
>
> BaseLib
>
> DebugLib
>
> CpuExceptionHandlerLib
>
> DebugAgentLib
>
> + UefiCpuLib
>
>
>
> [Depex]
>
> FALSE
>
> --
> 2.30.0.windows.2
>
>
>
> -=-=-=-=-=-=
> Groups.io Links: You receive all messages sent to this group.
> View/Reply Online (#87235): https://edk2.groups.io/g/devel/message/87235
> Mute This Topic: https://groups.io/mt/89503325/1712937
> Group Owner: devel+owner@edk2.groups.io
> Unsubscribe: https://edk2.groups.io/g/devel/unsub [ray.ni@intel.com]
> -=-=-=-=-=-=
>
>
>
>
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v1 3/7] IntelFsp2Pkg: Invoke GetPhysicalAddressBits() and remove the duplicated code
2022-03-02 9:18 [PATCH v1 0/7] *** SUBJECT HERE *** Yu Pu
2022-03-02 9:18 ` [PATCH v1 1/7] UefiCpuPackage: Add APIs for CPU physical address mask calculation Yu Pu
2022-03-02 9:18 ` [PATCH v1 2/7] MdeModulePkg: Invoke GetPhysicalAddressBits() and remove the duplicated code Yu Pu
@ 2022-03-02 9:18 ` Yu Pu
2022-03-02 9:26 ` Chiu, Chasel
2022-03-02 9:18 ` [PATCH v1 4/7] StandaloneMmPkg: " Yu Pu
` (3 subsequent siblings)
6 siblings, 1 reply; 16+ messages in thread
From: Yu Pu @ 2022-03-02 9:18 UTC (permalink / raw)
To: devel; +Cc: Yu Pu, Chasel Chiu
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 edk2\IntelFsp2Pkg\Library\BaseCacheLib\CacheLib.c.
Cc: Chasel Chiu <chasel.chiu@intel.com>
Signed-off-by: Yu Pu <yu.pu@intel.com>
---
IntelFsp2Pkg/Library/BaseCacheLib/CacheLib.c | 10 ++--------
IntelFsp2Pkg/Library/BaseCacheLib/BaseCacheLib.inf | 2 ++
2 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/IntelFsp2Pkg/Library/BaseCacheLib/CacheLib.c b/IntelFsp2Pkg/Library/BaseCacheLib/CacheLib.c
index f879c268e7ec..3f8ed122b2be 100644
--- a/IntelFsp2Pkg/Library/BaseCacheLib/CacheLib.c
+++ b/IntelFsp2Pkg/Library/BaseCacheLib/CacheLib.c
@@ -9,6 +9,7 @@
#include <Library/BaseLib.h>
#include <Library/CacheLib.h>
#include <Library/CacheAsRamLib.h>
+#include <Library/UefiCpuLib.h>
#include "CacheLibInternal.h"
/**
@@ -388,15 +389,8 @@ SetCacheAttributes (
UINT32 UsedMsrNum;
EFI_MEMORY_CACHE_TYPE UsedMemoryCacheType;
UINT64 ValidMtrrAddressMask;
- UINT32 Cpuid_RegEax;
- AsmCpuid (CPUID_EXTENDED_FUNCTION, &Cpuid_RegEax, NULL, NULL, NULL);
- if (Cpuid_RegEax >= CPUID_VIR_PHY_ADDRESS_SIZE) {
- AsmCpuid (CPUID_VIR_PHY_ADDRESS_SIZE, &Cpuid_RegEax, NULL, NULL, NULL);
- ValidMtrrAddressMask = (LShiftU64 ((UINT64)1, (Cpuid_RegEax & 0xFF)) - 1) & (~(UINT64)0x0FFF);
- } else {
- ValidMtrrAddressMask = (LShiftU64 ((UINT64)1, 36) - 1) & (~(UINT64)0x0FFF);
- }
+ GetPhysicalAddressBits(NULL, &ValidMtrrAddressMask);
//
// Check for invalid parameter
diff --git a/IntelFsp2Pkg/Library/BaseCacheLib/BaseCacheLib.inf b/IntelFsp2Pkg/Library/BaseCacheLib/BaseCacheLib.inf
index 9a513fb6df77..e6b14ae4a802 100644
--- a/IntelFsp2Pkg/Library/BaseCacheLib/BaseCacheLib.inf
+++ b/IntelFsp2Pkg/Library/BaseCacheLib/BaseCacheLib.inf
@@ -21,9 +21,11 @@
[Packages]
MdePkg/MdePkg.dec
+ UefiCpuPkg/UefiCpuPkg.dec
IntelFsp2Pkg/IntelFsp2Pkg.dec
[LibraryClasses]
BaseMemoryLib
CacheAsRamLib
+ UefiCpuLib
--
2.30.0.windows.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH v1 3/7] IntelFsp2Pkg: Invoke GetPhysicalAddressBits() and remove the duplicated code
2022-03-02 9:18 ` [PATCH v1 3/7] IntelFsp2Pkg: " Yu Pu
@ 2022-03-02 9:26 ` Chiu, Chasel
0 siblings, 0 replies; 16+ messages in thread
From: Chiu, Chasel @ 2022-03-02 9:26 UTC (permalink / raw)
To: Pu, Yu, devel@edk2.groups.io
Thanks Yu!
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
> -----Original Message-----
> From: Pu, Yu <yu.pu@intel.com>
> Sent: Wednesday, March 2, 2022 5:19 PM
> To: devel@edk2.groups.io
> Cc: Pu, Yu <yu.pu@intel.com>; Chiu, Chasel <chasel.chiu@intel.com>
> Subject: [PATCH v1 3/7] IntelFsp2Pkg: Invoke GetPhysicalAddressBits() and
> remove the duplicated code
>
> 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
> edk2\IntelFsp2Pkg\Library\BaseCacheLib\CacheLib.c.
>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
>
> Signed-off-by: Yu Pu <yu.pu@intel.com>
> ---
> IntelFsp2Pkg/Library/BaseCacheLib/CacheLib.c | 10 ++--------
> IntelFsp2Pkg/Library/BaseCacheLib/BaseCacheLib.inf | 2 ++
> 2 files changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/IntelFsp2Pkg/Library/BaseCacheLib/CacheLib.c
> b/IntelFsp2Pkg/Library/BaseCacheLib/CacheLib.c
> index f879c268e7ec..3f8ed122b2be 100644
> --- a/IntelFsp2Pkg/Library/BaseCacheLib/CacheLib.c
> +++ b/IntelFsp2Pkg/Library/BaseCacheLib/CacheLib.c
> @@ -9,6 +9,7 @@
> #include <Library/BaseLib.h> #include <Library/CacheLib.h> #include
> <Library/CacheAsRamLib.h>+#include <Library/UefiCpuLib.h> #include
> "CacheLibInternal.h" /**@@ -388,15 +389,8 @@ SetCacheAttributes (
> UINT32 UsedMsrNum; EFI_MEMORY_CACHE_TYPE
> UsedMemoryCacheType; UINT64 ValidMtrrAddressMask;- UINT32
> Cpuid_RegEax; - AsmCpuid (CPUID_EXTENDED_FUNCTION, &Cpuid_RegEax,
> NULL, NULL, NULL);- if (Cpuid_RegEax >= CPUID_VIR_PHY_ADDRESS_SIZE) {-
> AsmCpuid (CPUID_VIR_PHY_ADDRESS_SIZE, &Cpuid_RegEax, NULL, NULL,
> NULL);- ValidMtrrAddressMask = (LShiftU64 ((UINT64)1, (Cpuid_RegEax &
> 0xFF)) - 1) & (~(UINT64)0x0FFF);- } else {- ValidMtrrAddressMask = (LShiftU64
> ((UINT64)1, 36) - 1) & (~(UINT64)0x0FFF);- }+ GetPhysicalAddressBits(NULL,
> &ValidMtrrAddressMask); // // Check for invalid parameterdiff --git
> a/IntelFsp2Pkg/Library/BaseCacheLib/BaseCacheLib.inf
> b/IntelFsp2Pkg/Library/BaseCacheLib/BaseCacheLib.inf
> index 9a513fb6df77..e6b14ae4a802 100644
> --- a/IntelFsp2Pkg/Library/BaseCacheLib/BaseCacheLib.inf
> +++ b/IntelFsp2Pkg/Library/BaseCacheLib/BaseCacheLib.inf
> @@ -21,9 +21,11 @@
> [Packages] MdePkg/MdePkg.dec+ UefiCpuPkg/UefiCpuPkg.dec
> IntelFsp2Pkg/IntelFsp2Pkg.dec [LibraryClasses] BaseMemoryLib
> CacheAsRamLib+ UefiCpuLib --
> 2.30.0.windows.2
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v1 4/7] StandaloneMmPkg: Invoke GetPhysicalAddressBits() and remove the duplicated code
2022-03-02 9:18 [PATCH v1 0/7] *** SUBJECT HERE *** Yu Pu
` (2 preceding siblings ...)
2022-03-02 9:18 ` [PATCH v1 3/7] IntelFsp2Pkg: " Yu Pu
@ 2022-03-02 9:18 ` Yu Pu
2022-03-03 9:58 ` Ard Biesheuvel
2022-03-02 9:18 ` [PATCH v1 5/7] OvmfPkg: " Yu Pu
` (2 subsequent siblings)
6 siblings, 1 reply; 16+ messages in thread
From: Yu Pu @ 2022-03-02 9:18 UTC (permalink / raw)
To: devel; +Cc: Yu Pu, Ard Biesheuvel, Sami Mujawar, Jiewen Yao
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
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH v1 4/7] StandaloneMmPkg: Invoke GetPhysicalAddressBits() and remove the duplicated code
2022-03-02 9:18 ` [PATCH v1 4/7] StandaloneMmPkg: " Yu Pu
@ 2022-03-03 9:58 ` Ard Biesheuvel
2022-03-04 7:39 ` [edk2-devel] " Ni, Ray
0 siblings, 1 reply; 16+ messages in thread
From: Ard Biesheuvel @ 2022-03-03 9:58 UTC (permalink / raw)
To: Yu Pu; +Cc: edk2-devel-groups-io, Ard Biesheuvel, Sami Mujawar, Jiewen Yao
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?
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [PATCH v1 4/7] StandaloneMmPkg: Invoke GetPhysicalAddressBits() and remove the duplicated code
2022-03-03 9:58 ` Ard Biesheuvel
@ 2022-03-04 7:39 ` Ni, Ray
0 siblings, 0 replies; 16+ messages in thread
From: Ni, Ray @ 2022-03-04 7:39 UTC (permalink / raw)
To: devel@edk2.groups.io, ardb@kernel.org, Pu, Yu
Cc: Ard Biesheuvel, Sami Mujawar, Yao, Jiewen
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?
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v1 5/7] OvmfPkg: Invoke GetPhysicalAddressBits() and remove the duplicated code
2022-03-02 9:18 [PATCH v1 0/7] *** SUBJECT HERE *** Yu Pu
` (3 preceding siblings ...)
2022-03-02 9:18 ` [PATCH v1 4/7] StandaloneMmPkg: " Yu Pu
@ 2022-03-02 9:18 ` Yu Pu
2022-03-02 9:18 ` [PATCH v1 6/7] EmulatorPkg: fixed a bug caused by Invoking GetPhysicalAddressBits() Yu Pu
2022-03-02 9:18 ` [PATCH v1 7/7] UefiPayloadPkg: Invoke GetPhysicalAddressBits() and remove the duplicated code Yu Pu
6 siblings, 0 replies; 16+ messages in thread
From: Yu Pu @ 2022-03-02 9:18 UTC (permalink / raw)
To: devel; +Cc: Yu Pu
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
OvmfPkg\XenPlatformPei\MemDetect.c.
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Yu Pu <yu.pu@intel.com>
---
OvmfPkg/XenPlatformPei/MemDetect.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/OvmfPkg/XenPlatformPei/MemDetect.c b/OvmfPkg/XenPlatformPei/MemDetect.c
index d412d1f4db6f..bd24612c21ef 100644
--- a/OvmfPkg/XenPlatformPei/MemDetect.c
+++ b/OvmfPkg/XenPlatformPei/MemDetect.c
@@ -30,6 +30,7 @@ Module Name:
#include <Library/PciLib.h>
#include <Library/PeimEntryPoint.h>
#include <Library/ResourcePublicationLib.h>
+#include <Library/UefiCpuLib.h>
#include "Platform.h"
#include "Cmos.h"
@@ -180,15 +181,7 @@ AddressWidthInitialization (
VOID
)
{
- UINT32 RegEax;
-
- AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);
- if (RegEax >= 0x80000008) {
- AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);
- mPhysMemAddressWidth = (UINT8)RegEax;
- } else {
- mPhysMemAddressWidth = 36;
- }
+ mPhysMemAddressWidth = GetPhysicalAddressBits(NULL, NULL);
//
// IA-32e paging translates 48-bit linear addresses to 52-bit physical addresses.
--
2.30.0.windows.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v1 6/7] EmulatorPkg: fixed a bug caused by Invoking GetPhysicalAddressBits()
2022-03-02 9:18 [PATCH v1 0/7] *** SUBJECT HERE *** Yu Pu
` (4 preceding siblings ...)
2022-03-02 9:18 ` [PATCH v1 5/7] OvmfPkg: " Yu Pu
@ 2022-03-02 9:18 ` Yu Pu
2022-03-02 9:18 ` [PATCH v1 7/7] UefiPayloadPkg: Invoke GetPhysicalAddressBits() and remove the duplicated code Yu Pu
6 siblings, 0 replies; 16+ messages in thread
From: Yu Pu @ 2022-03-02 9:18 UTC (permalink / raw)
To: devel; +Cc: Yu Pu, Andrew Fish, Ray Ni
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3394
add the defination of UefiCpuLib in EmulatorPkg\EmulatorPkg.dsc
Cc: Andrew Fish <afish@apple.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Yu Pu <yu.pu@intel.com>
---
EmulatorPkg/EmulatorPkg.dsc | 1 +
1 file changed, 1 insertion(+)
diff --git a/EmulatorPkg/EmulatorPkg.dsc b/EmulatorPkg/EmulatorPkg.dsc
index 554c13ddb500..e33b98a4b682 100644
--- a/EmulatorPkg/EmulatorPkg.dsc
+++ b/EmulatorPkg/EmulatorPkg.dsc
@@ -78,6 +78,7 @@
HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
+ UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf
PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
--
2.30.0.windows.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v1 7/7] UefiPayloadPkg: Invoke GetPhysicalAddressBits() and remove the duplicated code
2022-03-02 9:18 [PATCH v1 0/7] *** SUBJECT HERE *** Yu Pu
` (5 preceding siblings ...)
2022-03-02 9:18 ` [PATCH v1 6/7] EmulatorPkg: fixed a bug caused by Invoking GetPhysicalAddressBits() Yu Pu
@ 2022-03-02 9:18 ` Yu Pu
2022-03-04 18:09 ` Guo Dong
[not found] ` <16D93FE5C3E39310.28436@groups.io>
6 siblings, 2 replies; 16+ messages in thread
From: Yu Pu @ 2022-03-02 9:18 UTC (permalink / raw)
To: devel; +Cc: Yu Pu, Guo Dong, Ray Ni
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 UefiPayloadPkg\UefiPayloadEntry
Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Yu Pu <yu.pu@intel.com>
---
UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c | 10 ++--------
UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c | 9 ++-------
2 files changed, 4 insertions(+), 15 deletions(-)
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
index 0fed1e36918a..4378aa4f1d97 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
@@ -4,6 +4,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
+#include <Library/UefiCpuLib.h>
#include "UefiPayloadEntry.h"
@@ -341,7 +342,6 @@ BuildGenericHob (
VOID
)
{
- UINT32 RegEax;
UINT8 PhysicalAddressBits;
EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute;
@@ -351,13 +351,7 @@ BuildGenericHob (
//
// Build CPU memory space and IO space hob
//
- 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);
BuildCpuHob (PhysicalAddressBits, 16);
diff --git a/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c b/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
index ac0d58e685c8..c61aeeda7f2e 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
@@ -25,6 +25,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <PiPei.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
+#include <Library/UefiCpuLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PcdLib.h>
@@ -738,13 +739,7 @@ CreateIdentityMappingPageTables (
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);
}
//
--
2.30.0.windows.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH v1 7/7] UefiPayloadPkg: Invoke GetPhysicalAddressBits() and remove the duplicated code
2022-03-02 9:18 ` [PATCH v1 7/7] UefiPayloadPkg: Invoke GetPhysicalAddressBits() and remove the duplicated code Yu Pu
@ 2022-03-04 18:09 ` Guo Dong
[not found] ` <16D93FE5C3E39310.28436@groups.io>
1 sibling, 0 replies; 16+ messages in thread
From: Guo Dong @ 2022-03-04 18:09 UTC (permalink / raw)
To: Pu, Yu, devel@edk2.groups.io; +Cc: Ni, Ray
Reviewed-by: Guo Dong <guo.dong@intel.com>
-----Original Message-----
From: Pu, Yu <yu.pu@intel.com>
Sent: Wednesday, March 2, 2022 2:19 AM
To: devel@edk2.groups.io
Cc: Pu, Yu <yu.pu@intel.com>; Dong, Guo <guo.dong@intel.com>; Ni, Ray <ray.ni@intel.com>
Subject: [PATCH v1 7/7] UefiPayloadPkg: Invoke GetPhysicalAddressBits() and remove the duplicated code
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 UefiPayloadPkg\UefiPayloadEntry
Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Yu Pu <yu.pu@intel.com>
---
UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c | 10 ++-------- UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c | 9 ++-------
2 files changed, 4 insertions(+), 15 deletions(-)
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
index 0fed1e36918a..4378aa4f1d97 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
@@ -4,6 +4,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent **/+#include <Library/UefiCpuLib.h> #include "UefiPayloadEntry.h" @@ -341,7 +342,6 @@ BuildGenericHob (
VOID ) {- UINT32 RegEax; UINT8 PhysicalAddressBits; EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute; @@ -351,13 +351,7 @@ BuildGenericHob (
// // Build CPU memory space and IO space hob //- 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); BuildCpuHob (PhysicalAddressBits, 16); diff --git a/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c b/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
index ac0d58e685c8..c61aeeda7f2e 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
@@ -25,6 +25,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include <PiPei.h> #include <Library/BaseLib.h> #include <Library/DebugLib.h>+#include <Library/UefiCpuLib.h> #include <Library/BaseMemoryLib.h> #include <Library/MemoryAllocationLib.h> #include <Library/PcdLib.h>@@ -738,13 +739,7 @@ CreateIdentityMappingPageTables (
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); } //--
2.30.0.windows.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
[parent not found: <16D93FE5C3E39310.28436@groups.io>]
* Re: [edk2-devel] [PATCH v1 7/7] UefiPayloadPkg: Invoke GetPhysicalAddressBits() and remove the duplicated code
[not found] ` <16D93FE5C3E39310.28436@groups.io>
@ 2022-03-05 3:43 ` Guo Dong
0 siblings, 0 replies; 16+ messages in thread
From: Guo Dong @ 2022-03-05 3:43 UTC (permalink / raw)
To: devel@edk2.groups.io, Dong, Guo, Pu, Yu; +Cc: Ni, Ray
Please double check, the commit message doesn't pass patch check.
And it looks GetPhysicalAddressBits() is not an API from UefiCpuLib.h since the build failed.
Thanks,
Guo
-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Guo Dong
Sent: Friday, March 4, 2022 11:10 AM
To: Pu, Yu <yu.pu@intel.com>; devel@edk2.groups.io
Cc: Ni, Ray <ray.ni@intel.com>
Subject: Re: [edk2-devel] [PATCH v1 7/7] UefiPayloadPkg: Invoke GetPhysicalAddressBits() and remove the duplicated code
Reviewed-by: Guo Dong <guo.dong@intel.com>
-----Original Message-----
From: Pu, Yu <yu.pu@intel.com>
Sent: Wednesday, March 2, 2022 2:19 AM
To: devel@edk2.groups.io
Cc: Pu, Yu <yu.pu@intel.com>; Dong, Guo <guo.dong@intel.com>; Ni, Ray <ray.ni@intel.com>
Subject: [PATCH v1 7/7] UefiPayloadPkg: Invoke GetPhysicalAddressBits() and remove the duplicated code
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 UefiPayloadPkg\UefiPayloadEntry
Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Yu Pu <yu.pu@intel.com>
---
UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c | 10 ++-------- UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c | 9 ++-------
2 files changed, 4 insertions(+), 15 deletions(-)
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
index 0fed1e36918a..4378aa4f1d97 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
@@ -4,6 +4,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent **/+#include <Library/UefiCpuLib.h> #include "UefiPayloadEntry.h" @@ -341,7 +342,6 @@ BuildGenericHob (
VOID ) {- UINT32 RegEax; UINT8 PhysicalAddressBits; EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute; @@ -351,13 +351,7 @@ BuildGenericHob (
// // Build CPU memory space and IO space hob //- 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); BuildCpuHob (PhysicalAddressBits, 16); diff --git a/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c b/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
index ac0d58e685c8..c61aeeda7f2e 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
@@ -25,6 +25,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include <PiPei.h> #include <Library/BaseLib.h> #include <Library/DebugLib.h>+#include <Library/UefiCpuLib.h> #include <Library/BaseMemoryLib.h> #include <Library/MemoryAllocationLib.h> #include <Library/PcdLib.h>@@ -738,13 +739,7 @@ CreateIdentityMappingPageTables (
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); } //--
2.30.0.windows.2
^ permalink raw reply related [flat|nested] 16+ messages in thread