From: sashiko-bot@kernel.org
To: "Shivank Garg" <shivankg@amd.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v3 4/9] KVM: guest_memfd: add GUEST_MEMFD_FLAG_MIGRATABLE
Date: Wed, 05 Aug 2026 07:08:46 +0000 [thread overview]
Message-ID: <20260805070846.D3B281F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260805-shivank-gmem-migrate-v3-4-00d8bdec4e1d@amd.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Global capability check for KVM_CAP_GUEST_MEMFD_FLAGS falsely advertises GUEST_MEMFD_FLAG_MIGRATABLE on unsupported architectures.
- [Low] Typo in API documentation for GUEST_MEMFD_FLAG_MIGRATABLE.
--
--- Patch [4]: [PATCH v3 4/9] KVM: guest_memfd: add GUEST_MEMFD_FLAG_MIGRATABLE ---
commit f12765f58cf3ad7c38abcf69c609570a66578e93
Author: Shivank Garg <shivankg@amd.com>
KVM: guest_memfd: add GUEST_MEMFD_FLAG_MIGRATABLE
This patch adds architecture support checks and a new flag,
GUEST_MEMFD_FLAG_MIGRATABLE, to allow the MM to migrate guest_memfd folios.
It updates the mapping GFP mask and removes a redundant WARN_ON_ONCE.
> diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst
> index e3003a241d5b0..976921527ef9a 100644
> --- a/Documentation/virt/kvm/api.rst
> +++ b/Documentation/virt/kvm/api.rst
> @@ -6461,6 +6461,9 @@ specified via KVM_CREATE_GUEST_MEMFD. Currently defined flags:
> without INIT_SHARED will be marked private).
> Shared memory can be faulted into host userspace
> page tables. Private memory cannot.
> + GUEST_MEMFD_FLAG_MIGRATABLE Allow MM to migrate guest_memfd folios.
> + Availability is architecture sepecific. Without
[Severity: Low]
This isn't a bug, but there is a typo here (sepecific instead of specific).
> + this flag, folios remain unmovable.
> ============================ ================================================
[ ... ]
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 47cb9eba113b1..7087b0b8f973f 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -14130,6 +14130,15 @@ bool kvm_arch_supports_gmem_init_shared(struct kvm *kvm)
> return !kvm_arch_has_private_mem(kvm);
> }
>
> +/*
> + * Migration of guest_memfd with private memory is not supported yet
> + * as this may require architecture-specific handling.
> + */
> +bool kvm_arch_supports_gmem_migration(struct kvm *kvm)
> +{
> + return !kvm_arch_has_private_mem(kvm);
> +}
[ ... ]
> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index ab8cfaec82d31..7b2f15b219705 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -731,6 +731,7 @@ static inline bool kvm_arch_has_private_mem(struct kvm *kvm)
>
> #ifdef CONFIG_KVM_GUEST_MEMFD
> bool kvm_arch_supports_gmem_init_shared(struct kvm *kvm);
> +bool kvm_arch_supports_gmem_migration(struct kvm *kvm);
>
> static inline u64 kvm_gmem_get_supported_flags(struct kvm *kvm)
> {
> @@ -738,6 +739,9 @@ static inline u64 kvm_gmem_get_supported_flags(struct kvm *kvm)
>
> if (!kvm || kvm_arch_supports_gmem_init_shared(kvm))
> flags |= GUEST_MEMFD_FLAG_INIT_SHARED;
> + if (IS_ENABLED(CONFIG_MIGRATION) &&
> + (!kvm || kvm_arch_supports_gmem_migration(kvm)))
> + flags |= GUEST_MEMFD_FLAG_MIGRATABLE;
[Severity: Medium]
When userspace queries KVM_CAP_GUEST_MEMFD_FLAGS on the global /dev/kvm
file descriptor, kvm is NULL. Does the !kvm check here cause the API to
unconditionally advertise GUEST_MEMFD_FLAG_MIGRATABLE for all architectures
where CONFIG_MIGRATION is enabled?
If so, architectures that do not support migration (relying on the weak
default returning false) would advertise support globally, but then return
-EINVAL when userspace actually attempts to create a guest_memfd with this
flag.
If we drop the !kvm bypass to fix the capability advertisement, would the
x86 implementation of kvm_arch_supports_gmem_migration() shown above need an
explicit check for a NULL kvm pointer before passing it to
kvm_arch_has_private_mem()?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260805-shivank-gmem-migrate-v3-0-00d8bdec4e1d@amd.com?part=4
next prev parent reply other threads:[~2026-08-05 7:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 6:40 [PATCH v3 0/9] KVM: guest_memfd: folio migration for non-confidential VMs Shivank Garg
2026-08-05 6:40 ` [PATCH v3 1/9] KVM: guest_memfd: take the invalidate lock when unbinding a dying file Shivank Garg
2026-08-05 7:06 ` sashiko-bot
2026-08-05 6:40 ` [PATCH v3 2/9] mm: split AS_UNMOVABLE back out of AS_INACCESSIBLE Shivank Garg
2026-08-05 6:40 ` [PATCH v3 3/9] KVM: guest_memfd: implement folio migration for non-confidential VMs Shivank Garg
2026-08-05 7:09 ` sashiko-bot
2026-08-05 6:40 ` [PATCH v3 4/9] KVM: guest_memfd: add GUEST_MEMFD_FLAG_MIGRATABLE Shivank Garg
2026-08-05 7:08 ` sashiko-bot [this message]
2026-08-05 6:40 ` [PATCH v3 5/9] KVM: selftests: fix maxnode arguments in xapic_ipi_test Shivank Garg
2026-08-05 6:40 ` [PATCH v3 6/9] KVM: selftests: use BITS_PER_TYPE() for NUMA masks Shivank Garg
2026-08-05 6:40 ` [PATCH v3 7/9] KVM: selftests: add get_numa_mem_nodes() Shivank Garg
2026-08-05 6:40 ` [PATCH v3 8/9] KVM: selftests: use allowed NUMA nodes in guest_memfd_test Shivank Garg
2026-08-05 6:40 ` [PATCH v3 9/9] KVM: selftests: exercise guest_memfd folio migration Shivank Garg
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=20260805070846.D3B281F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=shivankg@amd.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