diff mbox series

[1/3] hw/nvme: fix CRC64 for guard tag

Message ID 20230807212745.70151-2-ankit.kumar@samsung.com
State New
Headers show
Series hw/nvme: bug fixes and doc update | expand

Commit Message

Ankit Kumar Aug. 7, 2023, 9:27 p.m. UTC
The nvme CRC64 generator expects the caller to pass inverted seed value.
Pass inverted crc value for metadata buffer.

Signed-off-by: Ankit Kumar <ankit.kumar@samsung.com>
---
 hw/nvme/dif.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Klaus Jensen Aug. 8, 2023, 5:58 a.m. UTC | #1
On Aug  8 02:57, Ankit Kumar wrote:
> The nvme CRC64 generator expects the caller to pass inverted seed value.
> Pass inverted crc value for metadata buffer.
> 
> Signed-off-by: Ankit Kumar <ankit.kumar@samsung.com>
> ---
>  hw/nvme/dif.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/nvme/dif.c b/hw/nvme/dif.c
> index 63c44c86ab..01b19c3373 100644
> --- a/hw/nvme/dif.c
> +++ b/hw/nvme/dif.c
> @@ -115,7 +115,7 @@ static void nvme_dif_pract_generate_dif_crc64(NvmeNamespace *ns, uint8_t *buf,
>          uint64_t crc = crc64_nvme(~0ULL, buf, ns->lbasz);
>  
>          if (pil) {
> -            crc = crc64_nvme(crc, mbuf, pil);
> +            crc = crc64_nvme(~crc, mbuf, pil);
>          }
>  
>          dif->g64.guard = cpu_to_be64(crc);
> @@ -246,7 +246,7 @@ static uint16_t nvme_dif_prchk_crc64(NvmeNamespace *ns, NvmeDifTuple *dif,
>          uint64_t crc = crc64_nvme(~0ULL, buf, ns->lbasz);
>  
>          if (pil) {
> -            crc = crc64_nvme(crc, mbuf, pil);
> +            crc = crc64_nvme(~crc, mbuf, pil);
>          }
>  
>          trace_pci_nvme_dif_prchk_guard_crc64(be64_to_cpu(dif->g64.guard), crc);
> -- 
> 2.25.1
> 

Good catch, thanks!

Reviewed-by: Klaus Jensen <k.jensen@samsung.com>
diff mbox series

Patch

diff --git a/hw/nvme/dif.c b/hw/nvme/dif.c
index 63c44c86ab..01b19c3373 100644
--- a/hw/nvme/dif.c
+++ b/hw/nvme/dif.c
@@ -115,7 +115,7 @@  static void nvme_dif_pract_generate_dif_crc64(NvmeNamespace *ns, uint8_t *buf,
         uint64_t crc = crc64_nvme(~0ULL, buf, ns->lbasz);
 
         if (pil) {
-            crc = crc64_nvme(crc, mbuf, pil);
+            crc = crc64_nvme(~crc, mbuf, pil);
         }
 
         dif->g64.guard = cpu_to_be64(crc);
@@ -246,7 +246,7 @@  static uint16_t nvme_dif_prchk_crc64(NvmeNamespace *ns, NvmeDifTuple *dif,
         uint64_t crc = crc64_nvme(~0ULL, buf, ns->lbasz);
 
         if (pil) {
-            crc = crc64_nvme(crc, mbuf, pil);
+            crc = crc64_nvme(~crc, mbuf, pil);
         }
 
         trace_pci_nvme_dif_prchk_guard_crc64(be64_to_cpu(dif->g64.guard), crc);