Skip to contentSkip to conversation

hw/block/nvme: improve invalid zasl value reporting

PATCH In review Klaus Jensen 4 participants 6 messages Feb 8, 2021 – Feb 10, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/block/nvme: improve invalid zasl value reporting

From: Klaus Jensen <[email protected]>

The Zone Append Size Limit (ZASL) must be at least 4096 bytes, so improve the user experience by adding an early parameter check in nvme_check_constraints.

When ZASL is still too small due to the host configuring the device for an even larger page size, convert the trace point in nvme_start_ctrl to an NVME_GUEST_ERR such that this is logged by QEMU instead of only traced.

---
 hw/block/nvme.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
hw/block/nvme.c +10 -2
index c2f0c88fbf39..d96888cd2333 100644
@@ -3983,8 +3983,10 @@ static int nvme_start_ctrl(NvmeCtrl *n)
         n->zasl = n->params.mdts;
     } else {
         if (n->params.zasl_bs < n->page_size) {
-            trace_pci_nvme_err_startfail_zasl_too_small(n->params.zasl_bs,
-                                                        n->page_size);
+            NVME_GUEST_ERR(pci_nvme_err_startfail_zasl_too_small,
+                           "Zone Append Size Limit (ZASL) of %d bytes is too "
+                           "small; must be at least %d bytes",
+                           n->params.zasl_bs, n->page_size);
             return -1;
         }
         n->zasl = 31 - clz32(n->params.zasl_bs / n->page_size);
@@ -4503,6 +4505,12 @@ static void nvme_check_constraints(NvmeCtrl *n, Error **errp)
             error_setg(errp, "zone append size limit has to be a power of 2");
             return;
         }
+
+        if (n->params.zasl_bs < 4096) {
+            error_setg(errp, "zone append size limit must be at least "
+                       "4096 bytes");
+            return;
+        }
     }
 }
 
Signature · 1 line
2.30.0
#2 lore raw
In reply to [email protected]
Quoted 11 lines · On Feb 8 10:15, [email protected] wrote:
Quoted 3 lines · Klaus Jensen

The Zone Append Size Limit (ZASL) must be at least 4096 bytes, so improve the user experience by adding an early parameter check in nvme_check_constraints.

I have confirmed this and it works for me, I don't think I am actually qualified or understand QEMUs source well enough to sign this off but just wanted to let you know.

Thanks for the quick updates.

I'll add a 'Tested-by: ...' tag from you.

Thanks for reporting and following up! ;)

#1 lore raw
In reply to Klaus Jensen
Quoted 3 lines · Klaus Jensen

The Zone Append Size Limit (ZASL) must be at least 4096 bytes, so improve the user experience by adding an early parameter check in nvme_check_constraints.

I have confirmed this and it works for me, I don't think I am actually qualified or understand QEMUs source well enough to sign this off but just wanted to let you know.

Thanks for the quick updates.

Kind regards,
Corne

Reviewed-by on v1 1/1
#3 lore raw
In reply to Klaus Jensen
Quoted 37 lines · Klaus Jensen

From: Klaus Jensen <[email protected]>

The Zone Append Size Limit (ZASL) must be at least 4096 bytes, so improve the user experience by adding an early parameter check in nvme_check_constraints.

When ZASL is still too small due to the host configuring the device for an even larger page size, convert the trace point in nvme_start_ctrl to an NVME_GUEST_ERR such that this is logged by QEMU instead of only traced.

---
 hw/block/nvme.c | 12 ++++++++++--

 1 file changed, 10 insertions(+), 2 deletions(-)
hw/block/nvme.c +4 -2
index c2f0c88fbf39..d96888cd2333 100644
@@ -3983,8 +3983,10 @@ static int nvme_start_ctrl(NvmeCtrl *n)
          n->zasl = n->params.mdts;
      } else {
          if (n->params.zasl_bs < n->page_size) {
-            trace_pci_nvme_err_startfail_zasl_too_small(n->params.zasl_bs,
-                                                        n->page_size);
+            NVME_GUEST_ERR(pci_nvme_err_startfail_zasl_too_small,
+                           "Zone Append Size Limit (ZASL) of %d bytes is too "
+                           "small; must be at least %d bytes",
+                           n->params.zasl_bs, n->page_size);
              return -1;
          }
          n->zasl = 31 - clz32(n->params.zasl_bs / n->page_size);
@@ -4503,6 +4505,12 @@ static void nvme_check_constraints(NvmeCtrl *n, Error **errp)
              error_setg(errp, "zone append size limit has to be a power of 2");

hw/block/nvme.c static void nvme_check_constraints(NvmeCtrl *n, Error **errp) · line 4515

Quoted 10 lines
hw/block/nvme.c +6 -0
              return;
          }
+
+        if (n->params.zasl_bs < 4096) {
+            error_setg(errp, "zone append size limit must be at least "
+                       "4096 bytes");
+            return;
+        }
      }
  }

The guest error is less confusing than simply a trace. LGTM.

Quoted 4 lines

#4 lore raw
Quoted 7 lines · Dmitry Fomichev
Quoted 6 lines · Klaus Jensen

From: Klaus Jensen <[email protected]>

The Zone Append Size Limit (ZASL) must be at least 4096 bytes, so improve the user experience by adding an early parameter check in nvme_check_constraints.

Quoted 6 lines
Quoted 6 lines

When ZASL is still too small due to the host configuring the device for an even larger page size, convert the trace point in nvme_start_ctrl to an NVME_GUEST_ERR such that this is logged by QEMU instead of only traced.

Apparently the reporter signed 'Corne'.

Quoted 29 lines
Quoted 29 lines
Cc Dmitry Fomichev <[email protected]>

---
 hw/block/nvme.c | 12 ++++++++++--

 1 file changed, 10 insertions(+), 2 deletions(-)
hw/block/nvme.c +6 -2
index c2f0c88fbf39..d96888cd2333 100644
@@ -3983,8 +3983,10 @@ static int nvme_start_ctrl(NvmeCtrl *n)
          n->zasl = n->params.mdts;
      } else {
          if (n->params.zasl_bs < n->page_size) {
-            trace_pci_nvme_err_startfail_zasl_too_small(n->params.zasl_bs,
-                                                        n->page_size);
+            NVME_GUEST_ERR(pci_nvme_err_startfail_zasl_too_small,
+                           "Zone Append Size Limit (ZASL) of %d bytes is too "
+                           "small; must be at least %d bytes",
+                           n->params.zasl_bs, n->page_size);
              return -1;
          }
          n->zasl = 31 - clz32(n->params.zasl_bs / n->page_size);
@@ -4503,6 +4505,12 @@ static void nvme_check_constraints(NvmeCtrl *n, Error **errp)
              error_setg(errp, "zone append size limit has to be a power of 2");
              return;
          }
+
+        if (n->params.zasl_bs < 4096) {
Quoted 8 lines

hw/block/nvme.c static void nvme_check_constraints(NvmeCtrl *n, Error **errp) · line 4515

Quoted 6 lines
hw/block/nvme.c +4 -0
+            error_setg(errp, "zone append size limit must be at least "
+                       "4096 bytes");
+            return;
+        }
      }
  }

The guest error is less confusing than simply a trace. LGTM.

Trace events are meant for the developers when debugging, they are usually stripped out in final build.

Errors are reported to the user / operator (i.e. incorrect configuration).

Regards,

Phil.

#5 lore raw
In reply to Klaus Jensen
Quoted 11 lines · Klaus Jensen

From: Klaus Jensen <[email protected]>

The Zone Append Size Limit (ZASL) must be at least 4096 bytes, so improve the user experience by adding an early parameter check in nvme_check_constraints.

When ZASL is still too small due to the host configuring the device for an even larger page size, convert the trace point in nvme_start_ctrl to an NVME_GUEST_ERR such that this is logged by QEMU instead of only traced.

Thanks for the review; applied to nvme-next!