On Mon, 2019-04-08 at 10:48 -0700, Sean Christopherson wrote: > On Mon, Apr 08, 2019 at 05:54:25PM +0800, Xiaoyao Li wrote: > > On Fri, 2019-04-05 at 14:30 +0200, Thomas Gleixner wrote: > > > On Wed, 3 Apr 2019, Fenghua Yu wrote: > > > > @@ -1663,6 +1663,12 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, > > > > struct > > > > msr_data *msr_info) > > > > u32 index; > > > > > > > > switch (msr_info->index) { > > > > + case MSR_TEST_CTL: > > > > + if (!msr_info->host_initiated && > > > > + !(vcpu->arch.core_capability & > > > > CORE_CAP_SPLIT_LOCK_DETECT)) > > > > > > Errm? If the MSR_TEST_CTL is exposed to the guest via CPUID then the > > > rdmsr() in the guest is not supposed to fail just because > > > CORE_CAP_SPLIT_LOCK_DETECT is not set. > > > > you're right. > > > > > vmx->msr_test_ctl holds the proper value, which is either 0 or > > > CORE_CAP_SPLIT_LOCK_DETECT until more bits are supported. > > > > > > So the chek needs to be guest_cpuid_has(X86_FEATURE_CORE_CAPABILITY). > > > > I don't think so. There is no dependecy between > > guest_cpuid_has(X86_FEATURE_CORE_CAPABILITY) and MSR_TEST_CTL. > > guest_cpuid_has(X86_FEATURE_CORE_CAPABILITY) only indicates that guest has > > MSR > > CORE_CAPABILITY. > > > > Due to the fact that MSR_TEST_CTL is emulated with vmx->msr_test_ctl. I > > think it > > 's ok to always let userspace or guest to read MSR_TEST_CTL, it just returns > > the > > emulated value. Like you said, " vmx->msr_test_ctl holds the proper value, > > which > > is either 0 or CORE_CAP_SPLIT_LOCK_DETECT until more bits are supported." > > Assuming the next version implements "vmx->msr_test_ctl_mask", KVM should > inject #GP if the guest attempts RDMSR(MSR_TEST_CTL) and the mask is zero. > It stands to reason that a kernel can only reasonably assume the MSR exists > if the (virtual) CPU supports at least one feature enabled via MSR_TEST_CTL. It makes sense to me. Thanks for your reminder. Will apply it in next version.