mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-25 22:54:51 +02:00
OvmfPkg/PlatformPei: remove mFeatureControlValue
Use PlatformInfoHob->FeatureControlValue instead. OnMpServicesAvailable() will find PlatformInfoHob using GetFirstGuidHob() and pass a pointer to the WriteFeatureControl callback. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Tested-by: Tom Lendacky <thomas.lendacky@amd.com> Acked-by: Ard Biesheuvel <ardb@kernel.org>
This commit is contained in:
parent
862614e254
commit
f6a196c7eb
@ -48,6 +48,8 @@ typedef struct {
|
|||||||
|
|
||||||
UINT32 S3AcpiReservedMemoryBase;
|
UINT32 S3AcpiReservedMemoryBase;
|
||||||
UINT32 S3AcpiReservedMemorySize;
|
UINT32 S3AcpiReservedMemorySize;
|
||||||
|
|
||||||
|
UINT64 FeatureControlValue;
|
||||||
} EFI_HOB_PLATFORM_INFO;
|
} EFI_HOB_PLATFORM_INFO;
|
||||||
#pragma pack()
|
#pragma pack()
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
#include <Library/DebugLib.h>
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/HobLib.h>
|
||||||
#include <Library/PeiServicesLib.h>
|
#include <Library/PeiServicesLib.h>
|
||||||
#include <Library/QemuFwCfgLib.h>
|
#include <Library/QemuFwCfgLib.h>
|
||||||
#include <Ppi/MpServices.h>
|
#include <Ppi/MpServices.h>
|
||||||
@ -16,11 +17,6 @@
|
|||||||
|
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
|
|
||||||
//
|
|
||||||
// The value to be written to the Feature Control MSR, retrieved from fw_cfg.
|
|
||||||
//
|
|
||||||
STATIC UINT64 mFeatureControlValue;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Write the Feature Control MSR on an Application Processor or the Boot
|
Write the Feature Control MSR on an Application Processor or the Boot
|
||||||
Processor.
|
Processor.
|
||||||
@ -38,10 +34,22 @@ WriteFeatureControl (
|
|||||||
IN OUT VOID *WorkSpace
|
IN OUT VOID *WorkSpace
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
EFI_HOB_PLATFORM_INFO *PlatformInfoHob = WorkSpace;
|
||||||
|
|
||||||
if (TdIsEnabled ()) {
|
if (TdIsEnabled ()) {
|
||||||
TdVmCall (TDVMCALL_WRMSR, (UINT64)MSR_IA32_FEATURE_CONTROL, mFeatureControlValue, 0, 0, 0);
|
TdVmCall (
|
||||||
|
TDVMCALL_WRMSR,
|
||||||
|
(UINT64)MSR_IA32_FEATURE_CONTROL,
|
||||||
|
PlatformInfoHob->FeatureControlValue,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
AsmWriteMsr64 (MSR_IA32_FEATURE_CONTROL, mFeatureControlValue);
|
AsmWriteMsr64 (
|
||||||
|
MSR_IA32_FEATURE_CONTROL,
|
||||||
|
PlatformInfoHob->FeatureControlValue
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,6 +75,15 @@ OnMpServicesAvailable (
|
|||||||
{
|
{
|
||||||
EFI_PEI_MP_SERVICES_PPI *MpServices;
|
EFI_PEI_MP_SERVICES_PPI *MpServices;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
EFI_HOB_PLATFORM_INFO *PlatformInfoHob;
|
||||||
|
EFI_HOB_GUID_TYPE *GuidHob;
|
||||||
|
|
||||||
|
GuidHob = GetFirstGuidHob (&gUefiOvmfPkgPlatformInfoGuid);
|
||||||
|
if (GuidHob == NULL) {
|
||||||
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlatformInfoHob = (EFI_HOB_PLATFORM_INFO *)GET_GUID_HOB_DATA (GuidHob);
|
||||||
|
|
||||||
DEBUG ((DEBUG_VERBOSE, "%a: %a\n", gEfiCallerBaseName, __FUNCTION__));
|
DEBUG ((DEBUG_VERBOSE, "%a: %a\n", gEfiCallerBaseName, __FUNCTION__));
|
||||||
|
|
||||||
@ -80,7 +97,7 @@ OnMpServicesAvailable (
|
|||||||
WriteFeatureControl, // Procedure
|
WriteFeatureControl, // Procedure
|
||||||
FALSE, // SingleThread
|
FALSE, // SingleThread
|
||||||
0, // TimeoutInMicroSeconds: inf.
|
0, // TimeoutInMicroSeconds: inf.
|
||||||
NULL // ProcedureArgument
|
PlatformInfoHob // ProcedureArgument
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status) && (Status != EFI_NOT_STARTED)) {
|
if (EFI_ERROR (Status) && (Status != EFI_NOT_STARTED)) {
|
||||||
DEBUG ((DEBUG_ERROR, "%a: StartupAllAps(): %r\n", __FUNCTION__, Status));
|
DEBUG ((DEBUG_ERROR, "%a: StartupAllAps(): %r\n", __FUNCTION__, Status));
|
||||||
@ -90,7 +107,7 @@ OnMpServicesAvailable (
|
|||||||
//
|
//
|
||||||
// Now write the MSR on the BSP too.
|
// Now write the MSR on the BSP too.
|
||||||
//
|
//
|
||||||
WriteFeatureControl (NULL);
|
WriteFeatureControl (PlatformInfoHob);
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +124,7 @@ STATIC CONST EFI_PEI_NOTIFY_DESCRIPTOR mMpServicesNotify = {
|
|||||||
|
|
||||||
VOID
|
VOID
|
||||||
InstallFeatureControlCallback (
|
InstallFeatureControlCallback (
|
||||||
VOID
|
IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
@ -119,7 +136,7 @@ InstallFeatureControlCallback (
|
|||||||
&FwCfgItem,
|
&FwCfgItem,
|
||||||
&FwCfgSize
|
&FwCfgSize
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status) || (FwCfgSize != sizeof mFeatureControlValue)) {
|
if (EFI_ERROR (Status) || (FwCfgSize != sizeof (PlatformInfoHob->FeatureControlValue))) {
|
||||||
//
|
//
|
||||||
// Nothing to do.
|
// Nothing to do.
|
||||||
//
|
//
|
||||||
@ -127,7 +144,10 @@ InstallFeatureControlCallback (
|
|||||||
}
|
}
|
||||||
|
|
||||||
QemuFwCfgSelectItem (FwCfgItem);
|
QemuFwCfgSelectItem (FwCfgItem);
|
||||||
QemuFwCfgReadBytes (sizeof mFeatureControlValue, &mFeatureControlValue);
|
QemuFwCfgReadBytes (
|
||||||
|
sizeof (PlatformInfoHob->FeatureControlValue),
|
||||||
|
&(PlatformInfoHob->FeatureControlValue)
|
||||||
|
);
|
||||||
|
|
||||||
Status = PeiServicesNotifyPpi (&mMpServicesNotify);
|
Status = PeiServicesNotifyPpi (&mMpServicesNotify);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
|
@ -396,7 +396,7 @@ InitializePlatform (
|
|||||||
}
|
}
|
||||||
|
|
||||||
IntelTdxInitialize ();
|
IntelTdxInitialize ();
|
||||||
InstallFeatureControlCallback ();
|
InstallFeatureControlCallback (PlatformInfoHob);
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ MemTypeInfoInitialization (
|
|||||||
|
|
||||||
VOID
|
VOID
|
||||||
InstallFeatureControlCallback (
|
InstallFeatureControlCallback (
|
||||||
VOID
|
IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob
|
||||||
);
|
);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
Loading…
x
Reference in New Issue
Block a user