Centos-kernel-stream-9/drivers
Eric Auger a0f252f442 KVM: arm64: PMU: Don't overwrite PMUSERENR with vcpu loaded
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2203922

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: 83a7a4d643d3 ("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
(cherry picked from commit 0c2f9acf6ae74118385f7a7d48f4b2d93637b628)
Signed-off-by: Eric Auger <eric.auger@redhat.com>
2023-07-04 09:14:29 -04:00
..
accessibility
acpi ACPI: processor idle: avoid call to raw_local_irq_disable() from acpi_safe_halt() 2023-06-27 15:14:33 -04:00
amba
android
ata
atm
auxdisplay
base Merge: Proactively Backport MM fixes for el9.3 2023-06-28 07:52:43 +02:00
bcma
block Merge: loop: LOOP_CONFIGURE: send uevents for partitions 2023-06-21 03:41:29 -04:00
bluetooth
bus
cdrom
char
clk
clocksource
comedi
connector
counter
cpufreq
cpuidle
crypto
cxl
dax
dca
devfreq
dio
dma
dma-buf
edac Merge: EDAC: add support for Emerald Rapids 2023-06-21 03:41:33 -04:00
eisa
extcon
firewire
firmware
fpga
fsi
gnss
gpio
gpu Merge: DRM backport 9.3 from v6.3 2023-06-28 07:52:43 +02:00
greybus
hid Merge: Improve the error messages in the case where the MP2 driver fails to load 2023-06-26 12:33:51 +02:00
hsi
hte
hv
hwmon hwmon: (k10temp) Add PCI ID for family 19, model 78h 2023-06-23 11:43:49 -04:00
hwspinlock
hwtracing
i2c Merge: Qualcomm SPI updates for sa8775p 2023-06-26 12:33:49 +02:00
i3c
idle
iio
infiniband Merge: RDMA: Add support for MANA_INFINIBAND driver 2023-06-28 07:52:42 +02:00
input
interconnect
iommu
ipack
irqchip
isdn
leds
macintosh
mailbox
mcb
md
media
memory
memstick
message
mfd
misc
mmc
most
mtd
mux
net Merge: net: stmmac: propagate feature flags to vlan 2023-06-30 14:02:58 +02:00
nfc
ntb
nubus
nvdimm
nvme
nvmem
of
opp
parisc
parport
pci PCI: hv: Add a per-bus mutex state_lock 2023-06-21 10:01:38 +02:00
pcmcia
perf KVM: arm64: PMU: Don't overwrite PMUSERENR with vcpu loaded 2023-07-04 09:14:29 -04:00
phy Merge: phy: freescale: imx8m-pcie: driver updates 2023-06-21 03:41:24 -04:00
pinctrl
platform Merge: platform/x86: intel-uncore-freq: add Emerald Rapids support 2023-06-30 14:02:59 +02:00
pnp
power
powercap
pps
ps3
ptp
pwm
rapidio
ras
regulator
remoteproc
reset
rpmsg
rtc
s390 Merge: [s390]: RHEL9.0 - s390/dasd: Use correct lock while counting channel queue length 2023-06-22 13:25:11 +02:00
sbus
scsi Merge: scsi: scsi_transport_fc: Add an additional flag to fc_host_fpin_rcv() 2023-06-26 12:33:48 +02:00
sh
siox
slimbus
soc Merge: Qualcomm SPI updates for sa8775p 2023-06-26 12:33:49 +02:00
soundwire
spi
spmi
ssb
staging
target
tc
tee
thermal
thunderbolt
tty
ufs Merge: Update UFS to 6.3 2023-06-22 13:25:15 +02:00
uio
usb
vdpa
vfio
vhost
video
virt
virtio
visorbus
vlynq
vme
w1
watchdog
xen
zorro
Kconfig
Makefile