]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: PPC: Book3S HV P9: Demand fault PMU SPRs when marked not inuse
authorNicholas Piggin <npiggin@gmail.com>
Tue, 23 Nov 2021 09:51:53 +0000 (19:51 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 24 Nov 2021 10:08:58 +0000 (21:08 +1100)
commit05203e5acdf1e2a505a542d4b4a46bab5abffa90
tree845bdf2c6d784cd8a02af947d55404eb5fcf8c36
parent94f9aa840ea1e2cd08c287c792df8acf43690745
KVM: PPC: Book3S HV P9: Demand fault PMU SPRs when marked not inuse

The pmcregs_in_use field in the guest VPA can not be trusted to reflect
what the guest is doing with PMU SPRs, so the PMU must always be managed
(stopped) when exiting the guest, and SPR values set when entering the
guest to ensure it can't cause a covert channel or otherwise cause other
guests or the host to misbehave.

So prevent guest access to the PMU with HFSCR[PM] if pmcregs_in_use is
clear, and avoid the PMU SPR access on every partition switch. Guests
that set pmcregs_in_use incorrectly or when first setting it and using
the PMU will take a hypervisor facility unavailable interrupt that will
bring in the PMU SPRs.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20211123095231.1036501-16-npiggin@gmail.com
arch/powerpc/kvm/book3s_hv.c