Skip to content

Commit 371b804

Browse files
npigginmpe
authored andcommitted
powerpc/64s: Initialize ISAv3 MMU registers before setting partition table
kexec can leave MMU registers set when booting into a new kernel, the PIDR (Process Identification Register) in particular. The boot sequence does not zero PIDR, so it only gets set when CPUs first switch to a userspace processes (until then it's running a kernel thread with effective PID = 0). This leaves a window where a process table entry and page tables are set up due to user processes running on other CPUs, that happen to match with a stale PID. The CPU with that PID may cause speculative accesses that address quadrant 0 (aka userspace addresses), which will result in cached translations and PWC (Page Walk Cache) for that process, on a CPU which is not in the mm_cpumask and so they will not be invalidated properly. The most common result is the kernel hanging in infinite page fault loops soon after kexec (usually in schedule_tail, which is usually the first non-speculative quadrant 0 access to a new PID) due to a stale PWC. However being a stale translation error, it could result in anything up to security and data corruption problems. Fix this by zeroing out PIDR at boot and kexec. Fixes: 7e381c0 ("powerpc/mm/radix: Add mmu context handling callback for radix") Cc: [email protected] # v4.7+ Signed-off-by: Nicholas Piggin <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent ab9dbf7 commit 371b804

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

arch/powerpc/kernel/cpu_setup_power.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ _GLOBAL(__setup_cpu_power9)
102102
li r0,0
103103
mtspr SPRN_PSSCR,r0
104104
mtspr SPRN_LPID,r0
105+
mtspr SPRN_PID,r0
105106
mfspr r3,SPRN_LPCR
106107
LOAD_REG_IMMEDIATE(r4, LPCR_PECEDH | LPCR_PECE_HVEE | LPCR_HVICE | LPCR_HEIC)
107108
or r3, r3, r4
@@ -126,6 +127,7 @@ _GLOBAL(__restore_cpu_power9)
126127
li r0,0
127128
mtspr SPRN_PSSCR,r0
128129
mtspr SPRN_LPID,r0
130+
mtspr SPRN_PID,r0
129131
mfspr r3,SPRN_LPCR
130132
LOAD_REG_IMMEDIATE(r4, LPCR_PECEDH | LPCR_PECE_HVEE | LPCR_HVICE | LPCR_HEIC)
131133
or r3, r3, r4

0 commit comments

Comments
 (0)