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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5DE27C433F5 for ; Thu, 5 May 2022 13:42:28 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4KvFHk51CPz3bqy for ; Thu, 5 May 2022 23:42:26 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=139.178.84.217; helo=dfw.source.kernel.org; envelope-from=cmarinas@kernel.org; receiver=) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4KvFHD1ZBNz3bns for ; Thu, 5 May 2022 23:42:00 +1000 (AEST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5C4BA61E77; Thu, 5 May 2022 13:41:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7D69C385A8; Thu, 5 May 2022 13:41:51 +0000 (UTC) Date: Thu, 5 May 2022 14:41:48 +0100 From: Catalin Marinas To: Tong Tiangen Subject: Re: [PATCH -next v4 4/7] arm64: add copy_{to, from}_user to machine check safe Message-ID: References: <20220420030418.3189040-1-tongtiangen@huawei.com> <20220420030418.3189040-5-tongtiangen@huawei.com> <7da54d72-e5fa-41b5-67ea-a0b084e4c94a@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <7da54d72-e5fa-41b5-67ea-a0b084e4c94a@huawei.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Kefeng Wang , Dave Hansen , linux-mm@kvack.org, Paul Mackerras , Guohanjun , Will Deacon , "H . Peter Anvin" , x86@kernel.org, Ingo Molnar , Xie XiuQi , Borislav Petkov , Alexander Viro , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, Robin Murphy , linux-kernel@vger.kernel.org, James Morse , Andrew Morton , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Thu, May 05, 2022 at 02:39:43PM +0800, Tong Tiangen wrote: > 在 2022/5/4 18:26, Catalin Marinas 写道: > > On Wed, Apr 20, 2022 at 03:04:15AM +0000, Tong Tiangen wrote: > > > Add copy_{to, from}_user() to machine check safe. > > > > > > If copy fail due to hardware memory error, only the relevant processes are > > > affected, so killing the user process and isolate the user page with > > > hardware memory errors is a more reasonable choice than kernel panic. > > > > Just to make sure I understand - we can only recover if the fault is in > > a user page. That is, for a copy_from_user(), we can only handle the > > faults in the source address, not the destination. > > At the beginning, I also thought we can only recover if the fault is in a > user page. > After discussion with a Mark[1], I think no matter user page or kernel page, > as long as it is triggered by the user process, only related processes will > be affected. According to this > understanding, it seems that all uaccess can be recovered. > > [1]https://patchwork.kernel.org/project/linux-arm-kernel/patch/20220406091311.3354723-6-tongtiangen@huawei.com/ We can indeed safely skip this copy and return an error just like pretending there was a user page fault. However, my point was more around the "isolate the user page with hardware memory errors". If the fault is on a kernel address, there's not much you can do about. You'll likely trigger it later when you try to access that address (maybe it was freed and re-allocated). Do we hope we won't get the same error again on that kernel address? -- Catalin 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 69B22C433F5 for ; Thu, 5 May 2022 13:42:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kYoQC5Y5ERfYrtMymA+qH0jrvMeJek1a62gNhLyPjU4=; b=PfB9WQqYGn9pUA hKtGF2r0fCvJhGYEkRm969KK1ewKADxBaB6Ejv0T8mL/cbya3AyjG5cuI5oi/FfE2RBFi+//y5xg6 zM1A2xXMtS94nRkRetDX1TrS+Wbgu/2yeYWuVkxTMrmq0xTrVwoI30bLX7z1r5NTZ/itqrH8CB5kW wZp5r6tvdmqAVm44ulm3k9886THWIGpwEFgA3NG98L5BJAsAZCVPqWabI+b2/RP0DPi/ZH7lP2lhn N6nus8eL2s08AI2ziVswIY9J8OPrYfam72GDUAMT2nhStpUeWQt7tHZWnP1+0Lwkgp7T7E1JPuFu+ xAz/3oaoNw9+e2AmbpwA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nmbk1-00G65h-06; Thu, 05 May 2022 13:42:01 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nmbjx-00G63n-2r for linux-arm-kernel@lists.infradead.org; Thu, 05 May 2022 13:41:58 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5C4BA61E77; Thu, 5 May 2022 13:41:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7D69C385A8; Thu, 5 May 2022 13:41:51 +0000 (UTC) Date: Thu, 5 May 2022 14:41:48 +0100 From: Catalin Marinas To: Tong Tiangen Cc: Mark Rutland , James Morse , Andrew Morton , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Robin Murphy , Dave Hansen , Will Deacon , Alexander Viro , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , x86@kernel.org, "H . Peter Anvin" , linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Kefeng Wang , Xie XiuQi , Guohanjun Subject: Re: [PATCH -next v4 4/7] arm64: add copy_{to, from}_user to machine check safe Message-ID: References: <20220420030418.3189040-1-tongtiangen@huawei.com> <20220420030418.3189040-5-tongtiangen@huawei.com> <7da54d72-e5fa-41b5-67ea-a0b084e4c94a@huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <7da54d72-e5fa-41b5-67ea-a0b084e4c94a@huawei.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220505_064157_178725_C781B758 X-CRM114-Status: GOOD ( 23.85 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "linux-arm-kernel" Errors-To: linux-arm-k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IGdldCB0 aGUgc2FtZSBlcnJvcgphZ2FpbiBvbiB0aGF0IGtlcm5lbCBhZGRyZXNzPwoKLS0gCkNhdGFsaW4K Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCmxpbnV4LWFy bS1rZXJuZWwgbWFpbGluZyBsaXN0CmxpbnV4LWFybS1rZXJuZWxAbGlzdHMuaW5mcmFkZWFkLm9y ZwpodHRwOi8vbGlzdHMuaW5mcmFkZWFkLm9yZy9tYWlsbWFuL2xpc3RpbmZvL2xpbnV4LWFybS1r ZXJuZWwK 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 91624C433EF for ; Thu, 5 May 2022 13:41:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A46EA6B0071; Thu, 5 May 2022 09:41:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9F1756B0073; Thu, 5 May 2022 09:41:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8E1CD6B0074; Thu, 5 May 2022 09:41:58 -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 7BE296B0071 for ; Thu, 5 May 2022 09:41:58 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 38E898130D for ; Thu, 5 May 2022 13:41:58 +0000 (UTC) X-FDA: 79431802716.07.50E0F0E Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf17.hostedemail.com (Postfix) with ESMTP id 869744008B for ; Thu, 5 May 2022 13:41:43 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5C4BA61E77; Thu, 5 May 2022 13:41:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7D69C385A8; Thu, 5 May 2022 13:41:51 +0000 (UTC) Date: Thu, 5 May 2022 14:41:48 +0100 From: Catalin Marinas To: Tong Tiangen Cc: Mark Rutland , James Morse , Andrew Morton , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Robin Murphy , Dave Hansen , Will Deacon , Alexander Viro , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , x86@kernel.org, "H . Peter Anvin" , linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Kefeng Wang , Xie XiuQi , Guohanjun Subject: Re: [PATCH -next v4 4/7] arm64: add copy_{to, from}_user to machine check safe Message-ID: References: <20220420030418.3189040-1-tongtiangen@huawei.com> <20220420030418.3189040-5-tongtiangen@huawei.com> <7da54d72-e5fa-41b5-67ea-a0b084e4c94a@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <7da54d72-e5fa-41b5-67ea-a0b084e4c94a@huawei.com> X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 869744008B X-Stat-Signature: wgbe5gua9wrjdg1ip8sk9cfhj6xxafwx Authentication-Results: imf17.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf17.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org X-HE-Tag: 1651758103-353982 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: On Thu, May 05, 2022 at 02:39:43PM +0800, Tong Tiangen wrote: > 在 2022/5/4 18:26, Catalin Marinas 写道: > > On Wed, Apr 20, 2022 at 03:04:15AM +0000, Tong Tiangen wrote: > > > Add copy_{to, from}_user() to machine check safe. > > > > > > If copy fail due to hardware memory error, only the relevant processes are > > > affected, so killing the user process and isolate the user page with > > > hardware memory errors is a more reasonable choice than kernel panic. > > > > Just to make sure I understand - we can only recover if the fault is in > > a user page. That is, for a copy_from_user(), we can only handle the > > faults in the source address, not the destination. > > At the beginning, I also thought we can only recover if the fault is in a > user page. > After discussion with a Mark[1], I think no matter user page or kernel page, > as long as it is triggered by the user process, only related processes will > be affected. According to this > understanding, it seems that all uaccess can be recovered. > > [1]https://patchwork.kernel.org/project/linux-arm-kernel/patch/20220406091311.3354723-6-tongtiangen@huawei.com/ We can indeed safely skip this copy and return an error just like pretending there was a user page fault. However, my point was more around the "isolate the user page with hardware memory errors". If the fault is on a kernel address, there's not much you can do about. You'll likely trigger it later when you try to access that address (maybe it was freed and re-allocated). Do we hope we won't get the same error again on that kernel address? -- Catalin