aboutsummaryrefslogtreecommitdiff
path: root/hw/block
diff options
context:
space:
mode:
authorKlaus Jensen <k.jensen@samsung.com>2020-09-30 01:19:07 +0200
committerKlaus Jensen <k.jensen@samsung.com>2020-10-27 11:29:25 +0100
commit1b48e4611a7a3ee3065d3bb8428f5f6acb5232fe (patch)
tree5ec1a14c661eb2103adf6bdcfac19246eaf17836 /hw/block
parent8c5cea85934eb7b580ced14f7f188e19880d4c1c (diff)
downloadqemu-1b48e4611a7a3ee3065d3bb8428f5f6acb5232fe.zip
qemu-1b48e4611a7a3ee3065d3bb8428f5f6acb5232fe.tar.gz
qemu-1b48e4611a7a3ee3065d3bb8428f5f6acb5232fe.tar.bz2
hw/block/nvme: reject io commands if only admin command set selected
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. Reviewed-by: Dmitry Fomichev <dmitry.fomichev@wdc.com> Signed-off-by: Klaus Jensen <k.jensen@samsung.com> Signed-off-by: Keith Busch <kbusch@kernel.org>
Diffstat (limited to 'hw/block')
-rw-r--r--hw/block/nvme.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index c1323ca..32c35fe 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -1026,6 +1026,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;
}