Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp317071pxm; Wed, 2 Mar 2022 16:13:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJz48gx7LpSHQMfFNTXdpdnNbRkmg1w7iBpLYLiLjh/mfuza7ZHhec/MF58EPJSb5ZjGGwdt X-Received: by 2002:a05:6a00:244c:b0:4f6:67b8:a6b4 with SMTP id d12-20020a056a00244c00b004f667b8a6b4mr1642611pfj.51.1646266406658; Wed, 02 Mar 2022 16:13:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646266406; cv=none; d=google.com; s=arc-20160816; b=HjnDx8Der7Og+ZbV2H7NR8WbTzXCh2Oph/JEYMjiDn6KvjCqVwMLxsPomBmMok48Q/ pQO1tsXJrPt8TZc6zX0F9IZ/48o3oJAxRpgfCgg07kthi3KvwHkfDONYkivabGDDOY1G SsmgKevG0vZ44RYrQT/8i6FUzvw3GOTjlgvX6HVhB3YJE+V3IedETQfrOPLoehgzlAgl R7qXkwhIoLkEVeuKPSjVz5OHHZz4Y3tfUWTdcb7nh+ua3UDT3/rYTCNOHAA9Rk4DxtfN d1t7NXjLhVCNuvtdUspuVimBEyot6tYaQ0zUjMVbL9ly5OdRtFOfuO88kVoTJSP8QavG wkZw== 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=lKk3x8uXXjQyBVKUKuzhJBJZvtvNO106582p6u2NXrQ=; b=u4iamPDbueMYCwVkaDNE44k4Bcb6npVUGWSvp4qPVgmE1FskuWVkd5w7TuhFuXECCq L8a1oQV7/vj2ZkxfB1415ZfhvYg9dc5CN0e/0dqO/bR7pf1WJKih/2QIGUCLnc6MaJTN ufMwakAt9rZ2bHCgq15Prpm6DmtoGGqALmp4j816uFc99JWZRwRKCb3U7JHnVsNvW1Jt +IZItxjXsmq46jtoqeNlijc9qtW434bIW2fP7TYXhAwQ8IeSRwkyNhPKxaosCtK9QMRC i+O/IYRX4S9YQKQgoltKVvdVX7MP6HqItZ8t7+9nDe8VekIVaFsZiClVlT52QeFeHzvV ORCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=qPmZtH8m; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id g3-20020a056a0023c300b004f400764b6asi567905pfc.114.2022.03.02.16.13.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 16:13:26 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=qPmZtH8m; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DE33C1CC7C4; Wed, 2 Mar 2022 15:28:28 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242326AbiCBTvA (ORCPT + 99 others); Wed, 2 Mar 2022 14:51:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231847AbiCBTu6 (ORCPT ); Wed, 2 Mar 2022 14:50:58 -0500 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD9A6D109B for ; Wed, 2 Mar 2022 11:50:14 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id q11so2470982pln.11 for ; Wed, 02 Mar 2022 11:50:14 -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=lKk3x8uXXjQyBVKUKuzhJBJZvtvNO106582p6u2NXrQ=; b=qPmZtH8mC9Mer8Naw7XSShiYWujI0J3vVPBJ/6dwQB4LyhA5u35peVR+FBq1ELY2IR +Cx++8ZLYtMKXKQV14ldIpbynCLAsbmV8Ru+4d1aoZBUgXHe2xLI32h1Y1K7od2DdCRx u13TXaE4PIa8dFW7h+dBaan/ZeioxcWzhKQpw3rfBXqZmM6KtqkVNliFjl4MNz8iVbU4 qCvIVARH1cn29hoc6QbH6OfEOnVtNoSiWX2jCnc0iNY2U/V0hvV831YnCUMqCkLBMijz z4Br0RgRDOdtR7P2N5CpVkuozPQisNtcpoQ5NS/xKwSdJHpGmCqK9qnOqpRyafP5kNuX 5keA== 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=lKk3x8uXXjQyBVKUKuzhJBJZvtvNO106582p6u2NXrQ=; b=PK2xDhsleBcWTRVbQNFVjtqsyd1nwUfwnwL7dqTQubKyU4shHHfetY9n6NyHMTwXxr 1QiMYWLR+G01RL1JCaPJDiWGy1H8e5x51V6FHBPG6w5wW0bwswkoFYWme1T32EfKi2eM 6DxLiBoL5R873TsZs69XTDRpgTNozblQ84SSoh47Olq+8XbXrRBMvX6Aoe7GJJUNq4Pp /+U9YXawk3hxE9d8Z+sttDjwa60brE5ljGx5I1I8CZT4lO+ch5lfO/nNGOCOf/LFR3tL gtyHebBeZ356lJg1HJdaR9I2+44wARe59ozD2AdZOA5UMTeyBZSgdjjGXOP8QzZBUGk1 eZng== X-Gm-Message-State: AOAM533cT63XcFg1pQmK2zcAbY5I9F6bUxrwYGJhM50tsE0KqpE0Cpj3 tWwg/m2FLTVoU6x/ZS1ctV29iA== X-Received: by 2002:a17:90a:6508:b0:1be:d59c:1f10 with SMTP id i8-20020a17090a650800b001bed59c1f10mr1412919pjj.229.1646250613939; Wed, 02 Mar 2022 11:50:13 -0800 (PST) Received: from google.com (226.75.127.34.bc.googleusercontent.com. [34.127.75.226]) by smtp.gmail.com with ESMTPSA id h2-20020a056a00170200b004e0f0c0e13esm21500641pfc.66.2022.03.02.11.50.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 11:50:13 -0800 (PST) Date: Wed, 2 Mar 2022 19:50:09 +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 02/28] KVM: x86/mmu: Check for present SPTE when clearing dirty bit in TDP MMU Message-ID: References: <20220226001546.360188-1-seanjc@google.com> <20220226001546.360188-3-seanjc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220226001546.360188-3-seanjc@google.com> X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_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: > Explicitly check for present SPTEs when clearing dirty bits in the TDP > MMU. This isn't strictly required for correctness, as setting the dirty > bit in a defunct SPTE will not change the SPTE from !PRESENT to PRESENT. > However, the guarded MMU_WARN_ON() in spte_ad_need_write_protect() would > complain if anyone actually turned on KVM's MMU debugging. > > Fixes: a6a0b05da9f3 ("kvm: x86/mmu: Support dirty logging for the TDP MMU") > Cc: Ben Gardon > Signed-off-by: Sean Christopherson > Reviewed-by: Ben Gardon Reviewed-by: Mingwei Zhang > --- > arch/x86/kvm/mmu/tdp_mmu.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c > index 25148e8b711d..9357780ec28f 100644 > --- a/arch/x86/kvm/mmu/tdp_mmu.c > +++ b/arch/x86/kvm/mmu/tdp_mmu.c > @@ -1446,6 +1446,9 @@ static bool clear_dirty_gfn_range(struct kvm *kvm, struct kvm_mmu_page *root, > if (tdp_mmu_iter_cond_resched(kvm, &iter, false, true)) > continue; > > + if (!is_shadow_present_pte(iter.old_spte)) > + continue; > + > if (spte_ad_need_write_protect(iter.old_spte)) { > if (is_writable_pte(iter.old_spte)) > new_spte = iter.old_spte & ~PT_WRITABLE_MASK; > -- > 2.35.1.574.g5d30c73bfb-goog >