KVM: x86/svm: Account for family 17h event renumberings in amd_pmc_perf_hw_id
authorKyle Huey <me@kylehuey.com>
Tue, 3 May 2022 05:01:36 +0000 (22:01 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 3 May 2022 11:56:53 +0000 (07:56 -0400)
commit5eb849322d7f7ae9d5c587c7bc3b4f7c6872cd2f
treee74fc79aadbfcc9b515b2dc31dd745ae768a8329
parent44187235cbcc7c1129ea7c004bc12f8757d29415
KVM: x86/svm: Account for family 17h event renumberings in amd_pmc_perf_hw_id

Zen renumbered some of the performance counters that correspond to the
well known events in perf_hw_id. This code in KVM was never updated for
that, so guest that attempt to use counters on Zen that correspond to the
pre-Zen perf_hw_id values will silently receive the wrong values.

This has been observed in the wild with rr[0] when running in Zen 3
guests. rr uses the retired conditional branch counter 00d1 which is
incorrectly recognized by KVM as PERF_COUNT_HW_STALLED_CYCLES_BACKEND.

[0] https://rr-project.org/

Signed-off-by: Kyle Huey <me@kylehuey.com>
Message-Id: <20220503050136.86298-1-khuey@kylehuey.com>
Cc: stable@vger.kernel.org
[Check guest family, not host. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/svm/pmu.c