diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c index 61ed062d27..5cdb5bdeab 100644 --- a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -963,8 +964,9 @@ SmmIplEntry ( EFI_SMM_RESERVED_SMRAM_REGION *SmramResRegion; UINT64 MaxSize; VOID *Registration; - UINT64 SmmCodeSize; + UINT64 SmmCodeSize; EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE *LMFAConfigurationTable; + EFI_CPU_ARCH_PROTOCOL *CpuArch; // // Fill in the image handle of the SMM IPL so the SMM Core can use this as the @@ -1063,16 +1065,21 @@ SmmIplEntry ( GetSmramCacheRange (mCurrentSmramRange, &mSmramCacheBase, &mSmramCacheSize); // - // Attempt to set SMRAM cacheability to WB + // If CPU AP is present, attempt to set SMRAM cacheability to WB + // Note that it is expected that cacheability of SMRAM has been set to WB if CPU AP + // is not available here. // - Status = gDS->SetMemorySpaceAttributes( - mSmramCacheBase, - mSmramCacheSize, - EFI_MEMORY_WB - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_WARN, "SMM IPL failed to set SMRAM window to EFI_MEMORY_WB\n")); - } + Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **)&CpuArch); + if (!EFI_ERROR (Status)) { + Status = gDS->SetMemorySpaceAttributes( + mSmramCacheBase, + mSmramCacheSize, + EFI_MEMORY_WB + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "SMM IPL failed to set SMRAM window to EFI_MEMORY_WB\n")); + } + } // // if Loading module at Fixed Address feature is enabled, save the SMRAM base to Load // Modules At Fixed Address Configuration Table. diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf index 8cbaf8d5d3..73507cd239 100644 --- a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf @@ -56,7 +56,7 @@ gEfiSmmConfigurationProtocolGuid # PROTOCOL ALWAYS_CONSUMED gEfiSmmControl2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED gEfiDxeSmmReadyToLockProtocolGuid # PROTOCOL ALWAYS_CONSUMED - gEfiCpuArchProtocolGuid # PROTOCOL ALWAYS_CONSUMED + gEfiCpuArchProtocolGuid # PROTOCOL SIMETIMES_CONSUMED [Guids] gEfiEventDxeDispatchGuid # ALWAYS_CONSUMED @@ -71,4 +71,4 @@ [Depex] - gEfiSmmAccess2ProtocolGuid AND gEfiSmmControl2ProtocolGuid AND gEfiCpuArchProtocolGuid + gEfiSmmAccess2ProtocolGuid AND gEfiSmmControl2ProtocolGuid