Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp689084pxb; Tue, 5 Apr 2022 18:53:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzglyqhp0sZmXNwVU2gVwwyRErl3c09UYEjvALF5LIWG/0qJe6oJnHLwS/ardrEraqls6Pj X-Received: by 2002:a05:6a00:ad2:b0:4f1:2734:a3d9 with SMTP id c18-20020a056a000ad200b004f12734a3d9mr6625378pfl.61.1649210003162; Tue, 05 Apr 2022 18:53:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649210003; cv=none; d=google.com; s=arc-20160816; b=NNK7WF4DkHQhAOQOVGGK3FTzAg0SDdLCJ2xRHQm+K3VCVzYGrkZwrR9NQaGoTT2acB h+umyyrf8U3oJHwdXpAqkpSNVZN7CJJJ11KXE1skpansd56seYAec+MzCDsAPx5KFXgG /XB2uFfj4/ilXEylm7g30Z9iVv1FLrkujUZbCI/igB9kqmj+r4A+7qgDm5eDJS7uo4hP B+WSIEOuSZ5G4i7Wjp9Udhiw6/aIFXG3QYTDIPw5ZsOQVtEs1iB4w9/8/C2ago2VxqHb VbBE7K53xowvdmAkFaZoh+V2vEE9huQ18Ipa6jB8+47pPUHLeaXurlvRbifJH3BC00US iXlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=e08+NjwYcInUZGd+uat/JDAvGHpwfkD6xmrpLDL5GNQ=; b=0qGg/HBtpJKqG8ybn1Dcmbol9SqEPKv7GPN/uo00FACD7a62r6nthIsC3RmqJF16DC SSQ0t5kLtrMGkp0dre3aQ9R8PB0Dj5Otp0iyk9oNJZObbXGkG1a/kEG+UvC1lsvJmdzD Z+DOkYpX8fUk3OjD0wcI9TL8PJYDAvAzfQpM7raAdw4eglno/pfstwa8uF3rmBRdmmdt aLw+Gccu3p8iRwk+focS3CDJpeLgcc/a/pnAg614ftFyQ4iho1D+e7onvzKGr2KYf9FC yfYdu0XmprXUNnhFOWMJBgK673w1jGIgws1FRmvWud6Ps3xyP13Ll5MqGjK65ZnOVirp y4qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zN1ke6gw; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a24-20020a1709027d9800b0015454f1f0dfsi14155311plm.28.2022.04.05.18.53.08; Tue, 05 Apr 2022 18:53:23 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zN1ke6gw; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382874AbiDENaT (ORCPT + 99 others); Tue, 5 Apr 2022 09:30:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345350AbiDEJW3 (ORCPT ); Tue, 5 Apr 2022 05:22:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F6A72BB3D; Tue, 5 Apr 2022 02:10:44 -0700 (PDT) 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 CEEFC61527; Tue, 5 Apr 2022 09:10:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3553C385A4; Tue, 5 Apr 2022 09:10:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649149843; bh=SoTsVxUNgArb3KGJBW6jLzurc7grDCBVMz9x6nnfNFA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zN1ke6gwoyNM8LLVnMuMgWkmV3eVeBRfh+o/hYmDv7fIw7KctqKKk9LAuzEklUL91 oRMZu8UmN0Fuob9O4rF3kxn8AVN4FhLGX9CF2Gytk/SpGQAwzxjQerFZ5bzBrm5bS2 216varebq9VdWQn8XOnPIpjysp/UMfCBKK/1fSzU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ben Gardon , Sean Christopherson , Paolo Bonzini Subject: [PATCH 5.16 0861/1017] KVM: x86/mmu: Check for present SPTE when clearing dirty bit in TDP MMU Date: Tue, 5 Apr 2022 09:29:34 +0200 Message-Id: <20220405070419.791276787@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Sean Christopherson commit 3354ef5a592d219364cf442c2f784ce7ad7629fd upstream. 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 Message-Id: <20220226001546.360188-3-seanjc@google.com> Cc: stable@vger.kernel.org Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/mmu/tdp_mmu.c | 3 +++ 1 file changed, 3 insertions(+) --- a/arch/x86/kvm/mmu/tdp_mmu.c +++ b/arch/x86/kvm/mmu/tdp_mmu.c @@ -1261,6 +1261,9 @@ retry: 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;