Re: [edk2-devel] [Patch V2 2/2] UefiPayloadPkg: Remove clearing CR0.WP when protecting pagetable

2022-08-12 Thread Guo Dong


Reviewed-by: Guo Dong 

-Original Message-
From: Tan, Dun  
Sent: Tuesday, August 9, 2022 10:34 PM
To: devel@edk2.groups.io
Cc: Dong, Guo ; Ni, Ray ; Maurice Ma 
; You, Benjamin ; Rhodes, Sean 

Subject: [Patch V2 2/2] UefiPayloadPkg: 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 UefiPayloadEntry.
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 
Cc: Guo Dong 
Cc: Ray Ni 
Cc: Maurice Ma 
Cc: Benjamin You 
Cc: Sean Rhodes 
---
 UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c 
b/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
index 74b667a62a..a586941352 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
@@ -622,12 +622,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 (#92399): https://edk2.groups.io/g/devel/message/92399
Mute This Topic: https://groups.io/mt/92931316/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [Patch V2 2/2] UefiPayloadPkg: Remove clearing CR0.WP when protecting pagetable

2022-08-10 Thread Ni, Ray
Reviewed-by: Ray Ni 

> -Original Message-
> From: Tan, Dun 
> Sent: Wednesday, August 10, 2022 1:34 PM
> To: devel@edk2.groups.io
> Cc: Dong, Guo ; Ni, Ray ; Maurice
> Ma ; You, Benjamin ;
> Rhodes, Sean 
> Subject: [Patch V2 2/2] UefiPayloadPkg: 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 UefiPayloadEntry.
> 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 
> Cc: Guo Dong 
> Cc: Ray Ni 
> Cc: Maurice Ma 
> Cc: Benjamin You 
> Cc: Sean Rhodes 
> ---
>  UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c | 7 +--
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
> b/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
> index 74b667a62a..a586941352 100644
> --- a/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
> +++ b/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
> @@ -622,12 +622,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 (#92302): https://edk2.groups.io/g/devel/message/92302
Mute This Topic: https://groups.io/mt/92931316/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [Patch V2 2/2] UefiPayloadPkg: Remove clearing CR0.WP when protecting pagetable

2022-08-09 Thread duntan
Remove clearing CR0.WP when marking the memory used for page table
as read-only in the page table itself created by UefiPayloadEntry.
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 
Cc: Guo Dong 
Cc: Ray Ni 
Cc: Maurice Ma 
Cc: Benjamin You 
Cc: Sean Rhodes 
---
 UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c 
b/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
index 74b667a62a..a586941352 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c
@@ -622,12 +622,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 (#92287): https://edk2.groups.io/g/devel/message/92287
Mute This Topic: https://groups.io/mt/92931316/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-