diff mbox series

[v2] hw/nvme: fix copy cmd for pi enabled namespaces

Message ID 20220421105158.ufd3wzivaougxokx@localhost.localdomain
State New
Headers show
Series [v2] hw/nvme: fix copy cmd for pi enabled namespaces | expand

Commit Message

Dmitry Tihov April 21, 2022, 10:51 a.m. UTC
Current implementation have problem in the read part of copy command.
Because there is no metadata mangling before nvme_dif_check invocation,
reftag error could be thrown for blocks of namespace that have not been
previously written to.

Signed-off-by: Dmitry Tikhov <d.tihov@yadro.com>
---
v2:
    * remove refactoring
    * remove write part fix
---
 hw/nvme/ctrl.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Klaus Jensen April 28, 2022, 8:16 p.m. UTC | #1
On Apr 21 13:51, Dmitry Tikhov wrote:
> Current implementation have problem in the read part of copy command.
> Because there is no metadata mangling before nvme_dif_check invocation,
> reftag error could be thrown for blocks of namespace that have not been
> previously written to.
> 
> Signed-off-by: Dmitry Tikhov <d.tihov@yadro.com>
> ---
> v2:
>     * remove refactoring
>     * remove write part fix
> ---
>  hw/nvme/ctrl.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
> index 74540a03d5..08574c4dcb 100644
> --- a/hw/nvme/ctrl.c
> +++ b/hw/nvme/ctrl.c
> @@ -2787,6 +2787,10 @@ static void nvme_copy_in_completed_cb(void *opaque, int ret)
>          size_t mlen = nvme_m2b(ns, nlb);
>          uint8_t *mbounce = iocb->bounce + nvme_l2b(ns, nlb);
>  
> +        status = nvme_dif_mangle_mdata(ns, mbounce, mlen, slba);
> +        if (status) {
> +            goto invalid;
> +        }
>          status = nvme_dif_check(ns, iocb->bounce, len, mbounce, mlen, prinfor,
>                                  slba, apptag, appmask, &reftag);
>          if (status) {
> -- 
> 2.35.1
> 

Thanks Dmitry,

Applied to nvme-next.
diff mbox series

Patch

diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index 74540a03d5..08574c4dcb 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -2787,6 +2787,10 @@  static void nvme_copy_in_completed_cb(void *opaque, int ret)
         size_t mlen = nvme_m2b(ns, nlb);
         uint8_t *mbounce = iocb->bounce + nvme_l2b(ns, nlb);
 
+        status = nvme_dif_mangle_mdata(ns, mbounce, mlen, slba);
+        if (status) {
+            goto invalid;
+        }
         status = nvme_dif_check(ns, iocb->bounce, len, mbounce, mlen, prinfor,
                                 slba, apptag, appmask, &reftag);
         if (status) {