KVM: x86: omit absent pmu MSRs from MSR list
authorPaolo Bonzini <pbonzini@redhat.com>
Tue, 1 Oct 2019 13:18:26 +0000 (15:18 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 3 Oct 2019 10:07:59 +0000 (12:07 +0200)
commit24c29b7ac0da3e2eb589553f7a98bade6d0a0e60
tree2c5caab599aefbcd498265f273429974bd46f954
parent6e06983dde969c15eb4fdab77f0eda8b18ea28e6
KVM: x86: omit absent pmu MSRs from MSR list

INTEL_PMC_MAX_GENERIC is currently 32, which exceeds the 18 contiguous
MSR indices reserved by Intel for event selectors.  Since some machines
actually have MSRs past the reserved range, these may survive the
filtering of msrs_to_save array and would be rejected by KVM_GET/SET_MSR.
To avoid this, cut the list to whatever CPUID reports for the host's
architectural PMU.

Reported-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Suggested-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: Jim Mattson <jmattson@google.com>
Fixes: e2ada66ec418 ("kvm: x86: Add Intel PMU MSRs to msrs_to_save[]", 2019-08-21)
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/x86.c