From patchwork Sun Feb 4 08:26:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tong Tiangen X-Patchwork-Id: 13544559 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 8EB5AC48286 for ; Sun, 4 Feb 2024 08:26:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 98D306B0080; Sun, 4 Feb 2024 03:26:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 940616B0083; Sun, 4 Feb 2024 03:26:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 803116B0081; Sun, 4 Feb 2024 03:26:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 7315B6B007E for ; Sun, 4 Feb 2024 03:26:43 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D170D140367 for ; Sun, 4 Feb 2024 08:26:41 +0000 (UTC) X-FDA: 81753440202.12.F45BD2C Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf10.hostedemail.com (Postfix) with ESMTP id 7A314C0010 for ; Sun, 4 Feb 2024 08:26:37 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf10.hostedemail.com: domain of tongtiangen@huawei.com designates 45.249.212.190 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=1707035199; 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=+InWOawgvS4dFLP9HR/AQagIfV/sCSfeUZLqWbEDPeo=; b=h8TD/vKf+d1mUHxFzZ/1bC7G4pbhBAk020IzCV6d7PqlKTKi1ebXyZbml0zH3211Ners9g x776NPuqbD0F7BXmXNLRyMYRnmmcMbsqGE632MSJaTrbjro/hrPSukxtlL6++hsyWDSUjO gjNfofn0IMirfCSFtaeW+yrDvuxvksk= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf10.hostedemail.com: domain of tongtiangen@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=tongtiangen@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707035199; a=rsa-sha256; cv=none; b=5oh0Q0ahHoycKoWQ9rq2ulxteq2BugfU+5W31rePxeG+CbS7aiStg5hvmBIOg2kPfLLBHv YYMT2rEhhqYG6HW8gU2c2etP4PM6EZdN65FHCdn/fyNYlCuzp1SLNYLIgcG/23DJPt/U/H YgpCYF29ivgpL0A+K+IwY7t8XGbsxZA= Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4TSMyd6KVnz1xmyC; Sun, 4 Feb 2024 16:25:29 +0800 (CST) Received: from kwepemm600017.china.huawei.com (unknown [7.193.23.234]) by mail.maildlp.com (Postfix) with ESMTPS id 0FA311A016C; Sun, 4 Feb 2024 16:26:34 +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; Sun, 4 Feb 2024 16:26:32 +0800 From: Tong Tiangen To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , , Dave Hansen , , "H. Peter Anvin" , Tony Luck , Andy Lutomirski , Peter Zijlstra , Andrew Morton , Naoya Horiguchi CC: , , , Tong Tiangen , Guohanjun Subject: [PATCH -next v5 1/3] x86/mce: remove redundant fixup type EX_TYPE_COPY Date: Sun, 4 Feb 2024 16:26:25 +0800 Message-ID: <20240204082627.3892816-2-tongtiangen@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240204082627.3892816-1-tongtiangen@huawei.com> References: <20240204082627.3892816-1-tongtiangen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600017.china.huawei.com (7.193.23.234) X-Rspamd-Queue-Id: 7A314C0010 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: m3iuix6ktp6kyziddanjxkctxtn4yqbk X-HE-Tag: 1707035197-204603 X-HE-Meta: U2FsdGVkX18w8zFmQxJ01ACM56oWgz7ddiQXVCLh+wgdNOKlEXzl6CPwf9wgpRz7JAnm/wg0hzV19ivdG3ChWNVe9e8Jl/CRYo/5524/EfBck46b3jvK7OaO+kCEtWkl9+cI4g/wXCRC4WovhWafH37Amfx2SgskGP0Vv+YFRsyOIoTsm0bR8OtG/JDitROVfekxs/ChvRgLwsYFGRY+HMaFW6sHSsfFpnpbF+9tG/yZIwgsWgwifjWZGiO1RHjXkopQOXGXu12iMhV1J+rAq5ofoKezUA8TJVUmdq3XA/ORA+WfOdBHxd4F9H/I9S9T9E1t3+xgCYigU9YLzf1284ZwkcF0ZYJxklXAsS0tyzfQ+elhLxyk2QZ7tF9Agy2FqzUwlpFVmythBGjLxaTaQqVREZzScslboYUf0Nhc4sN1ODmlhwaNJPIwFUU27715GkUD7dYucL9EjZBbDnFJNMwHLISPX3JpQ5l/bhfzv1ZkUqBlPHHHqzmQSoAfAX+hOedXPSAyub0zZdrNv0SaN81zT1iCyGvnp+jYE792py/SsCR9L9OslkGNGd3kJdZOE7McuOWaFTo/pKrL7qSpSrbhSOEk8AGksNBX9bSJh8H72v/H1PKT7lvcaGt8LdxL+JTYYPIFb/QjGXqL+5wL8tlhLiDr9LF0p2YsssGPg5nFFbja4QIMf8Yon0EDJF4BSvJot2y/zBsVEzUNBmQgpiptD68ZIoIUfo8r5wLs5ItDLcBn5UwMWuoy+ju/rHD/rfPjDP3hnVquii932FHZwIEL5yhgmrMVYcKrQCmmuARe7WFKYhJEhC9Gj2YulNz7VScPliaOFTx1mnNabUBvGQHi6WPX5YlXvAwHYw9axvukOG16Yn1fWdHZS7EeEP8S04SudJSqg6b37CCTah5d17fz0zUuJHhGGcTM0aQAnRF4QpnT6/Q18ROt37jgxxb5B2Gje4EiGI3JDj4LHDo KuGEt1Yk mWG+msrDbS7vyOi2IyBW/J6+ayVbAmKyoQ4TW2xqj4WXkIpICvBqYJhmpneRxEDOcvruCCZJBWTfFqHAUOgY6fOfCSo7ifk5397v9tGVV7uKsEVNxumDCDma08KtWWDSGD0JYaVEEggsLFnDhZa0x7aGaQMGP1PuBmKpHD07iOIrFg2MXDHVO+PuplXDTjYxivvVd 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: Since commit 034ff37d3407 ("x86: rewrite '__copy_user_nocache' function") rewrited __copy_user_nocache() uses EX_TYPE_UACCESS instead of EX_TYPE_COPY, there is no user for EX_TYPE_COPY, so remove it. Signed-off-by: Tong Tiangen --- arch/x86/include/asm/asm.h | 3 --- arch/x86/include/asm/extable_fixup_types.h | 2 +- arch/x86/kernel/cpu/mce/severity.c | 1 - arch/x86/mm/extable.c | 9 --------- 4 files changed, 1 insertion(+), 14 deletions(-) diff --git a/arch/x86/include/asm/asm.h b/arch/x86/include/asm/asm.h index fbcfec4dc4cc..692409ea0c37 100644 --- a/arch/x86/include/asm/asm.h +++ b/arch/x86/include/asm/asm.h @@ -215,9 +215,6 @@ register unsigned long current_stack_pointer asm(_ASM_SP); #define _ASM_EXTABLE_UA(from, to) \ _ASM_EXTABLE_TYPE(from, to, EX_TYPE_UACCESS) -#define _ASM_EXTABLE_CPY(from, to) \ - _ASM_EXTABLE_TYPE(from, to, EX_TYPE_COPY) - #define _ASM_EXTABLE_FAULT(from, to) \ _ASM_EXTABLE_TYPE(from, to, EX_TYPE_FAULT) diff --git a/arch/x86/include/asm/extable_fixup_types.h b/arch/x86/include/asm/extable_fixup_types.h index 7acf0383be80..906b0d5541e8 100644 --- a/arch/x86/include/asm/extable_fixup_types.h +++ b/arch/x86/include/asm/extable_fixup_types.h @@ -36,7 +36,7 @@ #define EX_TYPE_DEFAULT 1 #define EX_TYPE_FAULT 2 #define EX_TYPE_UACCESS 3 -#define EX_TYPE_COPY 4 +/* unused, was: #define EX_TYPE_COPY 4 */ #define EX_TYPE_CLEAR_FS 5 #define EX_TYPE_FPU_RESTORE 6 #define EX_TYPE_BPF 7 diff --git a/arch/x86/kernel/cpu/mce/severity.c b/arch/x86/kernel/cpu/mce/severity.c index c4477162c07d..bca780fa5e57 100644 --- a/arch/x86/kernel/cpu/mce/severity.c +++ b/arch/x86/kernel/cpu/mce/severity.c @@ -290,7 +290,6 @@ static noinstr int error_context(struct mce *m, struct pt_regs *regs) switch (fixup_type) { case EX_TYPE_UACCESS: - case EX_TYPE_COPY: if (!copy_user) return IN_KERNEL; m->kflags |= MCE_IN_KERNEL_COPYIN; diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c index b522933bfa56..51986e8a9d35 100644 --- a/arch/x86/mm/extable.c +++ b/arch/x86/mm/extable.c @@ -164,13 +164,6 @@ static bool ex_handler_uaccess(const struct exception_table_entry *fixup, return ex_handler_default(fixup, regs); } -static bool ex_handler_copy(const struct exception_table_entry *fixup, - struct pt_regs *regs, int trapnr) -{ - WARN_ONCE(trapnr == X86_TRAP_GP, "General protection fault in user access. Non-canonical address?"); - return ex_handler_fault(fixup, regs, trapnr); -} - static bool ex_handler_msr(const struct exception_table_entry *fixup, struct pt_regs *regs, bool wrmsr, bool safe, int reg) { @@ -341,8 +334,6 @@ int fixup_exception(struct pt_regs *regs, int trapnr, unsigned long error_code, return ex_handler_fault(e, regs, trapnr); case EX_TYPE_UACCESS: return ex_handler_uaccess(e, regs, trapnr, fault_addr); - case EX_TYPE_COPY: - return ex_handler_copy(e, regs, trapnr); case EX_TYPE_CLEAR_FS: return ex_handler_clear_fs(e, regs); case EX_TYPE_FPU_RESTORE: From patchwork Sun Feb 4 08:26:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tong Tiangen X-Patchwork-Id: 13544560 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 95273C4828F for ; Sun, 4 Feb 2024 08:26:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C4B986B0081; Sun, 4 Feb 2024 03:26:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C285D6B007E; Sun, 4 Feb 2024 03:26:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 98D0A6B007E; Sun, 4 Feb 2024 03:26:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 830F36B007E for ; Sun, 4 Feb 2024 03:26:43 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 58441A036C for ; Sun, 4 Feb 2024 08:26:43 +0000 (UTC) X-FDA: 81753440286.02.55A4AF9 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf28.hostedemail.com (Postfix) with ESMTP id 874D5C0009 for ; Sun, 4 Feb 2024 08:26:40 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of tongtiangen@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=tongtiangen@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707035201; 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=1/hfG/AoTUNScs9lTyBC3Hj5z+BtwGolZlOronaGEbY=; b=bK4RChtCa6UQroyXjcOcyUkTPIYu5cJEz7DXhvtwcTbxDFUWgpdNwqzBg9bFYxmoPFL/IC BfsJF17O2fdvnXY/PY/am9mqO1r7WbWHBaa9RgzL6RXpTFCVWdfH89l+OkifHKIra75gzN NpEsEPQdoZqHjTqNNnhZnzRztScGJDk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707035201; a=rsa-sha256; cv=none; b=J3GbSSKnM4hXR1JxkcsbWT+rIqHO26vMcbmJKyqdLYxFKPTggkNiZguyzOQlfWQCWX5qmy RwEt1v/xtCh0+wkCbm4EwjYLtA/mjuhMW7ZVScEXPuyBsoTbyqNLD1i0cLpce+k4pj0VaF fxTEYmt9dOGrt90Db02mbJf/hUI3XkY= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of tongtiangen@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=tongtiangen@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.162.254]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4TSMyQ0lJtzsWrZ; Sun, 4 Feb 2024 16:25:18 +0800 (CST) Received: from kwepemm600017.china.huawei.com (unknown [7.193.23.234]) by mail.maildlp.com (Postfix) with ESMTPS id 3DF7618001A; Sun, 4 Feb 2024 16:26:35 +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; Sun, 4 Feb 2024 16:26:33 +0800 From: Tong Tiangen To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , , Dave Hansen , , "H. Peter Anvin" , Tony Luck , Andy Lutomirski , Peter Zijlstra , Andrew Morton , Naoya Horiguchi CC: , , , Tong Tiangen , Guohanjun Subject: [PATCH -next v5 2/3] x86/mce: set MCE_IN_KERNEL_COPYIN for DEFAULT_MCE_SAFE exception Date: Sun, 4 Feb 2024 16:26:26 +0800 Message-ID: <20240204082627.3892816-3-tongtiangen@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240204082627.3892816-1-tongtiangen@huawei.com> References: <20240204082627.3892816-1-tongtiangen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600017.china.huawei.com (7.193.23.234) X-Rspamd-Queue-Id: 874D5C0009 X-Rspam-User: X-Stat-Signature: ifz9arbwug7xaq8hxymxgoq13mx8etbs X-Rspamd-Server: rspam03 X-HE-Tag: 1707035200-391876 X-HE-Meta: U2FsdGVkX1/mrXDZj534BzmF8Ebc2HFRyoTjKkO/O2bv9K61GpM7UYbR/XTE13iOZCT02UnaON6f8VspJKbk7dLBSRWi7Rh6kI7pFewoT6caZkNRajJAz9RLVW+p8PKMnxjOmoCujugy0W0rZsnWVyVDuUB8OtSOXgnGjJG8cB8BFTmOxRaR29DfoeGliMCYHQEt0tUoQ0CNpTn6j65hn/oGH5RiJ6XoufMm0UvZ362tRU+p+Lxz6mGpXhZ8G6XWSWRJoFIYiVRnXAdP5yPM8GHLk/iNlKeBCI54OK83KWMqFnaCpTAW4vKbEcK+QYEC2iBOtjIKODQPbypqoizRiVDugPSfapqhhdEFJneAlaAGAxMRp1gaVpk9rLqEN8hXIWjMylddN1UREyD1iWNMWMfrzCiqgjNA3/m2HVwRqf75fP/M6OatWGqndVWxE0N7+hwD13osJlD4wmyOvPvfDJMaMAJe4zHezQ6o3plror7yrMwwZyjsyqdJeDHUzvlR2YL6s5UHaDfoINJavWIw4TvvFcRMQmomxD2PY1S86eYRvr+siz+cUmLyQ7y5QmDZ4VOuXQJllWi45OmpfD7daKO1ACZUgWtXjk/jIQyBh/SKLS7lImpxOnXC54wYyN47JT7n2MsZszGo1Glh34brCJJcPsZFuc8Pp8ShabagE1ExnDZpKmf86bIUBynis0YalABEiDXkhtDL64H2gBodCWiM8f+9+kWubjf59FtwdwUPhk8HSpIMAbJfszAZyBPMrSOjClckpaCEAA22EWOqDVGl+uWMYvjkzoYdoF7KpwSbpcn/g/0afjnnFvj8gAwTA8rT1xVzseqwgVQUOmChg2qc9nITEuvf/416STcwczoPlose2DnKpMNgOEYog+TB/QL7Wqo2aUmL0fQJylLy2xJUuSJNJFAfGnicyvVp5lTCHx53E5F08/UEvEtzsoPQoh7T0ldiBAsnYnd0noo qT8aKa8D Ok7FKe9bFJzgbsmyKK2MHmSYpigXUuMasoK9aJmnK3rxIFmHiItCirY4yVb0vSKtqzKPyYnObv4w8QrSkmCyJ3+bDK8JQ+xEtPSEei2DVehtSLaDt87OyY3OiEEFAxnQtKhvOg4jcCGOJ47iXVUQ6yitzt+PtpF6QSNnYUVKhbjbmBYpWnt5qMzblLCG0P0ZIXLndNbji/3V6dtZfwdnny8124gqpuJ+POCtzWqB+6Oyk/Oe//Ts83QYZTA== 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: From: Kefeng Wang Currently, some kernel memory copy scenarios[1][2][3] which use copy_mc_{user_}highpage() to safely abort copy and report 'bytes not copied' when accessing the poisoned source page, a recoverable synchronous exception generated in the processing and the fixup type EX_TYPE_DEFAULT_MCE_SAFE is used to distinguish from other exceptions, and an asynchronous memory_failure_queue() is called to handle memory failure of the source page , but scheduling someone else to handle it at some future point is unpredictable and risky. The better way is immediately deal with it during current context, fortunately, there is already a framework to synchronously call memory_failure(), see kill_me_never() in do_machine_check(), a task work is triggered once MCE_IN_KERNEL_COPYIN is set, in order to fix above issue, setting MCE_IN_KERNEL_COPYIN for EX_TYPE_DEFAULT_MCE_SAFE case too. [1] commit d302c2398ba2 ("mm, hwpoison: when copy-on-write hits poison, take page offline") [2] commit 1cb9dc4b475c ("mm: hwpoison: support recovery from HugePage copy-on-write faults") [3] commit 6b970599e807 ("mm: hwpoison: support recovery from ksm_might_need_to_copy()") Reviewed-by: Naoya Horiguchi Reviewed-by: Tony Luck Signed-off-by: Kefeng Wang Signed-off-by: Tong Tiangen --- arch/x86/kernel/cpu/mce/severity.c | 4 ++-- mm/ksm.c | 1 - mm/memory.c | 13 ++++--------- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/severity.c b/arch/x86/kernel/cpu/mce/severity.c index bca780fa5e57..b2cce1b6c96d 100644 --- a/arch/x86/kernel/cpu/mce/severity.c +++ b/arch/x86/kernel/cpu/mce/severity.c @@ -292,11 +292,11 @@ static noinstr int error_context(struct mce *m, struct pt_regs *regs) case EX_TYPE_UACCESS: if (!copy_user) return IN_KERNEL; + fallthrough; + case EX_TYPE_DEFAULT_MCE_SAFE: m->kflags |= MCE_IN_KERNEL_COPYIN; fallthrough; - case EX_TYPE_FAULT_MCE_SAFE: - case EX_TYPE_DEFAULT_MCE_SAFE: m->kflags |= MCE_IN_KERNEL_RECOV; return IN_KERNEL_RECOV; diff --git a/mm/ksm.c b/mm/ksm.c index 8c001819cf10..ba9d324ea1c6 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -3084,7 +3084,6 @@ struct folio *ksm_might_need_to_copy(struct folio *folio, if (copy_mc_user_highpage(folio_page(new_folio, 0), page, addr, vma)) { folio_put(new_folio); - memory_failure_queue(folio_pfn(folio), 0); return ERR_PTR(-EHWPOISON); } folio_set_dirty(new_folio); diff --git a/mm/memory.c b/mm/memory.c index 8d14ba440929..ee06a8f766ab 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2846,10 +2846,8 @@ static inline int __wp_page_copy_user(struct page *dst, struct page *src, unsigned long addr = vmf->address; if (likely(src)) { - if (copy_mc_user_highpage(dst, src, addr, vma)) { - memory_failure_queue(page_to_pfn(src), 0); + if (copy_mc_user_highpage(dst, src, addr, vma)) return -EHWPOISON; - } return 0; } @@ -6179,10 +6177,8 @@ static int copy_user_gigantic_page(struct folio *dst, struct folio *src, cond_resched(); if (copy_mc_user_highpage(dst_page, src_page, - addr + i*PAGE_SIZE, vma)) { - memory_failure_queue(page_to_pfn(src_page), 0); + addr + i*PAGE_SIZE, vma)) return -EHWPOISON; - } } return 0; } @@ -6199,10 +6195,9 @@ static int copy_subpage(unsigned long addr, int idx, void *arg) struct page *dst = nth_page(copy_arg->dst, idx); struct page *src = nth_page(copy_arg->src, idx); - if (copy_mc_user_highpage(dst, src, addr, copy_arg->vma)) { - memory_failure_queue(page_to_pfn(src), 0); + if (copy_mc_user_highpage(dst, src, addr, copy_arg->vma)) return -EHWPOISON; - } + return 0; } From patchwork Sun Feb 4 08:26:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tong Tiangen X-Patchwork-Id: 13544558 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 184DCC4828F for ; Sun, 4 Feb 2024 08:26:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4F7626B007D; Sun, 4 Feb 2024 03:26:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4A74E6B007E; Sun, 4 Feb 2024 03:26:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 396546B0080; Sun, 4 Feb 2024 03:26:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 283A36B007D for ; Sun, 4 Feb 2024 03:26:43 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id EE86BA19D7 for ; Sun, 4 Feb 2024 08:26:42 +0000 (UTC) X-FDA: 81753440244.04.3130E69 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf04.hostedemail.com (Postfix) with ESMTP id 520AA4000A for ; Sun, 4 Feb 2024 08:26:39 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf04.hostedemail.com: domain of tongtiangen@huawei.com designates 45.249.212.190 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=1707035201; 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=JIhTmCKp1JPvrDf4Nft0zYZgK3+6jgIK0+TowYYY4xU=; b=r/vAVIh5a0OEkhP/Cffg90S7OLe0/fYniKJDeFMrc204Gh1RjUJU2QdxQR7Diz6EdXFqFm wHPlPh7kgTYqM7JfORPOBpSP2aONwDpP1u7h88uSaypaptsNtLdVNoJC8w+945VH+hMDEx 3TduK6DJiwUfPF7C9Dm8E6f43HqdfE8= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf04.hostedemail.com: domain of tongtiangen@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=tongtiangen@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707035201; a=rsa-sha256; cv=none; b=D/+CrYfvXpvEuGlILbKv06r+czndYh+NnL2RNAdTwveOCCUubWV4DgZ9QlnrGF5ctUx798 iao3guig0HkjdnUqJdjquXPfO63Ie82kmFIB4AcH6EA0UbuvdLbsR3LboiDGxvvkwUMMh9 iXDTEAp1XwTlSRS0tpWWQYPcbPW4P7o= Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4TSMyh23QKz1xnCm; Sun, 4 Feb 2024 16:25:32 +0800 (CST) Received: from kwepemm600017.china.huawei.com (unknown [7.193.23.234]) by mail.maildlp.com (Postfix) with ESMTPS id 71B6814013B; Sun, 4 Feb 2024 16:26:36 +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; Sun, 4 Feb 2024 16:26:35 +0800 From: Tong Tiangen To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , , Dave Hansen , , "H. Peter Anvin" , Tony Luck , Andy Lutomirski , Peter Zijlstra , Andrew Morton , Naoya Horiguchi CC: , , , Tong Tiangen , Guohanjun Subject: [PATCH -next v5 3/3] x86/mce: rename MCE_IN_KERNEL_COPYIN to MCE_IN_KERNEL_COPY_MC Date: Sun, 4 Feb 2024 16:26:27 +0800 Message-ID: <20240204082627.3892816-4-tongtiangen@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240204082627.3892816-1-tongtiangen@huawei.com> References: <20240204082627.3892816-1-tongtiangen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600017.china.huawei.com (7.193.23.234) X-Rspamd-Queue-Id: 520AA4000A X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: uydmzk7s4nxf3nnckt4p4uiuinz6a1k9 X-HE-Tag: 1707035199-292835 X-HE-Meta: U2FsdGVkX19+aCdeeaIFH1obRK2jQ9WicdQXMVLRrqUEW4eOmtVtBsZrTlwB9zVh2AaA3y5HHqCSmRizswg7GJoRBpsbfqoOHPK7DqtMms/mQ1Q5nfgq6ePaIKvCygAqRCbvFfcUonPnKj4GzsYDuUxJRUNakEGS48wjYYS301BdI7pdwY92R3BlYlAltXF302dRG4nXwJXt+o8eG5roCzGJQNRu4cP6C0bkZEJpBMtLMZIBM9VNnA/3wNnnBb6JRCYIZVkdk0i18sVUQapQGGCcBEpu4HBrZuQ928Vfw11aF60GA62a3kptmPnGfCjNC+HIc3igwLEZxC3mn/fO/IP8K8gMJPfyaeTttmLMpFRiNLPucBOaWg51pfJQngyMyBMGy/i1hsOLKbl+33DKm2Q9RDXUlNlMlL2jbWKJNPETViEGoNh0mWRwvHwLiF8za2Kc7u/awSlBdQyIwrlSLfxCWfZJgpsxNLsRvCBz51xlI2EPbSf1gGgMNMlQmHdHcGeVIbDzOYkV+//O3BXQgzNd2QAxDGTvBfM4Smzo35juCZsMTe+erNlhKYPpl+K5netPYY2XfbGuLu09kIxWlO30G0950ebmT7Ptsq3aYPRiXW2AKyXJyVWBeH5LJ1dM/pEDae+OcmeBzkxhPYosECQ4AH7RvRPK3vtV5B94vPziKkHU8ATm73wmwraXjGp/GY3jFS6puKyOcycLWUjGyTUpx44MUVMIBRkagkhmClf0POS2oBrxwPAUziZv8UbbU9k8HY4ArMcxyeTEF+auE8l6P3zigfks1ORNwYq+FRSns4hlPyAiFfBWf7AEM2r9K7PJpkVSTrcNcRkSw6ltQZn1Tpd0+PsV34GXphK/KDsbbIDqe5pWz9e8dKEZIXUSIB6ItCy0AbT/xOzRY35x/03fXgZf4imG4hnw4MfU5IuCQ+ACVqLAsHGIewg45nkwaaBkuKpNhDgWuAyuMLf O2qXtjRL 46Fy4Q05aUELdSFcHPFVP6kErWycUhgmv/m29jZSEKa5BgWa1TiCKNnP45MDau+URYMt3Nj+EXrgiCw4mwCFqenDg7eKf3hQHdl9cX4nfDTnwaR+EHPUUFMECWRQexJ5oUpKPpGeHRtMH8iJFgtaCMrpNFKUoOZ1dOcFlj1j0w8344j8Pi2yNF3KalohOdItt7wdF 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: In the x86 mce processing, error_context() use MCE_IN_KERNEL_COPYIN for user-to-kernel copy(EX_TYPE_UACCESS) and kernel-to-kernel copy (EX_TYPE_DEFAULT_MCE_SAFE). "COPYIN" only stands for user-to-kernel copy and can't stands for kernel-to-kernel copy, this can cause some misunderstandings. So rename MCE_IN_KERNEL_COPYIN to MCE_IN_KERNEL_COPY_MC. Signed-off-by: Tong Tiangen --- arch/x86/include/asm/mce.h | 8 ++++---- arch/x86/kernel/cpu/mce/core.c | 2 +- arch/x86/kernel/cpu/mce/severity.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h index de3118305838..cb628ab2f32f 100644 --- a/arch/x86/include/asm/mce.h +++ b/arch/x86/include/asm/mce.h @@ -151,11 +151,11 @@ /* * Indicates an MCE that happened in kernel space while copying data - * from user. In this case fixup_exception() gets the kernel to the - * error exit for the copy function. Machine check handler can then - * treat it like a fault taken in user mode. + * from user or kernel. In this case fixup_exception() gets the kernel + * to the error exit for the copy function. Machine check handler can + * then treat it like a fault taken in user or kernel mode. */ -#define MCE_IN_KERNEL_COPYIN BIT_ULL(7) +#define MCE_IN_KERNEL_COPY_MC BIT_ULL(7) /* * This structure contains all data related to the MCE log. Also diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 04acdc3534c8..644748a5d98e 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -1608,7 +1608,7 @@ noinstr void do_machine_check(struct pt_regs *regs) mce_panic("Failed kernel mode recovery", &m, msg); } - if (m.kflags & MCE_IN_KERNEL_COPYIN) + if (m.kflags & MCE_IN_KERNEL_COPY_MC) queue_task_work(&m, msg, kill_me_never); } diff --git a/arch/x86/kernel/cpu/mce/severity.c b/arch/x86/kernel/cpu/mce/severity.c index b2cce1b6c96d..b4b1d028cbb3 100644 --- a/arch/x86/kernel/cpu/mce/severity.c +++ b/arch/x86/kernel/cpu/mce/severity.c @@ -294,7 +294,7 @@ static noinstr int error_context(struct mce *m, struct pt_regs *regs) return IN_KERNEL; fallthrough; case EX_TYPE_DEFAULT_MCE_SAFE: - m->kflags |= MCE_IN_KERNEL_COPYIN; + m->kflags |= MCE_IN_KERNEL_COPY_MC; fallthrough; case EX_TYPE_FAULT_MCE_SAFE: m->kflags |= MCE_IN_KERNEL_RECOV;