Re: [PATCH 2/2] KVM: selftests: Test guest_memfd binding overlap without GPA overlap
From: Sean Christopherson
Date: Tue May 19 2026 - 15:54:29 EST
On Tue, May 19, 2026, Ackerley Tng wrote:
> Sean Christopherson <seanjc@xxxxxxxxxx> writes:
> > @@ -542,6 +542,26 @@ static void test_add_overlapping_private_memory_regions(void)
> > TEST_ASSERT(r == -1 && errno == EEXIST, "%s",
> > "Overlapping guest_memfd() bindings should fail with EEXIST");
> >
> > + /*
> > + * Repeat the overlap tests, but so that there is overlap in the
> > + * guest_memfd bindings (i.e. in guest_memfd file offsets), but _not_
> > + * in the GPA space. Regardless of where there's overlap, KVM should
> > + * return -EEXIST.
> > + */
> > + r = __vm_set_user_memory_region2(vm, MEM_REGION_SLOT, KVM_MEM_GUEST_MEMFD,
> > + MEM_REGION_GPA,
> > + MEM_REGION_SIZE * 2,
> > + 0, memfd, MEM_REGION_SIZE);
> > + TEST_ASSERT(r == -1 && errno == EEXIST, "%s",
> > + "Overlapping guest_memfd() bindings should fail with EEXIST");
> > +
> > + /* And now the back half of the other slot's guest_memfd binding. */
> > + r = __vm_set_user_memory_region2(vm, MEM_REGION_SLOT, KVM_MEM_GUEST_MEMFD,
> > + MEM_REGION_GPA,
> > + MEM_REGION_SIZE * 2,
> > + 0, memfd, MEM_REGION_SIZE * 3);
> > + TEST_ASSERT(r == -1 && errno == EEXIST, "%s",
> > + "Overlapping guest_memfd() bindings should fail with EEXIST");
>
> I just noticed this is kind of odd, what is the purpose of "%s" and then
> filling the string in with a hardcoded string?
Purely oversight. I didn't even see it until you said something :-)