From patchwork Fri Sep 6 02:42:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13793156 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 F1290CE7AA5 for ; Fri, 6 Sep 2024 02:42:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 84A9E6B0089; Thu, 5 Sep 2024 22:42:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7818C6B0092; Thu, 5 Sep 2024 22:42:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3DC6A6B008A; Thu, 5 Sep 2024 22:42:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 171516B0089 for ; Thu, 5 Sep 2024 22:42:39 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id BA6051A0D20 for ; Fri, 6 Sep 2024 02:42:38 +0000 (UTC) X-FDA: 82532765196.06.C55C5EE Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf18.hostedemail.com (Postfix) with ESMTP id 6827F1C0010 for ; Fri, 6 Sep 2024 02:42:36 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf18.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725590448; 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=PvT9d86Vd5m/uEFHN1TquoaZCkBXKwi3oHPofFcobQ4=; b=kRKZJTc0qtdxRWv4FU8BQ+lr8FVeZAAywv+rMDNFN15BRMJ8E0ZQrsoR/Fn5SG54W3mtpE 63C7USR7/cDGNgxSvQl1JWPmwLZQyGQOptGoHl96oCMWnv5Lv7oH5key2FAdfm+mlVUCjE 46UKgiMyTSZqx06n3cA3YRjn9nNcZeI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725590448; a=rsa-sha256; cv=none; b=lxhDBJxowXPONHiY8nw0GSznXd6wUtBQNlvRcmUjUnZSsrIC+pPxMnVZlQeosoUeQdoOyl U7jT8rTgRNH9/KL3ZwXR4U710usrS0VzRlR3y6DpQFgbk9ZAwK7lyjh7UfMP3i5OiAAfgv jTMW0V16Gy1v/hyf/BxfSboio77rxs0= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf18.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4X0L7S1b65zpVTs; Fri, 6 Sep 2024 10:40:36 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id 660E41400D8; Fri, 6 Sep 2024 10:42:31 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemf100008.china.huawei.com (7.185.36.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 6 Sep 2024 10:42:30 +0800 From: Kefeng Wang To: Andrew Morton CC: , Jane Chu , Miaohe Lin , Naoya Horiguchi , Tony Luck , Jiaqi Yan , David Hildenbrand , Kefeng Wang Subject: [PATCH 1/2] mm: support poison recovery from do_cow_fault() Date: Fri, 6 Sep 2024 10:42:00 +0800 Message-ID: <20240906024201.1214712-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240906024201.1214712-1-wangkefeng.wang@huawei.com> References: <20240906024201.1214712-1-wangkefeng.wang@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 dggpemf100008.china.huawei.com (7.185.36.138) X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 6827F1C0010 X-Stat-Signature: dmz3igrq5gb1e3kj8pj6bxpr9uqyguu1 X-Rspam-User: X-HE-Tag: 1725590556-745344 X-HE-Meta: U2FsdGVkX1+E3eS1jZ/vkcGiOWoH3OpHKPaW5F5s91ZURYYKwtb9H9OIqh92YeqeDsXo9oU5mASO0Hf2N54rx7owiZf727cjQt0IAKQZl2+4Y4IxIf7KJ/fwC/RWjkNVqim7yKURS5Vb75rFlEVIckph18f3gxEnLvzp/WqzvUUOcoQ/ndzIW57joyXWkiiodyLNs22cG4xgNalFxNHZmVbIP78b30ZhMpKGj3mksdsGNtjHms91VtIe3qQa4aU4dnW/mP0KDcUe1eRGh8LNg3scS8oakie3w7rc5q/NsOGb7FNnSLkIN4FO+tYO1Q9iJo0/RijeXwe+n9Et2ryOJ9T/+1EMzxfExZP424/04Ee0NGNRUYnOsIt9qJJMrZIzMozLqGwGNNUD6Xsx4swrnD9tQzl0vhd+Y1Po6iGE5Z13NdrDgM+jXteKotv6Mxi/Iyr+GdKDrSsI4dP9JR2UyV8F70++O5Od6s55gi8szsnVPlSLMLk8mh2qM682knqEAQU8t1Oj1TzKDU37MgMqZNg1oK/h1hNCZzDJQ5nuj2a9CkQpBVxsXBQF51xqe7SC/gTf4C46rXCqI9ieijotqePX5+YPwQuoe6eK2xI2ebfOy2Iqh/op+xinoalH1PV9Fe8+Nqoi202DKrxz3aG9ugvoLXydAGqIvJaus2cNuvJbRofvX22goCwWgWDcIPepDeLGP8XZlvAYE1TmS3uzjxwobxX5HiojxHs1yWnIEeZI0pLn0u7VzJmLoNlseRYuJ6O8km75xK7U1I96vxttfXWBLIFoP5pzUt4imIIhxvpGua78lwWlYTPzPFIzILPIXnZXtsp0w+7lJAj/bMNchbHcsZx5q5LDLU8YvSPTi2n/49BAARJNJCRNHHlXlFAKnmUQxYdsprIkgLS+7fHKgCs9FFvBlkL9GH/qF1ZKCwm8CTpyZJY3jycuLInN0P2NnJhLge4PyOYjmFxs+dL 1xeaWa/j CjV/jOPU9MqtVFwX2f37nNPKPVASXYVOxI0yibk3RnwAL97fNfDozS2iPR0WvHb18HfliLzShd3lpS8Ise6RDKT2wY2bkbsNV0TG4J4fLpDy0fu5DDrO8RluVFs+miBLszhC6opxORCdHqVn+enaJzcGdB7wtDai/T6+Sroz5+OceoxZ5ib24of2UjA7I+X5abBs0inlHIaXAZFjUfWubgr52Uz0YNOUR0+mxGn+FRcAHegKskIaCfeadl7oI/Gg8nc4L54l+Cj+6bSU= 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: Like commit a873dfe1032a ("mm, hwpoison: try to recover from copy-on write faults"), there is another path which could crash because it does not have recovery code where poison is consumed by the kernel in do_cow_fault(), a crash calltrace shown below on old kernel, but it could be happened in the lastest mainline code, CPU: 7 PID: 3248 Comm: mpi Kdump: loaded Tainted: G OE 5.10.0 #1 pc : copy_page+0xc/0xbc lr : copy_user_highpage+0x50/0x9c Call trace: copy_page+0xc/0xbc do_cow_fault+0x118/0x2bc do_fault+0x40/0x1a4 handle_pte_fault+0x154/0x230 __handle_mm_fault+0x1a8/0x38c handle_mm_fault+0xf0/0x250 do_page_fault+0x184/0x454 do_translation_fault+0xac/0xd4 do_mem_abort+0x44/0xbc Fix it by using copy_mc_user_highpage() to handle this case and return VM_FAULT_HWPOISON for cow fault. Signed-off-by: Kefeng Wang Reviewed-by: Jane Chu --- mm/memory.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/memory.c b/mm/memory.c index 42674c0748cb..d310c073a1b3 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -5089,7 +5089,10 @@ static vm_fault_t do_cow_fault(struct vm_fault *vmf) if (ret & VM_FAULT_DONE_COW) return ret; - copy_user_highpage(vmf->cow_page, vmf->page, vmf->address, vma); + if (copy_mc_user_highpage(vmf->cow_page, vmf->page, vmf->address, vma)) { + ret = VM_FAULT_HWPOISON; + goto uncharge_out; + } __folio_mark_uptodate(folio); ret |= finish_fault(vmf);