From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E966606A33E for ; Fri, 4 Dec 2026 11:58:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=3Xo3Zps1; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=afi5MOg+ DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=c+/pH5yWxWiH2ahbs7OZf4q2eQ4k04q/ydOkOUHpwLI=; b=3Xo3Zps16bjaOC pgKcxGyY9MoakKXnKrxNVsSP6bm1ycB897f3op4Xrkk158nbrWckMiGTcFX6StUZs6I+0z2UlOwhb kjc698YxZWqBcq5o9ypHHrZ8n1+rauP1n4riSwz4I/eugX88mthCDd0K5xdH3+V9Qll/V8e+7PLS8 YX2t3x3Y+bgVF/d6bNLhnJjX44HWMhwFS/LWanFC9srciWhduPtk5rROJu3836a5BRGwqhLELlu0t 18s/bAeRR4wNfthGFhg+SiIuRUMOQKN0aQhG6qJ8SiyFwXBQs1FSvtyjrqU/mLwXaGmum4RmiopWD XkxcDLVO1xEIsfxKNSnQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZRvF-00000000CTH-2uyz; Fri, 04 Dec 2026 11:57:53 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZRvB-00000000CRV-3l6C for linux-arm-kernel@lists.infradead.org; Fri, 04 Dec 2026 11:57:51 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4020214BF; Fri, 4 Dec 2026 03:57:46 -0800 (PST) Received: from e122027.cambridge.arm.com (e122027.cambridge.arm.com [10.0.128.193]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7A57C3F632; Fri, 4 Dec 2026 03:57:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1796385469; bh=1ZOnc+z8Cv/EciN3cVm2fS6/ALnIPbwQVb4INNoTBYo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=afi5MOg+ArBe2HbCsXxr3R1Bc0DFcDrrVlZ65zB01QN1sEvkMuULCIXU/qjbn8Jen L2g+2aca5+szUnXjKfWOsQtCGBor+fbH2fiz801f3DAQ5D6zBrag+IuJAeNz1+NHgn sWWohl1Abvto21WLqju2lIK4HmHYBbWAe+FFMRCc= From: Steven Price To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: Suzuki K Poulose , Catalin Marinas , Marc Zyngier , Will Deacon , James Morse , Oliver Upton , Zenghui Yu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Joey Gouly , Alexandru Elisei , Christoffer Dall , Fuad Tabba , linux-coco@lists.linux.dev, Ganapatrao Kulkarni , Gavin Shan , Shanker Donthineni , Alper Gun , "Aneesh Kumar K . V" , Emi Kisanuki , Vishal Annapurve , WeiLin.Chang@arm.com, Lorenzo Pieralisi , Kohei Enju , Steven Price , Fuad Tabba Subject: [PATCH v6 02/11] KVM: arm64: Pass range filter to stage2_unmap_range Date: Fri, 4 Dec 2026 11:57:09 +0000 Message-ID: <20261204115725.45272-3-steven.price@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261204115725.45272-1-steven.price@arm.com> References: <20261204115725.45272-1-steven.price@arm.com> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261204_035750_024879_F22C9FE3 X-CRM114-Status: GOOD ( 13.59 ) X-Spam-Score: -4.4 (----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-19.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 From: Suzuki K Poulose With the introduction of private memory support, we need to handle invalidation requests with filters for a given type. Pass the range filter down to the stage-2 unmap operation. Signed-off-by: Suzuki K Poulose Signed-off-by: Steven Price Reviewed-by: Fuad Tabba --- arch/arm64/include/asm/kvm_host.h | 4 +++- arch/arm64/kvm/mmu.c | 31 +++++++++++++++++++++++-------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 8438251e1d1b..9d6258b213d1 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -233,6 +233,7 @@ struct kvm_vcpu_ops { }; struct kvm_gfn_range; +enum kvm_gfn_range_filter; struct kvm_s2_fault_desc; struct kvm_vm_s2_ops { @@ -243,7 +244,8 @@ struct kvm_vm_s2_ops { u64 nr_pages); void (*vm_stage2_unmap_range)(struct kvm_s2_mmu *mmu, phys_addr_t start, u64 size, - bool may_block); + bool may_block, + enum kvm_gfn_range_filter filter); int (*vm_mem_abort)(const struct kvm_s2_fault_desc *s2fd); }; diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 7ebc8959d6fd..1c72c7a622b3 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -324,7 +324,8 @@ static int kvm_pgtable_stage2_unmap_tracked(struct kvm_pgtable *pgt, static void kvm_vm_stage2_unmap_range(struct kvm_s2_mmu *mmu, phys_addr_t start, - u64 size, bool may_block) + u64 size, bool may_block, + enum kvm_gfn_range_filter filter) { struct kvm *kvm = kvm_s2_mmu_to_kvm(mmu); int (*fn)(struct kvm_pgtable *, u64, u64); @@ -339,14 +340,16 @@ static void kvm_vm_stage2_unmap_range(struct kvm_s2_mmu *mmu, static void pkvm_stage2_unmap_range(struct kvm_s2_mmu *mmu, phys_addr_t start, - u64 size, bool may_block) + u64 size, bool may_block, + enum kvm_gfn_range_filter filter) { WARN_ON(stage2_apply_range(mmu, start, start + size, pkvm_pgtable_stage2_unmap, may_block)); } static void no_stage2_unmap_range(struct kvm_s2_mmu *mmu, - phys_addr_t start, u64 size, bool may_block) + phys_addr_t start, u64 size, bool may_block, + enum kvm_gfn_range_filter filter) { } @@ -388,25 +391,36 @@ static int kvm_pgtable_stage2_unmap_tracked(struct kvm_pgtable *pgt, u64 addr, u } /** - * kvm_stage2_unmap_range -- Clear stage2 page table entries to unmap a range + * kvm_stage2_unmap_range_filter -- Clear stage2 page table entries to unmap a + * range * @mmu: The KVM stage-2 MMU pointer * @start: The intermediate physical base address of the range to unmap * @size: The size of the area to unmap * @may_block: Whether or not we are permitted to block + * @filter: Filter for the ipa range (private and/or shared) * * Clear a range of stage-2 mappings, lowering the various ref-counts. Must * be called while holding mmu_lock otherwise another faulting VCPU may * come in and mess with things behind our backs. */ -void kvm_stage2_unmap_range(struct kvm_s2_mmu *mmu, phys_addr_t start, - u64 size, bool may_block) +static void kvm_stage2_unmap_range_filter(struct kvm_s2_mmu *mmu, phys_addr_t start, + u64 size, bool may_block, + enum kvm_gfn_range_filter filter) { struct kvm *kvm = kvm_s2_mmu_to_kvm(mmu); lockdep_assert_held_write(&kvm->mmu_lock); WARN_ON(size & ~PAGE_MASK); - kvm->arch.vm_s2_ops->vm_stage2_unmap_range(mmu, start, size, may_block); + kvm->arch.vm_s2_ops->vm_stage2_unmap_range(mmu, start, size, + may_block, filter); +} + +void kvm_stage2_unmap_range(struct kvm_s2_mmu *mmu, phys_addr_t start, + u64 size, bool may_block) +{ + kvm_stage2_unmap_range_filter(mmu, start, size, may_block, + KVM_FILTER_PRIVATE | KVM_FILTER_SHARED); } void kvm_stage2_flush_range(struct kvm_s2_mmu *mmu, phys_addr_t addr, phys_addr_t end) @@ -2597,7 +2611,8 @@ bool kvm_unmap_gfn_range(struct kvm *kvm, struct kvm_gfn_range *range) if (!kvm->arch.mmu.pgt) return false; - kvm_stage2_unmap_range(&kvm->arch.mmu, gpa, size, may_block); + kvm_stage2_unmap_range_filter(&kvm->arch.mmu, gpa, size, may_block, + range->attr_filter); kvm_nested_unmap_cipa_range(kvm, gpa, size, may_block); return false; -- 2.43.0