nvme: fix copy direction in DMA reads going to CMB
PATCH 1/1 nvme: fix copy direction in DMA reads going to CMB
nvme_dma_read_prp erronously used qemu_iovec_*to*_buf instead of qemu_iovec_*from*_buf when the request involved the controller memory buffer.
--- hw/block/nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/block/nvme.c +1 -1
@@ -238,7 +238,7 @@ static uint16_t nvme_dma_read_prp(NvmeCtrl *n, uint8_t *ptr, uint32_t len, }qemu_sglist_destroy (&qsg); }else { -if (unlikely (qemu_iovec_to_buf (&iov,0 , ptr, len) != len)) { +if (unlikely (qemu_iovec_from_buf (&iov,0 , ptr, len) != len)) {trace_nvme_err_invalid_dma (); status =NVME_INVALID_FIELD |NVME_DNR ; }
Signature · 1 line
2.21.0
Quoted 15 lines · Klaus Birkelund Jensen
nvme_dma_read_prperronously usedqemu_iovec_*to*_bufinstead ofqemu_iovec_*from*_bufwhen the request involved the controller memory buffer.Signed-off-by Klaus Birkelund Jensen <[email protected]>--- hw/block/nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/block/nvme.c +0
-0
hw/block/nvme.c static uint16_t nvme_dma_read_prp(NvmeCtrl *n, uint8_t *ptr, uint32_t len, · line 244
Quoted 8 lines
hw/block/nvme.c +1
-1@@ -238,7 +238,7 @@ static uint16_t nvme_dma_read_prp(NvmeCtrl *n, uint8_t *ptr, uint32_t len, }qemu_sglist_destroy (&qsg); }else { -if (unlikely (qemu_iovec_to_buf (&iov,0 , ptr, len) != len)) { +if (unlikely (qemu_iovec_from_buf (&iov,0 , ptr, len) != len)) {trace_nvme_err_invalid_dma (); status =NVME_INVALID_FIELD |NVME_DNR ; }
Kevin Wolf
AppliedAm 18.05.2019 um 09:39 hat Klaus Birkelund Jensen geschrieben:
Quoted 5 lines
nvme_dma_read_prperronously usedqemu_iovec_*to*_bufinstead ofqemu_iovec_*from*_bufwhen the request involved the controller memory buffer.Signed-off-by Klaus Birkelund Jensen <[email protected]>
Thanks, applied to the block branch.
Kevin
Quoted 5 lines · Klaus Birkelund Jensen
nvme_dma_read_prperronously usedqemu_iovec_*to*_bufinstead ofqemu_iovec_*from*_bufwhen the request involved the controller memory buffer.Signed-off-by Klaus Birkelund Jensen <[email protected]>
I was wondering how this mistake got by for so long, and it looks like the only paths here require an admin command with dev->host transfer to CMB. That's just not done in any host implementation I'm aware of since it'd make it more difficult to use for no particular gain AFAICS, so I'd be curious to hear if you have a legit implementation doing this.
Anyway, thanks for the fix.
Quoted 5 lines · Keith Busch
Quoted 4 lines · Klaus Birkelund Jensen
nvme_dma_read_prperronously usedqemu_iovec_*to*_bufinstead ofqemu_iovec_*from*_bufwhen the request involved the controller memory buffer.
Quoted 8 lines
Quoted 1 line
Signed-off-by Klaus Birkelund Jensen <[email protected]>I was wondering how this mistake got by for so long, and it looks like the only paths here require an admin command with
dev->hosttransfer to CMB. That's just not done in any host implementation I'm aware of since it'd make it more difficult to use for no particular gain AFAICS, so I'd be curious to hear if you have a legit implementation doing this.
I'm just trying to get the device to be as compliant as possible, but I don't know why you'd have any reason to do a, say Get Feature, to the CMB.