KVM: x86: Fix MSR_IA32_PERF_CAPABILITIES writes check and vmx_pmu_msrs_test
v2 cover KVM: x86: Fix MSR_IA32_PERF_CAPABILITIES writes check and vmx_pmu_msrs_test
This is a continuation of "KVM: selftests: Avoid KVM_SET_CPUID2 after KVM_RUN in vmx_pmu_msrs_test" work. Instead of fixing the immediate issue, drop incorrect check in KVM which was making the result of host initiated writes to MSR_IA32_PERF_CAPABILITIES dependent on guest visible CPUIDs and the corresponding tests in vmx_pmu_msrs_test, this will also make the issue reported by kernel test robot to go away.
Vitaly Kuznetsov (2):
KVM: selftests: vmx_pmu_msrs_test: Drop tests mangling guest visible
CPUIDs
KVM: x86: Drop guest CPUID check for host initiated writes to
MSR_IA32_PERF_CAPABILITIES
arch/x86/kvm/x86.c | 2 +- .../selftests/kvm/x86_64/vmx_pmu_msrs_test.c | 17 ----------------- 2 files changed, 1 insertion(+), 18 deletions(-)
Signature · 1 line
2.33.1
PATCH v2 1/2 KVM: selftests: vmx_pmu_msrs_test: Drop tests mangling guest visible CPUIDs
Host initiated writes to MSR_IA32_PERF_CAPABILITIES should not depend on guest visible CPUIDs and (incorrect) KVM logic implementing it is about to change. Also, KVM_SET_CPUID{,2} after KVM_RUN is now forbidden and causes test to fail.
--- .../selftests/kvm/x86_64/vmx_pmu_msrs_test.c | 17 ----------------- 1 file changed, 17 deletions(-)
tools/testing/selftests/kvm/x86_64/vmx_pmu_msrs_test.c +0 -17
@@ -110,22 +110,5 @@ int main(int argc, char *argv[]) ret =_vcpu_set_msr (vm,0 ,MSR_IA32_PERF_CAPABILITIES ,PMU_CAP_LBR_FMT );TEST_ASSERT (ret ==0 ,"Bad PERF_CAPABILITIES didn't fail." ); -/* testcase 4, set capabilities when we don't have PDCM bit */ - entry_1_0->ecx &= ~X86_FEATURE_PDCM ; -vcpu_set_cpuid (vm,VCPU_ID , cpuid); - ret =_vcpu_set_msr (vm,0 ,MSR_IA32_PERF_CAPABILITIES , host_cap.capabilities); -TEST_ASSERT (ret ==0 ,"Bad PERF_CAPABILITIES didn't fail." ); - -/* testcase 5, set capabilities when we don't have PMU version bits */ - entry_1_0->ecx |=X86_FEATURE_PDCM ; - eax.split.version_id =0 ; - entry_1_0->ecx = eax.full; -vcpu_set_cpuid (vm,VCPU_ID , cpuid); - ret =_vcpu_set_msr (vm,0 ,MSR_IA32_PERF_CAPABILITIES ,PMU_CAP_FW_WRITES ); -TEST_ASSERT (ret ==0 ,"Bad PERF_CAPABILITIES didn't fail." ); - -vcpu_set_msr (vm,0 ,MSR_IA32_PERF_CAPABILITIES ,0 ); -ASSERT_EQ (vcpu_get_msr (vm,VCPU_ID ,MSR_IA32_PERF_CAPABILITIES ),0 ); -kvm_vm_free (vm); }
Signature · 1 line
2.33.1
PATCH v2 2/2 KVM: x86: Drop guest CPUID check for host initiated writes to MSR_IA32_PERF_CAPABILITIES
In reply to Vitaly KuznetsovThe ability to write to MSR_IA32_PERF_CAPABILITIES from the host should not depend on guest visible CPUID entries, even if just to allow creating/restoring guest MSRs and CPUIDs in any sequence.
--- arch/x86/kvm/x86.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/x86.c +1 -1
@@ -3413,7 +3413,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)if (!msr_info->host_initiated)return 1 ; -if (guest_cpuid_has (vcpu,X86_FEATURE_PDCM ) &&kvm_get_msr_feature (&msr_ent)) +if (kvm_get_msr_feature (&msr_ent))return 1 ;if (data & ~msr_ent.data)return 1 ;
Signature · 1 line
2.33.1
Quoted 13 lines · Vitaly Kuznetsov
This is a continuation of "KVM: selftests: Avoid
KVM_SET_CPUID2afterKVM_RUNinvmx_pmu_msrs_test" work. Instead of fixing the immediate issue, drop incorrect check in KVM which was making the result of host initiated writes toMSR_IA32_PERF_CAPABILITIESdependent on guest visible CPUIDs and the corresponding tests invmx_pmu_msrs_test, this will also make the issue reported by kernel test robot to go away.Vitaly Kuznetsov (2):
KVM: selftests:vmx_pmu_msrs_test: Drop tests mangling guest visible
CPUIDs
KVM: x86: Drop guest CPUID check for host initiated writes to
MSR_IA32_PERF_CAPABILITIES
Quoted 4 lines
arch/x86/kvm/x86.c | 2 +- .../selftests/kvm/x86_64/vmx_pmu_msrs_test.c | 17 ----------------- 2 files changed, 1 insertion(+), 18 deletions(-)
Queued, thanks,
Paolo