KVM: x86/pmu: Don't truncate the PerfEvtSeln MSR when creating a perf event
PATCH 1/2 KVM: x86/pmu: Don't truncate the PerfEvtSeln MSR when creating a perf event
AMD's event select is 3 nybbles, with the high nybble in bits 35:32 of a PerfEvtSeln MSR. Don't drop the high nybble when setting up the config field of a perf_event_attr structure for a call to perf_event_create_kernel_counter().
--- arch/x86/kvm/pmu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/x86/kvm/pmu.c +3 -2
@@ -95,7 +95,7 @@ static void kvm_perf_overflow(struct perf_event *perf_event, }static void pmc_reprogram_counter (struct kvm_pmc *pmc,u32 type, -unsigned config,bool exclude_user, +u64 config,bool exclude_user,bool exclude_kernel,bool intr,bool in_tx,bool in_tx_cp) {
@@ -181,7 +181,8 @@ static int cmp_u64(const void *a, const void *b)void reprogram_gp_counter (struct kvm_pmc *pmc,u64 eventsel) { -unsigned config, type =PERF_TYPE_RAW ; +u64 config; +u32 type =PERF_TYPE_RAW ;struct kvm *kvm = pmc->vcpu->kvm;struct kvm_pmu_event_filter *filter;bool allow_event = true;
Signature · 1 line
2.35.0.263.gb82422642f-goog
PATCH 2/2 KVM: x86/pmu: Use AMD64_RAW_EVENT_MASK for PERF_TYPE_RAW
AMD's event select is 3 nybbles, with the high nybble in bits 35:32 of a PerfEvtSeln MSR. Don't mask off the high nybble when configuring a RAW perf event.
--- arch/x86/kvm/pmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/pmu.c +1 -1
@@ -221,7 +221,7 @@ void reprogram_gp_counter(struct kvm_pmc *pmc, u64 eventsel) }if (type ==PERF_TYPE_RAW ) - config = eventsel &X86_RAW_EVENT_MASK ; + config = eventsel &AMD64_RAW_EVENT_MASK ;if (pmc->current_config == eventsel &&pmc_resume_counter (pmc))return ;
Signature · 1 line
2.35.0.263.gb82422642f-goog
Re: [PATCH 2/2] KVM: x86/pmu: Use AMD64_RAW_EVENT_MASK for PERF_TYPE_RAW
Quoted 4 lines · Jim Mattson
AMD's event select is 3 nybbles, with the high nybble in bits 35:32 of a PerfEvtSeln MSR. Don't mask off the high nybble when configuring a RAW perf event.
Quoted 5 lines · Jim Mattson
AMD's event select is 3 nybbles, with the high nybble in bits 35:32 of a PerfEvtSeln MSR. Don't drop the high nybble when setting up the config field of a
perf_event_attrstructure for a call toperf_event_create_kernel_counter().
Quoted 26 lines · Jim Mattson
AMD's event select is 3 nybbles, with the high nybble in bits 35:32 of a PerfEvtSeln MSR. Don't drop the high nybble when setting up the config field of a
perf_event_attrstructure for a call toperf_event_create_kernel_counter().Fixes ca724305a2b0 ("KVM: x86/vPMU: Implement AMD vPMU code for KVM")Reported-by Stephane Eranian <[email protected]>Signed-off-by Jim Mattson <[email protected]>--- arch/x86/kvm/pmu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)arch/x86/kvm/pmu.c +1
-1@@ -95,7 +95,7 @@ static void kvm_perf_overflow(struct perf_event *perf_event, }static void pmc_reprogram_counter (struct kvm_pmc *pmc,u32 type, -unsigned config,bool exclude_user, +u64 config,bool exclude_user,bool exclude_kernel,bool intr,bool in_tx,bool in_tx_cp) {
arch/x86/kvm/pmu.c static int cmp_u64(const void *a, const void *b) · line 188
Quoted 9 lines
arch/x86/kvm/pmu.c +2
-1@@ -181,7 +181,8 @@ static int cmp_u64(const void *a, const void *b)void reprogram_gp_counter (struct kvm_pmc *pmc,u64 eventsel) { -unsigned config, type =PERF_TYPE_RAW ; +u64 config; +u32 type =PERF_TYPE_RAW ;struct kvm *kvm = pmc->vcpu->kvm;struct kvm_pmu_event_filter *filter;bool allow_event = true;
Queued both, thanks.
Paolo