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: 136287 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp2575435vqi; Sun, 20 Aug 2023 10:22:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFUaVev//3iGnC30IOGZFQRRTwDy0da5K27BG1doRtDdP6VedyLHSD2IO+dQDdwb+xrSwa5 X-Received: by 2002:a05:6a00:15d4:b0:668:806d:c2d6 with SMTP id o20-20020a056a0015d400b00668806dc2d6mr3913925pfu.12.1692552142734; Sun, 20 Aug 2023 10:22:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692552142; cv=none; d=google.com; s=arc-20160816; b=wgKEKFm8ZWUQkenbukMXIqO1O5wRHqFvuCXSIkjXYpZbTJb0H5d+R9LvfC2jUKlI+0 VfG2Rztj6hxUTu+/f1P6lSD4Iai6bGbpvF3OJ37soAQPuYX6gs3wb5Io8W15hXEpM1mT +c1K1ieY1c7Ne1ciTY8ll9mfHJJL7TcJ9DcE9/S42s79IPSOhUzKWLPKoxC153MLgEeX GI0NyW3QOVcf93WQopO1fCDLKid7tnvubGx89E+S5gntLi3enKinsjzVffPZaaV+P8s8 a7uO0g2RHn7FbrEPSnTP4fTZq0pMt9T6hrqhMrHEWVtC1obG0lub4KrNunKXZmP4Ml0u xGGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=rVenbrUXrifTYEy64rBHm2hsy8GBsZXT6ALupjh6R8o=; fh=9m8gW/ecRSZRWJcC44JCiZBcquSP3S3mKyjPOUIlmiI=; b=u/m9Hh+ZEPx9FR1QGn25epcaO1I8VCAAnQZW6dStzIHt56f8bgPQXSPspjJE5aIpFM phz8lhqzVCoGc6xdWAV6n5pxJ6/cdwpan2VsiBTeuFBdBcge8LEPOMggChY3ToWApDq4 lnozg303K0WF7/7u5+PfH/6KZGNzZhT9qOXiah44KA5HpoTlBM0DuuZgrKE4j6nm0E4/ j8FjuQzJ4bzi8NdYYn7r58rsaspZfhBUSMMh7M8eTH/pBPPzJ8L7JpGU9HJAnUsbHcrF Dq2GopZ5wdLIYy2OBgDUiOBDkWcqo2REsvQD1FW4CbcpQJQu6wvAbjCDF5GIMFU5b828 0Vlw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id t184-20020a6381c1000000b0056bad7762c6si1559635pgd.226.2023.08.20.10.22.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Aug 2023 10:22:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C283D3C5D01; Sat, 19 Aug 2023 12:18:37 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231713AbjHSKnH (ORCPT + 99 others); Sat, 19 Aug 2023 06:43:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231294AbjHSKmo (ORCPT ); Sat, 19 Aug 2023 06:42:44 -0400 Received: from out30-98.freemail.mail.aliyun.com (out30-98.freemail.mail.aliyun.com [115.124.30.98]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6F7246734; Sat, 19 Aug 2023 03:22:25 -0700 (PDT) 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-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774769555246502047 X-GMAIL-MSGID: 1774769555246502047 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 --- 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));