Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc: Add VM_FAULT_HWPOISON handling to powerpc page fault handler

do_page_fault was missing knowledge of HWPOISON, and we would oops
if userspace tried to access a poisoned page:

kernel BUG at arch/powerpc/mm/fault.c:180!

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by

Anton Blanchard and committed by
Michael Ellerman
3913fdd7 63af5262

+11 -6
+11 -6
arch/powerpc/mm/fault.c
··· 114 114 #define MM_FAULT_CONTINUE -1 115 115 #define MM_FAULT_ERR(sig) (sig) 116 116 117 - static int do_sigbus(struct pt_regs *regs, unsigned long address) 117 + static int do_sigbus(struct pt_regs *regs, unsigned long address, 118 + unsigned int fault) 118 119 { 119 120 siginfo_t info; 120 121 ··· 129 128 info.si_errno = 0; 130 129 info.si_code = BUS_ADRERR; 131 130 info.si_addr = (void __user *)address; 131 + #ifdef CONFIG_MEMORY_FAILURE 132 + if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) { 133 + pr_err("MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n", 134 + current->comm, current->pid, address); 135 + info.si_code = BUS_MCEERR_AR; 136 + } 137 + #endif 132 138 force_sig_info(SIGBUS, &info, current); 133 139 return MM_FAULT_RETURN; 134 140 } ··· 178 170 return MM_FAULT_RETURN; 179 171 } 180 172 181 - /* Bus error. x86 handles HWPOISON here, we'll add this if/when 182 - * we support the feature in HW 183 - */ 184 - if (fault & VM_FAULT_SIGBUS) 185 - return do_sigbus(regs, addr); 173 + if (fault & (VM_FAULT_SIGBUS|VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) 174 + return do_sigbus(regs, addr, fault); 186 175 187 176 /* We don't understand the fault code, this is fatal */ 188 177 BUG();