Skip to content

Commit 37924f5

Browse files
nprao1gregkh
authored andcommitted
pds_core: order completion reads after the ownership check
[ Upstream commit dd6b1cc ] pdsc_process_adminq() and pdsc_process_notifyq() decide a completion is valid from its ownership field - the color bit for the adminq, the event id for the notifyq - then read the rest of the descriptor, with no barrier in between. On a weakly ordered architecture the CPU may read the payload first. Add dma_rmb() between the ownership read and the payload reads. Fixes: 7e82a87 ("pds_core: Prevent race issues involving the adminq") Reported-by: sashiko-bot <sashiko-bot@kernel.org> Closes: https://sashiko.dev/#/patchset/20260629200358.2626129-1-nikhil.rao%40amd.com?part=2 Signed-off-by: Nikhil P. Rao <nikhil.rao@amd.com> Reviewed-by: Eric Joyner <eric.joyner@amd.com> Link: https://patch.msgid.link/20260714204145.1782390-1-nikhil.rao@amd.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent f79c7af commit 37924f5

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

  • drivers/net/ethernet/amd/pds_core

drivers/net/ethernet/amd/pds_core/adminq.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ static int pdsc_process_notifyq(struct pdsc_qcq *qcq)
1818
comp = cq_info->comp;
1919
eid = le64_to_cpu(comp->event.eid);
2020
while (eid > pdsc->last_eid) {
21-
u16 ecode = le16_to_cpu(comp->event.ecode);
21+
u16 ecode;
22+
23+
/* Order the payload read after the event id, the field the
24+
* driver uses to detect a new completion.
25+
*/
26+
dma_rmb();
27+
ecode = le16_to_cpu(comp->event.ecode);
2228

2329
switch (ecode) {
2430
case PDS_EVENT_LINK_CHANGE:
@@ -102,6 +108,10 @@ void pdsc_process_adminq(struct pdsc_qcq *qcq)
102108
spin_lock_irqsave(&pdsc->adminq_lock, irqflags);
103109
comp = cq->info[cq->tail_idx].comp;
104110
while (pdsc_color_match(comp->color, cq->done_color)) {
111+
/* Order the payload reads after the color bit, the field the
112+
* driver uses to detect a new completion.
113+
*/
114+
dma_rmb();
105115
q_info = &q->info[q->tail_idx];
106116
q->tail_idx = (q->tail_idx + 1) & (q->num_descs - 1);
107117

0 commit comments

Comments
 (0)