All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hw/block/nvme: improve invalid zasl value reporting
@ 2021-02-08  8:25 Klaus Jensen
  2021-02-08  9:15 ` info
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Klaus Jensen @ 2021-02-08  8:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, qemu-block, Dmitry Fomichev, Klaus Jensen, Max Reitz,
	Keith Busch, Klaus Jensen, info

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

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.

Reported-by: "info@dantalion.nl" <info@dantalion.nl>
Cc: Dmitry Fomichev <Dmitry.Fomichev@wdc.com>
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
---
 hw/block/nvme.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index c2f0c88fbf39..d96888cd2333 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -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;
+        }
     }
 }
 
-- 
2.30.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] hw/block/nvme: improve invalid zasl value reporting
  2021-02-08  8:25 [PATCH] hw/block/nvme: improve invalid zasl value reporting Klaus Jensen
@ 2021-02-08  9:15 ` info
  2021-02-08  9:19   ` Klaus Jensen
  2021-02-09 19:39 ` Dmitry Fomichev
  2021-02-10 20:56 ` Klaus Jensen
  2 siblings, 1 reply; 6+ messages in thread
From: info @ 2021-02-08  9:15 UTC (permalink / raw)
  To: Klaus Jensen, qemu-devel
  Cc: Kevin Wolf, qemu-block, Dmitry Fomichev, Klaus Jensen, Max Reitz,
	Keith Busch

On 08-02-2021 09:25, Klaus Jensen wrote:
> 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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] hw/block/nvme: improve invalid zasl value reporting
  2021-02-08  9:15 ` info
@ 2021-02-08  9:19   ` Klaus Jensen
  0 siblings, 0 replies; 6+ messages in thread
From: Klaus Jensen @ 2021-02-08  9:19 UTC (permalink / raw)
  To: info
  Cc: Kevin Wolf, qemu-block, Dmitry Fomichev, Klaus Jensen,
	qemu-devel, Max Reitz, Keith Busch

[-- Attachment #1: Type: text/plain, Size: 572 bytes --]

On Feb  8 10:15, info@dantalion.nl wrote:
> On 08-02-2021 09:25, Klaus Jensen wrote:
> > 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! ;)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] hw/block/nvme: improve invalid zasl value reporting
  2021-02-08  8:25 [PATCH] hw/block/nvme: improve invalid zasl value reporting Klaus Jensen
  2021-02-08  9:15 ` info
@ 2021-02-09 19:39 ` Dmitry Fomichev
  2021-02-10  6:09   ` Philippe Mathieu-Daudé
  2021-02-10 20:56 ` Klaus Jensen
  2 siblings, 1 reply; 6+ messages in thread
From: Dmitry Fomichev @ 2021-02-09 19:39 UTC (permalink / raw)
  To: its, qemu-devel; +Cc: kwolf, qemu-block, k.jensen, mreitz, kbusch, info

On Mon, 2021-02-08 at 09:25 +0100, Klaus Jensen wrote:
> From: Klaus Jensen <k.jensen@samsung.com>
> 
> 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.
> 
> Reported-by: "info@dantalion.nl" <info@dantalion.nl>
> Cc: Dmitry Fomichev <Dmitry.Fomichev@wdc.com>
> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
> ---
>  hw/block/nvme.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/block/nvme.c b/hw/block/nvme.c
> index c2f0c88fbf39..d96888cd2333 100644
> --- a/hw/block/nvme.c
> +++ b/hw/block/nvme.c
> @@ -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;
> +        }
>      }
>  }

The guest error is less confusing than simply a trace. LGTM.
Reviewed-by: Dmitry Fomichev <dmitry.fomichev@wdc.com>

>  
> 
> 
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] hw/block/nvme: improve invalid zasl value reporting
  2021-02-09 19:39 ` Dmitry Fomichev
@ 2021-02-10  6:09   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-02-10  6:09 UTC (permalink / raw)
  To: Dmitry Fomichev, its, qemu-devel
  Cc: kwolf, qemu-block, k.jensen, mreitz, kbusch, info

On 2/9/21 8:39 PM, Dmitry Fomichev wrote:
> On Mon, 2021-02-08 at 09:25 +0100, Klaus Jensen wrote:
>> From: Klaus Jensen <k.jensen@samsung.com>
>>
>> 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.
>>
>> Reported-by: "info@dantalion.nl" <info@dantalion.nl>

Apparently the reporter signed 'Corne'.

>> Cc: Dmitry Fomichev <Dmitry.Fomichev@wdc.com>
>> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
>> ---
>>  hw/block/nvme.c | 12 ++++++++++--
>>  1 file changed, 10 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/block/nvme.c b/hw/block/nvme.c
>> index c2f0c88fbf39..d96888cd2333 100644
>> --- a/hw/block/nvme.c
>> +++ b/hw/block/nvme.c
>> @@ -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;
>> +        }
>>      }
>>  }
> 
> 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.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] hw/block/nvme: improve invalid zasl value reporting
  2021-02-08  8:25 [PATCH] hw/block/nvme: improve invalid zasl value reporting Klaus Jensen
  2021-02-08  9:15 ` info
  2021-02-09 19:39 ` Dmitry Fomichev
@ 2021-02-10 20:56 ` Klaus Jensen
  2 siblings, 0 replies; 6+ messages in thread
From: Klaus Jensen @ 2021-02-10 20:56 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, qemu-block, Dmitry Fomichev, Klaus Jensen, Max Reitz,
	Keith Busch, info

[-- Attachment #1: Type: text/plain, Size: 539 bytes --]

On Feb  8 09:25, Klaus Jensen wrote:
> From: Klaus Jensen <k.jensen@samsung.com>
> 
> 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!

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-02-10 21:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-08  8:25 [PATCH] hw/block/nvme: improve invalid zasl value reporting Klaus Jensen
2021-02-08  9:15 ` info
2021-02-08  9:19   ` Klaus Jensen
2021-02-09 19:39 ` Dmitry Fomichev
2021-02-10  6:09   ` Philippe Mathieu-Daudé
2021-02-10 20:56 ` Klaus Jensen

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.