From patchwork Sat Aug 19 10:22:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuai Xue X-Patchwork-Id: 13358557 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 205DEEE4993 for ; Sat, 19 Aug 2023 10:22:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :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=p+ayApqk6j2w5JR7QLBZLpmoDXQfbWGURxZn4f68B+o=; b=sMXOpOVnpx9UUj 6WcPsF+mpm+O9Q/mWtwAqedOKxfhNDKVNhDZAqBBBaqaZffL9xHz0wno2jDKoXxTplay1Fg7Ulfhq B4MccbojbL8VP958ISQXVQK7XhMMK0UquHt9/2lCcoesWsCT+9kn4en+CZctySC6h6faMq4ZuS6Ja 42IQTgoGC8kyE09zsh53gQTV5J60K05LYfWK16uGJbLDKoFu1GgGvOuVLktauWa1KBkqDQ8hMwt7i wkfSAJ0aazEbg/bS0cgHNq7zB7/j/VjEpqvH/Gcf0fT1fYsh7DiDJ/SsDjyWFZLNUUhXqDhrZ0J8M Nf+VQp2z5yDiYmIeiqrg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qXJ6L-00AgfC-2W; Sat, 19 Aug 2023 10:22:37 +0000 Received: from out30-131.freemail.mail.aliyun.com ([115.124.30.131]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qXJ6H-00AgXK-0Y for linux-arm-kernel@lists.infradead.org; Sat, 19 Aug 2023 10:22:36 +0000 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R111e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046050;MF=xueshuai@linux.alibaba.com;NM=1;PH=DS;RN=15;SR=0;TI=SMTPD_---0Vq53wpY_1692440537; Received: from localhost.localdomain(mailfrom:xueshuai@linux.alibaba.com fp:SMTPD_---0Vq53wpY_1692440537) by smtp.aliyun-inc.com; Sat, 19 Aug 2023 18:22:19 +0800 From: Shuai Xue To: catalin.marinas@arm.com, will@kernel.org, James.Bottomley@HansenPartnership.com, deller@gmx.de, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org Subject: [PATCH] HWPOISON: add a pr_err message when forcibly send a sigbus Date: Sat, 19 Aug 2023 18:22:12 +0800 Message-Id: <20230819102212.21103-1-xueshuai@linux.alibaba.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230819_032233_439565_3E434ACB X-CRM114-Status: GOOD ( 12.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When a process tries to access a page that is already offline, the kernel will send a sigbus signal with the BUS_MCEERR_AR code. This signal is typically handled by a registered sigbus handler in the process. However, if the process does not have a registered sigbus handler, it is important for end users to be informed about what happened. To address this, add an error message similar to those implemented on the x86, powerpc, and parisc platforms. Signed-off-by: Shuai Xue Acked-by: Helge Deller # parisc --- arch/arm64/mm/fault.c | 2 ++ arch/parisc/mm/fault.c | 5 ++--- arch/x86/mm/fault.c | 3 +-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 3fe516b32577..38e2186882bd 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -679,6 +679,8 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr, } else if (fault & (VM_FAULT_HWPOISON_LARGE | VM_FAULT_HWPOISON)) { unsigned int lsb; + pr_err("MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n", + current->comm, current->pid, far); lsb = PAGE_SHIFT; if (fault & VM_FAULT_HWPOISON_LARGE) lsb = hstate_index_to_shift(VM_FAULT_GET_HINDEX(fault)); diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c index a4c7c7630f48..6b096b47e149 100644 --- a/arch/parisc/mm/fault.c +++ b/arch/parisc/mm/fault.c @@ -395,9 +395,8 @@ void do_page_fault(struct pt_regs *regs, unsigned long code, #ifdef CONFIG_MEMORY_FAILURE if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) { unsigned int lsb = 0; - printk(KERN_ERR - "MCE: Killing %s:%d due to hardware memory corruption fault at %08lx\n", - tsk->comm, tsk->pid, address); + pr_err("MCE: Killing %s:%d due to hardware memory corruption fault at %08lx\n", + tsk->comm, tsk->pid, address); /* * Either small page or large page may be poisoned. * In other words, VM_FAULT_HWPOISON_LARGE and diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index e8711b2cafaf..7266509cca54 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -962,8 +962,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address, struct task_struct *tsk = current; unsigned lsb = 0; - pr_err( - "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n", + pr_err("MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n", tsk->comm, tsk->pid, address); if (fault & VM_FAULT_HWPOISON_LARGE) lsb = hstate_index_to_shift(VM_FAULT_GET_HINDEX(fault));