From: Sean Christopherson <seanjc@google.com>
To: sashiko-reviews@lists.linux.dev
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v4 4/5] KVM: guest_memfd: Establish memslot<=>guest_memfd bindings *after* memslot is ready
Date: Mon, 21 Sep 2026 14:27:38 -0700 [thread overview]
Message-ID: <arGhSlb-q8RkDiCO@google.com> (raw)
In-Reply-To: <20260921211941.5E8A91F000FF@smtp.kernel.org>
On Mon, Sep 21, 2026, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> > --- a/virt/kvm/kvm_main.c
> > +++ b/virt/kvm/kvm_main.c
> [ ... ]
> > @@ -1944,6 +1945,15 @@ static int kvm_set_memslot(struct kvm *kvm,
> > r = kvm_prepare_memory_region(kvm, old, new, change);
> > if (r)
> > goto err;
> >
> > + if (change == KVM_MR_CREATE && (new->flags & KVM_MEM_GUEST_MEMFD)) {
> > + r = kvm_gmem_bind(kvm, new, gmem_fd, gmem_offset);
>
> [Severity: High]
> Does this new initialization order break guest_memfd creation on arm64?
>
> By moving the kvm_gmem_bind() call to execute after kvm_prepare_memory_region(),
> the KVM_MEMSLOT_GMEM_ONLY flag is not populated in time for the architecture
> specific hooks.
>
> In virt/kvm/guest_memfd.c:kvm_gmem_bind(), the flag is assigned:
>
> if (kvm_gmem_supports_mmap(inode))
> slot->flags |= KVM_MEMSLOT_GMEM_ONLY;
>
> Because kvm_prepare_memory_region() now runs before this assignment, the
> architecture hook in arch/arm64/kvm/mmu.c:kvm_arch_prepare_memory_region()
> evaluates the flag before it is set:
>
> if (kvm_slot_has_gmem(new) && !kvm_memslot_is_gmem_only(new))
> return -EINVAL;
Argh, all that time spent trying to avoid adding a "prepare" phase to gmem, only
for it to be all for naught.
next prev parent reply other threads:[~2026-09-21 21:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 21:06 [PATCH v4 0/5] KVM: guest_memfd: Fix binding bugs Sean Christopherson
2026-09-21 21:06 ` [PATCH v4 1/5] KVM: guest_memfd: Gracefully handle xarray errors when binding a memslot Sean Christopherson
2026-09-21 21:06 ` [PATCH v4 2/5] KVM: Use goto to handle errors during memslot preparation Sean Christopherson
2026-09-21 21:06 ` [PATCH v4 3/5] KVM: Only bind memslot to guest_memfd instance for CREATE operations Sean Christopherson
2026-09-21 21:06 ` [PATCH v4 4/5] KVM: guest_memfd: Establish memslot<=>guest_memfd bindings *after* memslot is ready Sean Christopherson
2026-09-21 21:19 ` sashiko-bot
2026-09-21 21:27 ` Sean Christopherson [this message]
2026-09-21 21:06 ` [PATCH v4 5/5] KVM: guest_memfd: Drop superfluous WRITE_ONCE() when binding a memslot Sean Christopherson
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=arGhSlb-q8RkDiCO@google.com \
--to=seanjc@google.com \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.