Skip to content

Commit b69e2ef

Browse files
keithbuschChristoph Hellwig
authored andcommitted
nvme-pci: dma read memory barrier for completions
Control dependencies do not guarantee load order across the condition, allowing a CPU to predict and speculate memory reads. Commit 324b494 inlined verifying a new completion with its handling. At least one architecture was observed to access the contents out of order, resulting in the driver using stale data for the completion. Add a dma read barrier before reading the completion queue entry and after the condition its contents depend on to ensure the read order is determinsitic. Reported-by: John Garry <[email protected]> Suggested-by: Will Deacon <[email protected]> Signed-off-by: Keith Busch <[email protected]> Tested-by: John Garry <[email protected]> Acked-by: Will Deacon <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 59c7c3c commit b69e2ef

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/nvme/host/pci.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,11 @@ static inline int nvme_process_cq(struct nvme_queue *nvmeq)
989989

990990
while (nvme_cqe_pending(nvmeq)) {
991991
found++;
992+
/*
993+
* load-load control dependency between phase and the rest of
994+
* the cqe requires a full read memory barrier
995+
*/
996+
dma_rmb();
992997
nvme_handle_cqe(nvmeq, nvmeq->cq_head);
993998
nvme_update_cq_head(nvmeq);
994999
}

0 commit comments

Comments
 (0)