OvmfPkg: SmmControl2Dxe: Avoid double initialization

This change adds a build time PCD to prevent the SmmControl2Dxe driver
from re-initialization the MM related registers.

This register is to be used when MmControlPei is already executed in PEI
phase and completed setting up the MM control registers.

Signed-off-by: Kun Qin <kun.qin@microsoft.com>
This commit is contained in:
Kun Qin 2025-04-23 10:39:32 -07:00 committed by mergify[bot]
parent 8ac270e812
commit cf4534c9da
3 changed files with 14 additions and 7 deletions

View file

@ -485,3 +485,7 @@
## This feature flag indicates the firmware build needs the qemu variable service.
gUefiOvmfPkgTokenSpaceGuid.PcdQemuVarsRequire|FALSE|BOOLEAN|0x77
## Informs modules whether the platform firmware supports Standalone MM.
#
gUefiOvmfPkgTokenSpaceGuid.PcdStandaloneMmEnable|FALSE|BOOLEAN|0x100065

View file

@ -201,13 +201,15 @@ SmmControl2DxeEntryPoint (
// this bit is clear after each reset.
//
SmiEnableVal = IoRead32 (mSmiEnable);
if ((SmiEnableVal & ICH9_SMI_EN_APMC_EN) != 0) {
DEBUG ((
DEBUG_ERROR,
"%a: this Q35 implementation lacks SMI\n",
__func__
));
goto FatalError;
if (!FeaturePcdGet (PcdStandaloneMmEnable)) {
if ((SmiEnableVal & ICH9_SMI_EN_APMC_EN) != 0) {
DEBUG ((
DEBUG_ERROR,
"%a: this Q35 implementation lacks SMI\n",
__func__
));
goto FatalError;
}
}
//

View file

@ -69,6 +69,7 @@
[FeaturePcd]
gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire
gUefiOvmfPkgTokenSpaceGuid.PcdStandaloneMmEnable
[Depex]
TRUE