Messages in this thread | | | From | Haiwei Li <> | Date | Wed, 24 Mar 2021 20:23:30 +0800 | Subject | Re: [PATCH] KVM: x86/vPMU: Forbid writing to MSR_F15H_PERF MSRs when guest doesn't have X86_FEATURE_PERFCTR_CORE |
| |
On Tue, Mar 23, 2021 at 4:48 PM Vitaly Kuznetsov <vkuznets@redhat.com> wrote: > > MSR_F15H_PERF_CTL0-5, MSR_F15H_PERF_CTR0-5 MSRs are only available when > X86_FEATURE_PERFCTR_CORE CPUID bit was exposed to the guest. KVM, however, > allows these MSRs unconditionally because kvm_pmu_is_valid_msr() -> > amd_msr_idx_to_pmc() check always passes and because kvm_pmu_set_msr() -> > amd_pmu_set_msr() doesn't fail.
I have tested on AMD EPYC platform with perfctr_core(`cat /proc/cpuinfo | grep perfctr_core`). I started a vm without `perfctr-core`(-cpu host,-perfctr-core).
Before patch :
$ rdmsr 0xc0010200 0 $ wrmsr 0xc0010200 1 $ rdmsr 0xc0010200 1
After patch:
# rdmsr 0xc0010200 0 # wrmsr 0xc0010200 1 wrmsr: CPU 0 cannot set MSR 0xc0010200 to 0x0000000000000001 # rdmsr 0xc0010200 0
So,
Tested-by: Haiwei Li <lihaiwei@tencent.com>
| |