Skip to content

Commit 3913fdd

Browse files
antonblanchardmpe
authored andcommitted
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>
1 parent 63af526 commit 3913fdd

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

‎arch/powerpc/mm/fault.c‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ static int store_updates_sp(struct pt_regs *regs)
114114
#define MM_FAULT_CONTINUE -1
115115
#define MM_FAULT_ERR(sig) (sig)
116116

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)
118119
{
119120
siginfo_t info;
120121

@@ -128,6 +129,13 @@ static int do_sigbus(struct pt_regs *regs, unsigned long address)
128129
info.si_errno = 0;
129130
info.si_code = BUS_ADRERR;
130131
info.si_addr = (void __user *)address;
132+
#ifdef CONFIG_MEMORY_FAILURE
133+
if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
134+
pr_err("MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
135+
current->comm, current->pid, address);
136+
info.si_code = BUS_MCEERR_AR;
137+
}
138+
#endif
131139
force_sig_info(SIGBUS, &info, current);
132140
return MM_FAULT_RETURN;
133141
}
@@ -170,11 +178,8 @@ static int mm_fault_error(struct pt_regs *regs, unsigned long addr, int fault)
170178
return MM_FAULT_RETURN;
171179
}
172180

173-
/* Bus error. x86 handles HWPOISON here, we'll add this if/when
174-
* we support the feature in HW
175-
*/
176-
if (fault & VM_FAULT_SIGBUS)
177-
return do_sigbus(regs, addr);
181+
if (fault & (VM_FAULT_SIGBUS|VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE))
182+
return do_sigbus(regs, addr, fault);
178183

179184
/* We don't understand the fault code, this is fatal */
180185
BUG();

0 commit comments

Comments
 (0)