History

x86/topology: Disable CPU online/offline control for TDX guests

Unlike regular VMs, TDX guests use the firmware hand-off wakeup method to wake up the APs during the boot process. This wakeup model uses a mailbox to communicate with firmware to bring up the APs. As per the design, this mailbox can only be used once for the given AP, which means after the APs are booted, the same mailbox cannot be used to offline/online the given AP. More details about this requirement can be found in Intel TDX Virtual Firmware Design Guide, sec titled "AP initialization in OS" and in sec titled "Hotplug Device". Since the architecture does not support any method of offlining the CPUs, disable CPU hotplug support in the kernel. Since this hotplug disable feature can be re-used by other VM guests, add a new CC attribute CC_ATTR_HOTPLUG_DISABLED and use it to disable the hotplug support. Attempt to offline CPU will fail with -EOPNOTSUPP.

Kuppuswamy Sathyanarayanan committed 4 years ago

Commit bae1a961 parent 77a512e3 files · +18 −0Browse files

Showing the changes to kernel (1 of 3 files). Show all

Unified · Split

kernel/cpu.c+7−0
@@ -35,6 +35,7 @@ · 34 unmodified lines
3535 #include <linux/percpu-rwsem.h>
3636 #include <linux/cpuset.h>
3737 #include <linux/random.h>
38+#include <linux/cc_platform.h>
3839
3940 #include <trace/events/power.h>
4041 #define CREATE_TRACE_POINTS
@@ -1186,6 +1187,12 @@ out: · 1145 unmodified lines
11861187
11871188 static int cpu_down_maps_locked(unsigned int cpu, enum cpuhp_state target)
11881189 {
1190+ /*
1191+ * If the platform does not support hotplug, report it explicitly to
1192+ * differentiate it from a transient offlining failure.
1193+ */
1194+ if (cc_platform_has(CC_ATTR_HOTPLUG_DISABLED))
1195+ return -EOPNOTSUPP;
11891196 if (cpu_hotplug_disabled)
11901197 return -EBUSY;
11911198 return _cpu_down(cpu, 0, target);