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: 1965490 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=gretKhFh; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=iBeXJb+g; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WW4jK2WCbz1yY9 for ; Sat, 27 Jul 2024 10:08:53 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uK0pX+kwS5Eu2lYD9Ay2uXDDqhtwsv4x57fedoTiHaw=; b=gretKhFh/0VxPZ elQd7KDAEFmivzgXaVLt2QFcV9/qIGA9qHKkOFuvzqLsECEmA/r5yGSCEytb7yzQPo7esFnV97MoR RwA0A5IEnv2P1XCHcWb7Ag/jyBIsXDOLPznyTdfTQ5oU5YI5ihAu3PM/cJKE7pm19F4sIJ2UFWn2I hy01uLXUnR9Rw2mmSSCH4DfQwDvdnGwo/g6qey32/YT9q/NyG3WB75JGkLDdR/SuCBFoj7O4rVhe4 Qhefm6jzkDbD1p+Gs/8wMoSj+MluWv9bjQ1T/HawcMQvwKA+KPG6FHEBKiL8bwNCx60njm3ltNoOA DQu+7mZ4T4A93cfNj8Xw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXUzU-00000005YUT-06xF; Sat, 27 Jul 2024 00:08:52 +0000 Received: from mail-pg1-x549.google.com ([2607:f8b0:4864:20::549]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXUl3-00000005QC5-21Na for kvm-riscv@lists.infradead.org; Fri, 26 Jul 2024 23:53:59 +0000 Received: by mail-pg1-x549.google.com with SMTP id 41be03b00d2f7-7a242496838so1280387a12.3 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=QGB5MPbJiKvbHoQm2lqFOq3hASen0pD/JMvhyIA6irpvWinGYSuUmuIip3uRcmxyIs QfWcW3n9f5LVjwG19TXI5YIG/aDWM9xZC3QMwdr+fUe5PWphMiUXRxNm95mwX8cMnHO6 V1bYr107u1To4YtBtzeQmpwN0N+b+zX5A1UZxRo/W05/xdKUZpiLEYUMTYK0FS/UK6gS Pz4uh+uXUhmn+Sn7imXIsjtLpojAWDAYB/Kgh8RaYKnMhL4BMwroaFL/Kpw4cXg+N3nr p0EVC4XDSHQRfawHcy6n8WypRDPqfGx+hvFnEsbauokifJ2omP6pzHafdIKc2knaQt8D yJrg== X-Forwarded-Encrypted: i=1; AJvYcCXNornFCNsqdCMjypXeSRauVTR3WMq6EScaZJM1pQWJNlhf7PlE/33i/HCoBLXM2ovhFLCSAuwvaGebTEJKgP6WJdYhhSxEUIZIZFis2A== X-Gm-Message-State: AOJu0Yy6+W8BFVc5zoriPvyBsZ8px34ivtiChsffRJGA90Ud7QAk77fJ xLwVJMW7Rkc04qll3uvpM/zOA+Lxrg8O322Rn1EM9n3Sb9DmpdI5wC3/eKaZ2Vk3hxxsRIogeGO 8JA== 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_607892_AC1325D0 X-CRM114-Status: GOOD ( 11.52 ) X-Spam-Score: -9.5 (---------) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 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 [...] Content analysis details: (-9.5 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:549 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM welcome-list 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 DKIMWL_WL_MED DKIMwl.org - Medium trust sender X-BeenThere: kvm-riscv@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: "kvm-riscv" Errors-To: kvm-riscv-bounces+incoming=patchwork.ozlabs.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;