Re: [PATCH v2] misc: vmw_zerocopy: Add VMware zero-copy buffer sharing driver

From: David Laight

Date: Fri Jun 19 2026 - 11:13:34 EST


On Fri, 19 Jun 2026 07:10:33 +0200
Greg KH <gregkh@xxxxxxxxxxxxxxxxxxx> wrote:

> On Thu, Jun 18, 2026 at 11:10:34AM -0700, Rishi Chhibber wrote:
> > +/*
> > + * Used for sending user buffer.
> > + * Either is optional but not both.
> > + *
> > + * Pointers are __u64 so the struct layout is identical on 32-bit and 64-bit
> > + * userspace, avoiding a compat_ioctl handler. Use u64_to_user_ptr() in the
> > + * driver to convert back to a __user pointer.
> > + */
> > +struct vmw_zc_guest_data {
> > + __u64 buffer;
> > + __u32 buffer_length;
> > + __u64 metadata;
> > + __u32 metadata_length;
> > +} __packed;
>
> You have an unaligned metadata pointer here in the structure, are you
> sure that's a good idea? Or can you not change that anymore?

The compiler is going to assume the whole thing can be misaligned.

Possibly:

> > +struct vmw_zc_guest_data {
> > + __u64 buffer;
> > + __u32 buffer_length;
> > + __u64 metadata __packed;
> > + __u32 metadata_length;
> > +};

which just removes the pad before 'metadata' while leaving
the structure itself aligned.
The compiler will then only use two 32bit accesses for metadata
instead of byte accesses for all the structure members.

-- David