diff --git a/OvmfPkg/CpuHotplugSmm/CpuHotplugSmm.inf b/OvmfPkg/CpuHotplugSmm/CpuHotplugSmm.inf index ebcc7e2ac6..0996968016 100644 --- a/OvmfPkg/CpuHotplugSmm/CpuHotplugSmm.inf +++ b/OvmfPkg/CpuHotplugSmm/CpuHotplugSmm.inf @@ -42,6 +42,7 @@ BaseMemoryLib CpuLib DebugLib + HobLib LocalApicLib MmServicesTableLib PcdLib @@ -53,6 +54,9 @@ gEfiMmCpuIoProtocolGuid ## CONSUMES gEfiSmmCpuServiceProtocolGuid ## CONSUMES +[Guids] + gUefiOvmfPkgPlatformInfoGuid ## CONSUMES + [Pcd] gUefiCpuPkgTokenSpaceGuid.PcdCpuHotPlugDataAddress ## CONSUMES gUefiOvmfPkgTokenSpaceGuid.PcdCpuHotEjectDataAddress ## CONSUMES diff --git a/OvmfPkg/CpuHotplugSmm/Smbase.c b/OvmfPkg/CpuHotplugSmm/Smbase.c index 2fd3ffb0b0..433633df98 100644 --- a/OvmfPkg/CpuHotplugSmm/Smbase.c +++ b/OvmfPkg/CpuHotplugSmm/Smbase.c @@ -10,7 +10,9 @@ #include // CpuPause() #include // CopyMem() #include // DEBUG() +#include // GetFirstGuidHob() #include // SendInitSipiSipi() +#include // EFI_HOB_PLATFORM_INFO #include // InterlockedCompareExchange64() #include // SMM_DEFAULT_SMBASE @@ -133,7 +135,9 @@ SmbaseReleasePostSmmPen ( Note that this effects an "SMRAM to SMRAM" copy. Additionally, shut the APIC ID gate in FIRST_SMI_HANDLER_CONTEXT, and prepare - for configuring MSR_IA32_FEATURE_CONTROL. + for configuring MSR_IA32_FEATURE_CONTROL. (The latter depends on a GUID HOB, + which does not live in SMRAM; however, if we can't trust the HOB list at this + stage, we're doomed anyway.) This function may only be called from the entry point function of the driver, and only after PcdQ35SmramAtDefaultSmbase has been determined to be TRUE. @@ -144,6 +148,7 @@ SmbaseInstallFirstSmiHandler ( ) { FIRST_SMI_HANDLER_CONTEXT *Context; + EFI_HOB_GUID_TYPE *GuidHob; CopyMem ( (VOID *)(UINTN)(SMM_DEFAULT_SMBASE + SMM_HANDLER_OFFSET), @@ -155,6 +160,20 @@ SmbaseInstallFirstSmiHandler ( Context->ApicIdGate = MAX_UINT64; Context->FeatureControl = 0; + GuidHob = GetFirstGuidHob (&gUefiOvmfPkgPlatformInfoGuid); + if (GuidHob != NULL) { + EFI_HOB_PLATFORM_INFO *Info; + + Info = GET_GUID_HOB_DATA (GuidHob); + if (Info->FeatureControl) { + Context->FeatureControlHighValue = (UINT32)RShiftU64 ( + Info->FeatureControlValue, + 32 + ); + Context->FeatureControlLowValue = (UINT32)Info->FeatureControlValue; + Context->FeatureControl = 1; + } + } } /**