From patchwork Mon Sep 2 03:00:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuai Xue X-Patchwork-Id: 13786675 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28A0EC54FC6 for ; Mon, 2 Sep 2024 03:00:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 62DDB8D0066; Sun, 1 Sep 2024 23:00:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5DBEF8D0065; Sun, 1 Sep 2024 23:00:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 457B08D0066; Sun, 1 Sep 2024 23:00:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 2B4C38D0065 for ; Sun, 1 Sep 2024 23:00:58 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id BF82D161952 for ; Mon, 2 Sep 2024 03:00:57 +0000 (UTC) X-FDA: 82518296154.30.4BF5F2A Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) by imf16.hostedemail.com (Postfix) with ESMTP id B186D18000B for ; Mon, 2 Sep 2024 03:00:54 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=I+fvNf5D; spf=pass (imf16.hostedemail.com: domain of xueshuai@linux.alibaba.com designates 115.124.30.131 as permitted sender) smtp.mailfrom=xueshuai@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725246033; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=t8331V5MBhR/kbLGUOQ7ZR657iI1p64L0luynItU5k4=; b=NneGqm5dZ56LFz2A9OaUpfAvUTJoXDyXUaHqJAy3JM1w2F8VCs968sWbIy3dTPe1+e7cxZ NSgjI1P2Cs6hwBDAANLIm7dULfLN+GTdUJryjfGBTAYCfO5kcv0JjpJUZyqI8PJhPWPork uzH6wWC+W2xQsyWX3fFcePpO3Fkr1S0= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=I+fvNf5D; spf=pass (imf16.hostedemail.com: domain of xueshuai@linux.alibaba.com designates 115.124.30.131 as permitted sender) smtp.mailfrom=xueshuai@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725246033; a=rsa-sha256; cv=none; b=LvAzWrbgHvIfMu03Wfo26R4Wgpq2N6lCil3/a97zpyO6cglojysJON6IYK5jLhJp9KmSQv bMbeCLxUQufZyBrR6/XUPJ84kq5sVUJ/+ENxtKbGEuV+JqzisDvGve+Ju9p5u6TZhHmFFq 0p28+U8+gZN+qhfrUwGn15QBsPbolLI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1725246049; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=t8331V5MBhR/kbLGUOQ7ZR657iI1p64L0luynItU5k4=; b=I+fvNf5DXO+HxAoETwfMMnvw1bintNz30Iw251TIg4DKBQnGT6jqIHN9lfHc5D4FiRD8koQqN7wO9O2DG5UncKjZN/X6tfNeHcRPk9rpIgqy1LePL/7S2B8Fa4KixZYbQ2wkU3Yvo7nvn+rcqoKpSBBK7Rq7NGwbSJYdequVP3s= Received: from localhost.localdomain(mailfrom:xueshuai@linux.alibaba.com fp:SMTPD_---0WE1odod_1725246046) by smtp.aliyun-inc.com; Mon, 02 Sep 2024 11:00:47 +0800 From: Shuai Xue To: bp@alien8.de, rafael@kernel.org, wangkefeng.wang@huawei.com, tanxiaofei@huawei.com, mawupeng1@huawei.com, tony.luck@intel.com, linmiaohe@huawei.com, naoya.horiguchi@nec.com, james.morse@arm.com, tongtiangen@huawei.com, gregkh@linuxfoundation.org, will@kernel.org, jarkko@kernel.org Cc: linux-acpi@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, linux-edac@vger.kernel.org, x86@kernel.org, xueshuai@linux.alibaba.com, justin.he@arm.com, ardb@kernel.org, ying.huang@intel.com, ashish.kalra@amd.com, baolin.wang@linux.alibaba.com, tglx@linutronix.de, mingo@redhat.com, dave.hansen@linux.intel.com, lenb@kernel.org, hpa@zytor.com, robert.moore@intel.com, lvying6@huawei.com, xiexiuqi@huawei.com, zhuo.song@linux.alibaba.com Subject: [PATCH v12 1/3] ACPI: APEI: send SIGBUS to current task if synchronous memory error not recovered Date: Mon, 2 Sep 2024 11:00:32 +0800 Message-ID: <20240902030034.67152-2-xueshuai@linux.alibaba.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20221027042445.60108-1-xueshuai@linux.alibaba.com> References: <20221027042445.60108-1-xueshuai@linux.alibaba.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: txxhfebwecqwzjxwd9y9cgn43srogsg1 X-Rspamd-Queue-Id: B186D18000B X-Rspamd-Server: rspam11 X-HE-Tag: 1725246054-801108 X-HE-Meta: U2FsdGVkX1/KV30ryaUTDRn6YNRPmR/gT5sDBYSpkIpGPKAdtdO6MrLLcsXwglGZ/RehLSBkNsPSJT/gQ/FN5xMeCSN5rhZUvT+m6olU/VTD+BuWI//SbgajZsnyR3g+mLWFXIqmDYGCNjUtNcQpDZR1Uppg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F6yTkL+Q== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Synchronous error was detected as a result of user-space process accessing a 2-bit uncorrected error. The CPU will take a synchronous error exception such as Synchronous External Abort (SEA) on Arm64. The kernel will queue a memory_failure() work which poisons the related page, unmaps the page, and then sends a SIGBUS to the process, so that a system wide panic can be avoided. However, no memory_failure() work will be queued unless all bellow preconditions check passed: - `if (!(mem_err->validation_bits & CPER_MEM_VALID_PA))` in ghes_handle_memory_failure() - `if (flags == -1)` in ghes_handle_memory_failure() - `if (!IS_ENABLED(CONFIG_ACPI_APEI_MEMORY_FAILURE))` in ghes_do_memory_failure() - `if (!pfn_valid(pfn) && !arch_is_platform_page(physical_addr)) ` in ghes_do_memory_failure() In such case, the user-space process will trigger SEA again. This loop can potentially exceed the platform firmware threshold or even trigger a kernel hard lockup, leading to a system reboot. Fix it by performing a force kill if no memory_failure() work is queued for synchronous errors. Suggested-by: Xiaofei Tan Signed-off-by: Shuai Xue --- drivers/acpi/apei/ghes.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index 623cc0cb4a65..b0b20ee533d9 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -801,6 +801,16 @@ static bool ghes_do_proc(struct ghes *ghes, } } + /* + * If no memory failure work is queued for abnormal synchronous + * errors, do a force kill. + */ + if (sync && !queued) { + pr_err("Sending SIGBUS to %s:%d due to hardware memory corruption\n", + current->comm, task_pid_nr(current)); + force_sig(SIGBUS); + } + return queued; }