[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH RFC v3 12/23] i386: introduce hyperv_feature_supported()
From: |
Vitaly Kuznetsov |
Subject: |
[PATCH RFC v3 12/23] i386: introduce hyperv_feature_supported() |
Date: |
Fri, 9 Oct 2020 14:18:31 +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.c | 49 +++++++++++++++++++++++++++++------------------
1 file changed, 30 insertions(+), 19 deletions(-)
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index 2c14d45b40bf..73f0d3cd0c37 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -1106,13 +1106,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;
@@ -1131,23 +1151,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.25.4
- [PATCH RFC v3 02/23] i386: fill in FEAT_HYPERV_EDX from edx instead of eax, (continued)
- [PATCH RFC v3 02/23] i386: fill in FEAT_HYPERV_EDX from edx instead of eax, Vitaly Kuznetsov, 2020/10/09
- [PATCH RFC v3 03/23] i386: drop x86_cpu_get_supported_feature_word() forward declaration, Vitaly Kuznetsov, 2020/10/09
- [PATCH RFC v3 04/23] i386: move hyperv_vendor_id initialization to x86_cpu_realizefn(), Vitaly Kuznetsov, 2020/10/09
- [PATCH RFC v3 08/23] i386: keep hyperv_vendor string up-to-date, Vitaly Kuznetsov, 2020/10/09
- [PATCH RFC v3 10/23] i386: always fill Hyper-V CPUID feature leaves from X86CPU data, Vitaly Kuznetsov, 2020/10/09
- [PATCH RFC v3 09/23] i386: invert hyperv_spinlock_attempts setting logic with hv_passthrough, Vitaly Kuznetsov, 2020/10/09
- [PATCH RFC v3 05/23] i386: move hyperv_interface_id initialization to x86_cpu_realizefn(), Vitaly Kuznetsov, 2020/10/09
- [PATCH RFC v3 06/23] i386: move hyperv_version_id initialization to x86_cpu_realizefn(), Vitaly Kuznetsov, 2020/10/09
- [PATCH RFC v3 07/23] i386: move hyperv_limits initialization to x86_cpu_realizefn(), Vitaly Kuznetsov, 2020/10/09
- [PATCH RFC v3 13/23] i386: introduce hv_cpuid_get_host(), Vitaly Kuznetsov, 2020/10/09
- [PATCH RFC v3 12/23] i386: introduce hyperv_feature_supported(),
Vitaly Kuznetsov <=
- [PATCH RFC v3 14/23] i386: drop FEAT_HYPERV feature leaves, Vitaly Kuznetsov, 2020/10/09
- [PATCH RFC v3 15/23] i386: introduce hv_cpuid_cache, Vitaly Kuznetsov, 2020/10/09
- [PATCH RFC v3 11/23] i386: stop using env->features[] for filling Hyper-V CPUIDs, Vitaly Kuznetsov, 2020/10/09
- [PATCH RFC v3 17/23] i386: move eVMCS enablement to hyperv_init_vcpu(), Vitaly Kuznetsov, 2020/10/09
- [PATCH RFC v3 18/23] i386: switch hyperv_expand_features() to using error_setg(), Vitaly Kuznetsov, 2020/10/09
- [PATCH RFC v3 16/23] i386: split hyperv_handle_properties() into hyperv_expand_features()/hyperv_fill_cpuids(), Vitaly Kuznetsov, 2020/10/09
- [PATCH RFC v3 19/23] i386: adjust the expected KVM_GET_SUPPORTED_HV_CPUID array size, Vitaly Kuznetsov, 2020/10/09
- [PATCH RFC v3 20/23] i386: prefer system KVM_GET_SUPPORTED_HV_CPUID ioctl over vCPU's one, Vitaly Kuznetsov, 2020/10/09
- [PATCH RFC v3 21/23] i386: use global kvm_state in hyperv_enabled() check, Vitaly Kuznetsov, 2020/10/09
- [PATCH RFC v3 22/23] i386: expand Hyper-V features during CPU feature expansion time, Vitaly Kuznetsov, 2020/10/09