summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Lendacky <thomas.lendacky@amd.com>2023-11-07 06:45:31 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-11-28 11:07:59 +0000
commit3c5f9ac5c3b92bf63b3c0a39658f0ae991e8436d (patch)
treeeb24a793b70d398e5224818b7b5e221f54dc806d
parent447798cd3a78c8bfc5adb90254d50d22a838b301 (diff)
downloadedk2-3c5f9ac5c3b92bf63b3c0a39658f0ae991e8436d.tar.gz
edk2-3c5f9ac5c3b92bf63b3c0a39658f0ae991e8436d.tar.bz2
edk2-3c5f9ac5c3b92bf63b3c0a39658f0ae991e8436d.zip
UefiCpuPkg/MpInitLib: Copy SEV-ES save area pointer during APIC ID sorting
With SEV-SNP, the SEV-ES save area for a vCPU should be unique to that vCPU. After commit 3323359a811a, the VMSA allocation was re-used, but when sorting the CPUs by APIC ID, the save area was not updated to follow the original CPU. Similar to the StartupApSignal address, the SevEsSaveArea address should be updated when sorting the CPUs. This does not cause an issue at this time because all APs are in HLT state and then are (re)started at the same time, with the same VMSA contents. However, this should be fixed to account for any change in future behavior. Fixes: 3323359a811a ("UefiCpuPkg/MpInitLib: Reuse VMSA allocation to ...") Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
-rw-r--r--UefiCpuPkg/Library/MpInitLib/MpLib.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index f29e66a14f..a359906923 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
@@ -370,6 +370,7 @@ SortApicId (
UINT32 ApCount;
CPU_INFO_IN_HOB *CpuInfoInHob;
volatile UINT32 *StartupApSignal;
+ VOID *SevEsSaveArea;
ApCount = CpuMpData->CpuCount - 1;
CpuInfoInHob = (CPU_INFO_IN_HOB *)(UINTN)CpuMpData->CpuInfoInHob;
@@ -397,12 +398,17 @@ SortApicId (
CopyMem (&CpuInfoInHob[Index1], &CpuInfo, sizeof (CPU_INFO_IN_HOB));
//
- // Also exchange the StartupApSignal.
+ // Also exchange the StartupApSignal and SevEsSaveArea.
//
StartupApSignal = CpuMpData->CpuData[Index3].StartupApSignal;
CpuMpData->CpuData[Index3].StartupApSignal =
CpuMpData->CpuData[Index1].StartupApSignal;
CpuMpData->CpuData[Index1].StartupApSignal = StartupApSignal;
+
+ SevEsSaveArea = CpuMpData->CpuData[Index3].SevEsSaveArea;
+ CpuMpData->CpuData[Index3].SevEsSaveArea =
+ CpuMpData->CpuData[Index1].SevEsSaveArea;
+ CpuMpData->CpuData[Index1].SevEsSaveArea = SevEsSaveArea;
}
}