All of lore.kernel.org
 help / color / mirror / Atom feed
From: willy@linux.intel.com (Matthew Wilcox)
Subject: NVME identify command data structure length
Date: Tue, 27 Aug 2013 10:17:57 -0400	[thread overview]
Message-ID: <20130827141757.GP4707@linux.intel.com> (raw)
In-Reply-To: <CAB2zxrSPfCf4QVm=J__PX00ZFNU5XGehFKk4FNApMqbPS59BGA@mail.gmail.com>

On Tue, Aug 27, 2013@03:50:34PM +0530, anup shendkar wrote:
> 3. As nvme specification for IDENTIFY command says that 4096 is the
> output buffer length, we can add following code as a potential fix.

No.  The driver does not interpret the opcodes.  If you've mis-used the
ioctl, then you get to keep both pieces.

However, what we should do is check the bottom two bits of the opcode
(ie Data Transfer in Figure 38 of NVMe 1.1).  It is clearly a broken
command if the bottom two bits are zero and data_len is non-zero, or
for the bottom two bits to be non-zero and data_len to be zero.

Do you want to send a patch along those lines?

> diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c
> index ce79a59..b1c5e72 100644
> --- a/drivers/block/nvme-core.c
> +++ b/drivers/block/nvme-core.c
> @@ -1416,6 +1416,11 @@ static int nvme_user_admin_cmd(struct nvme_dev *dev,
>         c.common.cdw10[4] = cpu_to_le32(cmd.cdw14);
>         c.common.cdw10[5] = cpu_to_le32(cmd.cdw15);
> 
> +       if (cmd.opcode == nvme_admin_identify) {
> +               /* NVME Identiy command always uses 4096 data buffer */
> +               cmd.data_len = 4096;
> +       }
> +
>         length = cmd.data_len;
>         if (cmd.data_len) {
>                 iod = nvme_map_user_pages(dev, cmd.opcode & 1, cmd.addr,

  reply	other threads:[~2013-08-27 14:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-27 10:20 NVME identify command data structure length anup shendkar
2013-08-27 14:17 ` Matthew Wilcox [this message]
2013-08-28  7:36   ` anup shendkar
2013-08-28  7:38   ` anup shendkar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130827141757.GP4707@linux.intel.com \
    --to=willy@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.