Skip to content

Commit

Permalink
hw/nvme: fix CRC64 for guard tag
Browse files Browse the repository at this point in the history
The nvme CRC64 generator expects the caller to pass inverted seed value.
Pass inverted crc value for metadata buffer.

Cc: qemu-stable@nongnu.org
Fixes: 44219b6 ("hw/nvme: 64-bit pi support")
Signed-off-by: Ankit Kumar <ankit.kumar@samsung.com>
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
  • Loading branch information
ankit-sam authored and birkelund committed Aug 8, 2023
1 parent 0450cf0 commit dbdb13f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hw/nvme/dif.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit dbdb13f

Please sign in to comment.