From: Sean Christopherson <seanjc@google.com>
To: Zenghui Yu <yuzenghui@huawei.com>
Cc: Zenghui Yu <zenghui.yu@linux.dev>,
Paolo Bonzini <pbonzini@redhat.com>,
Marc Zyngier <maz@kernel.org>,
Oliver Upton <oliver.upton@linux.dev>,
kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org,
Ira Weiny <ira.weiny@intel.com>, Gavin Shan <gshan@redhat.com>,
Shivank Garg <shivankg@amd.com>, Vlastimil Babka <vbabka@suse.cz>,
Xiaoyao Li <xiaoyao.li@intel.com>,
David Hildenbrand <david@redhat.com>,
Fuad Tabba <tabba@google.com>,
Ackerley Tng <ackerleytng@google.com>,
Tao Chan <chentao@kylinos.cn>,
James Houghton <jthoughton@google.com>
Subject: Re: [PATCH v17 24/24] KVM: selftests: Add guest_memfd testcase to fault-in on !mmap()'d memory
Date: Tue, 12 May 2026 08:53:12 -0700 [thread overview]
Message-ID: <agNM6KSlsFjOaSUv@google.com> (raw)
In-Reply-To: <c17d864a-42fc-afbe-345e-c728e2735d0c@huawei.com>
On Tue, May 12, 2026, Zenghui Yu wrote:
> Hi Sean,
>
> On 2026/4/18 0:47, Sean Christopherson wrote:
> >
> > Does this fix things for you? If so, I'll send a proper patch.
> >
> > diff --git a/tools/testing/selftests/kvm/guest_memfd_test.c b/tools/testing/selftests/kvm/guest_memfd_test.c
> > index ec7644aae999..c682bda722f9 100644
> > --- a/tools/testing/selftests/kvm/guest_memfd_test.c
> > +++ b/tools/testing/selftests/kvm/guest_memfd_test.c
> > @@ -510,9 +510,15 @@ static void test_guest_memfd_guest(void)
> > "Default VM type should support INIT_SHARED, supported flags = 0x%x",
> > vm_check_cap(vm, KVM_CAP_GUEST_MEMFD_FLAGS));
> >
> > + /*
> > + * Use the guest's page size for all accesses, e.g. to avoid having to
> > + * map multiple pages, but create the guest_memfd instance with the max
> > + * of the host or guest page size, as KVM requires gmem files to be
> > + * aligned to the host page size.
> > + */
> > size = vm->page_size;
> > - fd = vm_create_guest_memfd(vm, size, GUEST_MEMFD_FLAG_MMAP |
> > - GUEST_MEMFD_FLAG_INIT_SHARED);
> > + fd = vm_create_guest_memfd(vm, max(size, page_size), GUEST_MEMFD_FLAG_MMAP |
> > + GUEST_MEMFD_FLAG_INIT_SHARED);
> > vm_set_user_memory_region2(vm, slot, KVM_MEM_GUEST_MEMFD, gpa, size, NULL, fd, 0);
> >
> > mem = kvm_mmap(size, PROT_READ | PROT_WRITE, MAP_SHARED, fd);
>
> This results in another failure at
>
> | vm_set_user_memory_region2(vm, slot, KVM_MEM_GUEST_MEMFD, gpa, size,
> NULL, fd, 0);
Gah, the memslot size also needs to be a multiple of the host page size. I
actually tested on a CONFIG_ARM64_64K_PAGES=y kernel this time, patch incoming...
Thanks!
prev parent reply other threads:[~2026-05-12 15:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20250729225455.670324-1-seanjc@google.com>
[not found] ` <20250729225455.670324-25-seanjc@google.com>
[not found] ` <0064952b-048c-455d-ad89-e27e5cb82591@linux.dev>
[not found] ` <aeJkCGwsrRmuBikT@google.com>
2026-05-12 7:28 ` [PATCH v17 24/24] KVM: selftests: Add guest_memfd testcase to fault-in on !mmap()'d memory Zenghui Yu
2026-05-12 15:53 ` Sean Christopherson [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=agNM6KSlsFjOaSUv@google.com \
--to=seanjc@google.com \
--cc=ackerleytng@google.com \
--cc=chentao@kylinos.cn \
--cc=david@redhat.com \
--cc=gshan@redhat.com \
--cc=ira.weiny@intel.com \
--cc=jthoughton@google.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=pbonzini@redhat.com \
--cc=shivankg@amd.com \
--cc=tabba@google.com \
--cc=vbabka@suse.cz \
--cc=xiaoyao.li@intel.com \
--cc=yuzenghui@huawei.com \
--cc=zenghui.yu@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox