From patchwork Wed Feb 7 13:22:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tong Tiangen X-Patchwork-Id: 13548490 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 B7CE1C4829B for ; Wed, 7 Feb 2024 13:22:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B2CC36B0080; Wed, 7 Feb 2024 08:22:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ADD126B0081; Wed, 7 Feb 2024 08:22:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8BB056B0083; Wed, 7 Feb 2024 08:22:30 -0500 (EST) 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 706776B0080 for ; Wed, 7 Feb 2024 08:22:30 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 46D4F120D4B for ; Wed, 7 Feb 2024 13:22:30 +0000 (UTC) X-FDA: 81765072060.21.A778303 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf03.hostedemail.com (Postfix) with ESMTP id 0AFCD20012 for ; Wed, 7 Feb 2024 13:22:27 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf03.hostedemail.com: domain of tongtiangen@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=tongtiangen@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707312148; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oB+8JlGTwk582KMXwYJP2mXXjHsi1i6g2eF2BP3W3tg=; b=z/KMhc/eihxfKSXeekiGGWV6G8P68wHnJ9EyiD6GaJwBgiEXBPd+AgSFX6O/KXhsfNdo88 rpMV6gjYx+h09MEJ28yvyCfka1vjnGLoLYGWADOtAD/OHYnhVOc2NNKMNZvmQxkGpEMoEI 6O5hD9gceNDjMAueESISz6crLUjPZ74= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf03.hostedemail.com: domain of tongtiangen@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=tongtiangen@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707312148; a=rsa-sha256; cv=none; b=Uzyby85BoR3vp89ohgCCSrRsIu5+xudlMulUBGtsNjHO8qJn87MNFhxtCI7ATa35xsIeqg Ryt8dAB7joWyKhDth/ftaQV0IFfD0lLWrjGYizzrq+t3SPX90sZsHirud9Ns41iZX6MFID qQLRDM46Dk9tcN3MYF3y0EGBvMgYYLE= Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4TVLMc0HTBz1gyb9; Wed, 7 Feb 2024 21:20:28 +0800 (CST) Received: from kwepemm600017.china.huawei.com (unknown [7.193.23.234]) by mail.maildlp.com (Postfix) with ESMTPS id 83CD218001A; Wed, 7 Feb 2024 21:22:24 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by kwepemm600017.china.huawei.com (7.193.23.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 7 Feb 2024 21:22:22 +0800 From: Tong Tiangen To: Mark Rutland , Catalin Marinas , Will Deacon , Andrew Morton , James Morse , Robin Murphy , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , Michael Ellerman , Nicholas Piggin , Andrey Ryabinin , Alexander Potapenko , Christophe Leroy , Aneesh Kumar K.V , "Naveen N. Rao" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , , "H. Peter Anvin" CC: , , , , Tong Tiangen , , Guohanjun Subject: [PATCH v11 5/5] arm64: send SIGBUS to user process for SEA exception Date: Wed, 7 Feb 2024 21:22:04 +0800 Message-ID: <20240207132204.1720444-6-tongtiangen@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240207132204.1720444-1-tongtiangen@huawei.com> References: <20240207132204.1720444-1-tongtiangen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemm600017.china.huawei.com (7.193.23.234) X-Rspam-User: X-Stat-Signature: ehx8f77m6eu9rzpwwiggrg8fqyumupt5 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 0AFCD20012 X-HE-Tag: 1707312147-312298 X-HE-Meta: U2FsdGVkX1/VBXYhxuNHD1TGLu7E5SL4pzR+2EIIDjuj1b4bl2O72Lx1e1tIBXH63An4k5dOunwwJ4dZZ1Kf6Wssnfp/nEJ8ZWUwEaaoo9NjibZU+xGtVAVylb5rNKregiSXkJpnAK7iKQFi8yqnjSdUg0v1f5BFQ2k6ES1n8epB30S9zGevpWnvf9m9b3qkl6fHTcARpl6XNsT0jhIsTm3kagVu5Q8iZTY7ltEHGdnmMv+A+NqYcn0/w29aoRIxHxIRXc1W6P37BwhcwufzqYFUcHMfzJDvHsJAcH7Y/X27N+NaR3cLmVPmqCN5D/TeoB8FILeVqr1R+VNlxsgRsfELU3Ap3jmNRUtXAWRyC4O+Tctl4G6Xs/gHcZni0Ungitfmu5jjC3aFRtxG67uI214LE/AKZVYgGc9eXp/5XWWQvSwP72oU9ZHF91e2/FHgP/04jx1oVHglKSUgVZOXs4dupdVxC2to8smSwpGWfZzaEHcBguOEIw6u97YLkzJC4PsACFyNENxkiw0HiqjNZMT6zZ9N3sJe5XVMj+cadi8W6/g6KD+FbshDGXLxYwhONWRspx70a8CkgSsx+qoNVaWSVKxPbZqT1c3qc5rbPRO22LEn/ZjXVrfr9gDJOHTse/liStO4FT0WAsItdu0v/DDl9+zY3ZTsNHka6M49USKNDiCowz1jALT8neJcxSBsq1W0sAo2urfSoHmG0q87sfIiu5Ogi/eGikSf4Fm5HrWOwaX143M2hbH3XyDaxbHTQYe2fPTCw/3C7sEWZwi83tl6ln85pam0SRq+Drj4vmBspcqO1CC8h87NvKsRSv513ZuBZn46YGWcZp27KozoXPVH8jk/Tu8DK5m8/kppf0uRiAXwXRG/7f9cI8V236CkDkLpfAWpQ34bDHGBUnAT+g4t9Ll9xAUXPsRt8hJLTsy4XdY4s7UXRBNQ2bs/AjGPVLw563AUszjzhji/yeC +GZagw4M RM4g5tXrqGL54KT8hLZfCe23ye9MPyDzXbQasg0BqwAoE68ptE/2/oacIUo6TGzV3ysmthK2oNvMZyfAEE8Qf6VDWxpPhJuP1REm375OW+8bf1yvdwtLF9EddOIeaZ2r0mEHqCUjDnV5QelzEAbvlpFSHi7sIP7lF/4Qh0asf1AZyakm1p7OkKNAkf5fIdoJGiRAlN8fUTtiZ/+LQGmsiYJd4nR2wmqJf+I5mjlfYZsFD8xWUjDSrA4POFdZ+BVMpfYu1DWy17f6RpNz/SD7thAPMGAfXGHHDUSQSGW3uH/sYF5U= 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: For SEA exception, kernel require take some action to recover from memory error, such as isolate poison page adn kill failure thread, which are done in memory_failure(). During the test, the failure thread cannot be killed due to this issue[1], Here, I temporarily workaround this issue by sending signals to user processes (!(PF_KTHREAD|PF_IO_WORKER|PF_WQ_WORKER|PF_USER_WORKER)) in do_sea(). After [1] is merged, this patch can be rolled back or the SIGBUS will be sent repeated. [1]https://lore.kernel.org/lkml/20240204080144.7977-1-xueshuai@linux.alibaba.com/ Signed-off-by: Tong Tiangen --- arch/arm64/mm/fault.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 78f9d5ce83bb..a27bb2de1a7c 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -824,9 +824,6 @@ static int do_sea(unsigned long far, unsigned long esr, struct pt_regs *regs) const struct fault_info *inf; unsigned long siaddr; - if (do_apei_claim_sea(regs)) - return 0; - inf = esr_to_fault_info(esr); if (esr & ESR_ELx_FnV) { siaddr = 0; @@ -838,6 +835,19 @@ static int do_sea(unsigned long far, unsigned long esr, struct pt_regs *regs) */ siaddr = untagged_addr(far); } + + if (do_apei_claim_sea(regs)) { + if (!(current->flags & (PF_KTHREAD | + PF_USER_WORKER | + PF_WQ_WORKER | + PF_IO_WORKER))) { + set_thread_esr(0, esr); + arm64_force_sig_fault(inf->sig, inf->code, siaddr, + "Uncorrected memory error on access to poison memory\n"); + } + return 0; + } + arm64_notify_die(inf->name, regs, inf->sig, inf->code, siaddr, esr); return 0;