linux-stable/drivers/perf
Reiji Watanabe 0c2f9acf6a KVM: arm64: PMU: Don't overwrite PMUSERENR with vcpu loaded
Currently, with VHE, KVM sets ER, CR, SW and EN bits of
PMUSERENR_EL0 to 1 on vcpu_load(), and saves and restores
the register value for the host on vcpu_load() and vcpu_put().
If the value of those bits are cleared on a pCPU with a vCPU
loaded (armv8pmu_start() would do that when PMU counters are
programmed for the guest), PMU access from the guest EL0 might
be trapped to the guest EL1 directly regardless of the current
PMUSERENR_EL0 value of the vCPU.

Fix this by not letting armv8pmu_start() overwrite PMUSERENR_EL0
on the pCPU where PMUSERENR_EL0 for the guest is loaded, and
instead updating the saved shadow register value for the host
so that the value can be restored on vcpu_put() later.
While vcpu_{put,load}() are manipulating PMUSERENR_EL0, disable
IRQs to prevent a race condition between these processes and IPIs
that attempt to update PMUSERENR_EL0 for the host EL0.

Suggested-by: Mark Rutland <mark.rutland@arm.com>
Suggested-by: Marc Zyngier <maz@kernel.org>
Fixes: 83a7a4d643 ("arm64: perf: Enable PMU counter userspace access for perf event")
Signed-off-by: Reiji Watanabe <reijiw@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20230603025035.3781797-3-reijiw@google.com
2023-06-04 17:19:36 +01:00
..
amlogic arm64 updates for 6.4 2023-04-25 12:39:01 -07:00
arm_cspmu perf: arm_cspmu: Fix variable dereference warning 2023-03-27 15:12:58 +01:00
hisilicon drivers/perf: hisi: add NULL check for name 2023-04-17 13:14:10 +01:00
Kconfig ARM: perf: Allow the use of the PMUv3 driver on 32bit ARM 2023-03-27 14:01:18 +01:00
Makefile arm64: perf: Move PMUv3 driver to drivers/perf 2023-03-27 14:01:18 +01:00
alibaba_uncore_drw_pmu.c drivers/perf: Use devm_platform_get_and_ioremap_resource() 2023-03-27 15:09:09 +01:00
apple_m1_cpu_pmu.c drivers/perf: apple_m1: Add Apple M2 support 2023-03-27 15:15:14 +01:00
arm-cci.c perf/arm-cci: Use the bitmap API to allocate bitmaps 2022-07-06 11:02:58 +01:00
arm-ccn.c drivers/perf:Directly use ida_alloc()/free() 2022-06-23 15:44:45 +01:00
arm-cmn.c perf/arm-cmn: Fix port detection for CMN-700 2023-04-14 13:45:00 +01:00
arm_dmc620_pmu.c perf: arm: Use devm_platform_get_and_ioremap_resource() 2023-03-27 15:02:32 +01:00
arm_dsu_pmu.c perf: arm_dsu: Fix hotplug callback leak in dsu_pmu_init() 2022-11-15 13:45:01 +00:00
arm_pmu.c Scheduler updates in this cycle are: 2023-02-20 17:41:08 -08:00
arm_pmu_acpi.c arm_pmu: acpi: handle allocation failure 2022-11-08 12:42:46 +00:00
arm_pmu_platform.c perf/arm_pmu_platform: fix tests for platform_get_irq() failure 2022-09-01 12:01:40 +01:00
arm_pmuv3.c KVM: arm64: PMU: Don't overwrite PMUSERENR with vcpu loaded 2023-06-04 17:19:36 +01:00
arm_smmuv3_pmu.c perf/smmuv3: Fix hotplug callback leak in arm_smmu_pmu_init() 2022-11-15 13:47:04 +00:00
arm_spe_pmu.c perf: arm_spe: Print the version of SPE detected 2023-02-07 11:52:21 +00:00
fsl_imx8_ddr_perf.c drivers/perf: fsl_imx8_ddr_perf: Remove set-but-not-used variable 2023-02-03 13:04:22 +00:00
marvell_cn10k_ddr_pmu.c perf/marvell: Add ACPI support to DDR uncore driver 2023-01-19 18:30:21 +00:00
marvell_cn10k_tad_pmu.c perf/marvell: Add ACPI support to TAD uncore driver 2023-01-19 18:30:22 +00:00
qcom_l2_pmu.c perf: qcom_l2_pmu: Refactor _UID handling to use acpi_dev_uid_to_integer() 2022-09-19 18:34:42 +02:00
qcom_l3_pmu.c perf: qcom: Use devm_platform_get_and_ioremap_resource() 2023-03-27 15:03:01 +01:00
riscv_pmu.c perf: riscv_pmu{,_sbi}: Miscallenous improvement & fixes 2022-08-12 07:17:38 -07:00
riscv_pmu_legacy.c RISC-V Patches for the 6.1 Merge Window, Part 1 2022-10-09 13:24:01 -07:00
riscv_pmu_sbi.c RISC-V: Align SBI probe implementation with spec 2023-04-29 13:04:50 -07:00
thunderx2_pmu.c perf: Replace acpi_bus_get_device() 2022-02-08 15:14:53 +00:00
xgene_pmu.c perf: replace bitmap_weight with bitmap_empty where appropriate 2022-02-15 14:38:57 +00:00