[edk2-devel] [PATCH 10/10] CpuPageTableLib: define IA32_PAGE_LEVEL enum type internally

Ni, Ray ray.ni at intel.com
Mon Jul 18 13:18:31 UTC 2022


The change doesn't change functionality behavior.

Signed-off-by: Ray Ni <ray.ni at intel.com>
Cc: Zhiguang Liu <zhiguang.liu at intel.com>
Cc: Eric Dong <eric.dong at intel.com>
---
 UefiCpuPkg/Library/CpuPageTableLib/CpuPageTable.h    |  8 ++++++++
 UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c | 12 ++++++------
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTable.h b/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTable.h
index 627f84e4e2..8d856d7c7e 100644
--- a/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTable.h
+++ b/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTable.h
@@ -20,6 +20,14 @@
 
 #define REGION_LENGTH(l)  LShiftU64 (1, (l) * 9 + 3)
 
+typedef enum {
+  Pte   = 1,
+  Pde   = 2,
+  Pdpte = 3,
+  Pml4  = 4,
+  Pml5  = 5
+} IA32_PAGE_LEVEL;
+
 typedef struct {
   UINT64    Present        : 1;       // 0 = Not present in memory, 1 = Present in memory
   UINT64    ReadWrite      : 1;       // 0 = Read-Only, 1= Read/Write
diff --git a/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c b/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c
index 16e6697ed4..d3fdf13429 100644
--- a/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c
+++ b/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c
@@ -245,8 +245,8 @@ PageTableLibMapInLevel (
   IN     BOOLEAN             Modify,
   IN     VOID                *Buffer,
   IN OUT INTN                *BufferSize,
-  IN     UINTN               Level,
-  IN     UINTN               MaxLeafLevel,
+  IN     IA32_PAGE_LEVEL     Level,
+  IN     IA32_PAGE_LEVEL     MaxLeafLevel,
   IN     UINT64              LinearAddress,
   IN     UINT64              Length,
   IN     UINT64              Offset,
@@ -572,8 +572,8 @@ PageTableMap (
   IA32_PAGING_ENTRY   TopPagingEntry;
   INTN                RequiredSize;
   UINT64              MaxLinearAddress;
-  UINTN               MaxLevel;
-  UINTN               MaxLeafLevel;
+  IA32_PAGE_LEVEL     MaxLevel;
+  IA32_PAGE_LEVEL     MaxLeafLevel;
   IA32_MAP_ATTRIBUTE  ParentAttribute;
 
   if ((PagingMode == Paging32bit) || (PagingMode == PagingPae) || (PagingMode >= PagingModeMax)) {
@@ -606,8 +606,8 @@ PageTableMap (
     return RETURN_INVALID_PARAMETER;
   }
 
-  MaxLeafLevel     = (UINT8)PagingMode;
-  MaxLevel         = (UINT8)(PagingMode >> 8);
+  MaxLeafLevel     = (IA32_PAGE_LEVEL)(UINT8)PagingMode;
+  MaxLevel         = (IA32_PAGE_LEVEL)(UINT8)(PagingMode >> 8);
   MaxLinearAddress = LShiftU64 (1, 12 + MaxLevel * 9);
 
   if ((LinearAddress > MaxLinearAddress) || (Length > MaxLinearAddress - LinearAddress)) {
-- 
2.35.1.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#91459): https://edk2.groups.io/g/devel/message/91459
Mute This Topic: https://groups.io/mt/92458168/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list