Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3089918rwb; Mon, 15 Aug 2022 17:52:59 -0700 (PDT) X-Google-Smtp-Source: AA6agR744DoMAYKBQqny7xy5lxKi+K3f64pjgh5FL/Nw0XYI1rFe6T63kFE4Dd4IXUkfECjStcV5 X-Received: by 2002:a05:6402:248d:b0:437:dd4c:e70e with SMTP id q13-20020a056402248d00b00437dd4ce70emr16292881eda.75.1660611179372; Mon, 15 Aug 2022 17:52:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660611179; cv=none; d=google.com; s=arc-20160816; b=XKG/77KLLKy+lV5Krt0n64ragY0EbQS1j5LlXfVdzwLdgqchzQc8zL68uAQGfIFY8R GfgXtT+b6eu7PbuL4YB5epvrJpwdRg90+67PfrKlv867fKflc59KJgBOlRBkjVNFk8gr vvZFoiytgBKp7RwSqwCfmS9ao6khXMz02xuqL0et1uzjMlKO3Fu8y/aypAW98HiQXM6N d7wxzQnLIIG2hjwlAssO6iiXmmAqhUmxPca7img3PKKgRfrpocTjjatBtLF4OwQUSNaH ncGCDCAZB/x7zmgE2FYC3U7io+CDBZqYSBUeRIouW6LATN8RA4WvxbwyRn1kAHQUGJ4p dkNA== 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=g0mq0KdRkB+mPFmIffrZnZrZhB96vmb5ceEOpwAamME=; b=PBSXE5b3e4GsBshKCBsCmkg1Z/R013WJMYRohuT1Y3DGsHFu5oMUKGB+C38iHki3mq ZrptbDy30eQbIPknrNmS59UCfyDwglbQyDEmYAhx/eMVbtpW3LMuWQfUsxRaoATIe0g4 uAC5hxedUyxX0zbvsZvS/umkN84di9Wlt3JHuiqqSh1VzAzvThSu01XhQ6esGPibBIOt qyPGI7GHXHzZ0P3Xpk2P0JtmMB8Ws1Oq81QtwZCMEmmaIoSTZjZl+Jttmouh30gGrdf1 o9/e4Qhmii8DvKABzSJqx0zKOfMA6WRYMk636dRB5WDuZSEqITmH1pt/M6lk04GQEacO sL1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=flowuNYV; 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 q13-20020a056402518d00b0043dcc0d6eb4si9956211edd.607.2022.08.15.17.52.34; Mon, 15 Aug 2022 17:52:59 -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=flowuNYV; 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 S1350275AbiHOVwi (ORCPT + 99 others); Mon, 15 Aug 2022 17:52:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350288AbiHOVrg (ORCPT ); Mon, 15 Aug 2022 17:47:36 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E5262B634; Mon, 15 Aug 2022 12:31:42 -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 0B3A660EF0; Mon, 15 Aug 2022 19:31:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14821C433D6; Mon, 15 Aug 2022 19:31:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660591901; bh=hVge2b40hrymoACoRoPHQOleTSb2rRVyOkW4WS8IgBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=flowuNYV4yBgInJ337f2gvVlvXmifOFo25pJCEgtTdcDjPynuoJxGV8Sdgp5MXEr+ pioZFHeCVmIhBdVp9zkjaSWeGXT/awRh1KaNZMK0uBM7ArOEI4mwbtjHzgwYBGY+JI 4AeTbtYLJSsr2X4Gw8fnAofHBmhtQGTbrZLTQ134= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Paolo Bonzini Subject: [PATCH 5.19 0028/1157] KVM: Put the extra pfn reference when reusing a pfn in the gpc cache Date: Mon, 15 Aug 2022 19:49:44 +0200 Message-Id: <20220815180440.551008180@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 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 3dddf65b4f4c451c345d34ae85bdf1791a746e49 upstream. Put the struct page reference to pfn acquired by hva_to_pfn() when the old and new pfns for a gfn=>pfn cache match. The cache already has a reference via the old/current pfn, and will only put one reference when the cache is done with the pfn. Fixes: 982ed0de4753 ("KVM: Reinstate gfn_to_pfn_cache with invalidation support") Cc: stable@vger.kernel.org Signed-off-by: Sean Christopherson Message-Id: <20220429210025.3293691-5-seanjc@google.com> Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- virt/kvm/pfncache.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/virt/kvm/pfncache.c +++ b/virt/kvm/pfncache.c @@ -206,6 +206,14 @@ int kvm_gfn_to_pfn_cache_refresh(struct if (gpc->usage & KVM_HOST_USES_PFN) { if (new_pfn == old_pfn) { + /* + * Reuse the existing pfn and khva, but put the + * reference acquired hva_to_pfn_retry(); the + * cache still holds a reference to the pfn + * from the previous refresh. + */ + gpc_release_pfn_and_khva(kvm, new_pfn, NULL); + new_khva = old_khva; old_pfn = KVM_PFN_ERR_FAULT; old_khva = NULL;