From mboxrd@z Thu Jan 1 00:00:00 1970 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 B5823C36014 for ; Thu, 3 Apr 2025 02:48:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A369C280003; Wed, 2 Apr 2025 22:48:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9E5B7280001; Wed, 2 Apr 2025 22:48:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8AEB0280003; Wed, 2 Apr 2025 22:48:15 -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 6D389280001 for ; Wed, 2 Apr 2025 22:48:15 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 85C25AC96F for ; Thu, 3 Apr 2025 02:48:15 +0000 (UTC) X-FDA: 83291198550.15.A89FB6F Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf24.hostedemail.com (Postfix) with ESMTP id 23D4E180003 for ; Thu, 3 Apr 2025 02:48:11 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of tongtiangen@huawei.com designates 45.249.212.189 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=1743648493; 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=If1ZsNgrBBDERc1MRA+MXXmaA+so/oBkFX2K0q6MNvI=; b=NaFLsaJY3gLNYZvg2hIgaNoEVHtkEGKutJ9+85+39xihp/Q0zBIXcS0p1/yRi+YD11xh3u epeczvoW40Sg3qSi7Rb+UwI4Rsrr7hAbrFrTBUrGHLBfMMj/e8M9yP9zCOXWDBSvk/hec0 aRN6nVutUrLNw+rkuzPXf7aQxbIRm5c= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of tongtiangen@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=tongtiangen@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743648493; a=rsa-sha256; cv=none; b=Fp5Q8dR9Yc6jnRwnIKIoRt2wcbdkdstj7zyIgMYO/rGdylOIR9HhWSYW66vdPsOBOhC/S2 VYDjNCt7rTNPEbzdkc3ILfpz/AhJ4vucWylvoCqf5/RFgtK16IQYmRDhGAKwZe/ZGhvsaV M2Ln+10CuLMvVJAGOfONMpSo6Z5P2eI= Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4ZSmKq0chQzHrDQ; Thu, 3 Apr 2025 10:44:47 +0800 (CST) Received: from kwepemk500005.china.huawei.com (unknown [7.202.194.90]) by mail.maildlp.com (Postfix) with ESMTPS id B33E31800EB; Thu, 3 Apr 2025 10:48:07 +0800 (CST) Received: from [10.174.179.234] (10.174.179.234) by kwepemk500005.china.huawei.com (7.202.194.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 3 Apr 2025 10:48:05 +0800 Message-ID: <82bf1b64-d887-c50b-17b1-2de978896d44@huawei.com> Date: Thu, 3 Apr 2025 10:48:04 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH v13 2/5] arm64: add support for ARCH_HAS_COPY_MC To: "Luck, Tony" CC: Catalin Marinas , Mark Rutland , Jonathan Cameron , Mauro Carvalho Chehab , 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" , Madhavan Srinivasan , , , , , , , Guohanjun References: <20241209024257.3618492-1-tongtiangen@huawei.com> <20241209024257.3618492-3-tongtiangen@huawei.com> From: Tong Tiangen In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.179.234] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemk500005.china.huawei.com (7.202.194.90) X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 23D4E180003 X-Stat-Signature: 4mxw1bo7uxu75minan5beeecj6ofn35f X-Rspam-User: X-HE-Tag: 1743648491-124032 X-HE-Meta: U2FsdGVkX19RzjWNG2IlPAwsRXZYlXpakGzTno3eLErHz4s5qbULuzDW7qJCZyeHK/YIcRpc3IBvnYZTnq97JFV3W7o4tqzcw7Pb+g1rT3KFEHlQBUv1i//8gKwbWABW4YtGg7chI4MswxZmFUFYZC16vkAZw+wR9WmkQ2hhmGveWf3ZvB/SD3YKI879hlnC35J7N10U3QL6xCUHMrllDUnVlGfIFM1/8qfnSZyusA6wEvMLUBFgseywETZgtMutyyl4SZBEO25ezHQUCykE1L0tUkcO+/InGUTAbhVPp4Q5R8G6gxEr3y7Kjyno4vs+aiOVbBgnPVZGRuDDHGd7/XPXjEkJuY+r4Gdgnm82vN1Bh2ORDOLsEKI4gl5yLUzjNxR/XeVqZkEjxVlKyOj9m2kOTTPl15P4R1QoiwUwtL6CLFV4KW9JGjIUqrAZzU7gu4g06nMxYMoD7Lvg/RKKmWc77Uc5t/bzTN1EGJBxxmvsjrX77DlXtDp9soVI9sKVzNrGCnQmoLiQacUFurReLbJKJ6qBbzPT62cKijB97b2uWBMep+NuvOBwG9ciAcGclT4VhkMZncNolUytPXr3OvGWqW7tRiC7uzOaRlcp3L0Y2AA9zGmat6hvmt0BIJr7kg4zVPzIElhEKRU9yMQPr1pdsdociPdiiweLI+RR7Z/KWvzqMIHZ3S4cWAuzGCKHFxXyEZUOE1WGfTt2BYaSxE5iuOWPDRs6fL70Jgr1m7jaauGNaWdz4uAXvKDyijMkgyT/nQLe5yM4+V7HQ9f95mQ8RL/2B3wqqjBzPehu1qnnvAa3Mv+GNKYmeRUE25eZ/MPjeHofdR9OLcHRG1Nq5quPpmxEeBAsQgTsAa0Ikv6SBbX5Rw5/axsp/yGuYdtMwrEls7pkEXx90+l4JtQBmMSFhbTI1dXl5JuNY3P/MHLailMMQiLNM43j4j8mU9oEsPuIDoGqZA7IS4xCuLU 9KxARb05 LkLjsd9Hw9AmTlmxQRUWGa2vqPsXIXJCeFQcO+RB2h6xP+WP8oZUql4HMO1C2Bn58A9PJktKlHTB3k/I50uIWJTYc3AQsXqWIGo1XmlQnFkc86ai32Nej2IGQG7oixh1gXgkB38Gs3MdiQvXia2uYakW0I9BrquKC5Pn1afwLlnWr5I/yrFFaP9RpGzAHYMXZ/BKIHqXskym0mrAhdJzkdRAeQAAiqleCPvnU9rV0NawOqFy9YAQcioszF7ue3eyb2FTIpOMMh3NxOMK+GBX3GXRRt2DKnHYjImTM 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: 在 2025/3/25 0:54, Luck, Tony 写道: > On Fri, Feb 14, 2025 at 09:44:02AM +0800, Tong Tiangen wrote: >> >> >> 在 2025/2/13 0:21, Catalin Marinas 写道: >>> (catching up with old threads) >>> >>> On Mon, Dec 09, 2024 at 10:42:54AM +0800, Tong Tiangen wrote: >>>> For the arm64 kernel, when it processes hardware memory errors for >>>> synchronize notifications(do_sea()), if the errors is consumed within the >>>> kernel, the current processing is panic. However, it is not optimal. >>>> >>>> Take copy_from/to_user for example, If ld* triggers a memory error, even in >>>> kernel mode, only the associated process is affected. Killing the user >>>> process and isolating the corrupt page is a better choice. >>> >>> I agree that killing the user process and isolating the page is a better >>> choice but I don't see how the latter happens after this patch. Which >>> page would be isolated? >> >> The SEA is triggered when the page with hardware error is read. After >> that, the page is isolated in memory_failure() (mf). The processing of >> mf is mentioned in the comments of do_sea(). >> >> /* >> * APEI claimed this as a firmware-first notification. >> * Some processing deferred to task_work before ret_to_user(). >> */ >> >> Some processing include mf. >> >>> >>>> Add new fixup type EX_TYPE_KACCESS_ERR_ZERO_MEM_ERR to identify insn >>>> that can recover from memory errors triggered by access to kernel memory, >>>> and this fixup type is used in __arch_copy_to_user(), This make the regular >>>> copy_to_user() will handle kernel memory errors. >>> >>> Is the assumption that the error on accessing kernel memory is >>> transient? There's no way to isolate the kernel page and also no point >>> in isolating the destination page either. >> >> Yes, it's transient, the kernel page in mf can't be isolated, the >> transient access (ld) of this kernel page is currently expected to kill >> the user-mode process to avoid error spread. >> >> >> The SEA processes synchronization errors. Only hardware errors on the >> source page can be detected (Through synchronous ld insn) and processed. >> The destination page cannot be processed. > > I've considered the copy_to_user() case as only partially fixable. There > are lots of cases to consider: > > 1) Many places where drivers copy to user in ioctl(2) calls. > Killing the application solves the immediate problem, but if > the problem with kernel memory is not transient, then you > may run into it again. > > 2) Copy from Linux page cache to user for a read(2) system call. > This one is a candidate for recovery. Might need help from the > file system code. If the kernel page is a clean copy of data in > the file system, then drop this page and re-read from storage > into a new page. Then resume the copy_to_user(). > If the page is modified, then need some file system action to > somehow mark this range of addresses in the file as lost forever. > First step in tackling this case is identifying that the source > address is a page cache page. > > 3) Probably many other places where the kernel copies to user for > other system calls. Would need to look at these on a case by case > basis. Likely most have the same issue as ioctl(2) above. 1) 3) Yes, in extreme cases, user-mode processes may be killed all the time. The hardware error that repeatedly triggered in the same page, in this case, firmware maybe report a fatal error, if yes, this problem can be solved. 2) This is indeed a workaround, somewhat complex, but it seems worthwhile to avoid kernel panic. Sorry for didn't catch your reply in time:) Thanks, Tong. > > -Tony > > .