]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/SmmControl2Dxe: negotiate ICH9_LPC_SMI_F_CPU_HOTPLUG
authorLaszlo Ersek <lersek@redhat.com>
Tue, 14 Jul 2020 18:43:05 +0000 (20:43 +0200)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Mon, 24 Aug 2020 16:41:44 +0000 (16:41 +0000)
The ICH9_LPC_SMI_F_BROADCAST and ICH9_LPC_SMI_F_CPU_HOTPLUG feature flags
cause QEMU to behave as follows:

  BROADCAST  CPU_HOTPLUG  use case / behavior
  ---------  -----------  ------------------------------------------------
  clear      clear        OVMF built without SMM_REQUIRE; or very old OVMF
                          (from before commit a316d7ac91d3 / 2017-02-07).
                          QEMU permits CPU hotplug operations, and does
                          not cause the OS to inject an SMI upon hotplug.
                          Firmware is not expected to be aware of hotplug
                          events.

  clear      set          Invalid feature set; QEMU rejects the feature
                          negotiation.

  set        clear        OVMF after a316d7ac91d3 / 2017-02-07, built with
                          SMM_REQUIRE, but no support for CPU hotplug.
                          QEMU gracefully refuses hotplug operations.

  set        set          OVMF after a316d7ac91d3 / 2017-02-07, built with
                          SMM_REQUIRE, and supporting CPU hotplug. QEMU
                          permits CPU hotplug operations, and causes the
                          OS to inject an SMI upon hotplug. Firmware is
                          expected to deal with hotplug events.

Negotiate ICH9_LPC_SMI_F_CPU_HOTPLUG -- but only if SEV is disabled, as
OvmfPkg/CpuHotplugSmm can't deal with SEV yet.

Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Igor Mammedov <imammedo@redhat.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Liran Alon <liran.alon@oracle.com>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20200714184305.9814-1-lersek@redhat.com>
Acked-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
OvmfPkg/SmmControl2Dxe/SmiFeatures.c
OvmfPkg/SmmControl2Dxe/SmmControl2Dxe.inf

index 6210b7515e3e5d3862ad99f6b3fb815c873c60a9..c9d875543205462292fda5b2db0a82268a262b2e 100644 (file)
@@ -9,6 +9,7 @@
 \r
 #include <Library/BaseLib.h>\r
 #include <Library/DebugLib.h>\r
+#include <Library/MemEncryptSevLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/QemuFwCfgLib.h>\r
 // "etc/smi/supported-features" and "etc/smi/requested-features" fw_cfg files.\r
 //\r
 #define ICH9_LPC_SMI_F_BROADCAST BIT0\r
+//\r
+// The following bit value stands for "enable CPU hotplug, and inject an SMI\r
+// with control value ICH9_APM_CNT_CPU_HOTPLUG upon hotplug", in the\r
+// "etc/smi/supported-features" and "etc/smi/requested-features" fw_cfg files.\r
+//\r
+#define ICH9_LPC_SMI_F_CPU_HOTPLUG BIT1\r
 \r
 //\r
 // Provides a scratch buffer (allocated in EfiReservedMemoryType type memory)\r
@@ -67,6 +74,7 @@ NegotiateSmiFeatures (
   UINTN                SupportedFeaturesSize;\r
   UINTN                RequestedFeaturesSize;\r
   UINTN                FeaturesOkSize;\r
+  UINT64               RequestedFeaturesMask;\r
 \r
   //\r
   // Look up the fw_cfg files used for feature negotiation. The selector keys\r
@@ -104,9 +112,16 @@ NegotiateSmiFeatures (
   QemuFwCfgReadBytes (sizeof mSmiFeatures, &mSmiFeatures);\r
 \r
   //\r
-  // We want broadcast SMI and nothing else.\r
+  // We want broadcast SMI, SMI on CPU hotplug, and nothing else.\r
   //\r
-  mSmiFeatures &= ICH9_LPC_SMI_F_BROADCAST;\r
+  RequestedFeaturesMask = ICH9_LPC_SMI_F_BROADCAST;\r
+  if (!MemEncryptSevIsEnabled ()) {\r
+    //\r
+    // For now, we only support hotplug with SEV disabled.\r
+    //\r
+    RequestedFeaturesMask |= ICH9_LPC_SMI_F_CPU_HOTPLUG;\r
+  }\r
+  mSmiFeatures &= RequestedFeaturesMask;\r
   QemuFwCfgSelectItem (mRequestedFeaturesItem);\r
   QemuFwCfgWriteBytes (sizeof mSmiFeatures, &mSmiFeatures);\r
 \r
@@ -144,6 +159,13 @@ NegotiateSmiFeatures (
     DEBUG ((DEBUG_INFO, "%a: using SMI broadcast\n", __FUNCTION__));\r
   }\r
 \r
+  if ((mSmiFeatures & ICH9_LPC_SMI_F_CPU_HOTPLUG) == 0) {\r
+    DEBUG ((DEBUG_INFO, "%a: CPU hotplug not negotiated\n", __FUNCTION__));\r
+  } else {\r
+    DEBUG ((DEBUG_INFO, "%a: CPU hotplug with SMI negotiated\n",\r
+      __FUNCTION__));\r
+  }\r
+\r
   //\r
   // Negotiation successful (although we may not have gotten the optimal\r
   // feature set).\r
index 3abed141e6447fcfcee734af199bb347e98eec3c..b8fdea8deb844a0ad6332cd910801a6da8afe660 100644 (file)
@@ -46,6 +46,7 @@
   BaseLib\r
   DebugLib\r
   IoLib\r
+  MemEncryptSevLib\r
   MemoryAllocationLib\r
   PcdLib\r
   PciLib\r