KVM: PPC: Book3S HV: Fix KVM_RUN clobbering FP/VEC user registers
authorNicholas Piggin <npiggin@gmail.com>
Wed, 22 Nov 2023 02:58:11 +0000 (12:58 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Dec 2023 07:52:19 +0000 (08:52 +0100)
commit10098448a51c1c1f27df9b9b2b4a2860855c3d53
treec6bab56d9346da852366960f3f63c562a7bdc64e
parent38b3542305d05aa70bc2b5e2dfc3b66ea0349bbe
KVM: PPC: Book3S HV: Fix KVM_RUN clobbering FP/VEC user registers

commit dc158d23b33df9033bcc8e7117e8591dd2f9d125 upstream.

Before running a guest, the host process (e.g., QEMU) FP/VEC registers
are saved if they were being used, similarly to when the kernel uses FP
registers. The guest values are then loaded into regs, and the host
process registers will be restored lazily when it uses FP/VEC.

KVM HV has a bug here: the host process registers do get saved, but the
user MSR bits remain enabled, which indicates the registers are valid
for the process. After they are clobbered by running the guest, this
valid indication causes the host process to take on the FP/VEC register
values of the guest.

Fixes: 34e119c96b2b ("KVM: PPC: Book3S HV P9: Reduce mtmsrd instructions required to save host SPRs")
Cc: stable@vger.kernel.org # v5.17+
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20231122025811.2973-1-npiggin@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/powerpc/kernel/process.c