public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [PATCH 1/3] UefiCpuPkg/CpuPageTableLib: Init local variable before using it.
@ 2023-11-27  8:32 Zhiguang Liu
  2023-11-27  8:32 ` [edk2-devel] [PATCH 2/3] UefiCpuPkg/CpuPageTableLib/TestCase: Refine test case for PAE paging Zhiguang Liu
  2023-11-27  8:32 ` [edk2-devel] [PATCH 3/3] UefiCpuPkg/CpuMpPei: Use CpuPageTableLib to set memory attribute Zhiguang Liu
  0 siblings, 2 replies; 3+ messages in thread
From: Zhiguang Liu @ 2023-11-27  8:32 UTC (permalink / raw)
  To: devel; +Cc: Zhiguang Liu, Ray Ni, Rahul Kumar, Gerd Hoffmann, Laszlo Ersek

The local variable OneOfPagingEntry is used before initialized, this
may cause reserved bit in page table entry is set especially in PAE
paging mode. The bug is random because it depends on the value in
stack.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
---
 UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c b/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c
index eff02619fa..36b2c4e6a3 100644
--- a/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c
+++ b/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c
@@ -338,7 +338,7 @@ PageTableLibMapInLevel (
   ParentAttribute             = &LocalParentAttribute;
 
   OriginalParentPagingEntry.Uint64 = ParentPagingEntry->Uint64;
-
+  OneOfPagingEntry.Uint64          = 0;
   //
   // RegionLength: 256T (1 << 48) 512G (1 << 39), 1G (1 << 30), 2M (1 << 21) or 4K (1 << 12).
   //
@@ -367,8 +367,6 @@ PageTableLibMapInLevel (
       if (RETURN_ERROR (Status)) {
         return Status;
       }
-
-      OneOfPagingEntry.Pnle.Uint64 = 0;
     } else {
       PageTableLibSetPle (Level, &OneOfPagingEntry, 0, &PleBAttribute, &AllOneMask);
     }
-- 
2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111729): https://edk2.groups.io/g/devel/message/111729
Mute This Topic: https://groups.io/mt/102825574/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-11-27  8:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-27  8:32 [edk2-devel] [PATCH 1/3] UefiCpuPkg/CpuPageTableLib: Init local variable before using it Zhiguang Liu
2023-11-27  8:32 ` [edk2-devel] [PATCH 2/3] UefiCpuPkg/CpuPageTableLib/TestCase: Refine test case for PAE paging Zhiguang Liu
2023-11-27  8:32 ` [edk2-devel] [PATCH 3/3] UefiCpuPkg/CpuMpPei: Use CpuPageTableLib to set memory attribute Zhiguang Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox