The

  Quark_EDKII_v1.1.0/IA32FamilyCpuBasePkg/CpuArchDxe

driver applies any MTRR changes to APs, if the EFI_MP_SERVICES_PROTOCOL is
available. We should do the same; port it to UefiCpuPkg.

The broadcast should occur even if PcdCpuSyncMtrrToAcpiNvs is set to
FALSE; in that case we just use a local MTRR_SETTINGS buffer, rather than
the firmware-wide "mMtrrTable" object.

Cc: Jeff Fan <jeff....@intel.com>
Cc: Chen Fan <chen.fan.f...@cn.fujitsu.com>
Cc: Jordan Justen <jordan.l.jus...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
 UefiCpuPkg/CpuDxe/CpuDxe.c | 46 +++++++++++++++++---
 1 file changed, 41 insertions(+), 5 deletions(-)

diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.c b/UefiCpuPkg/CpuDxe/CpuDxe.c
index 3d11807..269f834 100644
--- a/UefiCpuPkg/CpuDxe/CpuDxe.c
+++ b/UefiCpuPkg/CpuDxe/CpuDxe.c
@@ -407,11 +407,47 @@ CpuSetMemoryAttributes (
              );
 
   if (!RETURN_ERROR (Status)) {
-    if (FeaturePcdGet (PcdCpuSyncMtrrToAcpiNvs)) {
-      //
-      // Sync saved MTRR settings
-      //
-      MtrrGetAllMtrrs (mMtrrTable);
+    MTRR_SETTINGS            *SyncToBuffer;
+    MTRR_SETTINGS            LocalBuffer;
+    EFI_STATUS               MpStatus;
+    EFI_MP_SERVICES_PROTOCOL *MpService;
+
+    SyncToBuffer =
+      FeaturePcdGet (PcdCpuSyncMtrrToAcpiNvs) ? mMtrrTable : &LocalBuffer;
+    MpStatus = gBS->LocateProtocol (
+                      &gEfiMpServiceProtocolGuid,
+                      NULL,
+                      (VOID **) &MpService
+                      );
+
+    //
+    // Sync saved MTRR settings if (a) we have to reflect them to AcpiNVS, or
+    // (b) broadcast them to APs, or (c) both.
+    //
+    if (FeaturePcdGet (PcdCpuSyncMtrrToAcpiNvs) || !EFI_ERROR (MpStatus)) {
+      MtrrGetAllMtrrs (SyncToBuffer);
+    }
+
+    //
+    // Synchronize the update with all APs
+    //
+    if (!EFI_ERROR (MpStatus)) {
+      MpStatus = MpService->StartupAllAPs (
+                              MpService,    // This
+                              LoadMtrrData, // Procedure
+                              TRUE,         // SingleThread
+                              NULL,         // WaitEvent
+                              0,            // TimeoutInMicrosecsond
+                              SyncToBuffer, // ProcedureArgument
+                              NULL          // FailedCpuList
+                              );
+      if (MpStatus == EFI_NOT_STARTED) {
+        //
+        // If no enabled APs exit in the system, return success
+        //
+        MpStatus = EFI_SUCCESS;
+      }
+      ASSERT_EFI_ERROR (MpStatus);
     }
   }
   return (EFI_STATUS) Status;
-- 
1.8.3.1


_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to