android_kernel_samsung_sm8650/arch/arm64
Marc Zyngier 3d8c8a9ad5 KVM: arm64: PMU: Sanitise PMCR_EL0.LP on first vcpu run
[ Upstream commit 64d6820d64c0a206e744bd8945374d563a76c16c ]

Userspace can play some dirty tricks on us by selecting a given
PMU version (such as PMUv3p5), restore a PMCR_EL0 value that
has PMCR_EL0.LP set, and then switch the PMU version to PMUv3p1,
for example. In this situation, we end-up with PMCR_EL0.LP being
set and spreading havoc in the PMU emulation.

This is specially hard as the first two step can be done on
one vcpu and the third step on another, meaning that we need
to sanitise *all* vcpus when the PMU version is changed.

In orer to avoid a pretty complicated locking situation,
defer the sanitisation of PMCR_EL0 to the point where the
vcpu is actually run for the first tine, using the existing
KVM_REQ_RELOAD_PMU request that calls into kvm_pmu_handle_pmcr().

There is still an obscure corner case where userspace could
do the above trick, and then save the VM without running it.
They would then observe an inconsistent state (PMUv3.1 + LP set),
but that state will be fixed on the first run anyway whenever
the guest gets restored on a host.

Reported-by: Reiji Watanabe <reijiw@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Stable-dep-of: f6da81f650fa ("KVM: arm64: PMU: Don't save PMCR_EL0.{C,P} for the vCPU")
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-04-13 16:55:17 +02:00
..
boot arm64: dts: qcom: sm8150: Fix the iommu mask used for PCIe controllers 2023-03-30 12:49:29 +02:00
configs This update includes the following changes: 2022-10-10 13:04:25 -07:00
crypto crypto: arm64/sm3 - fix possible crash with CFI enabled 2022-12-31 13:32:34 +01:00
hyperv hyperv: simplify and rename generate_guest_id 2022-09-28 13:36:56 +00:00
include arm64: mte: Fix/clarify the PG_mte_tagged semantics 2023-03-11 13:55:44 +01:00
kernel arm64: efi: Set NX compat flag in PE/COFF header 2023-04-06 12:10:37 +02:00
kvm KVM: arm64: PMU: Sanitise PMCR_EL0.LP on first vcpu run 2023-04-13 16:55:17 +02:00
lib Networking changes for 6.0. 2022-08-03 16:29:08 -07:00
mm arm64: Reset KASAN tag in copy_highpage with HW tags only 2023-03-11 13:55:44 +01:00
net bpf: arm64: No support of struct argument in trampoline programs 2022-09-06 19:51:14 -07:00
tools arm64/sysreg: Fix typo in SCTR_EL1.SPINTMASK 2022-10-07 14:30:11 +01:00
xen
Kbuild
Kconfig arm64: mm: hugetlb: Disable HUGETLB_PAGE_OPTIMIZE_VMEMMAP 2023-03-10 09:34:24 +01:00
Kconfig.debug
Kconfig.platforms ARM: SoC code changes for 6.1 2022-10-06 11:22:25 -07:00
Makefile Kbuild updates for v6.1 2022-10-10 12:00:45 -07:00