All of lore.kernel.org
 help / color / mirror / Atom feed
From: Klaus Jensen <its@irrelevant.dk>
To: qemu-devel@nongnu.org
Cc: Fam Zheng <fam@euphon.net>, Kevin Wolf <kwolf@redhat.com>,
	qemu-block@nongnu.org, Klaus Jensen <k.jensen@samsung.com>,
	Max Reitz <mreitz@redhat.com>, Keith Busch <kbusch@kernel.org>,
	Klaus Jensen <its@irrelevant.dk>
Subject: [PATCH 04/16] hw/block/nvme: reject io commands if only admin command set selected
Date: Thu, 24 Sep 2020 22:45:04 +0200	[thread overview]
Message-ID: <20200924204516.1881843-5-its@irrelevant.dk> (raw)
In-Reply-To: <20200924204516.1881843-1-its@irrelevant.dk>

From: Klaus Jensen <k.jensen@samsung.com>

If the host sets CC.CSS to 111b, all commands submitted to I/O queues
should be completed with status Invalid Command Opcode.

Note that this is technically a v1.4 feature, but it does not hurt to
implement before we finally bump the reported version implemented.

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
---
 include/block/nvme.h | 5 +++++
 hw/block/nvme.c      | 4 ++++
 2 files changed, 9 insertions(+)

diff --git a/include/block/nvme.h b/include/block/nvme.h
index 58647bcdad0b..7a30cf285ae0 100644
--- a/include/block/nvme.h
+++ b/include/block/nvme.h
@@ -110,6 +110,11 @@ enum NvmeCcMask {
 #define NVME_CC_IOSQES(cc) ((cc >> CC_IOSQES_SHIFT) & CC_IOSQES_MASK)
 #define NVME_CC_IOCQES(cc) ((cc >> CC_IOCQES_SHIFT) & CC_IOCQES_MASK)
 
+enum NvmeCcCss {
+    NVME_CC_CSS_NVM        = 0x0,
+    NVME_CC_CSS_ADMIN_ONLY = 0x7,
+};
+
 enum NvmeCstsShift {
     CSTS_RDY_SHIFT      = 0,
     CSTS_CFS_SHIFT      = 1,
diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index 758f58c88026..27af2f0b38d5 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -1065,6 +1065,10 @@ static uint16_t nvme_io_cmd(NvmeCtrl *n, NvmeRequest *req)
     trace_pci_nvme_io_cmd(nvme_cid(req), nsid, nvme_sqid(req),
                           req->cmd.opcode, nvme_io_opc_str(req->cmd.opcode));
 
+    if (NVME_CC_CSS(n->bar.cc) == NVME_CC_CSS_ADMIN_ONLY) {
+        return NVME_INVALID_OPCODE | NVME_DNR;
+    }
+
     if (!nvme_nsid_valid(n, nsid)) {
         return NVME_INVALID_NSID | NVME_DNR;
     }
-- 
2.28.0



  parent reply	other threads:[~2020-09-24 20:50 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-24 20:45 [PATCH 00/16] hw/block/nvme: zoned namespace command set Klaus Jensen
2020-09-24 20:45 ` [PATCH 01/16] hw/block/nvme: add nsid to get/setfeat trace events Klaus Jensen
2020-09-24 20:45 ` [PATCH 02/16] hw/block/nvme: add trace event for requests with non-zero status code Klaus Jensen
2020-09-24 20:45 ` [PATCH 03/16] hw/block/nvme: make lba data size configurable Klaus Jensen
2020-09-24 21:13   ` Klaus Jensen
2020-09-24 20:45 ` Klaus Jensen [this message]
2020-09-24 20:45 ` [PATCH 05/16] hw/block/nvme: consolidate read, write and write zeroes Klaus Jensen
2020-09-24 20:45 ` [PATCH 06/16] hw/block/nvme: add support for dulbe and block utilization tracking Klaus Jensen
2020-09-24 20:45 ` [PATCH 07/16] hw/block/nvme: add commands supported and effects log page Klaus Jensen
2020-09-24 20:45 ` [PATCH 08/16] hw/block/nvme: support namespace types Klaus Jensen
2020-09-24 20:45 ` [PATCH 09/16] hw/block/nvme: add basic read/write for zoned namespaces Klaus Jensen
2020-09-24 20:45 ` [PATCH 10/16] hw/block/nvme: add the zone management receive command Klaus Jensen
2020-09-24 20:45 ` [PATCH 11/16] hw/block/nvme: add the zone management send command Klaus Jensen
2020-09-24 20:45 ` [PATCH 12/16] hw/block/nvme: add the zone append command Klaus Jensen
2020-09-24 20:45 ` [PATCH 13/16] hw/block/nvme: track and enforce zone resources Klaus Jensen
2020-09-24 20:45 ` [PATCH 14/16] hw/block/nvme: allow open to close transitions by controller Klaus Jensen
2020-09-24 20:45 ` [PATCH 15/16] hw/block/nvme: support zone active excursions Klaus Jensen
2020-09-24 20:45 ` [PATCH 16/16] hw/block/nvme: support reset/finish recommended limits Klaus Jensen
2020-09-24 22:43 ` [PATCH 00/16] hw/block/nvme: zoned namespace command set no-reply
2020-09-25  7:55   ` Klaus Jensen
2020-09-25  1:24 ` Keith Busch
2020-09-25  5:27   ` Klaus Jensen
2020-09-25 17:06 ` Dmitry Fomichev
2020-09-25 17:27   ` Klaus Jensen

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=20200924204516.1881843-5-its@irrelevant.dk \
    --to=its@irrelevant.dk \
    --cc=fam@euphon.net \
    --cc=k.jensen@samsung.com \
    --cc=kbusch@kernel.org \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /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.