Re: [PATCH v3 kvm/queue 04/16] KVM: Extend the memslot to support fd-based private memory

From: Sean Christopherson
Date: Tue Jan 04 2022 - 12:34:59 EST


On Fri, Dec 31, 2021, Chao Peng wrote:
> On Thu, Dec 23, 2021 at 05:35:37PM +0000, Sean Christopherson wrote:
> > On Thu, Dec 23, 2021, Chao Peng wrote:
> > > diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
> > > index 1daa45268de2..41434322fa23 100644
> > > --- a/include/uapi/linux/kvm.h
> > > +++ b/include/uapi/linux/kvm.h
> > > @@ -103,6 +103,17 @@ struct kvm_userspace_memory_region {
> > > __u64 userspace_addr; /* start of the userspace allocated memory */
> > > };
> > >
> > > +struct kvm_userspace_memory_region_ext {
> > > + __u32 slot;
> > > + __u32 flags;
> > > + __u64 guest_phys_addr;
> > > + __u64 memory_size; /* bytes */
> > > + __u64 userspace_addr; /* hva */
> >
> > Would it make sense to embed "struct kvm_userspace_memory_region"?
> >
> > > + __u64 ofs; /* offset into fd */
> > > + __u32 fd;
> >
> > Again, use descriptive names, then comments like "offset into fd" are unnecessary.
> >
> > __u64 private_offset;
> > __u32 private_fd;
>
> My original thought is the same fields might be used for shared memslot
> as well in future (e.g. there may be another KVM_MEM_* bit can reuse the
> same fields for shared slot) so non private-specific name may sound
> better. But definitely I have no objection and can use private_* names
> for next version unless there is other objection.

If that does happen, it's easy enough to wrap them in a union.