On 12/12/19 1:01 AM, Ni, Ray wrote: > OK I see now the Enable PCD is defined in MdeModulePkg, produced in platform > and consumed in MpInitLib. > > Is there a way to easily detect whether SEV-ES is enabled? (without > triggering CPUID as what SEC does)
No, I would need to read an MSR and I really should be certain the MSR is valid before trying to do that - and that requires checking CPUID. > > If no, can you define the PCD in UefiCpuPkg? I should be able to do that. Let me give it a try. Thanks, Tom > > >> -----Original Message----- >> From: Tom Lendacky <thomas.lenda...@amd.com> >> Sent: Thursday, November 21, 2019 4:07 AM >> To: devel@edk2.groups.io >> Cc: Justen, Jordan L <jordan.l.jus...@intel.com>; Laszlo Ersek >> <ler...@redhat.com>; Ard Biesheuvel >> <ard.biesheu...@linaro.org>; Kinney, Michael D <michael.d.kin...@intel.com>; >> Gao, Liming <liming....@intel.com>; Dong, >> Eric <eric.d...@intel.com>; Ni, Ray <ray...@intel.com>; Brijesh Singh >> <brijesh.si...@amd.com> >> Subject: [RFC PATCH v3 35/43] UefiCpuPkg/MpInitLib: Add a CPU MP data flag >> to indicate if SEV-ES is enabled >> >> BZ: >> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2198&data=02%7C01%7Cthomas.lendacky%40amd.com%7C8541911e903d4d05cb4708d77ed10ec4%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637117308681418556&sdata=Vt3vjZ7afbFWT59nR%2F332FMHm%2F%2FBkq62%2BN6oKEfiraE%3D&reserved=0 >> >> When starting APs in an SMP configuration, the AP needs to know if it is >> running as an SEV-ES guest in order to assign a GHCB page. >> >> Add a field to the CPU_MP_DATA structure that will indicate if SEV-ES is >> enabled. This new field is set during MP library initialization with the >> PCD value PcdSevEsIsEnabled. This flag can then be used to determine if >> SEV-ES is enabled. >> >> Cc: Eric Dong <eric.d...@intel.com> >> Cc: Ray Ni <ray...@intel.com> >> Cc: Laszlo Ersek <ler...@redhat.com> >> Signed-off-by: Tom Lendacky <thomas.lenda...@amd.com> >> --- >> UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf | 1 + >> UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf | 1 + >> UefiCpuPkg/Library/MpInitLib/MpLib.h | 2 ++ >> UefiCpuPkg/Library/MpInitLib/MpLib.c | 1 + >> 4 files changed, 5 insertions(+) >> >> diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf >> b/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf >> index cd912ab0c5ee..f84dbb09ae49 100644 >> --- a/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf >> +++ b/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf >> @@ -69,4 +69,5 @@ [Pcd] >> gUefiCpuPkgTokenSpaceGuid.PcdCpuApLoopMode ## >> CONSUMES >> gUefiCpuPkgTokenSpaceGuid.PcdCpuApTargetCstate ## >> SOMETIMES_CONSUMES >> gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard ## >> CONSUMES >> + gEfiMdeModulePkgTokenSpaceGuid.PcdSevEsIsEnabled ## >> CONSUMES >> >> diff --git a/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf >> b/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf >> index 1538185ef99a..9c1215ec75d0 100644 >> --- a/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf >> +++ b/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf >> @@ -60,6 +60,7 @@ [Pcd] >> gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchRegionSize ## >> CONSUMES >> gUefiCpuPkgTokenSpaceGuid.PcdCpuApLoopMode ## >> CONSUMES >> gUefiCpuPkgTokenSpaceGuid.PcdCpuApTargetCstate ## >> SOMETIMES_CONSUMES >> + gEfiMdeModulePkgTokenSpaceGuid.PcdSevEsIsEnabled ## >> CONSUMES >> >> [Guids] >> gEdkiiS3SmmInitDoneGuid >> diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h >> b/UefiCpuPkg/Library/MpInitLib/MpLib.h >> index 8fa07b12c5e1..c10fe894cf9b 100644 >> --- a/UefiCpuPkg/Library/MpInitLib/MpLib.h >> +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h >> @@ -259,6 +259,8 @@ struct _CPU_MP_DATA { >> // driver. >> // >> BOOLEAN WakeUpByInitSipiSipi; >> + >> + BOOLEAN SevEsIsEnabled; >> }; >> >> extern EFI_GUID mCpuInitMpLibHobGuid; >> diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c >> b/UefiCpuPkg/Library/MpInitLib/MpLib.c >> index 49be5d5385d9..aa25bf9b3671 100644 >> --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c >> +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c >> @@ -1708,6 +1708,7 @@ MpInitLibInitialize ( >> CpuMpData->MicrocodePatchAddress = >> OldCpuMpData->MicrocodePatchAddress; >> } >> InitializeSpinLock(&CpuMpData->MpLock); >> + CpuMpData->SevEsIsEnabled = PcdGetBool (PcdSevEsIsEnabled); >> >> // >> // Make sure no memory usage outside of the allocated buffer. >> -- >> 2.17.1 > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#52182): https://edk2.groups.io/g/devel/message/52182 Mute This Topic: https://groups.io/mt/60973142/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-