From patchwork Thu Sep 21 19:52:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 9964765 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3C2E8602D8 for ; Thu, 21 Sep 2017 19:52:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25256294FD for ; Thu, 21 Sep 2017 19:52:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1878729520; Thu, 21 Sep 2017 19:52:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9ED2A294FD for ; Thu, 21 Sep 2017 19:52:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751763AbdIUTwT (ORCPT ); Thu, 21 Sep 2017 15:52:19 -0400 Received: from mout.gmx.net ([212.227.17.20]:54030 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751754AbdIUTwS (ORCPT ); Thu, 21 Sep 2017 15:52:18 -0400 Received: from p100.box ([91.36.202.100]) by mail.gmx.com (mrgmx101 [212.227.17.168]) with ESMTPSA (Nemesis) id 0MMXVC-1e19Of0itS-008LM2; Thu, 21 Sep 2017 21:52:11 +0200 Date: Thu, 21 Sep 2017 21:52:08 +0200 From: Helge Deller To: linux-parisc@vger.kernel.org, James Bottomley , John David Anglin Subject: [PATCH] parisc: Add HWPOISON page fault handler code Message-ID: <20170921195208.GA15588@p100.box> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-Provags-ID: V03:K0:IjRlkDesLqWXNAodS91aXEVvNgQWo3zQRMPAILt2SEQRKrwcWkP z8LlA7/uaUCiI14+fiiShqf/xdJMqIWfRojJ8vx9coRYQdtuE5Gu5i+bL6EhtDnE0mL0zW1 vcwfWLBC3lSLFnPT23oH0apHole9LT9Bb5PKTwKZjFtiQfJOu22SLxvNz5isasYXP6q3gMz oqPgicQfkycFS0V+ygwqQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:+AAyFDcdiPc=:+HwdpG0tplla1iCkt91Eic a7gYJaqBzf1UE3VjfxX8HN41xM116Qu8szuRnhO1wr5x1Uu/m3BS6dt+fim2Ab5rXZTyITVP0 H+3uVpq8eU/MRdCOG/WmFnEUhTFud+tRKIaXSyvKW2dYniR9pwpANf2LUy6/M/Fyi55tEPitZ jHEWCkfzevzQyR06dqIj6SUYv+7rYjwJapWLnQUahXI6OtUNTsa9xEK4W9IsrYOjKhlK74wkH mKzcFqeZjuR1/SNkw5kHe3iUzPuJhT2nJB2kFDBDpIKp+BFcPC/Gg7x7X+ueqRioI5iRDNOTw 3T76+frT7stwhm4Id8aPXJAL9v79+K0f9XsZfLV2BwYcIY+HqItCcXg9S6tv0hoW+pci3Vv1K D4a0xtZoHNtuRgF+SygbYBfr5x0/IE2oSrJREoLFFerCjboEHYue8y/xdUdJ64kYqk+L4l+/6 viNpurrQ5C2SXJ6FcbiWrLWHfRHWKDG9X38WRO0wT+mK7G3JRF8JpFWO/GJYh9YiHPYBJQwuY KtVx60Uu5MRJsx881dPtSkcaHw0TMCAqjQrYBzR739DGwLikUapRjqBySKZYt5Bdc4MiOynN+ RIG4F4/RW+1Zsf8qGtLKBQ1Ps3Tfx+slgnGMH1w/tGOj/wkeIUP9PHcK5ZTOSLPksW/Dx5DSH f1FFtArWoxWAyo5WSBn7MZl7YOubTfPvCzmER2dWcjupY2A84w+BXpj0ipLce5CE949pexAmx YbvMjOuDfdxaKhFBOG6q2g7amwkmZg6bdgGpBL3BnZuDatf2fsHBYigKsBr6tseK/rCaiWeHJ CobBcInx0jg7tpf1OZHcGSSqvg5cg== Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit 24587380f61d ("parisc: Add MADV_HWPOISON and MADV_SOFT_OFFLINE") added the necessary constants to handle hardware-poisoning. Those were needed to support the page deallocation feature from firmware. But I completely missed to add the relevant fault handler code. This now showed up when I ran the madvise07 testcase from the Linux Test Project, which failed with a kernel BUG at arch/parisc/mm/fault.c:320. With this patch the parisc kernel now behaves like other platforms and gives the same kernel syslog warnings when poisoning pages. Signed-off-by: Helge Deller --- To unsubscribe from this list: send the line "unsubscribe linux-parisc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c index 5b101f6..0d55e23 100644 --- a/arch/parisc/mm/fault.c +++ b/arch/parisc/mm/fault.c @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -315,7 +316,8 @@ void do_page_fault(struct pt_regs *regs, unsigned long code, goto out_of_memory; else if (fault & VM_FAULT_SIGSEGV) goto bad_area; - else if (fault & VM_FAULT_SIGBUS) + else if (fault & (VM_FAULT_SIGBUS|VM_FAULT_HWPOISON| + VM_FAULT_HWPOISON_LARGE)) goto bad_area; BUG(); } @@ -352,8 +354,7 @@ void do_page_fault(struct pt_regs *regs, unsigned long code, if (user_mode(regs)) { struct siginfo si; - - show_signal_msg(regs, code, address, tsk, vma); + unsigned int lsb = 0; switch (code) { case 15: /* Data TLB miss fault/Data page fault */ @@ -386,6 +387,30 @@ void do_page_fault(struct pt_regs *regs, unsigned long code, si.si_code = (code == 26) ? SEGV_ACCERR : SEGV_MAPERR; break; } + +#ifdef CONFIG_MEMORY_FAILURE + if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) { + printk(KERN_ERR + "MCE: Killing %s:%d due to hardware memory corruption fault at %08lx\n", + tsk->comm, tsk->pid, address); + si.si_signo = SIGBUS; + si.si_code = BUS_MCEERR_AR; + } +#endif + + /* + * Either small page or large page may be poisoned. + * In other words, VM_FAULT_HWPOISON_LARGE and + * VM_FAULT_HWPOISON are mutually exclusive. + */ + if (fault & VM_FAULT_HWPOISON_LARGE) + lsb = hstate_index_to_shift(VM_FAULT_GET_HINDEX(fault)); + else if (fault & VM_FAULT_HWPOISON) + lsb = PAGE_SHIFT; + else + show_signal_msg(regs, code, address, tsk, vma); + si.si_addr_lsb = lsb; + si.si_errno = 0; si.si_addr = (void __user *) address; force_sig_info(si.si_signo, &si, current);