Skip to contentSkip to conversation

hw/nvme: Return error for fused operations

PATCH Applied Pankaj Raghav 3 participants 3 messages Sep 15, 2021 – Sep 23, 2021 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CGME20210915154333eucas1p2baf6aabb3bd0325233dae156f8bbbb32@eucas1p2.samsung.com

#1 lore raw

PATCH v2 1/1 hw/nvme: Return error for fused operations

Currently, FUSED operations are not supported by QEMU. As per the 1.4 SPEC, controller should abort the command that requested a fused operation with an INVALID FIELD error code if they are not supported.

Changes from v1:
Added FUSE flag check also to the admin cmd processing as the FUSED operations are mentioned in the general SQE section in the SPEC.

---
 hw/nvme/ctrl.c | 8 ++++++++
 1 file changed, 8 insertions(+)
hw/nvme/ctrl.c +8 -0
index dc0e7b0030..2f247a9275 100644
@@ -3893,6 +3893,10 @@ static uint16_t nvme_io_cmd(NvmeCtrl *n, NvmeRequest *req)
         return ns->status;
     }
 
+    if (NVME_CMD_FLAGS_FUSE(req->cmd.flags)) {
+        return NVME_INVALID_FIELD;
+    }
+
     req->ns = ns;
 
     switch (req->cmd.opcode) {
@@ -5475,6 +5479,10 @@ static uint16_t nvme_admin_cmd(NvmeCtrl *n, NvmeRequest *req)
         return NVME_INVALID_FIELD | NVME_DNR;
     }
 
+    if (NVME_CMD_FLAGS_FUSE(req->cmd.flags)) {
+        return NVME_INVALID_FIELD;
+    }
+
     switch (req->cmd.opcode) {
     case NVME_ADM_CMD_DELETE_SQ:
         return nvme_del_sq(n, req);
Signature · 1 line
2.25.1
Reviewed-by on v2 1/1
#2 lore raw
Quoted 7 lines · Pankaj Raghav

Currently, FUSED operations are not supported by QEMU. As per the 1.4 SPEC, controller should abort the command that requested a fused operation with an INVALID FIELD error code if they are not supported.

Changes from v1:
Added FUSE flag check also to the admin cmd processing as the FUSED operations are mentioned in the general SQE section in the SPEC.

Just for future reference, the changes from previous versions should go below the "---" line so that they don't get included in the official changelog.

Quoted 8 lines
hw/nvme/ctrl.c +4 -0
+    if (NVME_CMD_FLAGS_FUSE(req->cmd.flags)) {
+        return NVME_INVALID_FIELD;
+    }
+
     req->ns = ns;
 
     switch (req->cmd.opcode) {

hw/nvme/ctrl.c static uint16_t nvme_admin_cmd(NvmeCtrl *n, NvmeRequest *req) · line 5484

Quoted 6 lines
hw/nvme/ctrl.c +3 -0
@@ -5475,6 +5479,10 @@ static uint16_t nvme_admin_cmd(NvmeCtrl *n, NvmeRequest *req)
         return NVME_INVALID_FIELD | NVME_DNR;
     }
 
+    if (NVME_CMD_FLAGS_FUSE(req->cmd.flags)) {
+        return NVME_INVALID_FIELD;
+    }

I'm a little surprised this macro exists considering this is the first time it's used! But this looks fine, I really hope hosts weren't actually trying fused commands on this target, but it's good to confirm.

Applied
#3 lore raw
In reply to Pankaj Raghav
Quoted 41 lines · Pankaj Raghav

Currently, FUSED operations are not supported by QEMU. As per the 1.4 SPEC, controller should abort the command that requested a fused operation with an INVALID FIELD error code if they are not supported.

Changes from v1:
Added FUSE flag check also to the admin cmd processing as the FUSED operations are mentioned in the general SQE section in the SPEC.

---
 hw/nvme/ctrl.c | 8 ++++++++
 1 file changed, 8 insertions(+)
hw/nvme/ctrl.c +8 -0
index dc0e7b0030..2f247a9275 100644
@@ -3893,6 +3893,10 @@ static uint16_t nvme_io_cmd(NvmeCtrl *n, NvmeRequest *req)
         return ns->status;
     }
 
+    if (NVME_CMD_FLAGS_FUSE(req->cmd.flags)) {
+        return NVME_INVALID_FIELD;
+    }
+
     req->ns = ns;
 
     switch (req->cmd.opcode) {
@@ -5475,6 +5479,10 @@ static uint16_t nvme_admin_cmd(NvmeCtrl *n, NvmeRequest *req)
         return NVME_INVALID_FIELD | NVME_DNR;
     }
 
+    if (NVME_CMD_FLAGS_FUSE(req->cmd.flags)) {
+        return NVME_INVALID_FIELD;
+    }
+
     switch (req->cmd.opcode) {
     case NVME_ADM_CMD_DELETE_SQ:
         return nvme_del_sq(n, req);
Signature · 1 line
2.25.1

Applied to nvme-next. Thanks!