\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
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
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
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