[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 12/17] i386: Use hv_build_cpuid_leaf() for HV_CPUID_NESTED_FEATURE
From: |
Paolo Bonzini |
Subject: |
[PULL 12/17] i386: Use hv_build_cpuid_leaf() for HV_CPUID_NESTED_FEATURES |
Date: |
Wed, 25 May 2022 21:28:47 +0200 |
From: Vitaly Kuznetsov <vkuznets@redhat.com>
Previously, HV_CPUID_NESTED_FEATURES.EAX CPUID leaf was handled differently
as it was only used to encode the supported eVMCS version range. In fact,
there are also feature (e.g. Enlightened MSR-Bitmap) bits there. In
preparation to adding these features, move HV_CPUID_NESTED_FEATURES leaf
handling to hv_build_cpuid_leaf() and drop now-unneeded 'hyperv_nested'.
No functional change intended.
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Message-Id: <20220525115949.1294004-2-vkuznets@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
target/i386/cpu.h | 1 -
target/i386/kvm/kvm.c | 25 +++++++++++++++----------
2 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 0d528ac58f..2e918daf6b 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1804,7 +1804,6 @@ struct ArchCPU {
uint32_t hyperv_vendor_id[3];
uint32_t hyperv_interface_id[4];
uint32_t hyperv_limits[3];
- uint32_t hyperv_nested[4];
bool hyperv_enforce_cpuid;
uint32_t hyperv_ver_id_build;
uint16_t hyperv_ver_id_major;
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index e2d675115b..38af0e4f04 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -831,6 +831,8 @@ static bool tsc_is_stable_and_known(CPUX86State *env)
|| env->user_tsc_khz;
}
+#define DEFAULT_EVMCS_VERSION ((1 << 8) | 1)
+
static struct {
const char *desc;
struct {
@@ -1254,6 +1256,13 @@ static uint32_t hv_build_cpuid_leaf(CPUState *cs,
uint32_t func, int reg)
}
}
+ /* HV_CPUID_NESTED_FEATURES.EAX also encodes the supported eVMCS range */
+ if (func == HV_CPUID_NESTED_FEATURES && reg == R_EAX) {
+ if (hyperv_feat_enabled(cpu, HYPERV_FEAT_EVMCS)) {
+ r |= DEFAULT_EVMCS_VERSION;
+ }
+ }
+
return r;
}
@@ -1384,11 +1393,11 @@ static int hyperv_fill_cpuids(CPUState *cs,
struct kvm_cpuid_entry2 *c;
uint32_t signature[3];
uint32_t cpuid_i = 0, max_cpuid_leaf = 0;
+ uint32_t nested_eax =
+ hv_build_cpuid_leaf(cs, HV_CPUID_NESTED_FEATURES, R_EAX);
- max_cpuid_leaf = HV_CPUID_IMPLEMENT_LIMITS;
- if (hyperv_feat_enabled(cpu, HYPERV_FEAT_EVMCS)) {
- max_cpuid_leaf = MAX(max_cpuid_leaf, HV_CPUID_NESTED_FEATURES);
- }
+ max_cpuid_leaf = nested_eax ? HV_CPUID_NESTED_FEATURES :
+ HV_CPUID_IMPLEMENT_LIMITS;
if (hyperv_feat_enabled(cpu, HYPERV_FEAT_SYNDBG)) {
max_cpuid_leaf =
@@ -1461,7 +1470,7 @@ static int hyperv_fill_cpuids(CPUState *cs,
c->ecx = cpu->hyperv_limits[1];
c->edx = cpu->hyperv_limits[2];
- if (hyperv_feat_enabled(cpu, HYPERV_FEAT_EVMCS)) {
+ if (nested_eax) {
uint32_t function;
/* Create zeroed 0x40000006..0x40000009 leaves */
@@ -1473,7 +1482,7 @@ static int hyperv_fill_cpuids(CPUState *cs,
c = &cpuid_ent[cpuid_i++];
c->function = HV_CPUID_NESTED_FEATURES;
- c->eax = cpu->hyperv_nested[0];
+ c->eax = nested_eax;
}
if (hyperv_feat_enabled(cpu, HYPERV_FEAT_SYNDBG)) {
@@ -1522,8 +1531,6 @@ static bool evmcs_version_supported(uint16_t
evmcs_version,
(max_version <= max_supported_version);
}
-#define DEFAULT_EVMCS_VERSION ((1 << 8) | 1)
-
static int hyperv_init_vcpu(X86CPU *cpu)
{
CPUState *cs = CPU(cpu);
@@ -1620,8 +1627,6 @@ static int hyperv_init_vcpu(X86CPU *cpu)
supported_evmcs_version >> 8);
return -ENOTSUP;
}
-
- cpu->hyperv_nested[0] = evmcs_version;
}
if (cpu->hyperv_enforce_cpuid) {
--
2.36.1
- [PULL 02/17] hostmem: default the amount of prealloc-threads to smp-cpus, (continued)
- [PULL 02/17] hostmem: default the amount of prealloc-threads to smp-cpus, Paolo Bonzini, 2022/05/25
- [PULL 03/17] thread-pool: optimize scheduling of completion bottom half, Paolo Bonzini, 2022/05/25
- [PULL 04/17] thread-pool: replace semaphore with condition variable, Paolo Bonzini, 2022/05/25
- [PULL 05/17] thread-pool: remove stopping variable, Paolo Bonzini, 2022/05/25
- [PULL 06/17] contrib/elf2dmp: add ELF dump header checking, Paolo Bonzini, 2022/05/25
- [PULL 08/17] hw/audio/ac97: Remove unimplemented reset functions, Paolo Bonzini, 2022/05/25
- [PULL 07/17] hw/audio/ac97: Coding style fixes to avoid checkpatch errors, Paolo Bonzini, 2022/05/25
- [PULL 09/17] hw/audio/ac97: Remove unneeded local variables, Paolo Bonzini, 2022/05/25
- [PULL 10/17] target/i386/kvm: Fix disabling MPX on "-cpu host" with MPX-capable host, Paolo Bonzini, 2022/05/25
- [PULL 11/17] ide_ioport_read: Return lower octet of data register instead of 0xFF, Paolo Bonzini, 2022/05/25
- [PULL 12/17] i386: Use hv_build_cpuid_leaf() for HV_CPUID_NESTED_FEATURES,
Paolo Bonzini <=
- [PULL 14/17] i386: Hyper-V XMM fast hypercall input feature, Paolo Bonzini, 2022/05/25
- [PULL 15/17] i386: Hyper-V Support extended GVA ranges for TLB flush hypercalls, Paolo Bonzini, 2022/05/25
- [PULL 13/17] i386: Hyper-V Enlightened MSR bitmap feature, Paolo Bonzini, 2022/05/25
- [PULL 16/17] i386: Hyper-V Direct TLB flush hypercall, Paolo Bonzini, 2022/05/25
- [PULL 17/17] i386: docs: Convert hyperv.txt to rST, Paolo Bonzini, 2022/05/25
- Re: [PULL 00/17] Misc patches for 2022-05-25, Richard Henderson, 2022/05/25