OvmfPkg/CpuHotplugSmm: hook up MSR_IA32_FEATURE_CONTROL with platform info
Map the feature control MSR config from the OVMF platform info HOB to FIRST_SMI_HANDLER_CONTEXT. (Note that CpuHotplugSmm already consumes -- indirectly -- the "MdePkg/Library/DxeHobLib/DxeHobLib.inf" library instance, according to the build report; therefore adding an explicit HobLib class dependency shouldn't *generally* increase this SMM driver's exposure. The consumed lib instances are the same before and after this patch, at least in "OvmfPkgIa32X64.dsc".) Fixes: https://github.com/tianocore/edk2/issues/11188 Signed-off-by: Laszlo Ersek <laszlo.ersek@posteo.net>
This commit is contained in:
committed by
Laszlo Ersek
parent
0e814e829e
commit
43d696a366
@@ -42,6 +42,7 @@
|
|||||||
BaseMemoryLib
|
BaseMemoryLib
|
||||||
CpuLib
|
CpuLib
|
||||||
DebugLib
|
DebugLib
|
||||||
|
HobLib
|
||||||
LocalApicLib
|
LocalApicLib
|
||||||
MmServicesTableLib
|
MmServicesTableLib
|
||||||
PcdLib
|
PcdLib
|
||||||
@@ -53,6 +54,9 @@
|
|||||||
gEfiMmCpuIoProtocolGuid ## CONSUMES
|
gEfiMmCpuIoProtocolGuid ## CONSUMES
|
||||||
gEfiSmmCpuServiceProtocolGuid ## CONSUMES
|
gEfiSmmCpuServiceProtocolGuid ## CONSUMES
|
||||||
|
|
||||||
|
[Guids]
|
||||||
|
gUefiOvmfPkgPlatformInfoGuid ## CONSUMES
|
||||||
|
|
||||||
[Pcd]
|
[Pcd]
|
||||||
gUefiCpuPkgTokenSpaceGuid.PcdCpuHotPlugDataAddress ## CONSUMES
|
gUefiCpuPkgTokenSpaceGuid.PcdCpuHotPlugDataAddress ## CONSUMES
|
||||||
gUefiOvmfPkgTokenSpaceGuid.PcdCpuHotEjectDataAddress ## CONSUMES
|
gUefiOvmfPkgTokenSpaceGuid.PcdCpuHotEjectDataAddress ## CONSUMES
|
||||||
|
|||||||
@@ -10,7 +10,9 @@
|
|||||||
#include <Library/BaseLib.h> // CpuPause()
|
#include <Library/BaseLib.h> // CpuPause()
|
||||||
#include <Library/BaseMemoryLib.h> // CopyMem()
|
#include <Library/BaseMemoryLib.h> // CopyMem()
|
||||||
#include <Library/DebugLib.h> // DEBUG()
|
#include <Library/DebugLib.h> // DEBUG()
|
||||||
|
#include <Library/HobLib.h> // GetFirstGuidHob()
|
||||||
#include <Library/LocalApicLib.h> // SendInitSipiSipi()
|
#include <Library/LocalApicLib.h> // SendInitSipiSipi()
|
||||||
|
#include <Library/PlatformInitLib.h> // EFI_HOB_PLATFORM_INFO
|
||||||
#include <Library/SynchronizationLib.h> // InterlockedCompareExchange64()
|
#include <Library/SynchronizationLib.h> // InterlockedCompareExchange64()
|
||||||
#include <Register/Intel/SmramSaveStateMap.h> // SMM_DEFAULT_SMBASE
|
#include <Register/Intel/SmramSaveStateMap.h> // SMM_DEFAULT_SMBASE
|
||||||
|
|
||||||
@@ -133,7 +135,9 @@ SmbaseReleasePostSmmPen (
|
|||||||
Note that this effects an "SMRAM to SMRAM" copy.
|
Note that this effects an "SMRAM to SMRAM" copy.
|
||||||
|
|
||||||
Additionally, shut the APIC ID gate in FIRST_SMI_HANDLER_CONTEXT, and prepare
|
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,
|
This function may only be called from the entry point function of the driver,
|
||||||
and only after PcdQ35SmramAtDefaultSmbase has been determined to be TRUE.
|
and only after PcdQ35SmramAtDefaultSmbase has been determined to be TRUE.
|
||||||
@@ -144,6 +148,7 @@ SmbaseInstallFirstSmiHandler (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
FIRST_SMI_HANDLER_CONTEXT *Context;
|
FIRST_SMI_HANDLER_CONTEXT *Context;
|
||||||
|
EFI_HOB_GUID_TYPE *GuidHob;
|
||||||
|
|
||||||
CopyMem (
|
CopyMem (
|
||||||
(VOID *)(UINTN)(SMM_DEFAULT_SMBASE + SMM_HANDLER_OFFSET),
|
(VOID *)(UINTN)(SMM_DEFAULT_SMBASE + SMM_HANDLER_OFFSET),
|
||||||
@@ -155,6 +160,20 @@ SmbaseInstallFirstSmiHandler (
|
|||||||
Context->ApicIdGate = MAX_UINT64;
|
Context->ApicIdGate = MAX_UINT64;
|
||||||
|
|
||||||
Context->FeatureControl = 0;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user