Re: [PATCH v4 4/9] cxl/mem: Add basic IOCTL interface

2021-02-17 Thread Jonathan Cameron
On Tue, 16 Feb 2021 10:34:32 -0800
Ben Widawsky  wrote:

...

> > > diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c
> > > index 237b956f0be0..4ca4f5afd9d2 100644
> > > --- a/drivers/cxl/mem.c
> > > +++ b/drivers/cxl/mem.c
> > > @@ -686,7 +686,11 @@ static int cxl_validate_cmd_from_user(struct cxl_mem 
> > > *cxlm,
> > > 
> > > memcpy(out_cmd, c, sizeof(*c));
> > > out_cmd->info.size_in = send_cmd->in.size;
> > > -   out_cmd->info.size_out = send_cmd->out.size;
> > > +   /*
> > > +* XXX: out_cmd->info.size_out will be controlled by the driver, 
> > > and the
> > > +* specified number of bytes @send_cmd->out.size will be copied 
> > > back out
> > > +* to userspace.
> > > +*/
> > > 
> > > return 0;
> > >  }  
> > 
> > This deals with the buffer overflow being triggered from userspace.
> > 
> > I'm still nervous.  I really don't like assuming hardware will do the right
> > thing and never send us more data than we expect.
> > 
> > Given the check that it will fit in the target buffer is simple,
> > I'd prefer to harden it and know we can't have a problem.
> > 
> > Jonathan  
> 
> I'm working on hardening __cxl_mem_mbox_send_cmd now per your request. With
> that, I think this solves the issue, right?

Should do.  Thanks,

Jonathan
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


Re: [PATCH v4 4/9] cxl/mem: Add basic IOCTL interface

2021-02-16 Thread Al Viro
On Mon, Feb 15, 2021 at 05:45:33PM -0800, Ben Widawsky wrote:
> + if (cmd->info.size_in) {
> + mbox_cmd.payload_in = kvzalloc(cmd->info.size_in, GFP_KERNEL);
> + if (!mbox_cmd.payload_in) {
> + rc = -ENOMEM;
> + goto out;
> + }
> +
> + if (copy_from_user(mbox_cmd.payload_in,
> +u64_to_user_ptr(in_payload),
> +cmd->info.size_in)) {
> + rc = -EFAULT;
> + goto out;
> + }

Umm...  Do you need to open-code vmemdup_user()?  The only difference is
GFP_KERNEL allocation instead of GFP_USER one, and the latter is arguably
saner here...  Zeroing is definitely pointless - you either overwrite
the entire buffer with copy_from_user(), or you fail and free the damn
thing.
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


Re: [PATCH v4 4/9] cxl/mem: Add basic IOCTL interface

2021-02-16 Thread Ben Widawsky
On 21-02-16 18:12:05, Al Viro wrote:
> On Mon, Feb 15, 2021 at 05:45:33PM -0800, Ben Widawsky wrote:
> > +   if (cmd->info.size_in) {
> > +   mbox_cmd.payload_in = kvzalloc(cmd->info.size_in, GFP_KERNEL);
> > +   if (!mbox_cmd.payload_in) {
> > +   rc = -ENOMEM;
> > +   goto out;
> > +   }
> > +
> > +   if (copy_from_user(mbox_cmd.payload_in,
> > +  u64_to_user_ptr(in_payload),
> > +  cmd->info.size_in)) {
> > +   rc = -EFAULT;
> > +   goto out;
> > +   }
> 
> Umm...  Do you need to open-code vmemdup_user()?  The only difference is
> GFP_KERNEL allocation instead of GFP_USER one, and the latter is arguably
> saner here...  Zeroing is definitely pointless - you either overwrite
> the entire buffer with copy_from_user(), or you fail and free the damn
> thing.

mea culpa. In fact it was previously memdup_user and Dan suggested I switch to
vmemdup_user.
https://lore.kernel.org/linux-cxl/capcyv4j+ixvgeo5q2ohv4kdkbzbnohzj3kdovreqjjpbsre...@mail.gmail.com/


Will fix for the next version.

Thanks.
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


Re: [PATCH v4 4/9] cxl/mem: Add basic IOCTL interface

2021-02-16 Thread Jonathan Cameron
On Tue, 16 Feb 2021 09:53:14 -0800
Ben Widawsky  wrote:

> On 21-02-16 15:22:23, Jonathan Cameron wrote:
> > On Mon, 15 Feb 2021 17:45:33 -0800
> > Ben Widawsky  wrote:
> >   
> > > Add a straightforward IOCTL that provides a mechanism for userspace to
> > > query the supported memory device commands. CXL commands as they appear
> > > to userspace are described as part of the UAPI kerneldoc. The command
> > > list returned via this IOCTL will contain the full set of commands that
> > > the driver supports, however, some of those commands may not be
> > > available for use by userspace.
> > > 
> > > Memory device commands first appear in the CXL 2.0 specification. They
> > > are submitted through a mailbox mechanism specified in the CXL 2.0
> > > specification.
> > > 
> > > The send command allows userspace to issue mailbox commands directly to
> > > the hardware. The list of available commands to send are the output of
> > > the query command. The driver verifies basic properties of the command
> > > and possibly inspect the input (or output) payload to determine whether
> > > or not the command is allowed (or might taint the kernel).
> > > 
> > > Reported-by: kernel test robot  # bug in earlier revision
> > > Signed-off-by: Ben Widawsky 
> > > Reviewed-by: Dan Williams  (v2)  
> > 
> > I may be missreading this but I think the logic to ensure commands
> > using a variable sized buffer have enough space is broken.
> > 
> > Jonathan
> >   
> > > ---
> > >  .clang-format |   1 +
> > >  .../userspace-api/ioctl/ioctl-number.rst  |   1 +
> > >  drivers/cxl/mem.c | 288 +-
> > >  include/uapi/linux/cxl_mem.h  | 154 ++
> > >  4 files changed, 443 insertions(+), 1 deletion(-)
> > >  create mode 100644 include/uapi/linux/cxl_mem.h
> > > 
> > > diff --git a/.clang-format b/.clang-format
> > > index 10dc5a9a61b3..3f11c8901b43 100644
> > > --- a/.clang-format
> > > +++ b/.clang-format
> > > @@ -109,6 +109,7 @@ ForEachMacros:
> > >- 'css_for_each_child'
> > >- 'css_for_each_descendant_post'
> > >- 'css_for_each_descendant_pre'
> > > +  - 'cxl_for_each_cmd'
> > >- 'device_for_each_child_node'
> > >- 'dma_fence_chain_for_each'
> > >- 'do_for_each_ftrace_op'
> > > diff --git a/Documentation/userspace-api/ioctl/ioctl-number.rst 
> > > b/Documentation/userspace-api/ioctl/ioctl-number.rst
> > > index a4c75a28c839..6eb8e634664d 100644
> > > --- a/Documentation/userspace-api/ioctl/ioctl-number.rst
> > > +++ b/Documentation/userspace-api/ioctl/ioctl-number.rst
> > > @@ -352,6 +352,7 @@ Code  Seq#Include File
> > >Comments
> > >   
> > > 
> > >  0xCC  00-0F  drivers/misc/ibmvmc.h   
> > > pseries VMC driver
> > >  0xCD  01 linux/reiserfs_fs.h
> > > +0xCE  01-02  uapi/linux/cxl_mem.h
> > > Compute Express Link Memory Devices
> > >  0xCF  02 fs/cifs/ioctl.c
> > >  0xDB  00-0F  drivers/char/mwave/mwavepub.h
> > >  0xDD  00-3F  
> > > ZFCP device driver see drivers/s390/scsi/
> > > diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c
> > > index 410adb1bdffc..a4298cb1182d 100644
> > > --- a/drivers/cxl/mem.c
> > > +++ b/drivers/cxl/mem.c
> > > @@ -1,5 +1,6 @@
> > >  // SPDX-License-Identifier: GPL-2.0-only
> > >  /* Copyright(c) 2020 Intel Corporation. All rights reserved. */
> > > +#include 
> > >  #include 
> > >  #include 
> > >  #include 
> > > @@ -40,6 +41,7 @@
> > >  #define CXL_MAILBOX_TIMEOUT_MS (2 * HZ)
> > >  
> > >  enum opcode {
> > > + CXL_MBOX_OP_INVALID = 0x,
> > >   CXL_MBOX_OP_IDENTIFY= 0x4000,
> > >   CXL_MBOX_OP_MAX = 0x1
> > >  };
> > > @@ -91,6 +93,49 @@ struct cxl_memdev {
> > >  static int cxl_mem_major;
> > >  static DEFINE_IDA(cxl_memdev_ida);
> > >  
> > > +/**
> > > + * struct cxl_mem_command - Driver representation of a memory device 
> > > command
> > > + * @info: Command information as it exists for the UAPI
> > > + * @opcode: The actual bits used for the mailbox protocol
> > > + *
> > > + * The cxl_mem_command is the driver's internal representation of 
> > > commands that
> > > + * are supported by the driver. Some of these commands may not be 
> > > supported by
> > > + * the hardware. The driver will use @info to validate the fields passed 
> > > in by
> > > + * the user then submit the @opcode to the hardware.
> > > + *
> > > + * See struct cxl_command_info.
> > > + */
> > > +struct cxl_mem_command {
> > > + struct cxl_command_info info;
> > > + enum opcode opcode;
> > > +};
> > > +
> > > +#define CXL_CMD(_id, sin, sout)  
> > >   \
> > > + [CXL_MEM_COMMAND_ID_##_id] = {  

Re: [PATCH v4 4/9] cxl/mem: Add basic IOCTL interface

2021-02-16 Thread Ben Widawsky
On 21-02-16 18:28:49, Jonathan Cameron wrote:
> On Tue, 16 Feb 2021 09:53:14 -0800
> Ben Widawsky  wrote:
> 
> > On 21-02-16 15:22:23, Jonathan Cameron wrote:
> > > On Mon, 15 Feb 2021 17:45:33 -0800
> > > Ben Widawsky  wrote:
> > >   
> > > > Add a straightforward IOCTL that provides a mechanism for userspace to
> > > > query the supported memory device commands. CXL commands as they appear
> > > > to userspace are described as part of the UAPI kerneldoc. The command
> > > > list returned via this IOCTL will contain the full set of commands that
> > > > the driver supports, however, some of those commands may not be
> > > > available for use by userspace.
> > > > 
> > > > Memory device commands first appear in the CXL 2.0 specification. They
> > > > are submitted through a mailbox mechanism specified in the CXL 2.0
> > > > specification.
> > > > 
> > > > The send command allows userspace to issue mailbox commands directly to
> > > > the hardware. The list of available commands to send are the output of
> > > > the query command. The driver verifies basic properties of the command
> > > > and possibly inspect the input (or output) payload to determine whether
> > > > or not the command is allowed (or might taint the kernel).
> > > > 
> > > > Reported-by: kernel test robot  # bug in earlier 
> > > > revision
> > > > Signed-off-by: Ben Widawsky 
> > > > Reviewed-by: Dan Williams  (v2)  
> > > 
> > > I may be missreading this but I think the logic to ensure commands
> > > using a variable sized buffer have enough space is broken.
> > > 
> > > Jonathan
> > >   
> > > > ---
> > > >  .clang-format |   1 +
> > > >  .../userspace-api/ioctl/ioctl-number.rst  |   1 +
> > > >  drivers/cxl/mem.c | 288 +-
> > > >  include/uapi/linux/cxl_mem.h  | 154 ++
> > > >  4 files changed, 443 insertions(+), 1 deletion(-)
> > > >  create mode 100644 include/uapi/linux/cxl_mem.h
> > > > 
> > > > diff --git a/.clang-format b/.clang-format
> > > > index 10dc5a9a61b3..3f11c8901b43 100644
> > > > --- a/.clang-format
> > > > +++ b/.clang-format
> > > > @@ -109,6 +109,7 @@ ForEachMacros:
> > > >- 'css_for_each_child'
> > > >- 'css_for_each_descendant_post'
> > > >- 'css_for_each_descendant_pre'
> > > > +  - 'cxl_for_each_cmd'
> > > >- 'device_for_each_child_node'
> > > >- 'dma_fence_chain_for_each'
> > > >- 'do_for_each_ftrace_op'
> > > > diff --git a/Documentation/userspace-api/ioctl/ioctl-number.rst 
> > > > b/Documentation/userspace-api/ioctl/ioctl-number.rst
> > > > index a4c75a28c839..6eb8e634664d 100644
> > > > --- a/Documentation/userspace-api/ioctl/ioctl-number.rst
> > > > +++ b/Documentation/userspace-api/ioctl/ioctl-number.rst
> > > > @@ -352,6 +352,7 @@ Code  Seq#Include File  
> > > >  Comments
> > > >   
> > > > 
> > > >  0xCC  00-0F  drivers/misc/ibmvmc.h   
> > > > pseries VMC driver
> > > >  0xCD  01 linux/reiserfs_fs.h
> > > > +0xCE  01-02  uapi/linux/cxl_mem.h
> > > > Compute Express Link Memory Devices
> > > >  0xCF  02 fs/cifs/ioctl.c
> > > >  0xDB  00-0F  drivers/char/mwave/mwavepub.h
> > > >  0xDD  00-3F  
> > > > ZFCP device driver see drivers/s390/scsi/
> > > > diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c
> > > > index 410adb1bdffc..a4298cb1182d 100644
> > > > --- a/drivers/cxl/mem.c
> > > > +++ b/drivers/cxl/mem.c
> > > > @@ -1,5 +1,6 @@
> > > >  // SPDX-License-Identifier: GPL-2.0-only
> > > >  /* Copyright(c) 2020 Intel Corporation. All rights reserved. */
> > > > +#include 
> > > >  #include 
> > > >  #include 
> > > >  #include 
> > > > @@ -40,6 +41,7 @@
> > > >  #define CXL_MAILBOX_TIMEOUT_MS (2 * HZ)
> > > >  
> > > >  enum opcode {
> > > > +   CXL_MBOX_OP_INVALID = 0x,
> > > > CXL_MBOX_OP_IDENTIFY= 0x4000,
> > > > CXL_MBOX_OP_MAX = 0x1
> > > >  };
> > > > @@ -91,6 +93,49 @@ struct cxl_memdev {
> > > >  static int cxl_mem_major;
> > > >  static DEFINE_IDA(cxl_memdev_ida);
> > > >  
> > > > +/**
> > > > + * struct cxl_mem_command - Driver representation of a memory device 
> > > > command
> > > > + * @info: Command information as it exists for the UAPI
> > > > + * @opcode: The actual bits used for the mailbox protocol
> > > > + *
> > > > + * The cxl_mem_command is the driver's internal representation of 
> > > > commands that
> > > > + * are supported by the driver. Some of these commands may not be 
> > > > supported by
> > > > + * the hardware. The driver will use @info to validate the fields 
> > > > passed in by
> > > > + * the user then submit the @opcode to the hardware.
> > > > + *
> > > > + * See struct cxl_command_info.

Re: [PATCH v4 4/9] cxl/mem: Add basic IOCTL interface

2021-02-16 Thread Ben Widawsky
On 21-02-16 15:22:23, Jonathan Cameron wrote:
> On Mon, 15 Feb 2021 17:45:33 -0800
> Ben Widawsky  wrote:
> 
> > Add a straightforward IOCTL that provides a mechanism for userspace to
> > query the supported memory device commands. CXL commands as they appear
> > to userspace are described as part of the UAPI kerneldoc. The command
> > list returned via this IOCTL will contain the full set of commands that
> > the driver supports, however, some of those commands may not be
> > available for use by userspace.
> > 
> > Memory device commands first appear in the CXL 2.0 specification. They
> > are submitted through a mailbox mechanism specified in the CXL 2.0
> > specification.
> > 
> > The send command allows userspace to issue mailbox commands directly to
> > the hardware. The list of available commands to send are the output of
> > the query command. The driver verifies basic properties of the command
> > and possibly inspect the input (or output) payload to determine whether
> > or not the command is allowed (or might taint the kernel).
> > 
> > Reported-by: kernel test robot  # bug in earlier revision
> > Signed-off-by: Ben Widawsky 
> > Reviewed-by: Dan Williams  (v2)
> 
> I may be missreading this but I think the logic to ensure commands
> using a variable sized buffer have enough space is broken.
> 
> Jonathan
> 
> > ---
> >  .clang-format |   1 +
> >  .../userspace-api/ioctl/ioctl-number.rst  |   1 +
> >  drivers/cxl/mem.c | 288 +-
> >  include/uapi/linux/cxl_mem.h  | 154 ++
> >  4 files changed, 443 insertions(+), 1 deletion(-)
> >  create mode 100644 include/uapi/linux/cxl_mem.h
> > 
> > diff --git a/.clang-format b/.clang-format
> > index 10dc5a9a61b3..3f11c8901b43 100644
> > --- a/.clang-format
> > +++ b/.clang-format
> > @@ -109,6 +109,7 @@ ForEachMacros:
> >- 'css_for_each_child'
> >- 'css_for_each_descendant_post'
> >- 'css_for_each_descendant_pre'
> > +  - 'cxl_for_each_cmd'
> >- 'device_for_each_child_node'
> >- 'dma_fence_chain_for_each'
> >- 'do_for_each_ftrace_op'
> > diff --git a/Documentation/userspace-api/ioctl/ioctl-number.rst 
> > b/Documentation/userspace-api/ioctl/ioctl-number.rst
> > index a4c75a28c839..6eb8e634664d 100644
> > --- a/Documentation/userspace-api/ioctl/ioctl-number.rst
> > +++ b/Documentation/userspace-api/ioctl/ioctl-number.rst
> > @@ -352,6 +352,7 @@ Code  Seq#Include File  
> >  Comments
> >   
> > 
> >  0xCC  00-0F  drivers/misc/ibmvmc.h   
> > pseries VMC driver
> >  0xCD  01 linux/reiserfs_fs.h
> > +0xCE  01-02  uapi/linux/cxl_mem.h
> > Compute Express Link Memory Devices
> >  0xCF  02 fs/cifs/ioctl.c
> >  0xDB  00-0F  drivers/char/mwave/mwavepub.h
> >  0xDD  00-3F  ZFCP 
> > device driver see drivers/s390/scsi/
> > diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c
> > index 410adb1bdffc..a4298cb1182d 100644
> > --- a/drivers/cxl/mem.c
> > +++ b/drivers/cxl/mem.c
> > @@ -1,5 +1,6 @@
> >  // SPDX-License-Identifier: GPL-2.0-only
> >  /* Copyright(c) 2020 Intel Corporation. All rights reserved. */
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -40,6 +41,7 @@
> >  #define CXL_MAILBOX_TIMEOUT_MS (2 * HZ)
> >  
> >  enum opcode {
> > +   CXL_MBOX_OP_INVALID = 0x,
> > CXL_MBOX_OP_IDENTIFY= 0x4000,
> > CXL_MBOX_OP_MAX = 0x1
> >  };
> > @@ -91,6 +93,49 @@ struct cxl_memdev {
> >  static int cxl_mem_major;
> >  static DEFINE_IDA(cxl_memdev_ida);
> >  
> > +/**
> > + * struct cxl_mem_command - Driver representation of a memory device 
> > command
> > + * @info: Command information as it exists for the UAPI
> > + * @opcode: The actual bits used for the mailbox protocol
> > + *
> > + * The cxl_mem_command is the driver's internal representation of commands 
> > that
> > + * are supported by the driver. Some of these commands may not be 
> > supported by
> > + * the hardware. The driver will use @info to validate the fields passed 
> > in by
> > + * the user then submit the @opcode to the hardware.
> > + *
> > + * See struct cxl_command_info.
> > + */
> > +struct cxl_mem_command {
> > +   struct cxl_command_info info;
> > +   enum opcode opcode;
> > +};
> > +
> > +#define CXL_CMD(_id, sin, sout)
> > \
> > +   [CXL_MEM_COMMAND_ID_##_id] = { \
> > +   .info = {  \
> > +   .id = CXL_MEM_COMMAND_ID_##_id,\
> > +   .size_in = sin,\
> > +   .

Re: [PATCH v4 4/9] cxl/mem: Add basic IOCTL interface

2021-02-16 Thread Jonathan Cameron
On Mon, 15 Feb 2021 17:45:33 -0800
Ben Widawsky  wrote:

> Add a straightforward IOCTL that provides a mechanism for userspace to
> query the supported memory device commands. CXL commands as they appear
> to userspace are described as part of the UAPI kerneldoc. The command
> list returned via this IOCTL will contain the full set of commands that
> the driver supports, however, some of those commands may not be
> available for use by userspace.
> 
> Memory device commands first appear in the CXL 2.0 specification. They
> are submitted through a mailbox mechanism specified in the CXL 2.0
> specification.
> 
> The send command allows userspace to issue mailbox commands directly to
> the hardware. The list of available commands to send are the output of
> the query command. The driver verifies basic properties of the command
> and possibly inspect the input (or output) payload to determine whether
> or not the command is allowed (or might taint the kernel).
> 
> Reported-by: kernel test robot  # bug in earlier revision
> Signed-off-by: Ben Widawsky 
> Reviewed-by: Dan Williams  (v2)

I may be missreading this but I think the logic to ensure commands
using a variable sized buffer have enough space is broken.

Jonathan

> ---
>  .clang-format |   1 +
>  .../userspace-api/ioctl/ioctl-number.rst  |   1 +
>  drivers/cxl/mem.c | 288 +-
>  include/uapi/linux/cxl_mem.h  | 154 ++
>  4 files changed, 443 insertions(+), 1 deletion(-)
>  create mode 100644 include/uapi/linux/cxl_mem.h
> 
> diff --git a/.clang-format b/.clang-format
> index 10dc5a9a61b3..3f11c8901b43 100644
> --- a/.clang-format
> +++ b/.clang-format
> @@ -109,6 +109,7 @@ ForEachMacros:
>- 'css_for_each_child'
>- 'css_for_each_descendant_post'
>- 'css_for_each_descendant_pre'
> +  - 'cxl_for_each_cmd'
>- 'device_for_each_child_node'
>- 'dma_fence_chain_for_each'
>- 'do_for_each_ftrace_op'
> diff --git a/Documentation/userspace-api/ioctl/ioctl-number.rst 
> b/Documentation/userspace-api/ioctl/ioctl-number.rst
> index a4c75a28c839..6eb8e634664d 100644
> --- a/Documentation/userspace-api/ioctl/ioctl-number.rst
> +++ b/Documentation/userspace-api/ioctl/ioctl-number.rst
> @@ -352,6 +352,7 @@ Code  Seq#Include File
>Comments
>   
> 
>  0xCC  00-0F  drivers/misc/ibmvmc.h   pseries 
> VMC driver
>  0xCD  01 linux/reiserfs_fs.h
> +0xCE  01-02  uapi/linux/cxl_mem.hCompute 
> Express Link Memory Devices
>  0xCF  02 fs/cifs/ioctl.c
>  0xDB  00-0F  drivers/char/mwave/mwavepub.h
>  0xDD  00-3F  ZFCP 
> device driver see drivers/s390/scsi/
> diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c
> index 410adb1bdffc..a4298cb1182d 100644
> --- a/drivers/cxl/mem.c
> +++ b/drivers/cxl/mem.c
> @@ -1,5 +1,6 @@
>  // SPDX-License-Identifier: GPL-2.0-only
>  /* Copyright(c) 2020 Intel Corporation. All rights reserved. */
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -40,6 +41,7 @@
>  #define CXL_MAILBOX_TIMEOUT_MS (2 * HZ)
>  
>  enum opcode {
> + CXL_MBOX_OP_INVALID = 0x,
>   CXL_MBOX_OP_IDENTIFY= 0x4000,
>   CXL_MBOX_OP_MAX = 0x1
>  };
> @@ -91,6 +93,49 @@ struct cxl_memdev {
>  static int cxl_mem_major;
>  static DEFINE_IDA(cxl_memdev_ida);
>  
> +/**
> + * struct cxl_mem_command - Driver representation of a memory device command
> + * @info: Command information as it exists for the UAPI
> + * @opcode: The actual bits used for the mailbox protocol
> + *
> + * The cxl_mem_command is the driver's internal representation of commands 
> that
> + * are supported by the driver. Some of these commands may not be supported 
> by
> + * the hardware. The driver will use @info to validate the fields passed in 
> by
> + * the user then submit the @opcode to the hardware.
> + *
> + * See struct cxl_command_info.
> + */
> +struct cxl_mem_command {
> + struct cxl_command_info info;
> + enum opcode opcode;
> +};
> +
> +#define CXL_CMD(_id, sin, sout)  
>   \
> + [CXL_MEM_COMMAND_ID_##_id] = { \
> + .info = {  \
> + .id = CXL_MEM_COMMAND_ID_##_id,\
> + .size_in = sin,\
> + .size_out = sout,  \
> + }, \
> + .opcode = CXL_MBOX_OP_##_id,   \
> + }
> +
> +/*
> + * This table defines th