i386: introduce hyperv_feature_supported()
Clean up hv_cpuid_check_and_set() by separating hyperv_feature_supported() off it. No functional change intended. Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20210422161130.652779-6-vkuznets@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
This commit is contained in:
parent
c830015e85
commit
7682f857f4
|
@ -1108,13 +1108,33 @@ static int hv_cpuid_get_fw(struct kvm_cpuid2 *cpuid, int fw, uint32_t *r)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static bool hyperv_feature_supported(struct kvm_cpuid2 *cpuid, int feature)
|
||||
{
|
||||
uint32_t r, fw, bits;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(kvm_hyperv_properties[feature].flags); i++) {
|
||||
fw = kvm_hyperv_properties[feature].flags[i].fw;
|
||||
bits = kvm_hyperv_properties[feature].flags[i].bits;
|
||||
|
||||
if (!fw) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (hv_cpuid_get_fw(cpuid, fw, &r) || (r & bits) != bits) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static int hv_cpuid_check_and_set(CPUState *cs, struct kvm_cpuid2 *cpuid,
|
||||
int feature)
|
||||
{
|
||||
X86CPU *cpu = X86_CPU(cs);
|
||||
uint32_t r, fw, bits;
|
||||
uint64_t deps;
|
||||
int i, dep_feat;
|
||||
int dep_feat;
|
||||
|
||||
if (!hyperv_feat_enabled(cpu, feature) && !cpu->hyperv_passthrough) {
|
||||
return 0;
|
||||
|
@ -1133,15 +1153,7 @@ static int hv_cpuid_check_and_set(CPUState *cs, struct kvm_cpuid2 *cpuid,
|
|||
deps &= ~(1ull << dep_feat);
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(kvm_hyperv_properties[feature].flags); i++) {
|
||||
fw = kvm_hyperv_properties[feature].flags[i].fw;
|
||||
bits = kvm_hyperv_properties[feature].flags[i].bits;
|
||||
|
||||
if (!fw) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (hv_cpuid_get_fw(cpuid, fw, &r) || (r & bits) != bits) {
|
||||
if (!hyperv_feature_supported(cpuid, feature)) {
|
||||
if (hyperv_feat_enabled(cpu, feature)) {
|
||||
fprintf(stderr,
|
||||
"Hyper-V %s is not supported by kernel\n",
|
||||
|
@ -1151,7 +1163,6 @@ static int hv_cpuid_check_and_set(CPUState *cs, struct kvm_cpuid2 *cpuid,
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cpu->hyperv_passthrough) {
|
||||
cpu->hyperv_features |= BIT(feature);
|
||||
|
|
Loading…
Reference in a new issue