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@xxxxxxxxx> --- 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