summaryrefslogtreecommitdiffstats
path: root/UefiCpuPkg
diff options
context:
space:
mode:
authorDun Tan <dun.tan@intel.com>2024-08-02 11:45:49 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-08-05 06:59:09 +0000
commit5d43165ff8596c2fa07b7d4de3c482d64338ca99 (patch)
tree8dc64ac0be57dbe1aa7ee2bfb506eb6c3493135f /UefiCpuPkg
parentcff06413604a980bd3f04782c4a745f7c02ccd7b (diff)
downloadedk2-5d43165ff8596c2fa07b7d4de3c482d64338ca99.tar.gz
edk2-5d43165ff8596c2fa07b7d4de3c482d64338ca99.tar.bz2
edk2-5d43165ff8596c2fa07b7d4de3c482d64338ca99.zip
UefiCpuPkg: rename and simplify IsAddressValid function
In this commit, we rename IsAddressValid function to IsSmmProfilePFAddressAbove4GValid and remove unneeded code logic in it. Currently, IsAddressValid is only used in the function RestorePageTableAbove4G. It's used to identify if a SMM profile PF address above 4G is inside mProtectionMemRange or not. So we can remove the PcdCpuSmmProfileEnable FALSE condition related code logic in it. Also the function name is change to be more detailed and specific. Signed-off-by: Dun Tan <dun.tan@intel.com>
Diffstat (limited to 'UefiCpuPkg')
-rw-r--r--UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c44
-rw-r--r--UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfileInternal.h15
-rw-r--r--UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmProfileArch.c6
3 files changed, 31 insertions, 34 deletions
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c
index 2dd166d39c..115d477fd0 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c
@@ -298,41 +298,35 @@ IsInSmmRanges (
}
/**
- Check if the memory address will be mapped by 4KB-page.
+ Check if the SMM profile page fault address above 4GB is in protected range or not.
- @param Address The address of Memory.
- @param Nx The flag indicates if the memory is execute-disable.
+ @param[in] Address The address of Memory.
+ @param[out] Nx The flag indicates if the memory is execute-disable.
+
+ @retval TRUE The input address is in protected range.
+ @retval FALSE The input address is not in protected range.
**/
BOOLEAN
-IsAddressValid (
- IN EFI_PHYSICAL_ADDRESS Address,
- IN BOOLEAN *Nx
+IsSmmProfilePFAddressAbove4GValid (
+ IN EFI_PHYSICAL_ADDRESS Address,
+ OUT BOOLEAN *Nx
)
{
UINTN Index;
- if (FeaturePcdGet (PcdCpuSmmProfileEnable)) {
- //
- // Check configuration
- //
- for (Index = 0; Index < mProtectionMemRangeCount; Index++) {
- if ((Address >= mProtectionMemRange[Index].Range.Base) && (Address < mProtectionMemRange[Index].Range.Top)) {
- *Nx = mProtectionMemRange[Index].Nx;
- return mProtectionMemRange[Index].Present;
- }
- }
-
- *Nx = TRUE;
- return FALSE;
- } else {
- *Nx = TRUE;
- if (IsInSmmRanges (Address)) {
- *Nx = FALSE;
+ //
+ // Check configuration
+ //
+ for (Index = 0; Index < mProtectionMemRangeCount; Index++) {
+ if ((Address >= mProtectionMemRange[Index].Range.Base) && (Address < mProtectionMemRange[Index].Range.Top)) {
+ *Nx = mProtectionMemRange[Index].Nx;
+ return mProtectionMemRange[Index].Present;
}
-
- return TRUE;
}
+
+ *Nx = TRUE;
+ return FALSE;
}
/**
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfileInternal.h b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfileInternal.h
index df6bdae0cc..42a6effe52 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfileInternal.h
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfileInternal.h
@@ -129,16 +129,19 @@ IsAddressSplit (
);
/**
- Check if the memory address will be mapped by 4KB-page.
+ Check if the SMM profile page fault address above 4GB is in protected range or not.
- @param Address The address of Memory.
- @param Nx The flag indicates if the memory is execute-disable.
+ @param[in] Address The address of Memory.
+ @param[out] Nx The flag indicates if the memory is execute-disable.
+
+ @retval TRUE The input address is in protected range.
+ @retval FALSE The input address is not in protected range.
**/
BOOLEAN
-IsAddressValid (
- IN EFI_PHYSICAL_ADDRESS Address,
- IN BOOLEAN *Nx
+IsSmmProfilePFAddressAbove4GValid (
+ IN EFI_PHYSICAL_ADDRESS Address,
+ OUT BOOLEAN *Nx
);
/**
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmProfileArch.c b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmProfileArch.c
index 39dd2c8029..a95653ddbf 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmProfileArch.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmProfileArch.c
@@ -358,7 +358,7 @@ RestorePageTableAbove4G (
// If page entry does not existed in page table at all, create a new entry.
//
if (!Existed) {
- if (IsAddressValid (PFAddress, &Nx)) {
+ if (IsSmmProfilePFAddressAbove4GValid (PFAddress, &Nx)) {
//
// If page fault address above 4GB is in protected range but it causes a page fault exception,
// Will create a page entry for this page fault address, make page table entry as present/rw and execution-disable.
@@ -401,7 +401,7 @@ RestorePageTableAbove4G (
PageTable = (UINT64 *)(UINTN)(PageTable[PTIndex] & ~mAddressEncMask & PHYSICAL_ADDRESS_MASK);
for (Index = 0; Index < 512; Index++) {
PageTable[Index] = Address | mAddressEncMask | PAGE_ATTRIBUTE_BITS;
- if (!IsAddressValid (Address, &Nx)) {
+ if (!IsSmmProfilePFAddressAbove4GValid (Address, &Nx)) {
PageTable[Index] = PageTable[Index] & (INTN)(INT32)(~PAGE_ATTRIBUTE_BITS);
}
@@ -419,7 +419,7 @@ RestorePageTableAbove4G (
//
// Update 2MB page entry.
//
- if (!IsAddressValid (Address, &Nx)) {
+ if (!IsSmmProfilePFAddressAbove4GValid (Address, &Nx)) {
//
// Patch to remove present flag and rw flag.
//