Otherwise, QEMU on a host with MPX support will try to set guest
MSR_IA32_BNDCFGS although guest MPX is not enabled, and result in
abort.
For example,
qemu-system-x86_64 -enable-kvm -cpu qemu64,-mpx ...
aborts with messages:
qemu-system-x86_64: error: failed to set MSR 0xd90 to 0x0
qemu-system-x86_64: /root/qemu.git/target/i386/kvm.c:1832: kvm_put_msrs: Assertion `ret == cpu->kvm_msr_buf->nmsrs' failed
Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
---
target/i386/kvm.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index ee36502789..7b3a310a31 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -943,6 +943,11 @@ int kvm_arch_init_vcpu(CPUState *cs)
has_msr_mcg_ext_ctl = has_msr_feature_control = true;
}
+ if (has_msr_bndcfgs) {
+ c = cpuid_find_entry(&cpuid_data.cpuid, 7, 0);
+ has_msr_bndcfgs = c && (c->ebx & CPUID_7_0_EBX_MPX);
+ }
+
if (!env->user_tsc_khz) {
if ((env->features[FEAT_8000_0007_EDX] & CPUID_APM_INVTSC) &&
invtsc_mig_blocker == NULL) {
--
2.11.0
On 03/07/2017 17:23, Haozhong Zhang wrote: > Otherwise, QEMU on a host with MPX support will try to set guest > MSR_IA32_BNDCFGS although guest MPX is not enabled, and result in > abort. > > For example, > qemu-system-x86_64 -enable-kvm -cpu qemu64,-mpx ... > aborts with messages: > qemu-system-x86_64: error: failed to set MSR 0xd90 to 0x0 > qemu-system-x86_64: /root/qemu.git/target/i386/kvm.c:1832: kvm_put_msrs: Assertion `ret == cpu->kvm_msr_buf->nmsrs' failed I think the fix should be in KVM, allowing BNDCFGS = 0 if host_initiated, even if MPX is not enabled. Paolo > Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com> > --- > target/i386/kvm.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/target/i386/kvm.c b/target/i386/kvm.c > index ee36502789..7b3a310a31 100644 > --- a/target/i386/kvm.c > +++ b/target/i386/kvm.c > @@ -943,6 +943,11 @@ int kvm_arch_init_vcpu(CPUState *cs) > has_msr_mcg_ext_ctl = has_msr_feature_control = true; > } > > + if (has_msr_bndcfgs) { > + c = cpuid_find_entry(&cpuid_data.cpuid, 7, 0); > + has_msr_bndcfgs = c && (c->ebx & CPUID_7_0_EBX_MPX); > + } > + > if (!env->user_tsc_khz) { > if ((env->features[FEAT_8000_0007_EDX] & CPUID_APM_INVTSC) && > invtsc_mig_blocker == NULL) { >
On 07/03/17 17:45 +0200, Paolo Bonzini wrote: > > > On 03/07/2017 17:23, Haozhong Zhang wrote: > > Otherwise, QEMU on a host with MPX support will try to set guest > > MSR_IA32_BNDCFGS although guest MPX is not enabled, and result in > > abort. > > > > For example, > > qemu-system-x86_64 -enable-kvm -cpu qemu64,-mpx ... > > aborts with messages: > > qemu-system-x86_64: error: failed to set MSR 0xd90 to 0x0 > > qemu-system-x86_64: /root/qemu.git/target/i386/kvm.c:1832: kvm_put_msrs: Assertion `ret == cpu->kvm_msr_buf->nmsrs' failed > > I think the fix should be in KVM, allowing BNDCFGS = 0 if > host_initiated, even if MPX is not enabled. > Agree. I've sent a KVM patch to fix this issue. Thanks, Haozhong
© 2016 - 2024 Red Hat, Inc.