From patchwork Tue Feb 21 23:36:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Baicar X-Patchwork-Id: 9585891 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 2E789600CA for ; Tue, 21 Feb 2017 23:37:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F55828623 for ; Tue, 21 Feb 2017 23:37:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0130228621; Tue, 21 Feb 2017 23:37:41 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9EA6C28621 for ; Tue, 21 Feb 2017 23:37:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=9aTyeLBa8IKsnYwd5Fot2JFjlPjwEthTt02iiuKbg08=; b=kJk Ysoj77diixS65RZL3pQ/DaZyZ+NnqBdRv3VXuNxoY7B4f4LxZx+gVqOMIFtzHup+vTH6+2irsrHxq fniRSIDCxIbUD2H8oQpMevXj/YublIDWkfj0Ah0wjZyCkQN6+4wzvy37FmhITb33GWAozY+vyU4ug Ng8ut647R1RzXq337RXenoyqOLx4Silm2sb08g8/mo6Bm3fiGaUWtoeJBMfTiXeLN8V5GKBXEKlqS bl6zATdnhoYIblZ8adAENfePmDJ2JfUq/nBdIiaWc6lWNSqWcLV2uCMMDwgOLyKBfjhmY0vVHszXH ZoDWgINV5VL2Hu89P7PCqIjdeW/m05g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cgK02-00039z-31; Tue, 21 Feb 2017 23:37:38 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cgJzt-00035W-T1 for linux-arm-kernel@lists.infradead.org; Tue, 21 Feb 2017 23:37:34 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 029FB60D73; Tue, 21 Feb 2017 23:37:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1487720229; bh=dhKs5jSWrXEXMoWi1AcO/NZEZzUXllb/HCz3tIrEoWE=; h=From:To:Cc:Subject:Date:From; b=aS2+We2VZ/OF91fwS4gBbKcP7Yn8lsNmK0GLSw0oa32kTqrIItKCEiWkGREuwo22h Cc5IIpvvBDtxCnv6f2694wkbHAYRoobO+ath6QsQSeq3uiHbtRnqoXUH8dTG3nCSRD FT7djdEXbnT+M99CwFH57/k4ueuXh+4PwfHwOBZ8= Received: from tbaicar-lnx.qualcomm.com (unknown [129.46.14.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: tbaicar@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 1FE3160D73; Tue, 21 Feb 2017 23:37:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1487720227; bh=dhKs5jSWrXEXMoWi1AcO/NZEZzUXllb/HCz3tIrEoWE=; h=From:To:Cc:Subject:Date:From; b=RvK5SxbdyUrLjFXLkgp6nf6SK/epNz3ihinUGtVTryxSau/b/UBfTGzmHlAkLlfRD hwo4xxndIII2HBA45tulWTBxk1frUMv44XId5ZM4KvoF3ddZxvB1kLlKELsRbp59Av QacdGu8XxxiiU9Bar9iHr2miV4UiM8i0nVcrV4RU= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 1FE3160D73 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=tbaicar@codeaurora.org From: Tyler Baicar To: catalin.marinas@arm.com, will.deacon@arm.com, mark.rutland@arm.com, james.morse@arm.com, akpm@linux-foundation.org, paul.gortmaker@windriver.com, sandeepa.s.prabhu@gmail.com, shijie.huang@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, punit.agrawal@arm.com Subject: [PATCH V2] arm64: hwpoison: add VM_FAULT_HWPOISON[_LARGE] handling Date: Tue, 21 Feb 2017 16:36:45 -0700 Message-Id: <1487720205-14594-1-git-send-email-tbaicar@codeaurora.org> X-Mailer: git-send-email 1.8.2.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170221_153730_112143_8AB3BF4B X-CRM114-Status: GOOD ( 14.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tyler Baicar , "Jonathan \(Zhixiong\) Zhang" MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Jonathan (Zhixiong) Zhang" Add VM_FAULT_HWPOISON[_LARGE] handling to the arm64 page fault handler. Handling of VM_FAULT_HWPOISON[_LARGE] is very similar to VM_FAULT_OOM, the only difference is that a different si_code (BUS_MCEERR_AR) is passed to user space and si_addr_lsb field is initialized. Signed-off-by: Jonathan (Zhixiong) Zhang Signed-off-by: Tyler Baicar --- arch/arm64/mm/fault.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 156169c..ceaa82f 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -193,9 +194,10 @@ static void __do_kernel_fault(struct mm_struct *mm, unsigned long addr, */ static void __do_user_fault(struct task_struct *tsk, unsigned long addr, unsigned int esr, unsigned int sig, int code, - struct pt_regs *regs) + struct pt_regs *regs, int fault) { struct siginfo si; + unsigned int lsb = 0; if (unhandled_signal(tsk, sig) && show_unhandled_signals_ratelimited()) { pr_info("%s[%d]: unhandled %s (%d) at 0x%08lx, esr 0x%03x\n", @@ -211,6 +213,17 @@ static void __do_user_fault(struct task_struct *tsk, unsigned long addr, si.si_errno = 0; si.si_code = code; si.si_addr = (void __user *)addr; + /* + * 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; + si.si_addr_lsb = lsb; + force_sig_info(sig, &si, tsk); } @@ -224,7 +237,7 @@ static void do_bad_area(unsigned long addr, unsigned int esr, struct pt_regs *re * handle this fault with. */ if (user_mode(regs)) - __do_user_fault(tsk, addr, esr, SIGSEGV, SEGV_MAPERR, regs); + __do_user_fault(tsk, addr, esr, SIGSEGV, SEGV_MAPERR, regs, 0); else __do_kernel_fault(mm, addr, esr, regs); } @@ -426,6 +439,9 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr, */ sig = SIGBUS; code = BUS_ADRERR; + } else if (fault & (VM_FAULT_HWPOISON | VM_FAULT_HWPOISON_LARGE)) { + sig = SIGBUS; + code = BUS_MCEERR_AR; } else { /* * Something tried to access memory that isn't in our memory @@ -436,7 +452,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr, SEGV_ACCERR : SEGV_MAPERR; } - __do_user_fault(tsk, addr, esr, sig, code, regs); + __do_user_fault(tsk, addr, esr, sig, code, regs, fault); return 0; no_context: