Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2345072rwd; Fri, 26 May 2023 05:30:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5MdqQE0jcyboVoEsGt4/5W8/mAT2KAwliOeopfnAjre2GORAr2Kv/MlOCXtVKQ6gYRHCem X-Received: by 2002:a17:902:6846:b0:1ae:35b8:d5ae with SMTP id f6-20020a170902684600b001ae35b8d5aemr1435773pln.19.1685104229668; Fri, 26 May 2023 05:30:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685104229; cv=none; d=google.com; s=arc-20160816; b=Ehf53xnmfv2xt4cac2OIC5LrTJkTCMiSLntY5KojToFfBVXQVO6DPYVvlyKGsdDjXh o+xQYch9qkKQ+tKEioj51zzXvEhNpsR8UNqF0AuRQqitMy56c3OB3BBleu8YR0PUfvyP ICGUvfA62l8GKlnqha4NN4wWqFHsdMLptusFgRDtBucpjyS3FdldGFf4bg24oCUJtwQo baX6B2QUb1Nljz561Hi4rER9cbPol0CT0Xs5yRThyExE15xkrKhXrSCUFwiZMYXwYQe/ PMbygLX3ozssoiLeGxDZmN39LOSmGKup1jppMbwQUSQHjFkAWIj7oHi+JCwRFpmZG3xT YHWA== 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:content-language:subject:user-agent:mime-version :date:message-id; bh=eToAeMANqbuVN1xQdQlNQ1WKbkqFJZ6a73fbvP0J32U=; b=zMS26RyFfyRFwDhtdwBoRv+TdN0+i+dE4q6QYx6FWgQBwsPplZM8lNE73Y+eRrz4sq MJnOnkDHdEOpJ5beuIsk0x9Bfly0EDzpONR8Mr01Fm68GAyH6WxGpQn9vOAH3ezrhJio e6ABnj73/8JGENXQEeG27jK3ddbmtOE7hPgEWuyPxk7Ik2/OOz+2gMRlPdznQ313Ld4/ KgXEx9qYUrfRMouZ7UPm01k6Gjo3nWGHUh5VMSz7tsuNWII+snptu2ZxxNPq+d2Ve60Q bpl6Of5bnqImiMIvBt7kzmvkGQHD59ZaShotvUFtzcwwnQAUVYKbQMP0JpNZyAFRZ7Q7 jx3Q== 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 n3-20020a170902968300b001afdfd0b363si3493341plp.489.2023.05.26.05.30.17; Fri, 26 May 2023 05:30:29 -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 S243203AbjEZMSS (ORCPT + 99 others); Fri, 26 May 2023 08:18:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243348AbjEZMSO (ORCPT ); Fri, 26 May 2023 08:18:14 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1024419A; Fri, 26 May 2023 05:18:12 -0700 (PDT) Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4QSP362Jwlz18LbC; Fri, 26 May 2023 20:13:38 +0800 (CST) Received: from [10.174.177.243] (10.174.177.243) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 26 May 2023 20:18:09 +0800 Message-ID: Date: Fri, 26 May 2023 20:18:09 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 Subject: Re: [PATCH v2] x86/mce: set MCE_IN_KERNEL_COPYIN for all MC-Safe Copy Content-Language: en-US To: Borislav Petkov , Youquan Song CC: , , , , , , , , , , References: <20230526063242.133656-1-wangkefeng.wang@huawei.com> <20230526070952.GAZHBbQNAWZJP6tOXv@nazgul.local> From: Kefeng Wang In-Reply-To: <20230526070952.GAZHBbQNAWZJP6tOXv@nazgul.local> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.3 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 On 2023/5/26 15:09, Borislav Petkov wrote: > On Fri, May 26, 2023 at 02:32:42PM +0800, Kefeng Wang wrote: >> The best way to fix them is set MCE_IN_KERNEL_COPYIN for MC-Safe Copy, >> then let the core do_machine_check() to isolate corrupted page instead >> of doing it one-by-one. > > No, this whole thing is confused. > > * Indicates an MCE that happened in kernel space while copying data > * from user. > > #define MCE_IN_KERNEL_COPYIN > > This is a very specific exception type: EX_TYPE_COPY which got added by > > 278b917f8cb9 ("x86/mce: Add _ASM_EXTABLE_CPY for copy user access") > > but Linus then removed all such user copy exception points in > > 034ff37d3407 ("x86: rewrite '__copy_user_nocache' function") > > So now that EX_TYPE_COPY never happens. Is this broken the recover when kernel was copying from user space? + Youquan could you help to check it? > > And what you're doing is lumping the handling for > EX_TYPE_DEFAULT_MCE_SAFE and EX_TYPE_FAULT_MCE_SAFE together and saying > that the MCE happened while copying data from user. > > And XSTATE_OP() is one example where this is not really the case. > Oh, for XSTATE_OP(), it uses EX_TYPE_DEFAULT_MCE_SAFE, but I'm focus on EX_TYPE_DEFAULT_MCE_SAFE, which use copy_mc (arch/x86/lib/copy_mc_64.S), like I maintained in changelog, CoW/Coredump/nvdimm/dax, they use copy_mc_xxx function, sorry for mixed them up. > So no, this is not correct. so only add MCE_IN_KERNEL_COPYIN for EX_TYPE_DEFAULT_MCE_SAFE? diff --git a/arch/x86/kernel/cpu/mce/severity.c b/arch/x86/kernel/cpu/mce/severity.c index c4477162c07d..6d2587994623 100644 --- a/arch/x86/kernel/cpu/mce/severity.c +++ b/arch/x86/kernel/cpu/mce/severity.c @@ -293,11 +293,11 @@ static noinstr int error_context(struct mce *m, struct pt_regs *regs) case EX_TYPE_COPY: 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; Correct me if I am wrong, thanks for you reviewing. >