From: Alexandru Elisei <alexandru.elisei@arm.com>
To: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Fuad Tabba <fuad.tabba@linux.dev>,
kvm@vger.kernel.org, kvmarm@lists.linux.dev,
Will Deacon <will@kernel.org>,
Andre Przywara <andre.przywara@arm.com>,
Oliver Upton <oliver.upton@linux.dev>,
Marc Zyngier <maz@kernel.org>, Fuad Tabba <tabba@google.com>
Subject: Re: [PATCH kvmtool v1 3/5] Use kvm_userspace_memory_region2 for all memory registration
Date: Mon, 6 Jul 2026 11:57:01 +0100 [thread overview]
Message-ID: <akuJ_eFvDHLpiU-Y@raptor> (raw)
In-Reply-To: <556ab72c-f440-434b-a24d-84200bd25842@arm.com>
Hi Fuad, Suzuki,
On Mon, Jul 06, 2026 at 11:23:47AM +0100, Suzuki K Poulose wrote:
> Hi Fuad
>
> On 06/07/2026 09:35, Fuad Tabba wrote:
> > Switch kvm__register_mem() and kvm__destroy_mem() from
> > kvm_userspace_memory_region to kvm_userspace_memory_region2 and
> > KVM_SET_USER_MEMORY_REGION2 unconditionally. The v2 struct is a
> > superset; when the extra fields are zero, the ioctl behaves
> > identically to v1.
>
> Doesn't this break using this on older KVM implementations ? Not that I
> care, but do others care ?
I haven't had the time to review the series, but I do care about this
change, I find myself from time to time testing old kernels.
I think the two ioctls can coexist without much maintenance burden. For
example, the usage of KVM_SET_USER_MEMORY_REGION can be kept as-is and
KVM_SET_USER_MEMORY_REGION2 can be used only for guest_memfd in
kvm__register_mem().
Thoughts?
Thanks,
Alex
>
> Cheers
> Suzuki
>
>
> >
> > This prepares for adding guest_memfd support.
> >
> > Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
> > ---
> > kvm.c | 11 +++++------
> > 1 file changed, 5 insertions(+), 6 deletions(-)
> >
> > diff --git a/kvm.c b/kvm.c
> > index 95ccfcb..8a7fd09 100644
> > --- a/kvm.c
> > +++ b/kvm.c
> > @@ -189,7 +189,7 @@ core_exit(kvm__exit);
> > int kvm__destroy_mem(struct kvm *kvm, u64 guest_phys, u64 size,
> > void *userspace_addr)
> > {
> > - struct kvm_userspace_memory_region mem;
> > + struct kvm_userspace_memory_region2 mem;
> > struct kvm_mem_bank *bank;
> > int ret;
> > @@ -213,14 +213,14 @@ int kvm__destroy_mem(struct kvm *kvm, u64 guest_phys, u64 size,
> > goto out;
> > }
> > - mem = (struct kvm_userspace_memory_region) {
> > + mem = (struct kvm_userspace_memory_region2) {
> > .slot = bank->slot,
> > .guest_phys_addr = guest_phys,
> > .memory_size = 0,
> > .userspace_addr = (unsigned long)userspace_addr,
> > };
> > - ret = ioctl(kvm->vm_fd, KVM_SET_USER_MEMORY_REGION, &mem);
> > + ret = ioctl(kvm->vm_fd, KVM_SET_USER_MEMORY_REGION2, &mem);
> > if (ret < 0) {
> > ret = -errno;
> > goto out;
> > @@ -239,7 +239,6 @@ out:
> > int kvm__register_mem(struct kvm *kvm, u64 guest_phys, u64 size,
> > void *userspace_addr, enum kvm_mem_type type)
> > {
> > - struct kvm_userspace_memory_region mem;
> > struct kvm_mem_bank *merged = NULL;
> > struct kvm_mem_bank *bank;
> > struct list_head *prev_entry;
> > @@ -320,7 +319,7 @@ int kvm__register_mem(struct kvm *kvm, u64 guest_phys, u64 size,
> > flags |= KVM_MEM_READONLY;
> > if (type != KVM_MEM_TYPE_RESERVED) {
> > - mem = (struct kvm_userspace_memory_region) {
> > + struct kvm_userspace_memory_region2 mem = {
> > .slot = slot,
> > .flags = flags,
> > .guest_phys_addr = guest_phys,
> > @@ -328,7 +327,7 @@ int kvm__register_mem(struct kvm *kvm, u64 guest_phys, u64 size,
> > .userspace_addr = (unsigned long)userspace_addr,
> > };
> > - ret = ioctl(kvm->vm_fd, KVM_SET_USER_MEMORY_REGION, &mem);
> > + ret = ioctl(kvm->vm_fd, KVM_SET_USER_MEMORY_REGION2, &mem);
> > if (ret < 0) {
> > ret = -errno;
> > goto out;
>
next prev parent reply other threads:[~2026-07-06 10:57 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 8:35 [PATCH kvmtool v1 0/5] Add guest_memfd support for arm64 Fuad Tabba
2026-07-06 8:35 ` [PATCH kvmtool v1 1/5] Initialize the return value in kvm__for_each_mem_bank() Fuad Tabba
2026-07-06 8:35 ` [PATCH kvmtool v1 2/5] Remove newline from end of die() aborts Fuad Tabba
2026-07-06 10:53 ` Suzuki K Poulose
2026-07-06 10:57 ` Fuad Tabba
2026-07-06 8:35 ` [PATCH kvmtool v1 3/5] Use kvm_userspace_memory_region2 for all memory registration Fuad Tabba
2026-07-06 10:23 ` Suzuki K Poulose
2026-07-06 10:41 ` Fuad Tabba
2026-07-06 10:46 ` Will Deacon
2026-07-06 10:47 ` Fuad Tabba
2026-07-06 10:57 ` Alexandru Elisei [this message]
2026-07-06 10:59 ` Fuad Tabba
2026-07-06 8:35 ` [PATCH kvmtool v1 4/5] Add guest_memfd support to kvm__register_mem() Fuad Tabba
2026-07-06 11:00 ` Suzuki K Poulose
2026-07-06 11:13 ` Suzuki K Poulose
2026-07-06 11:25 ` Fuad Tabba
2026-07-06 12:34 ` Suzuki K Poulose
2026-07-06 8:35 ` [PATCH kvmtool v1 5/5] arm64: Add --guest-memfd option to back guest RAM with guest_memfd Fuad Tabba
2026-07-06 11:18 ` Suzuki K Poulose
2026-07-06 11:24 ` Fuad Tabba
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=akuJ_eFvDHLpiU-Y@raptor \
--to=alexandru.elisei@arm.com \
--cc=andre.przywara@arm.com \
--cc=fuad.tabba@linux.dev \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=suzuki.poulose@arm.com \
--cc=tabba@google.com \
--cc=will@kernel.org \
/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