[edk2-devel] [PATCH v5 9/9] OvmfPkg/SmmControl2Dxe: negotiate CPU hot-unplug

Ankur Arora posted 9 patches 3 years, 9 months ago
There is a newer version of this series
[edk2-devel] [PATCH v5 9/9] OvmfPkg/SmmControl2Dxe: negotiate CPU hot-unplug
Posted by Ankur Arora 3 years, 9 months ago
As part of the negotiation treat ICH9_LPC_SMI_F_CPU_HOT_UNPLUG as a
subfeature of feature flag ICH9_LPC_SMI_F_CPU_HOTPLUG, so enable it
only if the other is also being negotiated.

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>
---
 OvmfPkg/SmmControl2Dxe/SmiFeatures.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/OvmfPkg/SmmControl2Dxe/SmiFeatures.c b/OvmfPkg/SmmControl2Dxe/SmiFeatures.c
index c9d875543205..af01104d69c6 100644
--- a/OvmfPkg/SmmControl2Dxe/SmiFeatures.c
+++ b/OvmfPkg/SmmControl2Dxe/SmiFeatures.c
@@ -29,6 +29,13 @@
 //

 #define ICH9_LPC_SMI_F_CPU_HOTPLUG BIT1

 

+// The following bit value stands for "enable CPU hot unplug, and inject an SMI

+// with control value ICH9_APM_CNT_CPU_HOT_UNPLUG upon hot unplug", in the

+// "etc/smi/supported-features" and "etc/smi/requested-features" fw_cfg files.

+// Can only be negotiated alongside ICH9_LPC_SMI_F_CPU_HOTPLUG.

+//

+#define ICH9_LPC_SMI_F_CPU_HOT_UNPLUG BIT2

+

 //

 // Provides a scratch buffer (allocated in EfiReservedMemoryType type memory)

 // for the S3 boot script fragment to write to and read from.

@@ -112,7 +119,8 @@ NegotiateSmiFeatures (
   QemuFwCfgReadBytes (sizeof mSmiFeatures, &mSmiFeatures);

 

   //

-  // We want broadcast SMI, SMI on CPU hotplug, and nothing else.

+  // We want broadcast SMI, SMI on CPU hotplug, on CPU hot-unplug

+  // and nothing else.

   //

   RequestedFeaturesMask = ICH9_LPC_SMI_F_BROADCAST;

   if (!MemEncryptSevIsEnabled ()) {

@@ -120,8 +128,18 @@ NegotiateSmiFeatures (
     // For now, we only support hotplug with SEV disabled.

     //

     RequestedFeaturesMask |= ICH9_LPC_SMI_F_CPU_HOTPLUG;

+    RequestedFeaturesMask |= ICH9_LPC_SMI_F_CPU_HOT_UNPLUG;

   }

   mSmiFeatures &= RequestedFeaturesMask;

+

+  if (!(mSmiFeatures & ICH9_LPC_SMI_F_CPU_HOTPLUG) &&

+      (mSmiFeatures & ICH9_LPC_SMI_F_CPU_HOT_UNPLUG)) {

+    DEBUG ((DEBUG_WARN, "%a CPU host-features %Lx, requested mask %Lx\n",

+      __FUNCTION__, mSmiFeatures, RequestedFeaturesMask));

+

+    mSmiFeatures &= ~ICH9_LPC_SMI_F_CPU_HOT_UNPLUG;

+  }

+

   QemuFwCfgSelectItem (mRequestedFeaturesItem);

   QemuFwCfgWriteBytes (sizeof mSmiFeatures, &mSmiFeatures);

 

@@ -162,8 +180,9 @@ NegotiateSmiFeatures (
   if ((mSmiFeatures & ICH9_LPC_SMI_F_CPU_HOTPLUG) == 0) {

     DEBUG ((DEBUG_INFO, "%a: CPU hotplug not negotiated\n", __FUNCTION__));

   } else {

-    DEBUG ((DEBUG_INFO, "%a: CPU hotplug with SMI negotiated\n",

-      __FUNCTION__));

+    DEBUG ((DEBUG_INFO, "%a: CPU hotplug%s with SMI negotiated\n",

+      __FUNCTION__,

+      (mSmiFeatures & ICH9_LPC_SMI_F_CPU_HOT_UNPLUG) ? ", unplug" : ""));

   }

 

   //

-- 
2.9.3



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#70768): https://edk2.groups.io/g/devel/message/70768
Mute This Topic: https://groups.io/mt/80125324/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-