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

signal/parisc: Use force_sig_mceerr where appropriate

In do_page_fault where an mceerr is generated stop and call force_sig_mceerr.
Keeping the mcerr handling logic out of the force_sig_info call below.

This ensures that only and always in the mcerr case is lsb interesting.

This ensures setting set si_lsb in the future won't accidentally
stomp another siginfo field in the non mcerr case.

Cc: James Bottomley <jejb@parisc-linux.org>
Cc: Helge Deller <deller@gmx.de>
Cc: linux-parisc@vger.kernel.org
Acked-by: Helge Deller <deller@gmx.de> # parisc
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>

+15 -15
+15 -15
arch/parisc/mm/fault.c
··· 354 354 355 355 if (user_mode(regs)) { 356 356 struct siginfo si; 357 - unsigned int lsb = 0; 358 357 359 358 clear_siginfo(&si); 360 359 switch (code) { ··· 390 391 391 392 #ifdef CONFIG_MEMORY_FAILURE 392 393 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) { 394 + unsigned int lsb = 0; 393 395 printk(KERN_ERR 394 396 "MCE: Killing %s:%d due to hardware memory corruption fault at %08lx\n", 395 397 tsk->comm, tsk->pid, address); 396 - si.si_signo = SIGBUS; 397 - si.si_code = BUS_MCEERR_AR; 398 + /* 399 + * Either small page or large page may be poisoned. 400 + * In other words, VM_FAULT_HWPOISON_LARGE and 401 + * VM_FAULT_HWPOISON are mutually exclusive. 402 + */ 403 + if (fault & VM_FAULT_HWPOISON_LARGE) 404 + lsb = hstate_index_to_shift(VM_FAULT_GET_HINDEX(fault)); 405 + else if (fault & VM_FAULT_HWPOISON) 406 + lsb = PAGE_SHIFT; 407 + 408 + force_sig_mceerr(BUS_MCEERR_AR, (void __user *) address, 409 + lsb, current); 410 + return; 398 411 } 399 412 #endif 400 413 401 - /* 402 - * Either small page or large page may be poisoned. 403 - * In other words, VM_FAULT_HWPOISON_LARGE and 404 - * VM_FAULT_HWPOISON are mutually exclusive. 405 - */ 406 - if (fault & VM_FAULT_HWPOISON_LARGE) 407 - lsb = hstate_index_to_shift(VM_FAULT_GET_HINDEX(fault)); 408 - else if (fault & VM_FAULT_HWPOISON) 409 - lsb = PAGE_SHIFT; 410 - else 411 - show_signal_msg(regs, code, address, tsk, vma); 412 - si.si_addr_lsb = lsb; 414 + show_signal_msg(regs, code, address, tsk, vma); 413 415 414 416 si.si_errno = 0; 415 417 si.si_addr = (void __user *) address;