提交 54f60ef9 编写于 作者: A Andrea Bolognani

qemu: Validate ARM CPU features

This introduces semantic validation for SVE-related features,
preventing the user from combining them in invalid ways; it also
automatically enables overall SVE support if any SVE vector
length has been enabled by the user to make sure QEMU behaves
correctly.
Signed-off-by: NAndrea Bolognani <abologna@redhat.com>
Tested-by: NAndrew Jones <drjones@redhat.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 ea6c107a
......@@ -4465,6 +4465,10 @@ qemuDomainDefVcpusPostParse(virDomainDefPtr def)
static int
qemuDomainDefCPUPostParse(virDomainDefPtr def)
{
virCPUFeatureDefPtr sveFeature = NULL;
bool sveVectorLengthsProvided = false;
size_t i;
if (!def->cpu)
return 0;
......@@ -4522,6 +4526,39 @@ qemuDomainDefCPUPostParse(virDomainDefPtr def)
}
}
for (i = 0; i < def->cpu->nfeatures; i++) {
virCPUFeatureDefPtr feature = &def->cpu->features[i];
if (STREQ(feature->name, "sve")) {
sveFeature = feature;
} else if (STRPREFIX(feature->name, "sve")) {
sveVectorLengthsProvided = true;
}
}
if (sveVectorLengthsProvided) {
if (sveFeature) {
if (sveFeature->policy == VIR_CPU_FEATURE_DISABLE ||
sveFeature->policy == VIR_CPU_FEATURE_FORBID) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("SVE disabled, but SVE vector lengths provided"));
return -1;
} else {
sveFeature->policy = VIR_CPU_FEATURE_REQUIRE;
}
} else {
if (VIR_RESIZE_N(def->cpu->features, def->cpu->nfeatures_max,
def->cpu->nfeatures, 1) < 0) {
return -1;
}
def->cpu->features[def->cpu->nfeatures].name = g_strdup("sve");
def->cpu->features[def->cpu->nfeatures].policy = VIR_CPU_FEATURE_REQUIRE;
def->cpu->nfeatures++;
}
}
/* Nothing to be done if only CPU topology is specified. */
if (def->cpu->mode == VIR_CPU_MODE_CUSTOM &&
!def->cpu->model)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册