[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7946bff8d8c529f0a2fabc80ca988879ea783b2e.camel@infradead.org>
Date: Wed, 02 Mar 2022 21:55:50 +0000
From: David Woodhouse <dwmw2@...radead.org>
To: Paolo Bonzini <pbonzini@...hat.com>,
Sean Christopherson <seanjc@...gle.com>,
Christian Borntraeger <borntraeger@...ux.ibm.com>,
Janosch Frank <frankja@...ux.ibm.com>,
Claudio Imbrenda <imbrenda@...ux.ibm.com>
Cc: Vitaly Kuznetsov <vkuznets@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Joerg Roedel <joro@...tes.org>,
David Hildenbrand <david@...hat.com>, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org, David Matlack <dmatlack@...gle.com>,
Ben Gardon <bgardon@...gle.com>,
Mingwei Zhang <mizhang@...gle.com>
Subject: Re: [PATCH v3 26/28] KVM: selftests: Split out helper to allocate
guest mem via memfd
On Wed, 2022-03-02 at 19:36 +0100, Paolo Bonzini wrote:
> On 3/1/22 00:36, David Woodhouse wrote:
> > On Sat, 2022-02-26 at 00:15 +0000, Sean Christopherson wrote:
> > > Extract the code for allocating guest memory via memfd out of
> > > vm_userspace_mem_region_add() and into a new helper, kvm_memfd_alloc().
> > > A future selftest to populate a guest with the maximum amount of guest
> > > memory will abuse KVM's memslots to alias guest memory regions to a
> > > single memfd-backed host region, i.e. needs to back a guest with memfd
> > > memory without a 1:1 association between a memslot and a memfd instance.
> > >
> > > No functional change intended.
> > >
> > > Signed-off-by: Sean Christopherson <seanjc@...gle.com>
> >
> > While we're at it, please can we make the whole thing go away and just
> > return failure #ifndef MFD_CLOEXEC, instead of breaking the build on
> > older userspace?
>
> We can just use old school F_SETFD if that's helpful for you.
The system on which I had that problem doesn't have memfd at all. As a
local hack just to build the TSC test case on a system that actually
supports TSC scaling, I just made it all go away thus:
--- a/tools/testing/selftests/kvm/lib/kvm_util.c
+++ b/tools/testing/selftests/kvm/lib/kvm_util.c
@@ -938,6 +938,7 @@ void vm_userspace_mem_region_add(struct kvm_vm *vm,
region->fd = -1;
if (backing_src_is_shared(src_type)) {
+#ifdef MFD_CLOEXEC
int memfd_flags = MFD_CLOEXEC;
if (src_type == VM_MEM_SRC_SHARED_HUGETLB)
@@ -954,6 +955,9 @@ void vm_userspace_mem_region_add(struct kvm_vm *vm,
FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0,
region->mmap_size);
TEST_ASSERT(ret == 0, "fallocate failed, errno: %i", errno);
+#else
+ TEST_ASSERT(false, "memfd support not present");
+#endif
}
region->mmap_start = mmap(NULL, region->mmap_size,
Download attachment "smime.p7s" of type "application/pkcs7-signature" (5965 bytes)
Powered by blists - more mailing lists