When writing to guest's MSR_IA32_ARCH_CAPABILITIES, check whether it's
supported in the guest using the KVM_GET_MSR_INDEX_LIST ioctl.
Fixes: d86f963694df27f11b3681ffd225c9362de1b634
Suggested-by: Eduardo Habkost <ehabkost@redhat.com>
Tested-by: balducci@units.it
Signed-off-by: Bandan Das <bsd@redhat.com>
---
target/i386/kvm.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index f524e7d929..3d6739a2b2 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -95,6 +95,7 @@ static bool has_msr_xss;
static bool has_msr_spec_ctrl;
static bool has_msr_virt_ssbd;
static bool has_msr_smi_count;
+static bool has_msr_arch_capabs;
static uint32_t has_architectural_pmu_version;
static uint32_t num_architectural_pmu_gp_counters;
@@ -1481,6 +1482,9 @@ static int kvm_get_supported_msrs(KVMState *s)
case MSR_VIRT_SSBD:
has_msr_virt_ssbd = true;
break;
+ case MSR_IA32_ARCH_CAPABILITIES:
+ has_msr_arch_capabs = true;
+ break;
}
}
}
@@ -2002,14 +2006,9 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
#endif
/* If host supports feature MSR, write down. */
- if (kvm_feature_msrs) {
- int i;
- for (i = 0; i < kvm_feature_msrs->nmsrs; i++)
- if (kvm_feature_msrs->indices[i] == MSR_IA32_ARCH_CAPABILITIES) {
- kvm_msr_entry_add(cpu, MSR_IA32_ARCH_CAPABILITIES,
- env->features[FEAT_ARCH_CAPABILITIES]);
- break;
- }
+ if (has_msr_arch_capabs) {
+ kvm_msr_entry_add(cpu, MSR_IA32_ARCH_CAPABILITIES,
+ env->features[FEAT_ARCH_CAPABILITIES]);
}
/*
--
2.14.5
On Sun, Nov 25, 2018 at 11:17:28PM -0500, Bandan Das wrote: > > When writing to guest's MSR_IA32_ARCH_CAPABILITIES, check whether it's > supported in the guest using the KVM_GET_MSR_INDEX_LIST ioctl. > > Fixes: d86f963694df27f11b3681ffd225c9362de1b634 > Suggested-by: Eduardo Habkost <ehabkost@redhat.com> > Tested-by: balducci@units.it > Signed-off-by: Bandan Das <bsd@redhat.com> Thanks! Queued for 3.1. -- Eduardo
Thanks for fixing. Sorry I missed the whole discussion for I hadn't checked my linux.intel.com account for a long time. Best Regards, Robert Hoo > -----Original Message----- > From: Qemu-devel <qemu-devel-bounces+robert.hu=intel.com@nongnu.org> > On Behalf Of Bandan Das > Sent: Monday, November 26, 2018 12:17 > To: Eduardo Habkost <ehabkost@redhat.com>; Paolo Bonzini > <pbonzini@redhat.com> > Cc: balducci@units.it; Cole Robinson <crobinso@redhat.com>; qemu- > devel@nongnu.org; Laine Stump <laine@redhat.com>; David Alan Gilbert > <dgilbert@redhat.com> > Subject: [Qemu-devel] [PATCH] kvm: Use KVM_GET_MSR_INDEX_LIST for > MSR_IA32_ARCH_CAPABILITIES support > > > When writing to guest's MSR_IA32_ARCH_CAPABILITIES, check whether it's > supported in the guest using the KVM_GET_MSR_INDEX_LIST ioctl. > > Fixes: d86f963694df27f11b3681ffd225c9362de1b634 > Suggested-by: Eduardo Habkost <ehabkost@redhat.com> > Tested-by: balducci@units.it > Signed-off-by: Bandan Das <bsd@redhat.com> > --- > target/i386/kvm.c | 15 +++++++-------- > 1 file changed, 7 insertions(+), 8 deletions(-) > > diff --git a/target/i386/kvm.c b/target/i386/kvm.c index > f524e7d929..3d6739a2b2 100644 > --- a/target/i386/kvm.c > +++ b/target/i386/kvm.c > @@ -95,6 +95,7 @@ static bool has_msr_xss; static bool has_msr_spec_ctrl; > static bool has_msr_virt_ssbd; static bool has_msr_smi_count; > +static bool has_msr_arch_capabs; > > static uint32_t has_architectural_pmu_version; static uint32_t > num_architectural_pmu_gp_counters; > @@ -1481,6 +1482,9 @@ static int kvm_get_supported_msrs(KVMState *s) > case MSR_VIRT_SSBD: > has_msr_virt_ssbd = true; > break; > + case MSR_IA32_ARCH_CAPABILITIES: > + has_msr_arch_capabs = true; > + break; > } > } > } > @@ -2002,14 +2006,9 @@ static int kvm_put_msrs(X86CPU *cpu, int level) > #endif > > /* If host supports feature MSR, write down. */ > - if (kvm_feature_msrs) { > - int i; > - for (i = 0; i < kvm_feature_msrs->nmsrs; i++) > - if (kvm_feature_msrs->indices[i] == MSR_IA32_ARCH_CAPABILITIES) { > - kvm_msr_entry_add(cpu, MSR_IA32_ARCH_CAPABILITIES, > - env->features[FEAT_ARCH_CAPABILITIES]); > - break; > - } > + if (has_msr_arch_capabs) { [Robert Hoo] Why not as your original "if (kvm_arch_get_supported_msr_feature(kvm_state, MSR_IA32_ARCH_CAPABILITIES))"? checking if there is the MSR feature? > + kvm_msr_entry_add(cpu, MSR_IA32_ARCH_CAPABILITIES, > + env->features[FEAT_ARCH_CAPABILITIES]); > } > > /* > -- > 2.14.5 >
© 2016 - 2024 Red Hat, Inc.