[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 05/19] i386: introduce hyperv_feature_supported()
From: |
Vitaly Kuznetsov |
Subject: |
[PATCH v6 05/19] i386: introduce hyperv_feature_supported() |
Date: |
Thu, 22 Apr 2021 18:11:16 +0200 |
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 f791baa29acf..ba093dba4d23 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.30.2
- [PATCH v6 00/19] i386: KVM: expand Hyper-V features early, Vitaly Kuznetsov, 2021/04/22
- [PATCH v6 01/19] i386: keep hyperv_vendor string up-to-date, Vitaly Kuznetsov, 2021/04/22
- [PATCH v6 03/19] i386: always fill Hyper-V CPUID feature leaves from X86CPU data, Vitaly Kuznetsov, 2021/04/22
- [PATCH v6 02/19] i386: invert hyperv_spinlock_attempts setting logic with hv_passthrough, Vitaly Kuznetsov, 2021/04/22
- [PATCH v6 04/19] i386: stop using env->features[] for filling Hyper-V CPUIDs, Vitaly Kuznetsov, 2021/04/22
- [PATCH v6 06/19] i386: introduce hv_cpuid_get_host(), Vitaly Kuznetsov, 2021/04/22
- [PATCH v6 05/19] i386: introduce hyperv_feature_supported(),
Vitaly Kuznetsov <=
- [PATCH v6 07/19] i386: drop FEAT_HYPERV feature leaves, Vitaly Kuznetsov, 2021/04/22
- [PATCH v6 08/19] i386: introduce hv_cpuid_cache, Vitaly Kuznetsov, 2021/04/22
- [PATCH v6 11/19] i386: switch hyperv_expand_features() to using error_setg(), Vitaly Kuznetsov, 2021/04/22
- [PATCH v6 09/19] i386: split hyperv_handle_properties() into hyperv_expand_features()/hyperv_fill_cpuids(), Vitaly Kuznetsov, 2021/04/22
- [PATCH v6 17/19] i386: HV_HYPERCALL_AVAILABLE privilege bit is always needed, Vitaly Kuznetsov, 2021/04/22
- [PATCH v6 10/19] i386: move eVMCS enablement to hyperv_init_vcpu(), Vitaly Kuznetsov, 2021/04/22
- [PATCH v6 16/19] i386: kill off hv_cpuid_check_and_set(), Vitaly Kuznetsov, 2021/04/22
- [PATCH v6 18/19] i386: Hyper-V SynIC requires POST_MESSAGES/SIGNAL_EVENTS priviliges, Vitaly Kuznetsov, 2021/04/22
- [PATCH v6 19/19] qtest/hyperv: Introduce a simple hyper-v test, Vitaly Kuznetsov, 2021/04/22
- [PATCH v6 12/19] i386: adjust the expected KVM_GET_SUPPORTED_HV_CPUID array size, Vitaly Kuznetsov, 2021/04/22