Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1153947pxm; Thu, 3 Mar 2022 11:22:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJzWFyYnGe15dHRyUC71AUiljt6pnYM2hGQu/uXZYpJdmIyVx5DU572LTYz4v/QN9y3X+FyF X-Received: by 2002:a17:906:aed4:b0:6da:aa56:c923 with SMTP id me20-20020a170906aed400b006daaa56c923mr1205591ejb.148.1646335323184; Thu, 03 Mar 2022 11:22:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646335323; cv=none; d=google.com; s=arc-20160816; b=EBYoBIU0UmBC9kJ7QtNavOBWPa8OMTJrn94Rp+pvzj6UfqjkLovNwg+VG0EZcP/01K 7yq3i746Q50mtUs+6B1HwFIGJ22bYE2NT2g0Zr3BH7GHX1enzaS9rh76TnJ0zFrcFNgz 7H2Y5rHdqbr+5liJbz0mZcCBqk7EzNCqXsT678MGvpLG99iPnXq/vBpVcrPprKMz0WIb f6baXFgG+O8X6oY6LDLYcs4Omi6pl+5o3vWfX/b+dwgoDanFHWPt2e8H2ElPKhQxQVPc hxrJxcM4GaHH9FLjxbVhBSdlVHfSxHFu1sHRulEwn+iS8ftTfrTdMT8yACUA2rCFwTBv 6Y1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=R+X4H7M+LG6xqrD1uLHkuUkSn555GPzR7bQZLtF1ork=; b=HrC6OZUfvkWotG0jf6zkbU3CAtKJ+tvMgKKdKdh0T+vRS5tBqjXY0VqLVo3lIQxODp Uj4fwf4dna++thoZoPBNlzeL+w1Ho6cHKO4y47NlxL7MxJYpDoveeuQ6v/hHmXyA6MTS RflkGP58CcCPyyaWZm2ZWe14F6NwBSi3prsxj+uQJmzDDM77v13ILUEFu6psB9vMdogK tM1Jld+RnJ4g0UEnYsYytMAEc0nPm0V/d51Z/AIHBbejdsSgkhA1MPKabx68KW6VgMez 3YPl68K0M23vz7luBpP53DIuRuTPq6Uov0fWH+SVMguAHmbzjsAgU2e9RX0IFeocenMI vWJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=LkS88C+V; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nd31-20020a170907629f00b006da74aac1aasi2244789ejc.516.2022.03.03.11.21.40; Thu, 03 Mar 2022 11:22:03 -0800 (PST) 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; dkim=pass header.i=@google.com header.s=20210112 header.b=LkS88C+V; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235676AbiCCSi1 (ORCPT + 99 others); Thu, 3 Mar 2022 13:38:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234931AbiCCSiX (ORCPT ); Thu, 3 Mar 2022 13:38:23 -0500 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B7EB63BF for ; Thu, 3 Mar 2022 10:37:30 -0800 (PST) Received: by mail-pj1-x102d.google.com with SMTP id c16-20020a17090aa61000b001befad2bfaaso5251145pjq.1 for ; Thu, 03 Mar 2022 10:37:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=R+X4H7M+LG6xqrD1uLHkuUkSn555GPzR7bQZLtF1ork=; b=LkS88C+V+Y/2YuBrjM1LK9lu3FTjB6y45JNMZ25CcyorbjadrcynBYaSgI2tYCEUPH q0Ze9253duaJTDfVRq4tj57tERA6ThBweTLeqL0MwuEVJkTdHfVuAOXvbdYcTtqlcJ48 C5lnzNsvXzWFWr4LQfuVuoJYzStHyQwAU7OL+YGsp/hRQ1vA3ppCoVpFLLJZwjw2v1Zw kJGSV9bkc/aGCFIRDoPJsKXCAmTfl3+mfVNMWnCp+T21zuV7HakRxXIw9V0WaWi9d2/7 /5BaX/7mKPhjyXrTDM4hyb3+zJJnKXQL+rB/IoyrUZwZM3S45gtH84wUogmLbrFvNHdk Zw1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=R+X4H7M+LG6xqrD1uLHkuUkSn555GPzR7bQZLtF1ork=; b=Dnhgf9m073FqgDAOgsUqmHMXhSBe5s00ol+gqEkl1Qx4oBkGm7ZHYPmsuRLtppSF9n S/Ilz3If4hNVuWegdQ54A2O2r5mKZRSIplFWgAQglIK21ntAfyDQORFe4NlgDUBPk8o7 Ktm4rM9qkkZZdvyYGUQNDwX9jaeTbOhYeYfZgIZRIj1bCHLBHOSsJXPCkco2xSF0bRmI a2eMMvCCJOcyp+R3aYh/ySfXcFHQZf9DtOxk44rboA6t4Q/29lb4EmBe8i6l9d5kAfxJ EDCI8rYVx2AkRHOiYyUnWOCZiEhNKO61YTqoSyt2YBj1kSYswWpNq6sD/j7rZnplsDcd 5tmg== X-Gm-Message-State: AOAM5315+UUbbPQdhSHhccBpU+a6U+SLBF8HOZ1Y/B+jeg4ALfMql3t7 S/zzCPVO+O7+OFxcmLMbkzEpmg== X-Received: by 2002:a17:902:b201:b0:14d:66b5:5d69 with SMTP id t1-20020a170902b20100b0014d66b55d69mr36879757plr.95.1646332649551; Thu, 03 Mar 2022 10:37:29 -0800 (PST) Received: from google.com (226.75.127.34.bc.googleusercontent.com. [34.127.75.226]) by smtp.gmail.com with ESMTPSA id s21-20020a056a00195500b004f65b15b3a0sm3234216pfk.8.2022.03.03.10.37.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 10:37:29 -0800 (PST) Date: Thu, 3 Mar 2022 18:37:25 +0000 From: Mingwei Zhang To: Sean Christopherson Cc: Paolo Bonzini , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , David Hildenbrand , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, David Matlack , Ben Gardon Subject: Re: [PATCH v3 11/28] KVM: x86/mmu: WARN if old _or_ new SPTE is REMOVED in non-atomic path Message-ID: References: <20220226001546.360188-1-seanjc@google.com> <20220226001546.360188-12-seanjc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220226001546.360188-12-seanjc@google.com> X-Spam-Status: No, score=-18.1 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable 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 Sat, Feb 26, 2022, Sean Christopherson wrote: > WARN if the new_spte being set by __tdp_mmu_set_spte() is a REMOVED_SPTE, > which is called out by the comment as being disallowed but not actually > checked. Keep the WARN on the old_spte as well, because overwriting a > REMOVED_SPTE in the non-atomic path is also disallowed (as evidence by > lack of splats with the existing WARN). > > Fixes: 08f07c800e9d ("KVM: x86/mmu: Flush TLBs after zap in TDP MMU PF handler") > Cc: Ben Gardon > Signed-off-by: Sean Christopherson > Reviewed-by: Ben Gardon Reviewed-by: Mingwei Zhang > --- > arch/x86/kvm/mmu/tdp_mmu.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c > index 8fbf3364f116..1dcdf1a4fcc1 100644 > --- a/arch/x86/kvm/mmu/tdp_mmu.c > +++ b/arch/x86/kvm/mmu/tdp_mmu.c > @@ -640,13 +640,13 @@ static inline void __tdp_mmu_set_spte(struct kvm *kvm, struct tdp_iter *iter, > lockdep_assert_held_write(&kvm->mmu_lock); > > /* > - * No thread should be using this function to set SPTEs to the > + * No thread should be using this function to set SPTEs to or from the > * temporary removed SPTE value. > * If operating under the MMU lock in read mode, tdp_mmu_set_spte_atomic > * should be used. If operating under the MMU lock in write mode, the > * use of the removed SPTE should not be necessary. > */ > - WARN_ON(is_removed_spte(iter->old_spte)); > + WARN_ON(is_removed_spte(iter->old_spte) || is_removed_spte(new_spte)); > > kvm_tdp_mmu_write_spte(iter->sptep, new_spte); > > -- > 2.35.1.574.g5d30c73bfb-goog >