The ARM extensions configuration *must* match the existing vCPUs already
initialized in KVM at VM initialization. ARM does not allow any per-vCPU
features to be changed once the system has fully initialized. This is an
immutable constraint of the ARM CPU architecture.
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
target/arm/cpu.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index 3de0cb346b..14fcabc2c9 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -1912,6 +1912,49 @@ static void arm_cpu_finalizefn(Object *obj)
#endif
}
+static void arm_cpu_check_features_change(ARMCPU *cpu, Error **errp)
+{
+#if defined(TARGET_AARCH64) && !defined(CONFIG_USER_ONLY)
+ MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
+ ARMCPU *firstcpu = ARM_CPU(first_cpu);
+ DeviceState *dev = DEVICE(cpu);
+
+ if (!arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
+ return;
+ }
+
+ /* For now, features of hotplugged CPU MUST match earlier booted CPUs */
+ if (!dev->hotplugged || !mc->has_hotpluggable_cpus) {
+ return;
+ }
+
+ if (cpu_isar_feature(aa64_sve, cpu) &&
+ (cpu->sve_max_vq != firstcpu->sve_max_vq ||
+ cpu->sve_vq.map != firstcpu->sve_vq.map)) {
+ error_setg(errp,
+ "CPU %d: 'SVE' feature didn't match with existing CPUs",
+ CPU(cpu)->cpu_index);
+ return;
+ }
+
+ if (cpu_isar_feature(aa64_sme, cpu) &&
+ (cpu->sme_vq.map != firstcpu->sme_vq.map)) {
+ error_setg(errp,
+ "CPU %d: 'SME' feature didn't match with exisitng CPUs",
+ CPU(cpu)->cpu_index);
+ return;
+ }
+
+ if (cpu_isar_feature(aa64_pauth, cpu) &&
+ (cpu->prop_pauth != firstcpu->prop_pauth)) {
+ error_setg(errp,
+ "CPU %d: 'PAuth' feature didn't match with exisitng CPUs",
+ CPU(cpu)->cpu_index);
+ return;
+ }
+#endif
+}
+
void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp)
{
Error *local_err = NULL;
@@ -1961,6 +2004,13 @@ void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp)
return;
}
}
+
+ /*
+ * As of now, we do not support heterogeneous computing, hence, features of
+ * all cpus should match. Hotplugged vCPUs are not allowed to have
+ * different features than the existing cold-plugged vCPUs
+ */
+ arm_cpu_check_features_change(cpu, &local_err);
}
static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
--
2.34.1