Skip to content

Commit dc158d2

Browse files
npigginmpe
authored andcommitted
KVM: PPC: Book3S HV: Fix KVM_RUN clobbering FP/VEC user registers
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: 34e119c ("KVM: PPC: Book3S HV P9: Reduce mtmsrd instructions required to save host SPRs") Cc: [email protected] # v5.17+ Signed-off-by: Nicholas Piggin <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://msgid.link/[email protected]
1 parent 5e1d824 commit dc158d2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

arch/powerpc/kernel/process.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,11 +1198,11 @@ void kvmppc_save_user_regs(void)
11981198

11991199
usermsr = current->thread.regs->msr;
12001200

1201+
/* Caller has enabled FP/VEC/VSX/TM in MSR */
12011202
if (usermsr & MSR_FP)
1202-
save_fpu(current);
1203-
1203+
__giveup_fpu(current);
12041204
if (usermsr & MSR_VEC)
1205-
save_altivec(current);
1205+
__giveup_altivec(current);
12061206

12071207
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
12081208
if (usermsr & MSR_TM) {

0 commit comments

Comments
 (0)