Skip to content

Commit e724f08

Browse files
paulusmackbonzini
authored andcommitted
KVM: PPC: Book3S HV: Fix register usage when loading/saving VRSAVE
Commit 595e4f7 ("KVM: PPC: Book3S HV: Use load/store_fp_state functions in HV guest entry/exit") changed the register usage in kvmppc_save_fp() and kvmppc_load_fp() but omitted changing the instructions that load and save VRSAVE. The result is that the VRSAVE value was loaded from a constant address, and saved to a location past the end of the vcpu struct, causing host kernel memory corruption and various kinds of host kernel crashes. This fixes the problem by using register r31, which contains the vcpu pointer, instead of r3 and r4. Signed-off-by: Paul Mackerras <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent a5b0ccb commit e724f08

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/powerpc/kvm/book3s_hv_rmhandlers.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2136,7 +2136,7 @@ BEGIN_FTR_SECTION
21362136
END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
21372137
#endif
21382138
mfspr r6,SPRN_VRSAVE
2139-
stw r6,VCPU_VRSAVE(r3)
2139+
stw r6,VCPU_VRSAVE(r31)
21402140
mtlr r30
21412141
mtmsrd r5
21422142
isync
@@ -2173,7 +2173,7 @@ BEGIN_FTR_SECTION
21732173
bl .load_vr_state
21742174
END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
21752175
#endif
2176-
lwz r7,VCPU_VRSAVE(r4)
2176+
lwz r7,VCPU_VRSAVE(r31)
21772177
mtspr SPRN_VRSAVE,r7
21782178
mtlr r30
21792179
mr r4,r31

0 commit comments

Comments
 (0)