]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
KVM: arm64: PMU: Don't save PMCR_EL0.{C,P} for the vCPU
authorReiji Watanabe <reijiw@google.com>
Mon, 13 Mar 2023 03:32:34 +0000 (20:32 -0700)
committerRoxana Nicolescu <roxana.nicolescu@canonical.com>
Wed, 17 May 2023 11:33:52 +0000 (13:33 +0200)
commit2f4c137d46a701e75ee4aac03b0a978f7c20ccf3
treedca3ed869e970be4d57135190a10126bd3bf3c5d
parent119d90bf0a0f3e3439f55a36cfedd6ff83765b13
KVM: arm64: PMU: Don't save PMCR_EL0.{C,P} for the vCPU

BugLink: https://bugs.launchpad.net/bugs/2016878
commit f6da81f650fa47b61b847488f3938d43f90d093d upstream.

Presently, when a guest writes 1 to PMCR_EL0.{C,P}, which is WO/RAZ,
KVM saves the register value, including these bits.
When userspace reads the register using KVM_GET_ONE_REG, KVM returns
the saved register value as it is (the saved value might have these
bits set).  This could result in userspace setting these bits on the
destination during migration.  Consequently, KVM may end up resetting
the vPMU counter registers (PMCCNTR_EL0 and/or PMEVCNTR<n>_EL0) to
zero on the first KVM_RUN after migration.

Fix this by not saving those bits when a guest writes 1 to those bits.

Fixes: ab9468340d2b ("arm64: KVM: Add access handler for PMCR 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/20230313033234.1475987-1-reijiw@google.com
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
arch/arm64/kvm/pmu-emul.c