Message ID | DE8DF0795D48FD4CA783C40EC82923350150E43C@SHSMSX101.ccr.corp.intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Il 24/02/2014 11:58, Liu, Jinsong ha scritto: > @@ -599,6 +599,9 @@ int __kvm_set_xcr(struct kvm_vcpu *vcpu, u32 index, u64 xcr) > u64 old_xcr0 = vcpu->arch.xcr0; > u64 valid_bits; > > + if (!kvm_x86_ops->mpx_supported || !kvm_x86_ops->mpx_supported()) > + xcr0 &= ~(XSTATE_BNDREGS | XSTATE_BNDCSR); > + > /* Only support XCR_XFEATURE_ENABLED_MASK(xcr0) now */ > if (index != XCR_XFEATURE_ENABLED_MASK) > return 1; This hunk is incorrect, and I can simply drop it when applying. If MPX is not supported, it should not be in the 0Dh CPUID leaf and thus in vcpu->arch.guest_supported_xcr0. This however relies on userspace passing a "sensible" value of CPUID. I'll send a patch to strengthen the computation of guest_supported_xcr0. Thanks! Paolo -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Paolo Bonzini wrote: > Il 24/02/2014 11:58, Liu, Jinsong ha scritto: >> @@ -599,6 +599,9 @@ int __kvm_set_xcr(struct kvm_vcpu *vcpu, u32 >> index, u64 xcr) u64 old_xcr0 = vcpu->arch.xcr0; >> u64 valid_bits; >> >> + if (!kvm_x86_ops->mpx_supported || !kvm_x86_ops->mpx_supported()) >> + xcr0 &= ~(XSTATE_BNDREGS | XSTATE_BNDCSR); >> + >> /* Only support XCR_XFEATURE_ENABLED_MASK(xcr0) now */ >> if (index != XCR_XFEATURE_ENABLED_MASK) >> return 1; > > This hunk is incorrect, and I can simply drop it when applying. If > MPX is not supported, it should not be in the 0Dh CPUID leaf and thus > in vcpu->arch.guest_supported_xcr0. > > This however relies on userspace passing a "sensible" value of CPUID. > I'll send a patch to strengthen the computation of > guest_supported_xcr0. > > Thanks! > > Paolo So patch v5 would be applied except you will remove the incorrect hunk, and you will send a patch strengthenning guest_supported_xcr0? Thanks, Jinsong-- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Il 24/02/2014 16:37, Liu, Jinsong ha scritto: > So patch v5 would be applied except you will remove the incorrect > hunk, and you will send a patch strengthenning guest_supported_xcr0? Yes. Paolo -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index b241325..ddc8a7e 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -256,6 +256,8 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, #endif unsigned f_rdtscp = kvm_x86_ops->rdtscp_supported() ? F(RDTSCP) : 0; unsigned f_invpcid = kvm_x86_ops->invpcid_supported() ? F(INVPCID) : 0; + unsigned f_mpx = kvm_x86_ops->mpx_supported ? + (kvm_x86_ops->mpx_supported() ? F(MPX) : 0) : 0; /* cpuid 1.edx */ const u32 kvm_supported_word0_x86_features = @@ -303,7 +305,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, /* cpuid 7.0.ebx */ const u32 kvm_supported_word9_x86_features = F(FSGSBASE) | F(BMI1) | F(HLE) | F(AVX2) | F(SMEP) | - F(BMI2) | F(ERMS) | f_invpcid | F(RTM) | F(RDSEED) | + F(BMI2) | F(ERMS) | f_invpcid | F(RTM) | f_mpx | F(RDSEED) | F(ADX); /* all calls to cpuid_count() should be made on the same cpu */ diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 89e4e27..3570e71 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -599,6 +599,9 @@ int __kvm_set_xcr(struct kvm_vcpu *vcpu, u32 index, u64 xcr) u64 old_xcr0 = vcpu->arch.xcr0; u64 valid_bits; + if (!kvm_x86_ops->mpx_supported || !kvm_x86_ops->mpx_supported()) + xcr0 &= ~(XSTATE_BNDREGS | XSTATE_BNDCSR); + /* Only support XCR_XFEATURE_ENABLED_MASK(xcr0) now */ if (index != XCR_XFEATURE_ENABLED_MASK) return 1; @@ -616,6 +619,9 @@ int __kvm_set_xcr(struct kvm_vcpu *vcpu, u32 index, u64 xcr) if (xcr0 & ~valid_bits) return 1; + if ((!(xcr0 & XSTATE_BNDREGS)) != (!(xcr0 & XSTATE_BNDCSR))) + return 1; + kvm_put_guest_xcr0(vcpu); vcpu->arch.xcr0 = xcr0; diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h index 8da5823..392ecbf 100644 --- a/arch/x86/kvm/x86.h +++ b/arch/x86/kvm/x86.h @@ -122,7 +122,8 @@ int kvm_write_guest_virt_system(struct x86_emulate_ctxt *ctxt, gva_t addr, void *val, unsigned int bytes, struct x86_exception *exception); -#define KVM_SUPPORTED_XCR0 (XSTATE_FP | XSTATE_SSE | XSTATE_YMM) +#define KVM_SUPPORTED_XCR0 (XSTATE_FP | XSTATE_SSE | XSTATE_YMM \ + | XSTATE_BNDREGS | XSTATE_BNDCSR) extern u64 host_xcr0; extern unsigned int min_timer_period_us;