Re: [edk2-devel] [PATCH 02/18] OvmfPkg: Save MTRR by lockbox in CpuS3DataDxe

2024-05-20 Thread Ard Biesheuvel
On Fri, 10 May 2024 at 12:08, Dun Tan  wrote:
>
> Save MTRR by lockbox in CpuS3DataDxe. In S3 boot,
> The MTRR setting will be restored in S3Resume.c
> in following patches. Then S3Resume.c will wakeup
> all APs to load the MTRR setting. This can avoid
> waking up APs in CpuS3.c.
>
> Signed-off-by: Dun Tan 
> Cc: Ard Biesheuvel 
> Cc: Jiewen Yao 
> Cc: Gerd Hoffmann 
> Cc: Ray Ni 
> Cc: Jiaxin Wu 

Reviewed-by: Ard Biesheuvel 


> ---
>  OvmfPkg/CpuS3DataDxe/CpuS3Data.c  | 11 +++
>  OvmfPkg/CpuS3DataDxe/CpuS3DataDxe.inf |  2 ++
>  2 files changed, 13 insertions(+)
>
> diff --git a/OvmfPkg/CpuS3DataDxe/CpuS3Data.c 
> b/OvmfPkg/CpuS3DataDxe/CpuS3Data.c
> index 289048b75d..d1aba32842 100644
> --- a/OvmfPkg/CpuS3DataDxe/CpuS3Data.c
> +++ b/OvmfPkg/CpuS3DataDxe/CpuS3Data.c
> @@ -26,6 +26,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
>  #include 
>  #include 
>  #include 
> +#include 
>
>  #include 
>  #include 
> @@ -130,6 +131,16 @@ CpuS3DataOnEndOfDxe (
>DEBUG ((DEBUG_VERBOSE, "%a\n", __func__));
>MtrrGetAllMtrrs (>MtrrTable);
>
> +  //
> +  // Save MTRR in lockbox
> +  //
> +  Status = SaveLockBox (
> + ,
> + >MtrrTable,
> + sizeof (MTRR_SETTINGS)
> + );
> +  ASSERT_EFI_ERROR (Status);
> +
>//
>// Close event, so it will not be invoked again.
>//
> diff --git a/OvmfPkg/CpuS3DataDxe/CpuS3DataDxe.inf 
> b/OvmfPkg/CpuS3DataDxe/CpuS3DataDxe.inf
> index 228d5ae1b2..f5032a9222 100644
> --- a/OvmfPkg/CpuS3DataDxe/CpuS3DataDxe.inf
> +++ b/OvmfPkg/CpuS3DataDxe/CpuS3DataDxe.inf
> @@ -46,9 +46,11 @@
>MtrrLib
>UefiBootServicesTableLib
>UefiDriverEntryPoint
> +  LockBoxLib
>
>  [Guids]
>gEfiEndOfDxeEventGroupGuid ## CONSUMES   ## Event
> +  gEdkiiS3MtrrSettingGuid
>
>  [Protocols]
>gEfiMpServiceProtocolGuid  ## CONSUMES
> --
> 2.31.1.windows.1
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119077): https://edk2.groups.io/g/devel/message/119077
Mute This Topic: https://groups.io/mt/106018122/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH 02/18] OvmfPkg: Save MTRR by lockbox in CpuS3DataDxe

2024-05-12 Thread Ni, Ray
Reviewed-by: Ray Ni 



Thanks,
Ray

From: Tan, Dun 
Sent: Friday, May 10, 2024 18:08
To: devel@edk2.groups.io 
Cc: Ard Biesheuvel ; Yao, Jiewen 
; Gerd Hoffmann ; Ni, Ray 
; Wu, Jiaxin 
Subject: [PATCH 02/18] OvmfPkg: Save MTRR by lockbox in CpuS3DataDxe

Save MTRR by lockbox in CpuS3DataDxe. In S3 boot,
The MTRR setting will be restored in S3Resume.c
in following patches. Then S3Resume.c will wakeup
all APs to load the MTRR setting. This can avoid
waking up APs in CpuS3.c.

Signed-off-by: Dun Tan 
Cc: Ard Biesheuvel 
Cc: Jiewen Yao 
Cc: Gerd Hoffmann 
Cc: Ray Ni 
Cc: Jiaxin Wu 
---
 OvmfPkg/CpuS3DataDxe/CpuS3Data.c  | 11 +++
 OvmfPkg/CpuS3DataDxe/CpuS3DataDxe.inf |  2 ++
 2 files changed, 13 insertions(+)

diff --git a/OvmfPkg/CpuS3DataDxe/CpuS3Data.c b/OvmfPkg/CpuS3DataDxe/CpuS3Data.c
index 289048b75d..d1aba32842 100644
--- a/OvmfPkg/CpuS3DataDxe/CpuS3Data.c
+++ b/OvmfPkg/CpuS3DataDxe/CpuS3Data.c
@@ -26,6 +26,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
+#include 

 #include 
 #include 
@@ -130,6 +131,16 @@ CpuS3DataOnEndOfDxe (
   DEBUG ((DEBUG_VERBOSE, "%a\n", __func__));
   MtrrGetAllMtrrs (>MtrrTable);

+  //
+  // Save MTRR in lockbox
+  //
+  Status = SaveLockBox (
+ ,
+ >MtrrTable,
+ sizeof (MTRR_SETTINGS)
+ );
+  ASSERT_EFI_ERROR (Status);
+
   //
   // Close event, so it will not be invoked again.
   //
diff --git a/OvmfPkg/CpuS3DataDxe/CpuS3DataDxe.inf 
b/OvmfPkg/CpuS3DataDxe/CpuS3DataDxe.inf
index 228d5ae1b2..f5032a9222 100644
--- a/OvmfPkg/CpuS3DataDxe/CpuS3DataDxe.inf
+++ b/OvmfPkg/CpuS3DataDxe/CpuS3DataDxe.inf
@@ -46,9 +46,11 @@
   MtrrLib
   UefiBootServicesTableLib
   UefiDriverEntryPoint
+  LockBoxLib

 [Guids]
   gEfiEndOfDxeEventGroupGuid ## CONSUMES   ## Event
+  gEdkiiS3MtrrSettingGuid

 [Protocols]
   gEfiMpServiceProtocolGuid  ## CONSUMES
--
2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#118835): https://edk2.groups.io/g/devel/message/118835
Mute This Topic: https://groups.io/mt/106018122/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-