[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 20/30] i386: Implement pseudo 'hv-avic' ('hv-apicv') enlightenment
From: |
Paolo Bonzini |
Subject: |
[PULL 20/30] i386: Implement pseudo 'hv-avic' ('hv-apicv') enlightenment |
Date: |
Sun, 3 Oct 2021 09:42:40 +0200 |
From: Vitaly Kuznetsov <vkuznets@redhat.com>
The enlightenment allows to use Hyper-V SynIC with hardware APICv/AVIC
enabled. Normally, Hyper-V SynIC disables these hardware features and
suggests the guest to use paravirtualized AutoEOI feature. Linux-4.15
gains support for conditional APICv/AVIC disablement, the feature
stays on until the guest tries to use AutoEOI feature with SynIC. With
'HV_DEPRECATING_AEOI_RECOMMENDED' bit exposed, modern enough Windows/
Hyper-V versions should follow the recommendation and not use the
(unwanted) feature.
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Message-Id: <20210902093530.345756-7-vkuznets@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
docs/hyperv.txt | 10 +++++++++-
target/i386/cpu.c | 4 ++++
target/i386/cpu.h | 1 +
target/i386/kvm/hyperv-proto.h | 1 +
target/i386/kvm/kvm.c | 10 +++++++++-
5 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/docs/hyperv.txt b/docs/hyperv.txt
index 072709a68f..cd1ea3bbe9 100644
--- a/docs/hyperv.txt
+++ b/docs/hyperv.txt
@@ -189,7 +189,15 @@ enabled.
Requires: hv-vpindex, hv-synic, hv-time, hv-stimer
-3.17. hv-no-nonarch-coresharing=on/off/auto
+3.18. hv-avic (hv-apicv)
+=======================
+The enlightenment allows to use Hyper-V SynIC with hardware APICv/AVIC enabled.
+Normally, Hyper-V SynIC disables these hardware feature and suggests the guest
+to use paravirtualized AutoEOI feature.
+Note: enabling this feature on old hardware (without APICv/AVIC support) may
+have negative effect on guest's performace.
+
+3.19. hv-no-nonarch-coresharing=on/off/auto
===========================================
This enlightenment tells guest OS that virtual processors will never share a
physical core unless they are reported as sibling SMT threads. This information
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 2a19eba56d..8154343cc4 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -6644,6 +6644,8 @@ static void x86_cpu_initfn(Object *obj)
object_property_add_alias(obj, "sse4_1", obj, "sse4.1");
object_property_add_alias(obj, "sse4_2", obj, "sse4.2");
+ object_property_add_alias(obj, "hv-apicv", obj, "hv-avic");
+
if (xcc->model) {
x86_cpu_load_model(cpu, xcc->model);
}
@@ -6831,6 +6833,8 @@ static Property x86_cpu_properties[] = {
HYPERV_FEAT_IPI, 0),
DEFINE_PROP_BIT64("hv-stimer-direct", X86CPU, hyperv_features,
HYPERV_FEAT_STIMER_DIRECT, 0),
+ DEFINE_PROP_BIT64("hv-avic", X86CPU, hyperv_features,
+ HYPERV_FEAT_AVIC, 0),
DEFINE_PROP_ON_OFF_AUTO("hv-no-nonarch-coresharing", X86CPU,
hyperv_no_nonarch_cs, ON_OFF_AUTO_OFF),
DEFINE_PROP_BOOL("hv-passthrough", X86CPU, hyperv_passthrough, false),
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 8a7209bbf2..65f0ee2caf 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1056,6 +1056,7 @@ typedef uint64_t FeatureWordArray[FEATURE_WORDS];
#define HYPERV_FEAT_EVMCS 12
#define HYPERV_FEAT_IPI 13
#define HYPERV_FEAT_STIMER_DIRECT 14
+#define HYPERV_FEAT_AVIC 15
#ifndef HYPERV_SPINLOCK_NEVER_NOTIFY
#define HYPERV_SPINLOCK_NEVER_NOTIFY 0xFFFFFFFF
diff --git a/target/i386/kvm/hyperv-proto.h b/target/i386/kvm/hyperv-proto.h
index 5fbb385cc1..89f81afda7 100644
--- a/target/i386/kvm/hyperv-proto.h
+++ b/target/i386/kvm/hyperv-proto.h
@@ -66,6 +66,7 @@
#define HV_APIC_ACCESS_RECOMMENDED (1u << 3)
#define HV_SYSTEM_RESET_RECOMMENDED (1u << 4)
#define HV_RELAXED_TIMING_RECOMMENDED (1u << 5)
+#define HV_DEPRECATING_AEOI_RECOMMENDED (1u << 9)
#define HV_CLUSTER_IPI_RECOMMENDED (1u << 10)
#define HV_EX_PROCESSOR_MASKS_RECOMMENDED (1u << 11)
#define HV_ENLIGHTENED_VMCS_RECOMMENDED (1u << 14)
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index a9a8f77df3..68faf72e34 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -924,6 +924,13 @@ static struct {
},
.dependencies = BIT(HYPERV_FEAT_STIMER)
},
+ [HYPERV_FEAT_AVIC] = {
+ .desc = "AVIC/APICv support (hv-avic/hv-apicv)",
+ .flags = {
+ {.func = HV_CPUID_ENLIGHTMENT_INFO, .reg = R_EAX,
+ .bits = HV_DEPRECATING_AEOI_RECOMMENDED}
+ }
+ },
};
static struct kvm_cpuid2 *try_get_hv_cpuid(CPUState *cs, int max,
@@ -1373,7 +1380,8 @@ static int hyperv_fill_cpuids(CPUState *cs,
c->eax = hv_build_cpuid_leaf(cs, HV_CPUID_ENLIGHTMENT_INFO, R_EAX);
c->ebx = cpu->hyperv_spinlock_attempts;
- if (hyperv_feat_enabled(cpu, HYPERV_FEAT_VAPIC)) {
+ if (hyperv_feat_enabled(cpu, HYPERV_FEAT_VAPIC) &&
+ !hyperv_feat_enabled(cpu, HYPERV_FEAT_AVIC)) {
c->eax |= HV_APIC_ACCESS_RECOMMENDED;
}
--
2.31.1
- [PULL 10/30] machine: Use ms instead of global current_machine in sanity-check, (continued)
- [PULL 10/30] machine: Use ms instead of global current_machine in sanity-check, Paolo Bonzini, 2021/10/03
- [PULL 13/30] machine: Remove smp_parse callback from MachineClass, Paolo Bonzini, 2021/10/03
- [PULL 14/30] machine: Move smp_prefer_sockets to struct SMPCompatProps, Paolo Bonzini, 2021/10/03
- [PULL 15/30] machine: Use g_autoptr in machine_set_smp, Paolo Bonzini, 2021/10/03
- [PULL 16/30] machine: Put all sanity-check in the generic SMP parser, Paolo Bonzini, 2021/10/03
- [PULL 17/30] i386: Support KVM_CAP_ENFORCE_PV_FEATURE_CPUID, Paolo Bonzini, 2021/10/03
- [PULL 18/30] i386: Support KVM_CAP_HYPERV_ENFORCE_CPUID, Paolo Bonzini, 2021/10/03
- [PULL 22/30] i386: Change the default Hyper-V version to match WS2016, Paolo Bonzini, 2021/10/03
- [PULL 19/30] i386: Move HV_APIC_ACCESS_RECOMMENDED bit setting to hyperv_fill_cpuids(), Paolo Bonzini, 2021/10/03
- [PULL 21/30] i386: Make Hyper-V version id configurable, Paolo Bonzini, 2021/10/03
- [PULL 20/30] i386: Implement pseudo 'hv-avic' ('hv-apicv') enlightenment,
Paolo Bonzini <=
- [PULL 23/30] configure: Loosen GCC requirement from 7.5.0 to 7.4.0, Paolo Bonzini, 2021/10/03
- [PULL 24/30] virtio-mem-pci: Fix memory leak when creating MEMORY_DEVICE_SIZE_CHANGE event, Paolo Bonzini, 2021/10/03
- [PULL 27/30] tpm: mark correct memory region range dirty when clearing RAM, Paolo Bonzini, 2021/10/03
- [PULL 26/30] monitor: Rate-limit MEMORY_DEVICE_SIZE_CHANGE qapi events per device, Paolo Bonzini, 2021/10/03
- [PULL 25/30] qapi: Include qom-path in MEMORY_DEVICE_SIZE_CHANGE qapi events, Paolo Bonzini, 2021/10/03
- [PULL 28/30] softmmu/memory_mapping: never merge ranges accross memory regions, Paolo Bonzini, 2021/10/03
- [PULL 29/30] softmmu/memory_mapping: factor out adding physical memory ranges, Paolo Bonzini, 2021/10/03
- [PULL 30/30] softmmu/memory_mapping: optimize for RamDiscardManager sections, Paolo Bonzini, 2021/10/03
- Re: [PULL 00/30] Misc changes for 2021-10-03, Philippe Mathieu-Daudé, 2021/10/03
- Re: [PULL 00/30] Misc changes for 2021-10-03, Richard Henderson, 2021/10/03