Remove clearing CR0.WP when marking the memory used for page table
as read-only in the page table itself created by DxeIpl. This page
table address is written to Cr3 after these protection steps. Till
this, the memory used for page table is always RW.
Signed-off-by: Dun Tan <dun.tan@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Ray Ni <ray.ni@intel.com>
---
MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
index a451ca1604..18b121d768 100644
--- a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
+++ b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
@@ -626,12 +626,7 @@ EnablePageTableProtection (
}
//
- // Disable write protection, because we need to mark page table to be write
- // protected.
- //
- AsmWriteCr0 (AsmReadCr0 () & ~CR0_WP);
-
- //
+ // No need to clear CR0.WP since PageTableBase has't been written to CR3 yet.
// SetPageTablePoolReadOnly might update mPageTablePool. It's safer to
// remember original one in advance.
//
--
2.31.1.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#92286): https://edk2.groups.io/g/devel/message/92286
Mute This Topic: https://groups.io/mt/92931315/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Reviewed-by: Ray Ni <ray.ni@intel.com> > -----Original Message----- > From: Tan, Dun <dun.tan@intel.com> > Sent: Wednesday, August 10, 2022 1:34 PM > To: devel@edk2.groups.io > Cc: Bi, Dandan <dandan.bi@intel.com>; Gao, Liming > <gaoliming@byosoft.com.cn>; Ni, Ray <ray.ni@intel.com> > Subject: [Patch V2 1/2] MdeModulePkg/DxeIpl: Remove clearing CR0.WP > when protecting pagetable > > Remove clearing CR0.WP when marking the memory used for page table > as read-only in the page table itself created by DxeIpl. This page > table address is written to Cr3 after these protection steps. Till > this, the memory used for page table is always RW. > > Signed-off-by: Dun Tan <dun.tan@intel.com> > Cc: Dandan Bi <dandan.bi@intel.com> > Cc: Liming Gao <gaoliming@byosoft.com.cn> > Cc: Ray Ni <ray.ni@intel.com> > --- > MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c | 7 +------ > 1 file changed, 1 insertion(+), 6 deletions(-) > > diff --git a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c > b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c > index a451ca1604..18b121d768 100644 > --- a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c > +++ b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c > @@ -626,12 +626,7 @@ EnablePageTableProtection ( > } > > // > - // Disable write protection, because we need to mark page table to be > write > - // protected. > - // > - AsmWriteCr0 (AsmReadCr0 () & ~CR0_WP); > - > - // > + // No need to clear CR0.WP since PageTableBase has't been written to CR3 > yet. > // SetPageTablePoolReadOnly might update mPageTablePool. It's safer to > // remember original one in advance. > // > -- > 2.31.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#92301): https://edk2.groups.io/g/devel/message/92301 Mute This Topic: https://groups.io/mt/92931315/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=-=-=-=-=-=-=-=-=-=-=-
© 2016 - 2026 Red Hat, Inc.