From patchwork Fri Jul 26 23:52:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13743531 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 4E100C3DA49 for ; Sat, 27 Jul 2024 00:21:59 +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=zSr/S7cQW+jg6+5Yur5d69GSxQ0D+3E/XB18qDPP3eA=; b=Zco3tLUuSrMOEumUlx1uqYYlvB Q+FW8aYXEr1wgvcIllzBTLbqFs8n645+1fpL3Gje5rXfa4CIZkTrCX2u/ATLu1o3JwIevioJJV+1N +2H485QqUUNyuVhdIfnUrhvVu1QV/z61E8RIpIwp79xqq2PYy40/eVOXy5+IJmt5BmU7GZm+a2dXe HbwPfh3DUV/YovBR0ft1b+mOOqDp/UJ4SirYAmweeJuShkX0fEyX5coYRkXmYdwg+GkpA2Fwv5fIh 9RfnTIVd2Xdl1LB4KPyXkwIIXZHfK1q/VjFE9JcB541VJ1TwrmxVni/f4jBuuzcLYhjKh0mSRP4lQ 5UZTc90w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXVC2-00000005elE-1Z6s; Sat, 27 Jul 2024 00:21:50 +0000 Received: from mail-pf1-x44a.google.com ([2607:f8b0:4864:20::44a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXUlY-00000005Qc0-1VFf for linux-arm-kernel@lists.infradead.org; Fri, 26 Jul 2024 23:54:32 +0000 Received: by mail-pf1-x44a.google.com with SMTP id d2e1a72fcca58-70d1a9bad5dso1374482b3a.0 for ; Fri, 26 Jul 2024 16:54:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1722038067; x=1722642867; 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=zSr/S7cQW+jg6+5Yur5d69GSxQ0D+3E/XB18qDPP3eA=; b=Yn2ggu6BQKcMFB9DloD1NFvFA9WT1o9AlWGknyXfGwG66zrtNAvRhYE2xZMC0UhBNd Hfdz0YWI9rVcQXoycJxQmWwG8+QUP5MvwQTECGM0HuaAYE2ZWQ3cfgjV+iKj4NSwp4gc ng2LYUanNE8VfqgI3cJkwp14zLswAmvuRvpupZkkZO463l8z5Fg0unzetH1RzAOe02rQ H8rYQl9WExMEn+zdhXxOQTnIfBnpRBgm3HXmXSMNs7IECkK5jHNRv0hHamL+4SXPlYlc AdV4NxIUVIpTd4NF5g+jOmVmzA8JYHkUWPQgQR/3GqZI6soPGtrozOd0sMWpRgvGm+6D Ydlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722038067; x=1722642867; 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=zSr/S7cQW+jg6+5Yur5d69GSxQ0D+3E/XB18qDPP3eA=; b=TfzbVfpEFywEF08CKLmASwyUcKV5quqau5kJvdDYR3G1JmwArQDwKGFy6QAWULEStb El+pjIhVZ+O/g5gYrKVWneEp9pmWl7SlYDfYE7pYBp91Xgi2jdMKMiT6jb3cB1jPZ0Zc xdsn2LvNtGO6Av5t0OIACHOyJPUVxnYwrS8IgYtryQFAWwAD0dIerdlyugaQiIz/2TDT 0+sNH50BziKpKDFaacWHUzEGMTBkNy25BQHZjYRltO/siyKe4JGn0ixBsE9L3bj7+Y+v uPki88zRJ2e+EmwePVysdE2GH+1l/IpB6PfhtIPm1SJ8Xcw9KDAJuSpTGVLlpEjDxfnk eAyA== X-Forwarded-Encrypted: i=1; AJvYcCWy64zJL/dLwvnSjw93rAIv6KaPVegXAJuIxfq8PAXt8aL6p9oTYS2KsDGyuBU3k8w/o8Wq1uOOaLFLSlJox2sp0I3k072XbETCw2RUeiE+bkNpvaE= X-Gm-Message-State: AOJu0YynzcJvg7U2+z4jYpefNSadSG5KD51nGnUju4wxdJgiG0uFDd9l 3trOCEm59qgTSuIXA16GgXHs7VEP5bVim0jn8PEfkGgbWyvxOpt52qQIKmA0x8I9hEliSAEWM0n fjg== X-Google-Smtp-Source: AGHT+IEvvOLEi17q5BnKGFU80vyNCkxL+K4ME2VW/zA0UgmW3Jn60esm+Gg/1wQhRB2++SmF9ZjJ4yJ/TXU= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6a00:238d:b0:70e:98e2:fdae with SMTP id d2e1a72fcca58-70ecee6db73mr19809b3a.0.1722038066705; Fri, 26 Jul 2024 16:54:26 -0700 (PDT) Date: Fri, 26 Jul 2024 16:52:02 -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-54-seanjc@google.com> Subject: [PATCH v12 53/84] KVM: PPC: e500: Use __kvm_faultin_pfn() to handle page faults 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_165428_577350_0427765F X-CRM114-Status: GOOD ( 13.37 ) 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 Convert PPC e500 to use __kvm_faultin_pfn()+kvm_release_faultin_page(), and continue the inexorable march towards the demise of kvm_pfn_to_refcounted_page(). Signed-off-by: Sean Christopherson --- arch/powerpc/kvm/e500_mmu_host.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/kvm/e500_mmu_host.c b/arch/powerpc/kvm/e500_mmu_host.c index 334dd96f8081..e5a145b578a4 100644 --- a/arch/powerpc/kvm/e500_mmu_host.c +++ b/arch/powerpc/kvm/e500_mmu_host.c @@ -322,6 +322,7 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500, { struct kvm_memory_slot *slot; unsigned long pfn = 0; /* silence GCC warning */ + struct page *page = NULL; unsigned long hva; int pfnmap = 0; int tsize = BOOK3E_PAGESZ_4K; @@ -443,7 +444,7 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500, if (likely(!pfnmap)) { tsize_pages = 1UL << (tsize + 10 - PAGE_SHIFT); - pfn = gfn_to_pfn_memslot(slot, gfn); + pfn = __kvm_faultin_pfn(slot, gfn, FOLL_WRITE, NULL, &page); if (is_error_noslot_pfn(pfn)) { if (printk_ratelimit()) pr_err("%s: real page not found for gfn %lx\n", @@ -488,8 +489,6 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500, } } writable = kvmppc_e500_ref_setup(ref, gtlbe, pfn, wimg); - if (writable) - kvm_set_pfn_dirty(pfn); kvmppc_e500_setup_stlbe(&vcpu_e500->vcpu, gtlbe, tsize, ref, gvaddr, stlbe); @@ -498,8 +497,7 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500, kvmppc_mmu_flush_icache(pfn); out: - /* Drop refcount on page, so that mmu notifiers can clear it */ - kvm_release_pfn_clean(pfn); + kvm_release_faultin_page(kvm, page, !!ret, writable); spin_unlock(&kvm->mmu_lock); return ret; }