From patchwork Fri Jul 26 23:51:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13743489 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 33BB9C3DA49 for ; Sat, 27 Jul 2024 00:09:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Reply-To:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:Cc:To: From:Subject:Message-ID:References:Mime-Version:In-Reply-To:Date: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=G6XdYYnK6SmaIVsSbjLWLiXTD6vQEkdodh0PTaLJXbU=; b=wPdC8o638Y0nPzF/mKiYX6D1E0 KDMEuSBXgvW/gE4CM02GpLWwG3L1VCu47kEFgeXc14GI2AXF57YDKNYZxpe6wCEafPsm8NUyF2w1j EFIb+RRh4Z6orscv+rYdO8m3xRW+/ysFEV6ZvAiigWZTLMGbIY3IilA4I3JZgogVVD/fqR6OM7aL6 g6w9nddkEte4YDBr6jVXpiKEr55T/PtPxWbfMor7QVpacXiz6dgyWsfG4SCg0f8srEL8nJKYiCkJi yZKaAWcpPVtYxNowTJju9Yl494+a51+13T8G4UXK+1hdoI8pNAc1A9+rUmntoupHZdgqlmVEKeicg 6PqJl7kw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXUzS-00000005YT8-1hd0; Sat, 27 Jul 2024 00:08:50 +0000 Received: from mail-pl1-x649.google.com ([2607:f8b0:4864:20::649]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXUl3-00000005QC4-0dO1 for linux-arm-kernel@lists.infradead.org; Fri, 26 Jul 2024 23:53:58 +0000 Received: by mail-pl1-x649.google.com with SMTP id d9443c01a7336-1fc5e61f0bbso13361955ad.1 for ; Fri, 26 Jul 2024 16:53:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1722038036; x=1722642836; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=G6XdYYnK6SmaIVsSbjLWLiXTD6vQEkdodh0PTaLJXbU=; b=iBeXJb+g0qQJ2gVCuL5L2WREBrai8rYzW1tegUMgyrC7f3tNKZDnPvY/+FY8h+tu19 FAqx7jTpFWs9HRJ6j/ID2yP2hNE8wxPrSM6dccHVoAbKu9xHto+hmRmkQeNknM8FH+93 PjA8Vl/d+Nc8bzKM5W/YqVUX99+Pwi5i79aSjpvijZVuHl3Mdu60ojnMfanBg6mqDSbY nCQZkJ17kRAg3nqszLlAldZknGUqg4qtc2UArT6hE2kaYLUaBR5MfwEGyBdy3R06U5nL n8mqgD78SYPTCVzf12e8EfNLyVHmNxquEAdVOtZ+JJgsdG7m4RDRlWDuVZBqfCQ7CZUg OmlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722038036; x=1722642836; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=G6XdYYnK6SmaIVsSbjLWLiXTD6vQEkdodh0PTaLJXbU=; b=qgf3k2jSXa5Fbjhgt3dgn3oT/VpTVM6XCNQziwTrM+rx6HwiKuB1KKkGF7n7m9gKEt dZD7c2jgQtyO4sf/yjjpW9HD7RLyvNg2agHUGsZIpjHzDr/4cNUKTFMfs/RneirS4zSG h4hPpdYkEh298OOHH0R4zFZudb5oZ2WOeH7zI59ufVLvV5A3ZfMVN+cri6ULTjOdJbP6 1SdGU7hccPp1bzOni2BWSut3OeEQ0rzXxWtema9+gozzYk0pcOvkfk3i3DN51T3SSydX HAcJdKirA22dMtoihayVN5DNBjDTHuOMa78lWVhOfYQRGXQRD387wmNX9DpiAhydXKC8 XTkQ== X-Forwarded-Encrypted: i=1; AJvYcCXQdx6WQ+cvfrmBtuygVAAdCOE2yCGqlupiYyLxQA6fotT42GzMs4I92IWIeq/vqf18p12HF8u3thfAb+pUUZnnwRk4c3ZXxGIbTgH5/NGRZlfE6O0= X-Gm-Message-State: AOJu0YxZ0pL1SxkLJL3fyHbVCW+9vEZMVecjTO84drDvwfeKlu5Hn4WD 7TbFnBXmAXketXOPvbKK6r5YKAZ56pRETv4/44NVW+QN0ymRp1KQ+/0H55uQR7e1eK+9W+mG0PZ 1bw== X-Google-Smtp-Source: AGHT+IFqcJX/9FY6hmZYd8EnC/sSURY7mS/rFneQMUHDSr3ovaE0Tb6dbx+RwJc5DGDg7FZUxHqlUK5Q8cY= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:902:c945:b0:1fc:733d:8465 with SMTP id d9443c01a7336-1ff0488cadamr598725ad.8.1722038035986; Fri, 26 Jul 2024 16:53:55 -0700 (PDT) Date: Fri, 26 Jul 2024 16:51:47 -0700 In-Reply-To: <20240726235234.228822-1-seanjc@google.com> Mime-Version: 1.0 References: <20240726235234.228822-1-seanjc@google.com> X-Mailer: git-send-email 2.46.0.rc1.232.g9752f9e123-goog Message-ID: <20240726235234.228822-39-seanjc@google.com> Subject: [PATCH v12 38/84] KVM: x86/mmu: Put direct prefetched pages via kvm_release_page_clean() From: Sean Christopherson To: Paolo Bonzini , Marc Zyngier , Oliver Upton , Tianrui Zhao , Bibo Mao , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Sean Christopherson Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, David Matlack , David Stevens X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240726_165357_291662_CDD57B46 X-CRM114-Status: GOOD ( 12.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use kvm_release_page_clean() to put prefeteched pages instead of calling put_page() directly. This will allow de-duplicating the prefetch code between indirect and direct MMUs. Note, there's a small functional change as kvm_release_page_clean() marks the page/folio as accessed. While it's not strictly guaranteed that the guest will access the page, KVM won't intercept guest accesses, i.e. won't mark the page accessed if it _is_ accessed by the guest (unless A/D bits are disabled, but running without A/D bits is effectively limited to pre-HSW Intel CPUs). Signed-off-by: Sean Christopherson --- arch/x86/kvm/mmu/mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 4d30920f653d..0def1444c01c 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -2919,7 +2919,7 @@ static int direct_pte_prefetch_many(struct kvm_vcpu *vcpu, for (i = 0; i < ret; i++, gfn++, start++) { mmu_set_spte(vcpu, slot, start, access, gfn, page_to_pfn(pages[i]), NULL); - put_page(pages[i]); + kvm_release_page_clean(pages[i]); } return 0;