[PATCH] Add data transfer length check for admin commands

Matthew Wilcox willy at linux.intel.com
Tue Sep 3 13:05:08 EDT 2013


On Mon, Sep 02, 2013 at 10:31:16PM +0530, Prasad Joshi wrote:
> diff --git a/include/linux/nvme.h b/include/linux/nvme.h

I think you generated this patch against Linus' tree rather than the NVMe
tree (http://git.infradead.org/users/willy/linux-nvme.git).  The __KERNEL__
ifdefs are gone due to the separation of this file into the uapi and non-uapi
versions.

> +/*
> + * The 2 LSB bits of NVME Admin command opcode are called as data transfer bits.
> + * These two bits define where a command should include data transfer
> + * information.
> + */
> +#define NVME_ADMIN_CMD_DATA_XFER_MASK (0b11)
> +

Binary constants are a GCC extension, which I would prefer to avoid.
They're only available from gcc 4.3 onwards, and apparently we still
support gcc versions as old as 3.2.

The bits aren't just for admin commands (so we should correct both the
comment and the name of the constant).  How about adding:

	NVME_DATA_XFER_NONE	= 0,
	NVME_DATA_XFER_READ	= 1,
	NVME_DATA_XFER_WRITE	= 2,
	NVME_DATA_XFER_BIDI	= 3,
	NVME_DATA_XFER_MASK	= 3,

to the 'enum nvme_opcode' definition?



More information about the Linux-nvme mailing list