* Thu Jan 24 2019 Danilo Cesar Lemes de Paula <ddepaula@redhat.com> - 3.1.0-7.el8

- kvm-i386-kvm-expose-HV_CPUID_ENLIGHTMENT_INFO.EAX-and-HV.patch [bz#1653511]
- kvm-i386-kvm-add-a-comment-explaining-why-.feat_names-ar.patch [bz#1653511]
- Resolves: bz#1653511
  (qemu doesn't report all support cpu features which cause libvirt cannot get the support status of hv_tlbflush)
This commit is contained in:
Danilo C. L. de Paula 2019-01-24 18:00:01 +00:00
parent a9595f021e
commit aa76ca88ee
3 changed files with 270 additions and 1 deletions

View File

@ -0,0 +1,48 @@
From 61470c276a7785f3615da564f15a5c2368354638 Mon Sep 17 00:00:00 2001
From: Vitaly Kuznetsov <vkuznets@redhat.com>
Date: Fri, 18 Jan 2019 11:57:05 +0000
Subject: [PATCH 2/2] i386/kvm: add a comment explaining why .feat_names are
commented out for Hyper-V feature bits
RH-Author: Vitaly Kuznetsov <vkuznets@redhat.com>
Message-id: <20190118115705.19731-3-vkuznets@redhat.com>
Patchwork-id: 84048
O-Subject: [RHEL8 qemu-kvm PATCH 2/2] i386/kvm: add a comment explaining why .feat_names are commented out for Hyper-V feature bits
Bugzilla: 1653511
RH-Acked-by: Mohammed Gamal <mgamal@redhat.com>
RH-Acked-by: Eduardo Otubo <otubo@redhat.com>
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
Hyper-V .feat_names are, unlike hardware features, commented out and it is
not obvious why we do that. Document the current status quo.
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Message-Id: <20181221141604.16935-1-vkuznets@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
(cherry picked from commit abd5fc4c862d033a989552914149f01c9476bb16)
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
target/i386/cpu.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 460fe06..8570b25 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -929,6 +929,13 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
*/
.no_autoenable_flags = ~0U,
},
+ /*
+ * .feat_names are commented out for Hyper-V enlightenments because we
+ * don't want to have two different ways for enabling them on QEMU command
+ * line. Some features (e.g. "hyperv_time", "hyperv_vapic", ...) require
+ * enabling several feature bits simultaneously, exposing these bits
+ * individually may just confuse guests.
+ */
[FEAT_HYPERV_EAX] = {
.type = CPUID_FEATURE_WORD,
.feat_names = {
--
1.8.3.1

View File

@ -0,0 +1,211 @@
From 4d58784a4a507fa1070b330846d941f91bb9abdc Mon Sep 17 00:00:00 2001
From: Vitaly Kuznetsov <vkuznets@redhat.com>
Date: Fri, 18 Jan 2019 11:57:04 +0000
Subject: [PATCH 1/2] i386/kvm: expose HV_CPUID_ENLIGHTMENT_INFO.EAX and
HV_CPUID_NESTED_FEATURES.EAX as feature words
RH-Author: Vitaly Kuznetsov <vkuznets@redhat.com>
Message-id: <20190118115705.19731-2-vkuznets@redhat.com>
Patchwork-id: 84046
O-Subject: [RHEL8 qemu-kvm PATCH 1/2] i386/kvm: expose HV_CPUID_ENLIGHTMENT_INFO.EAX and HV_CPUID_NESTED_FEATURES.EAX as feature words
Bugzilla: 1653511
RH-Acked-by: Mohammed Gamal <mgamal@redhat.com>
RH-Acked-by: Eduardo Otubo <otubo@redhat.com>
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
It was found that QMP users of QEMU (e.g. libvirt) may need
HV_CPUID_ENLIGHTMENT_INFO.EAX/HV_CPUID_NESTED_FEATURES.EAX information. In
particular, 'hv_tlbflush' and 'hv_evmcs' enlightenments are only exposed in
HV_CPUID_ENLIGHTMENT_INFO.EAX.
HV_CPUID_NESTED_FEATURES.EAX is exposed for two reasons: convenience
(we don't need to export it from hyperv_handle_properties() and as
future-proof for Enlightened MSR-Bitmap, PV EPT invalidation and
direct virtual flush features.
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Message-Id: <20181126135958.20956-1-vkuznets@redhat.com>
Reviewed-by: Roman Kagan <rkagan@virtuozzo.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
(cherry picked from commit a2b107dbbd342ff2077aa5af705efaf68c375459)
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
target/i386/cpu.c | 30 ++++++++++++++++++++
target/i386/cpu.h | 2 ++
target/i386/kvm.c | 85 +++++++++++++++++++++++++++++--------------------------
3 files changed, 77 insertions(+), 40 deletions(-)
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 573de14..460fe06 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -980,6 +980,36 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
},
.cpuid = { .eax = 0x40000003, .reg = R_EDX, },
},
+ [FEAT_HV_RECOMM_EAX] = {
+ .type = CPUID_FEATURE_WORD,
+ .feat_names = {
+ NULL /* hv_recommend_pv_as_switch */,
+ NULL /* hv_recommend_pv_tlbflush_local */,
+ NULL /* hv_recommend_pv_tlbflush_remote */,
+ NULL /* hv_recommend_msr_apic_access */,
+ NULL /* hv_recommend_msr_reset */,
+ NULL /* hv_recommend_relaxed_timing */,
+ NULL /* hv_recommend_dma_remapping */,
+ NULL /* hv_recommend_int_remapping */,
+ NULL /* hv_recommend_x2apic_msrs */,
+ NULL /* hv_recommend_autoeoi_deprecation */,
+ NULL /* hv_recommend_pv_ipi */,
+ NULL /* hv_recommend_ex_hypercalls */,
+ NULL /* hv_hypervisor_is_nested */,
+ NULL /* hv_recommend_int_mbec */,
+ NULL /* hv_recommend_evmcs */,
+ NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL,
+ },
+ .cpuid = { .eax = 0x40000004, .reg = R_EAX, },
+ },
+ [FEAT_HV_NESTED_EAX] = {
+ .type = CPUID_FEATURE_WORD,
+ .cpuid = { .eax = 0x4000000A, .reg = R_EAX, },
+ },
[FEAT_SVM] = {
.type = CPUID_FEATURE_WORD,
.feat_names = {
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 9c52d0c..dd88151 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -497,6 +497,8 @@ typedef enum FeatureWord {
FEAT_HYPERV_EAX, /* CPUID[4000_0003].EAX */
FEAT_HYPERV_EBX, /* CPUID[4000_0003].EBX */
FEAT_HYPERV_EDX, /* CPUID[4000_0003].EDX */
+ FEAT_HV_RECOMM_EAX, /* CPUID[4000_0004].EAX */
+ FEAT_HV_NESTED_EAX, /* CPUID[4000_000A].EAX */
FEAT_SVM, /* CPUID[8000_000A].EDX */
FEAT_XSAVE, /* CPUID[EAX=0xd,ECX=1].EAX */
FEAT_6_EAX, /* CPUID[6].EAX */
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index 5b0ce82..0c9a5e4 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -798,6 +798,48 @@ static int hyperv_handle_properties(CPUState *cs)
}
env->features[FEAT_HYPERV_EAX] |= HV_SYNTIMERS_AVAILABLE;
}
+ if (cpu->hyperv_relaxed_timing) {
+ env->features[FEAT_HV_RECOMM_EAX] |= HV_RELAXED_TIMING_RECOMMENDED;
+ }
+ if (cpu->hyperv_vapic) {
+ env->features[FEAT_HV_RECOMM_EAX] |= HV_APIC_ACCESS_RECOMMENDED;
+ }
+ if (cpu->hyperv_tlbflush) {
+ if (kvm_check_extension(cs->kvm_state,
+ KVM_CAP_HYPERV_TLBFLUSH) <= 0) {
+ fprintf(stderr, "Hyper-V TLB flush support "
+ "(requested by 'hv-tlbflush' cpu flag) "
+ " is not supported by kernel\n");
+ return -ENOSYS;
+ }
+ env->features[FEAT_HV_RECOMM_EAX] |= HV_REMOTE_TLB_FLUSH_RECOMMENDED;
+ env->features[FEAT_HV_RECOMM_EAX] |= HV_EX_PROCESSOR_MASKS_RECOMMENDED;
+ }
+ if (cpu->hyperv_ipi) {
+ if (kvm_check_extension(cs->kvm_state,
+ KVM_CAP_HYPERV_SEND_IPI) <= 0) {
+ fprintf(stderr, "Hyper-V IPI send support "
+ "(requested by 'hv-ipi' cpu flag) "
+ " is not supported by kernel\n");
+ return -ENOSYS;
+ }
+ env->features[FEAT_HV_RECOMM_EAX] |= HV_CLUSTER_IPI_RECOMMENDED;
+ env->features[FEAT_HV_RECOMM_EAX] |= HV_EX_PROCESSOR_MASKS_RECOMMENDED;
+ }
+ if (cpu->hyperv_evmcs) {
+ uint16_t evmcs_version;
+
+ if (kvm_vcpu_enable_cap(cs, KVM_CAP_HYPERV_ENLIGHTENED_VMCS, 0,
+ (uintptr_t)&evmcs_version)) {
+ fprintf(stderr, "Hyper-V Enlightened VMCS "
+ "(requested by 'hv-evmcs' cpu flag) "
+ "is not supported by kernel\n");
+ return -ENOSYS;
+ }
+ env->features[FEAT_HV_RECOMM_EAX] |= HV_ENLIGHTENED_VMCS_RECOMMENDED;
+ env->features[FEAT_HV_NESTED_EAX] = evmcs_version;
+ }
+
return 0;
}
@@ -871,7 +913,6 @@ int kvm_arch_init_vcpu(CPUState *cs)
uint32_t unused;
struct kvm_cpuid_entry2 *c;
uint32_t signature[3];
- uint16_t evmcs_version;
int kvm_base = KVM_CPUID_SIGNATURE;
int r;
Error *local_err = NULL;
@@ -946,44 +987,8 @@ int kvm_arch_init_vcpu(CPUState *cs)
c = &cpuid_data.entries[cpuid_i++];
c->function = HV_CPUID_ENLIGHTMENT_INFO;
- if (cpu->hyperv_relaxed_timing) {
- c->eax |= HV_RELAXED_TIMING_RECOMMENDED;
- }
- if (cpu->hyperv_vapic) {
- c->eax |= HV_APIC_ACCESS_RECOMMENDED;
- }
- if (cpu->hyperv_tlbflush) {
- if (kvm_check_extension(cs->kvm_state,
- KVM_CAP_HYPERV_TLBFLUSH) <= 0) {
- fprintf(stderr, "Hyper-V TLB flush support "
- "(requested by 'hv-tlbflush' cpu flag) "
- " is not supported by kernel\n");
- return -ENOSYS;
- }
- c->eax |= HV_REMOTE_TLB_FLUSH_RECOMMENDED;
- c->eax |= HV_EX_PROCESSOR_MASKS_RECOMMENDED;
- }
- if (cpu->hyperv_ipi) {
- if (kvm_check_extension(cs->kvm_state,
- KVM_CAP_HYPERV_SEND_IPI) <= 0) {
- fprintf(stderr, "Hyper-V IPI send support "
- "(requested by 'hv-ipi' cpu flag) "
- " is not supported by kernel\n");
- return -ENOSYS;
- }
- c->eax |= HV_CLUSTER_IPI_RECOMMENDED;
- c->eax |= HV_EX_PROCESSOR_MASKS_RECOMMENDED;
- }
- if (cpu->hyperv_evmcs) {
- if (kvm_vcpu_enable_cap(cs, KVM_CAP_HYPERV_ENLIGHTENED_VMCS, 0,
- (uintptr_t)&evmcs_version)) {
- fprintf(stderr, "Hyper-V Enlightened VMCS "
- "(requested by 'hv-evmcs' cpu flag) "
- "is not supported by kernel\n");
- return -ENOSYS;
- }
- c->eax |= HV_ENLIGHTENED_VMCS_RECOMMENDED;
- }
+
+ c->eax = env->features[FEAT_HV_RECOMM_EAX];
c->ebx = cpu->hyperv_spinlock_attempts;
c = &cpuid_data.entries[cpuid_i++];
@@ -1007,7 +1012,7 @@ int kvm_arch_init_vcpu(CPUState *cs)
c = &cpuid_data.entries[cpuid_i++];
c->function = HV_CPUID_NESTED_FEATURES;
- c->eax = evmcs_version;
+ c->eax = env->features[FEAT_HV_NESTED_EAX];
}
}
--
1.8.3.1

View File

@ -68,7 +68,7 @@ Obsoletes: %1-rhev
Summary: QEMU is a machine emulator and virtualizer
Name: qemu-kvm
Version: 3.1.0
Release: 6%{?dist}
Release: 7%{?dist}
# Epoch because we pushed a qemu-1.0 package. AIUI this can't ever be dropped
Epoch: 15
License: GPLv2 and GPLv2+ and CC-BY
@ -158,6 +158,10 @@ Patch36: kvm-aarch64-Use-256MB-ECAM-region-by-default.patch
Patch37: kvm-spapr-Fix-ibm-max-associativity-domains-property-num.patch
# For bz#1668205 - Guest quit with error when hotunplug cpu
Patch38: kvm-cpus-ignore-ESRCH-in-qemu_cpu_kick_thread.patch
# For bz#1653511 - qemu doesn't report all support cpu features which cause libvirt cannot get the support status of hv_tlbflush
Patch39: kvm-i386-kvm-expose-HV_CPUID_ENLIGHTMENT_INFO.EAX-and-HV.patch
# For bz#1653511 - qemu doesn't report all support cpu features which cause libvirt cannot get the support status of hv_tlbflush
Patch40: kvm-i386-kvm-add-a-comment-explaining-why-.feat_names-ar.patch
BuildRequires: zlib-devel
BuildRequires: glib2-devel
@ -1005,6 +1009,12 @@ useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin \
%changelog
* Thu Jan 24 2019 Danilo Cesar Lemes de Paula <ddepaula@redhat.com> - 3.1.0-7.el8
- kvm-i386-kvm-expose-HV_CPUID_ENLIGHTMENT_INFO.EAX-and-HV.patch [bz#1653511]
- kvm-i386-kvm-add-a-comment-explaining-why-.feat_names-ar.patch [bz#1653511]
- Resolves: bz#1653511
(qemu doesn't report all support cpu features which cause libvirt cannot get the support status of hv_tlbflush)
* Wed Jan 23 2019 Danilo Cesar Lemes de Paula <ddepaula@redhat.com> - 3.1.0-6.el8
- kvm-spapr-Fix-ibm-max-associativity-domains-property-num.patch [bz#1653114]
- kvm-cpus-ignore-ESRCH-in-qemu_cpu_kick_thread.patch [bz#1668205]