Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2924921rwb; Mon, 15 Aug 2022 14:09:54 -0700 (PDT) X-Google-Smtp-Source: AA6agR47sKr/MLMRjx+HOcF9LurAJPvD4Q0ySZXcFHHw+sRd73/QHxCZxPaJ4kForcEUUBtS+Ai3 X-Received: by 2002:a17:907:280a:b0:730:ed6a:ad1c with SMTP id eb10-20020a170907280a00b00730ed6aad1cmr11658977ejc.543.1660597794160; Mon, 15 Aug 2022 14:09:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660597794; cv=none; d=google.com; s=arc-20160816; b=BdBc3Xria2y4vp6lbBzSSviigbCCWJJ34WrgxCfjI+KzpCe+2DR3aJivPF1Ww4YRvk sIubAPfPoqf1Xd62nnwznM9OmzoAhvB040265JQJ9uKkU7uaJf1YFJZtSaaqVPBLTQ/I 3OthJXn6NQNfPx5sL27oR3bL8zUeYH1FUHxzyE+LQvF6Lidl6yx7J0SdLwr7TZshGuG9 cIIdHu+oEkgnRsTCx4LTVB3+qjEGW3s8w4e+TT7nedcc/PTew6PHbBgoLLHbSnQeJR3F zJUlI1O6OKzejDAIAOIP4irgWFROD+h0C8C0Mq4lgYLQi5A1ShQmWCc8/3i/z9VTPrcR Dy5A== 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=ZrlZKCb0ii4VXAxDsnY+JPrruNj8XNX+azJ5FEaocuyNLPmpc2CHaewF/Aw5Kln+ia K/9DYFg7RSkGcKeD3UkvW+JKINZcNSS2uUxrQQYRB+/Tl9u2tpItLcacciqH+mWzZgi2 RWEryuHWxmpRLj7Mz+JHt/t/pX1nIfqKIN2koyiBf5XAgAq0LO0D++DDKw2uuI3tqPWA EotnZqVzmznTlYqbTO9ItUd+UnETBYKGlHHzTYV28m0zUeoguYTjr15P742iXM251BmY rbma0ITpj0wCLlPslIGeu2rCrrktMz2HCTN7yzxb+KNkYdQrmMG00MZDyFyf5VxWTe65 +8SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ubVuyo+H; 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 md12-20020a170906ae8c00b00730a3c9aeeasi6981107ejb.549.2022.08.15.14.09.28; Mon, 15 Aug 2022 14:09:54 -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=ubVuyo+H; 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 S1345952AbiHOUJz (ORCPT + 99 others); Mon, 15 Aug 2022 16:09:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240020AbiHOUJF (ORCPT ); Mon, 15 Aug 2022 16:09:05 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7571F2663; Mon, 15 Aug 2022 11:55:53 -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 ams.source.kernel.org (Postfix) with ESMTPS id E2C19B8109E; Mon, 15 Aug 2022 18:55:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49302C433C1; Mon, 15 Aug 2022 18:55:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660589747; bh=hVge2b40hrymoACoRoPHQOleTSb2rRVyOkW4WS8IgBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ubVuyo+HMWd8fssHjtNrvIyrbdpZ51Ym5GNvJEQz8ruZzTFbsTHLT03HsonuB31mU E0znBIokEuS+gJGxFUrh/xx2UewWWx2DtyCINFwqTgcusP2B+vmB6TyxggflZRld+B hAaE7y31tbSVZzgxa1rAmY08l3hveNRrSetq3Awc= 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.18 0028/1095] KVM: Put the extra pfn reference when reusing a pfn in the gpc cache Date: Mon, 15 Aug 2022 19:50:27 +0200 Message-Id: <20220815180430.527997742@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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;