From: sashiko-bot@kernel.org
To: "Sean Christopherson" <seanjc@google.com>
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 21:19:40 +0000 [thread overview]
Message-ID: <20260921211941.5E8A91F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260921210616.1024168-5-seanjc@google.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] kvm: arm64 guest_memfd creation always fails with -EINVAL
--
commit 4ef8ddb233e05072a60b26ea82b2f5c73a298a71
Author: Sean Christopherson <seanjc@google.com>
KVM: guest_memfd: Establish memslot<=>guest_memfd bindings *after* memslot is ready
This patch delays binding a memslot to a guest_memfd instance until after
the memslot is prepared. It accomplishes this by moving the kvm_gmem_bind()
call directly into kvm_set_memslot(), running it after the call to
kvm_prepare_memory_region().
Closes: https://lore.kernel.org/all/20260826170551.BEF801F000E9@smtp.kernel.org
> 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;
Will this cause all userspace attempts to create a guest_memfd memslot via
KVM_SET_USER_MEMORY_REGION2 on arm64 to unconditionally fail with -EINVAL?
> + if (r) {
> + kvm_arch_free_memslot(kvm, new);
> + kvm_destroy_dirty_bitmap(new);
> + goto err;
> + }
> + }
> +
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260921210616.1024168-1-seanjc@google.com?part=4
next prev parent reply other threads:[~2026-09-21 21:19 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 [this message]
2026-09-21 21:27 ` Sean Christopherson
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=20260921211941.5E8A91F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=seanjc@google.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