From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: Sean Christopherson <seanjc@google.com>
Cc: Alexandru Elisei <alexandru.elisei@arm.com>,
pbonzini@redhat.com, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org, maz@kernel.org, oupton@kernel.org,
suzuki.poulose@arm.com, kvmarm@lists.linux.dev,
linux-arm-kernel@lists.infradead.org, david@kernel.org,
mark.rutland@arm.com, ackerleytng@google.com
Subject: Re: [PATCH v2] KVM: Ignore MMU notifiers for guest_memfd-only memslots
Date: Wed, 4 Nov 2026 18:06:12 +0000 [thread overview]
Message-ID: <autwsR83Ii-tRrqF@gremlin> (raw)
In-Reply-To: <anxAGkdyPYXBlS00@raptor>
[updated David's email address to @kernel.org]
On Wed, Aug 12, 2026 at 10:42:50AM +0100, Alexandru Elisei wrote:
[ ... ]
> On Fri, Jul 24, 2026 at 12:52:20PM -0700, Sean Christopherson wrote:
> > It'll probably take me a few weeks to circle back to this, as I finally crawled
> > out from underneath a pile of urgent and am just now getting back into review
> > mode, but this is fairly high on my todo list, so with luck we might still squeeze
> > this into 7.3.
Hey Sean,
I wondered whether you'd had a chance to look at this?
After discussing this with Marc and Alex it is clear that this is really a
blocker for Alex's SPE series, as we need a sensible means of ensuring
that stage-2 mappings stay in place.
So ideally would prefer to get something like this in in the next cycle,
if you don't have any objections to it? :)
If it'd be easier, I think a smaller version of the same patch would also
give us what we need? I.e. your snippet from June with the page ageing part
dropped, as below.
Thanks!
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index e7fc94e2910a..a6f37bdb0902 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -264,6 +264,7 @@ union kvm_mmu_notifier_arg {
enum kvm_gfn_range_filter {
KVM_FILTER_SHARED = BIT(0),
KVM_FILTER_PRIVATE = BIT(1),
+ KVM_FILTER_USERSPACE_MAPPINGS = BIT(2),
};
struct kvm_gfn_range {
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index cf4cb586f140..6fc3b443c305 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -616,8 +616,13 @@ static __always_inline kvm_mn_ret_t kvm_handle_hva_range(struct kvm *kvm,
/*
* HVA-based notifications aren't relevant to private
* mappings as they don't have a userspace mapping.
+ *
+ * Memslots where guest_memfd is the only memory
+ * provider can also safely ignore changes to the
+ * userspace mapping.
*/
- gfn_range.attr_filter = KVM_FILTER_SHARED;
+ gfn_range.attr_filter = KVM_FILTER_SHARED |
+ KVM_FILTER_USERSPACE_MAPPINGS;
/*
* {gfn(page) | page intersects with [hva_start, hva_end)} =
@@ -724,6 +729,17 @@ void kvm_mmu_invalidate_range_add(struct kvm *kvm, gfn_t start, gfn_t end)
bool kvm_mmu_unmap_gfn_range(struct kvm *kvm, struct kvm_gfn_range *range)
{
kvm_mmu_invalidate_range_add(kvm, range->start, range->end);
+
+ /*
+ * When reacting to changes in userspace mappings, don't unmap memslots
+ * that are guest_memfd-only, in which case KVM's MMU mappings are
+ * pulled directly from guest_memfd, i.e. don't depend on the userspace
+ * mappings.
+ */
+ if (range->attr_filter & KVM_FILTER_USERSPACE_MAPPINGS &&
+ kvm_memslot_is_gmem_only(range->slot))
+ return false;
+
return kvm_unmap_gfn_range(kvm, range);
}
--
Cheers, Lorenzo
prev parent reply other threads:[~2026-11-04 18:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 16:04 Alexandru Elisei
2026-07-24 19:52 ` Sean Christopherson
2026-08-12 9:42 ` Alexandru Elisei
2026-11-04 18:06 ` Lorenzo Stoakes (ARM) [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=autwsR83Ii-tRrqF@gremlin \
--to=ljs@kernel.org \
--cc=ackerleytng@google.com \
--cc=alexandru.elisei@arm.com \
--cc=david@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=suzuki.poulose@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®