Skip to contentSkip to conversation

nvme: clear the prp2 field of the nvme command.

PATCH Applied Lei Rao 2 participants 2 messages Nov 29, 2022 NVMe

lore
Share & tools
lore

Lei Rao

author
#0 lore raw

PATCH 1/1 nvme: clear the prp2 field of the nvme command.

If the prp2 field is not filled in nvme_setup_prp_simple(), the prp2 field is garbage data. According to nvme spec, the prp2 is reserved if the data transfer does not cross a memory page boundary. Writing a reserved coded value into a controller property field produces undefined results, so it needs to be cleared in nvme_setup_prp_simple().

---
 drivers/nvme/host/pci.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/nvme/host/pci.c +2 -0
index f4335519399d..488ad7dabeb8 100644
@@ -797,6 +797,8 @@ static blk_status_t nvme_setup_prp_simple(struct nvme_dev *dev,
 	cmnd->dptr.prp1 = cpu_to_le64(iod->first_dma);
 	if (bv->bv_len > first_prp_len)
 		cmnd->dptr.prp2 = cpu_to_le64(iod->first_dma + first_prp_len);
+	else
+		cmnd->dptr.prp2 = 0;
 	return BLK_STS_OK;
 }
 
Signature · 1 line
2.34.1
maintainer Applied
#1 lore raw

Thanks,

I've applied the patch with a slightly update commit message to the nvme-6.1 tree.