Skip to content

Commit ee83484

Browse files
agrafmpe
authored andcommitted
KVM: PPC: Book3S PR: Enable MSR_DR for switch_mmu_context()
Commit 863771a ("powerpc/32s: Convert switch_mmu_context() to C") moved the switch_mmu_context() to C. While in principle a good idea, it meant that the function now uses the stack. The stack is not accessible from real mode though. So to keep calling the function, let's turn on MSR_DR while we call it. That way, all pointer references to the stack are handled virtually. In addition, make sure to save/restore r12 on the stack, as it may get clobbered by the C function. Fixes: 863771a ("powerpc/32s: Convert switch_mmu_context() to C") Cc: [email protected] # v5.14+ Reported-by: Matt Evans <[email protected]> Signed-off-by: Alexander Graf <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 348c713 commit ee83484

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

arch/powerpc/kvm/book3s_32_sr.S

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,27 @@
122122

123123
/* 0x0 - 0xb */
124124

125-
/* 'current->mm' needs to be in r4 */
126-
tophys(r4, r2)
127-
lwz r4, MM(r4)
128-
tophys(r4, r4)
129-
/* This only clobbers r0, r3, r4 and r5 */
125+
/* switch_mmu_context() needs paging, let's enable it */
126+
mfmsr r9
127+
ori r11, r9, MSR_DR
128+
mtmsr r11
129+
sync
130+
131+
/* switch_mmu_context() clobbers r12, rescue it */
132+
SAVE_GPR(12, r1)
133+
134+
/* Calling switch_mmu_context(<inv>, current->mm, <inv>); */
135+
lwz r4, MM(r2)
130136
bl switch_mmu_context
131137

138+
/* restore r12 */
139+
REST_GPR(12, r1)
140+
141+
/* Disable paging again */
142+
mfmsr r9
143+
li r6, MSR_DR
144+
andc r9, r9, r6
145+
mtmsr r9
146+
sync
147+
132148
.endm

0 commit comments

Comments
 (0)