public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [Patch V3] UefiCpuPkg: Decouple the SEV-ES functionality.
@ 2023-07-26  7:51 Yuanhao Xie
  2023-07-26  8:03 ` Ni, Ray
  2023-07-26 13:58 ` Lendacky, Thomas via groups.io
  0 siblings, 2 replies; 3+ messages in thread
From: Yuanhao Xie @ 2023-07-26  7:51 UTC (permalink / raw)
  To: devel; +Cc: Eric Dong, Rahul Kumar, Tom Lendacky, Ray Ni, Yuanhao Xie

The purpose is to fix an issue where an exception occurs at the start
of the DXE phase by applying the following patch series on INTEL-based
systems.

UefiCpuPkg: Refactor the logic for placing APs in HltLoop.
UefiCpuPkg: Refactor the logic for placing APs in Mwait/Runloop.
UefiCpuPkg: Create MpHandOff.
UefiCpuPkg: ApWakeupFunction directly use CpuMpData.
UefiCpuPkg: Eliminate the second INIT-SIPI-SIPI sequence.

This series of patches makes changes to the way the APs are
initialized and woken up. It removes the 2nd time INIT-SIPI-SIPI and
introduces a special startup signal to wake up APs. These patches also
create a new HOB identified by the mMpHandOffGuid, which stores only the
 minimum information required from the PEI phase to the DXE phase.
As a result, the original HOB (mCpuInitMpLibHobGuid) is now used only
as a global variable in the PEI phase and is no longer necessary in the
DXE phase for INTEL-based systems. The AMD SEV-ES related code
still relies on the OldCpuMpData in the DXE phase.

This patch decouple the SEV-ES functionality of assigning CpuMpData to
OldCpuMpData->NewCpuMpData from the Intel logic.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Yuanhao Xie <yuanhao.xie@intel.com>
---
 UefiCpuPkg/Library/MpInitLib/MpLib.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index 737e03ffc5..e7054adbcc 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
@@ -2160,7 +2160,10 @@ MpInitLibInitialize (
     // APs have been wakeup before, just get the CPU Information
     // from HOB
     //
-    AmdSevUpdateCpuMpData (CpuMpData);
+    if (CpuMpData->UseSevEsAPMethod) {
+      AmdSevUpdateCpuMpData (CpuMpData);
+    }
+
     CpuMpData->CpuCount  = MpHandOff->CpuCount;
     CpuMpData->BspNumber = GetBspNumber (MpHandOff);
     CpuInfoInHob         = (CPU_INFO_IN_HOB *)(UINTN)CpuMpData->CpuInfoInHob;
-- 
2.36.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107264): https://edk2.groups.io/g/devel/message/107264
Mute This Topic: https://groups.io/mt/100366586/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

* Re: [edk2-devel] [Patch V3] UefiCpuPkg: Decouple the SEV-ES functionality.
  2023-07-26  7:51 [edk2-devel] [Patch V3] UefiCpuPkg: Decouple the SEV-ES functionality Yuanhao Xie
@ 2023-07-26  8:03 ` Ni, Ray
  2023-07-26 13:58 ` Lendacky, Thomas via groups.io
  1 sibling, 0 replies; 3+ messages in thread
From: Ni, Ray @ 2023-07-26  8:03 UTC (permalink / raw)
  To: Xie, Yuanhao, devel@edk2.groups.io, Tom Lendacky
  Cc: Dong, Eric, Kumar, Rahul R

Reviewed-by: Ray Ni <ray.ni@intel.com>

@Tom Lendacky, can you please comment?

> -----Original Message-----
> From: Xie, Yuanhao <yuanhao.xie@intel.com>
> Sent: Wednesday, July 26, 2023 3:51 PM
> To: devel@edk2.groups.io
> Cc: Dong, Eric <eric.dong@intel.com>; Kumar, Rahul R
> <rahul.r.kumar@intel.com>; Tom Lendacky <thomas.lendacky@amd.com>; Ni,
> Ray <ray.ni@intel.com>; Xie, Yuanhao <yuanhao.xie@intel.com>
> Subject: [Patch V3] UefiCpuPkg: Decouple the SEV-ES functionality.
> 
> The purpose is to fix an issue where an exception occurs at the start
> of the DXE phase by applying the following patch series on INTEL-based
> systems.
> 
> UefiCpuPkg: Refactor the logic for placing APs in HltLoop.
> UefiCpuPkg: Refactor the logic for placing APs in Mwait/Runloop.
> UefiCpuPkg: Create MpHandOff.
> UefiCpuPkg: ApWakeupFunction directly use CpuMpData.
> UefiCpuPkg: Eliminate the second INIT-SIPI-SIPI sequence.
> 
> This series of patches makes changes to the way the APs are
> initialized and woken up. It removes the 2nd time INIT-SIPI-SIPI and
> introduces a special startup signal to wake up APs. These patches also
> create a new HOB identified by the mMpHandOffGuid, which stores only the
>  minimum information required from the PEI phase to the DXE phase.
> As a result, the original HOB (mCpuInitMpLibHobGuid) is now used only
> as a global variable in the PEI phase and is no longer necessary in the
> DXE phase for INTEL-based systems. The AMD SEV-ES related code
> still relies on the OldCpuMpData in the DXE phase.
> 
> This patch decouple the SEV-ES functionality of assigning CpuMpData to
> OldCpuMpData->NewCpuMpData from the Intel logic.
> 
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Rahul Kumar <rahul1.kumar@intel.com>
> Cc: Tom Lendacky <thomas.lendacky@amd.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Signed-off-by: Yuanhao Xie <yuanhao.xie@intel.com>
> ---
>  UefiCpuPkg/Library/MpInitLib/MpLib.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c
> b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> index 737e03ffc5..e7054adbcc 100644
> --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
> +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> @@ -2160,7 +2160,10 @@ MpInitLibInitialize (
>      // APs have been wakeup before, just get the CPU Information
>      // from HOB
>      //
> -    AmdSevUpdateCpuMpData (CpuMpData);
> +    if (CpuMpData->UseSevEsAPMethod) {
> +      AmdSevUpdateCpuMpData (CpuMpData);
> +    }
> +
>      CpuMpData->CpuCount  = MpHandOff->CpuCount;
>      CpuMpData->BspNumber = GetBspNumber (MpHandOff);
>      CpuInfoInHob         = (CPU_INFO_IN_HOB *)(UINTN)CpuMpData-
> >CpuInfoInHob;
> --
> 2.36.1.windows.1



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



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

* Re: [edk2-devel] [Patch V3] UefiCpuPkg: Decouple the SEV-ES functionality.
  2023-07-26  7:51 [edk2-devel] [Patch V3] UefiCpuPkg: Decouple the SEV-ES functionality Yuanhao Xie
  2023-07-26  8:03 ` Ni, Ray
@ 2023-07-26 13:58 ` Lendacky, Thomas via groups.io
  1 sibling, 0 replies; 3+ messages in thread
From: Lendacky, Thomas via groups.io @ 2023-07-26 13:58 UTC (permalink / raw)
  To: YuanhaoXie, devel; +Cc: Eric Dong, Rahul Kumar, Ray Ni

On 7/26/23 02:51, YuanhaoXie wrote:
> The purpose is to fix an issue where an exception occurs at the start
> of the DXE phase by applying the following patch series on INTEL-based
> systems.
> 
> UefiCpuPkg: Refactor the logic for placing APs in HltLoop.
> UefiCpuPkg: Refactor the logic for placing APs in Mwait/Runloop.
> UefiCpuPkg: Create MpHandOff.
> UefiCpuPkg: ApWakeupFunction directly use CpuMpData.
> UefiCpuPkg: Eliminate the second INIT-SIPI-SIPI sequence.
> 
> This series of patches makes changes to the way the APs are
> initialized and woken up. It removes the 2nd time INIT-SIPI-SIPI and
> introduces a special startup signal to wake up APs. These patches also
> create a new HOB identified by the mMpHandOffGuid, which stores only the
>   minimum information required from the PEI phase to the DXE phase.
> As a result, the original HOB (mCpuInitMpLibHobGuid) is now used only
> as a global variable in the PEI phase and is no longer necessary in the
> DXE phase for INTEL-based systems. The AMD SEV-ES related code
> still relies on the OldCpuMpData in the DXE phase.
> 
> This patch decouple the SEV-ES functionality of assigning CpuMpData to
> OldCpuMpData->NewCpuMpData from the Intel logic.
> 
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Rahul Kumar <rahul1.kumar@intel.com>
> Cc: Tom Lendacky <thomas.lendacky@amd.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Signed-off-by: Yuanhao Xie <yuanhao.xie@intel.com>
> ---
>   UefiCpuPkg/Library/MpInitLib/MpLib.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> index 737e03ffc5..e7054adbcc 100644
> --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
> +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> @@ -2160,7 +2160,10 @@ MpInitLibInitialize (
>       // APs have been wakeup before, just get the CPU Information
>       // from HOB
>       //
> -    AmdSevUpdateCpuMpData (CpuMpData);
> +    if (CpuMpData->UseSevEsAPMethod) {
> +      AmdSevUpdateCpuMpData (CpuMpData);
> +    }

This looks fine. Applying this patch did not regress SEV-ES or SEV-SNP 
guest boots.

Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>

Thanks,
Tom

> +
>       CpuMpData->CpuCount  = MpHandOff->CpuCount;
>       CpuMpData->BspNumber = GetBspNumber (MpHandOff);
>       CpuInfoInHob         = (CPU_INFO_IN_HOB *)(UINTN)CpuMpData->CpuInfoInHob;


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



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

end of thread, other threads:[~2023-07-26 13:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-26  7:51 [edk2-devel] [Patch V3] UefiCpuPkg: Decouple the SEV-ES functionality Yuanhao Xie
2023-07-26  8:03 ` Ni, Ray
2023-07-26 13:58 ` Lendacky, Thomas via groups.io

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