]> www.infradead.org Git - users/jedix/linux-maple.git/commit
KVM: arm64: PMU: Fix GET_ONE_REG for vPMC regs to return the current value
authorReiji Watanabe <reijiw@google.com>
Mon, 13 Mar 2023 03:32:08 +0000 (20:32 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 6 Apr 2023 10:10:56 +0000 (12:10 +0200)
commit051e660c8185e4c4bee6fb30d796cfe4ae2c345f
treee015a70b0022b9da56457c447cb9067f0b9fe71c
parentfcf712b4e5d0aacbc193e71962bdaa4d4afe3335
KVM: arm64: PMU: Fix GET_ONE_REG for vPMC regs to return the current value

commit 9228b26194d1cc00449f12f306f53ef2e234a55b upstream.

Have KVM_GET_ONE_REG for vPMU counter (vPMC) registers (PMCCNTR_EL0
and PMEVCNTR<n>_EL0) return the sum of the register value in the sysreg
file and the current perf event counter value.

Values of vPMC registers are saved in sysreg files on certain occasions.
These saved values don't represent the current values of the vPMC
registers if the perf events for the vPMCs count events after the save.
The current values of those registers are the sum of the sysreg file
value and the current perf event counter value.  But, when userspace
reads those registers (using KVM_GET_ONE_REG), KVM returns the sysreg
file value to userspace (not the sum value).

Fix this to return the sum value for KVM_GET_ONE_REG.

Fixes: 051ff581ce70 ("arm64: KVM: Add access handler for event counter register")
Cc: stable@vger.kernel.org
Reviewed-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Reiji Watanabe <reijiw@google.com>
Link: https://lore.kernel.org/r/20230313033208.1475499-1-reijiw@google.com
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/arm64/kvm/sys_regs.c