]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/SmmCpuFeaturesLib: call CPU hot-eject handler
authorAnkur Arora <ankur.a.arora@oracle.com>
Fri, 12 Mar 2021 06:26:53 +0000 (22:26 -0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 16 Mar 2021 13:21:46 +0000 (13:21 +0000)
Call the CPU hot-eject handler if one is installed. The condition for
installation is (PcdCpuMaxLogicalProcessorNumber > 1), and there's
a hot-unplug request.

The handler is called from SmmCpuFeaturesRendezvousExit(), which is
in-turn called at the tail-end of SmiRendezvous() after the BSP has
signalled an SMI exit via the "AllCpusInSync" loop.

Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Igor Mammedov <imammedo@redhat.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Aaron Young <aaron.young@oracle.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3132
Signed-off-by: Ankur Arora <ankur.a.arora@oracle.com>
Message-Id: <20210312062656.2477515-8-ankur.a.arora@oracle.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c

index 5c025bc717c33f89f05ed420498bdfe4c2ebc928..fdf2380974fa20c1b24cb37267514bf99de15aaa 100644 (file)
@@ -452,6 +452,40 @@ SmmCpuFeaturesRendezvousExit (
   IN UINTN  CpuIndex\r
   )\r
 {\r
+  //\r
+  // We only call the Handler if CPU hot-eject is enabled\r
+  // (PcdCpuMaxLogicalProcessorNumber > 1), and hot-eject is needed\r
+  // in this SMI exit (otherwise mCpuHotEjectData->Handler is not armed.)\r
+  //\r
+\r
+  if (mCpuHotEjectData != NULL) {\r
+    CPU_HOT_EJECT_HANDLER Handler;\r
+\r
+    //\r
+    // As the comment above mentions, mCpuHotEjectData->Handler might be\r
+    // written to on the BSP as part of handling of the CPU-ejection.\r
+    //\r
+    // We know that any initial assignment to mCpuHotEjectData->Handler\r
+    // (on the BSP, in the CpuHotplugMmi() context) is ordered-before the\r
+    // load below, since it is guaranteed to happen before the\r
+    // control-dependency of the BSP's SMI exit signal -- by way of a store\r
+    // to AllCpusInSync (on the BSP, in BspHandler()) and the corresponding\r
+    // AllCpusInSync loop (on the APs, in SmiRendezvous()) which depends on\r
+    // that store.\r
+    //\r
+    // This guarantees that these pieces of code can never execute\r
+    // simultaneously. In addition, we ensure that the following load is\r
+    // ordered-after the AllCpusInSync loop by using a MemoryFence() with\r
+    // acquire semantics.\r
+    //\r
+    MemoryFence();\r
+\r
+    Handler = mCpuHotEjectData->Handler;\r
+\r
+    if (Handler != NULL) {\r
+      Handler (CpuIndex);\r
+    }\r
+  }\r
 }\r
 \r
 /**\r