[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 05/17] i386: introduce hyperv_feature_supported()
From: |
Vitaly Kuznetsov |
Subject: |
[PATCH v5 05/17] i386: introduce hyperv_feature_supported() |
Date: |
Mon, 1 Mar 2021 14:50:51 +0100 |
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>
---
target/i386/kvm/kvm.c | 49 ++++++++++++++++++++++++++-----------------
1 file changed, 30 insertions(+), 19 deletions(-)
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index dc372ed213ff..bbc76a7475cd 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -1107,13 +1107,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;
@@ -1132,23 +1152,14 @@ 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_feat_enabled(cpu, feature)) {
- fprintf(stderr,
- "Hyper-V %s is not supported by kernel\n",
- kvm_hyperv_properties[feature].desc);
- return 1;
- } else {
- return 0;
- }
+ if (!hyperv_feature_supported(cpuid, feature)) {
+ if (hyperv_feat_enabled(cpu, feature)) {
+ fprintf(stderr,
+ "Hyper-V %s is not supported by kernel\n",
+ kvm_hyperv_properties[feature].desc);
+ return 1;
+ } else {
+ return 0;
}
}
--
2.29.2
- [PATCH v5 00/17] i386: KVM: expand Hyper-V features early and provide simple 'hv-default=on' option, Vitaly Kuznetsov, 2021/03/01
- [PATCH v5 01/17] i386: keep hyperv_vendor string up-to-date, Vitaly Kuznetsov, 2021/03/01
- [PATCH v5 02/17] i386: invert hyperv_spinlock_attempts setting logic with hv_passthrough, Vitaly Kuznetsov, 2021/03/01
- [PATCH v5 03/17] i386: always fill Hyper-V CPUID feature leaves from X86CPU data, Vitaly Kuznetsov, 2021/03/01
- [PATCH v5 04/17] i386: stop using env->features[] for filling Hyper-V CPUIDs, Vitaly Kuznetsov, 2021/03/01
- [PATCH v5 05/17] i386: introduce hyperv_feature_supported(),
Vitaly Kuznetsov <=
- [PATCH v5 06/17] i386: introduce hv_cpuid_get_host(), Vitaly Kuznetsov, 2021/03/01
- [PATCH v5 07/17] i386: drop FEAT_HYPERV feature leaves, Vitaly Kuznetsov, 2021/03/01
- [PATCH v5 09/17] i386: split hyperv_handle_properties() into hyperv_expand_features()/hyperv_fill_cpuids(), Vitaly Kuznetsov, 2021/03/01
- [PATCH v5 08/17] i386: introduce hv_cpuid_cache, Vitaly Kuznetsov, 2021/03/01
- [PATCH v5 10/17] i386: move eVMCS enablement to hyperv_init_vcpu(), Vitaly Kuznetsov, 2021/03/01
- [PATCH v5 11/17] i386: switch hyperv_expand_features() to using error_setg(), Vitaly Kuznetsov, 2021/03/01
- [PATCH v5 12/17] i386: adjust the expected KVM_GET_SUPPORTED_HV_CPUID array size, Vitaly Kuznetsov, 2021/03/01
- [PATCH v5 13/17] i386: prefer system KVM_GET_SUPPORTED_HV_CPUID ioctl over vCPU's one, Vitaly Kuznetsov, 2021/03/01
- [PATCH v5 14/17] i386: use global kvm_state in hyperv_enabled() check, Vitaly Kuznetsov, 2021/03/01
- [PATCH v5 15/17] i386: expand Hyper-V features during CPU feature expansion time, Vitaly Kuznetsov, 2021/03/01