]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg: CpuDxe: broadcast MTRR changes to APs
authorLaszlo Ersek <lersek@redhat.com>
Mon, 19 Oct 2015 19:08:47 +0000 (19:08 +0000)
committermdkinney <mdkinney@Edk2>
Mon, 19 Oct 2015 19:08:47 +0000 (19:08 +0000)
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.

Additionally, the broadcast should occur at MP startup as well,
not only when MTRR settings are changed. The inspiration is
taken from

  Quark_EDKII_v1.1.0/IA32FamilyCpuBasePkg/CpuMpDxe/

(see the EarlyMpInit() function and its call sites in
"ProcessorConfig.c").

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Michael Kinney <michael.d.kinney@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18632 6f19259b-4bc3-4df7-8a09-765794883524

UefiCpuPkg/CpuDxe/CpuDxe.c
UefiCpuPkg/CpuDxe/CpuMp.c
UefiCpuPkg/CpuDxe/CpuMp.h

index c9df4e146ac37d9c1424e7a7e4becdb9381bc01a..daf97bd4a6cf6b762b103d6db7d35205e204c89a 100644 (file)
@@ -350,6 +350,9 @@ CpuSetMemoryAttributes (
 {\r
   RETURN_STATUS             Status;\r
   MTRR_MEMORY_CACHE_TYPE    CacheType;\r
+  EFI_STATUS                MpStatus;\r
+  EFI_MP_SERVICES_PROTOCOL  *MpService;\r
+  MTRR_SETTINGS             MtrrSettings;\r
 \r
   if (!IsMtrrSupported ()) {\r
     return EFI_UNSUPPORTED;\r
@@ -405,6 +408,29 @@ CpuSetMemoryAttributes (
              CacheType\r
              );\r
 \r
+  if (!RETURN_ERROR (Status)) {\r
+    MpStatus = gBS->LocateProtocol (\r
+                      &gEfiMpServiceProtocolGuid,\r
+                      NULL,\r
+                      (VOID **)&MpService\r
+                      );\r
+    //\r
+    // Synchronize the update with all APs\r
+    //\r
+    if (!EFI_ERROR (MpStatus)) {\r
+      MtrrGetAllMtrrs (&MtrrSettings);\r
+      MpStatus = MpService->StartupAllAPs (\r
+                              MpService,          // This\r
+                              SetMtrrsFromBuffer, // Procedure\r
+                              TRUE,               // SingleThread\r
+                              NULL,               // WaitEvent\r
+                              0,                  // TimeoutInMicrosecsond\r
+                              &MtrrSettings,      // ProcedureArgument\r
+                              NULL                // FailedCpuList\r
+                              );\r
+      ASSERT (MpStatus == EFI_SUCCESS || MpStatus == EFI_NOT_STARTED);\r
+    }\r
+  }\r
   return (EFI_STATUS) Status;\r
 }\r
 \r
index f3a5a24b0f6639aa9005a74eff9a54990fe532e9..04c2f1f0ac12ff3511ddfd444bf8000ee302bebc 100644 (file)
@@ -1666,6 +1666,22 @@ ExitBootServicesCallback (
   SendInitIpiAllExcludingSelf ();\r
 }\r
 \r
+/**\r
+  A minimal wrapper function that allows MtrrSetAllMtrrs() to be passed to\r
+  EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() as Procedure.\r
+\r
+  @param[in] Buffer  Pointer to an MTRR_SETTINGS object, to be passed to\r
+                     MtrrSetAllMtrrs().\r
+**/\r
+VOID\r
+EFIAPI\r
+SetMtrrsFromBuffer (\r
+  IN VOID *Buffer\r
+  )\r
+{\r
+  MtrrSetAllMtrrs (Buffer);\r
+}\r
+\r
 /**\r
   Initialize Multi-processor support.\r
 \r
@@ -1676,6 +1692,7 @@ InitializeMpSupport (
   )\r
 {\r
   EFI_STATUS     Status;\r
+  MTRR_SETTINGS  MtrrSettings;\r
   UINTN          Timeout;\r
 \r
   gMaxLogicalProcessorNumber = (UINTN) PcdGet32 (PcdCpuMaxLogicalProcessorNumber);\r
@@ -1748,6 +1765,21 @@ InitializeMpSupport (
   //\r
   CollectBistDataFromHob ();\r
 \r
+  //\r
+  // Synchronize MTRR settings to APs.\r
+  //\r
+  MtrrGetAllMtrrs (&MtrrSettings);\r
+  Status = mMpServicesTemplate.StartupAllAPs (\r
+                                 &mMpServicesTemplate, // This\r
+                                 SetMtrrsFromBuffer,   // Procedure\r
+                                 TRUE,                 // SingleThread\r
+                                 NULL,                 // WaitEvent\r
+                                 0,                    // TimeoutInMicrosecsond\r
+                                 &MtrrSettings,        // ProcedureArgument\r
+                                 NULL                  // FailedCpuList\r
+                                 );\r
+  ASSERT (Status == EFI_SUCCESS || Status == EFI_NOT_STARTED);\r
+\r
   Status = gBS->InstallMultipleProtocolInterfaces (\r
                   &mMpServiceHandle,\r
                   &gEfiMpServiceProtocolGuid,  &mMpServicesTemplate,\r
index d2866e463bc97e35d1d4dffd34bcb31a383959ae..503f3ae944fe850e1a2afeeb15aa6604ef2e0242 100644 (file)
@@ -643,5 +643,18 @@ ResetApStackless (
   IN UINT32 ProcessorId\r
   );\r
 \r
+/**\r
+  A minimal wrapper function that allows MtrrSetAllMtrrs() to be passed to\r
+  EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() as Procedure.\r
+\r
+  @param[in] Buffer  Pointer to an MTRR_SETTINGS object, to be passed to\r
+                     MtrrSetAllMtrrs().\r
+**/\r
+VOID\r
+EFIAPI\r
+SetMtrrsFromBuffer (\r
+  IN VOID *Buffer\r
+  );\r
+\r
 #endif // _CPU_MP_H_\r
 \r