Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1519036iob; Thu, 5 May 2022 03:13:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFYMdnIPkfWVWK3I1a/aowf9VLeis4f9UV0oFXHzuhBayXEwukoOPsONnKdUF1mlG58vKO X-Received: by 2002:a17:907:97cc:b0:6df:83bc:314c with SMTP id js12-20020a17090797cc00b006df83bc314cmr25356211ejc.587.1651745608210; Thu, 05 May 2022 03:13:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651745608; cv=none; d=google.com; s=arc-20160816; b=PcbKDZC1rYoleveVnlfcACQrEFZcGzwYIWvrfIvS4kLnj5IZe02XV6LKXtbL16QrLW xQHcorR9ps+Z5vLg6bUKXaO7lyrK9vIeuAKEOBmfx2H6ujEpD8wAx2U2FvySByepRzPo 1XlbbRmzVheW1PyHAqUpVasOEie+LXRkFTfK9Een24cW0tp5xo2itrZnEjqjqZLmr7qU vjFn7VzktTOfntVHfGmxuArvFRjOWCLCqgx8gDztPZ1/72OmAIvThHIV218dkz+Mk2+5 zqXeqoOBRaqomtRgnaN7+GSoC0ISq6OLLdabrfV2BqAQGTHCXM13/IDqOvZaYoGD1A3H zrag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=hCNK+tw85jI7Kvh+XTGvwGtaS/1fuTSRL9kkzHKEulY=; b=SP00vKFkb0RnWpo+OnUwNEWmuf1zUZ33EVFMmHuGZGIV/Ok9fIL1mLUiFyumSWBTnO 1TDca9RSkzLr/UP9q69agemZBAlb8gABeVHDZ/8s1oL93TAwcpIcopmdQvYhBMP7EHYZ 8qpRuvlxpPWrnYQv1/gtBpmouhoFAdqkQtgNSqtkyrBED1+IY6rZvCw3uW24trnRqANy 9gycscGUKrvTRF1rsJ0ocpyMeZk8txs8zmvZx2ubcS/39bQgt41qypLaVXA5wn67emGd 8RrxIYsl6du+TZsEfg32AmF2H4U1CybrL1kYYB9xYvRUrZ8qEnNgy9kPaGJ66/VaWkHP V5Ow== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l15-20020a056402254f00b00425c6ad47edsi1574116edb.291.2022.05.05.03.13.04; Thu, 05 May 2022 03:13:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244943AbiEEGnb (ORCPT + 99 others); Thu, 5 May 2022 02:43:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233799AbiEEGn2 (ORCPT ); Thu, 5 May 2022 02:43:28 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B00633A0C for ; Wed, 4 May 2022 23:39:48 -0700 (PDT) Received: from kwepemi500023.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Kv3pc69TXzDqKY; Thu, 5 May 2022 14:35:04 +0800 (CST) Received: from kwepemm600017.china.huawei.com (7.193.23.234) by kwepemi500023.china.huawei.com (7.221.188.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 5 May 2022 14:39:45 +0800 Received: from [10.174.179.234] (10.174.179.234) 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.2375.24; Thu, 5 May 2022 14:39:44 +0800 Message-ID: <7da54d72-e5fa-41b5-67ea-a0b084e4c94a@huawei.com> Date: Thu, 5 May 2022 14:39:43 +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 -next v4 4/7] arm64: add copy_{to, from}_user to machine check safe To: Catalin Marinas 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 , , "H . Peter Anvin" , , , , , Kefeng Wang , Xie XiuQi , Guohanjun References: <20220420030418.3189040-1-tongtiangen@huawei.com> <20220420030418.3189040-5-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: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemm600017.china.huawei.com (7.193.23.234) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 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/ Thanks, Tong. > >> diff --git a/arch/arm64/lib/copy_from_user.S b/arch/arm64/lib/copy_from_user.S >> index 34e317907524..480cc5ac0a8d 100644 >> --- a/arch/arm64/lib/copy_from_user.S >> +++ b/arch/arm64/lib/copy_from_user.S >> @@ -25,7 +25,7 @@ >> .endm >> >> .macro strb1 reg, ptr, val >> - strb \reg, [\ptr], \val >> + USER_MC(9998f, strb \reg, [\ptr], \val) >> .endm > > So if I got the above correctly, why do we need an exception table entry > for the store to the kernel address? >