lkml.org 
[lkml]   [2009]   [Jun]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] [7/16] HWPOISON: x86: Add VM_FAULT_HWPOISON handling to x86 page fault handler v2
On Wed, Jun 03, 2009 at 08:46:40PM +0200, Andi Kleen wrote:
>
> Add VM_FAULT_HWPOISON handling to the x86 page fault handler. This is
> very similar to VM_FAULT_OOM, the only difference is that a different
> si_code is passed to user space and the new addr_lsb field is initialized.
>
> v2: Make the printk more verbose/unique
>
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
>
> ---
> arch/x86/mm/fault.c | 19 +++++++++++++++----
> 1 file changed, 15 insertions(+), 4 deletions(-)
>
> Index: linux/arch/x86/mm/fault.c
> ===================================================================
> --- linux.orig/arch/x86/mm/fault.c 2009-06-03 19:36:21.000000000 +0200
> +++ linux/arch/x86/mm/fault.c 2009-06-03 19:36:23.000000000 +0200
> @@ -166,6 +166,7 @@
> info.si_errno = 0;
> info.si_code = si_code;
> info.si_addr = (void __user *)address;
> + info.si_addr_lsb = si_code == BUS_MCEERR_AR ? PAGE_SHIFT : 0;
>
> force_sig_info(si_signo, &info, tsk);
> }
> @@ -797,10 +798,12 @@
> }
>
> static void
> -do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address)
> +do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
> + unsigned int fault)
> {
> struct task_struct *tsk = current;
> struct mm_struct *mm = tsk->mm;
> + int code = BUS_ADRERR;
>
> up_read(&mm->mmap_sem);
>
> @@ -816,7 +819,15 @@
> tsk->thread.error_code = error_code;
> tsk->thread.trap_no = 14;
>
> - force_sig_info_fault(SIGBUS, BUS_ADRERR, address, tsk);
> +#ifdef CONFIG_MEMORY_FAILURE
> + if (fault & VM_FAULT_HWPOISON) {
> + printk(KERN_ERR
> + "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
> + tsk->comm, tsk->pid, address);
> + code = BUS_MCEERR_AR;
> + }
> +#endif

If you make VM_FAULT_HWPOISON 0 when !CONFIG_MEMORY_FAILURE, then
you can remove this ifdef, can't you?

> + force_sig_info_fault(SIGBUS, code, address, tsk);
> }
>
> static noinline void
> @@ -826,8 +837,8 @@
> if (fault & VM_FAULT_OOM) {
> out_of_memory(regs, error_code, address);
> } else {
> - if (fault & VM_FAULT_SIGBUS)
> - do_sigbus(regs, error_code, address);
> + if (fault & (VM_FAULT_SIGBUS|VM_FAULT_HWPOISON))
> + do_sigbus(regs, error_code, address, fault);
> else
> BUG();
> }


\
 
 \ /
  Last update: 2009-06-09 11:57    [from the cache]
©2003-2014 Jasper Spaans. hosted at Digital Ocean