Skip to content

Commit 7988bdb

Browse files
bmarreddyjgunthorpe
authored andcommitted
RDMA/bnxt_re: Fix a bug while setting up Level-2 PBL pages
Avoid memory corruption while setting up Level-2 PBL pages for the non MR resources when num_pages > 256K. There will be a single PDE page address (contiguous pages in the case of > PAGE_SIZE), but, current logic assumes multiple pages, leading to invalid memory access after 256K PBL entries in the PDE. Fixes: 0c4dcd6 ("RDMA/bnxt_re: Refactor hardware queue memory allocation") Link: https://patch.msgid.link/r/[email protected] Signed-off-by: Bhargava Chenna Marreddy <[email protected]> Signed-off-by: Selvin Xavier <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 2df4113 commit 7988bdb

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

drivers/infiniband/hw/bnxt_re/qplib_res.c

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -257,22 +257,9 @@ int bnxt_qplib_alloc_init_hwq(struct bnxt_qplib_hwq *hwq,
257257
dst_virt_ptr =
258258
(dma_addr_t **)hwq->pbl[PBL_LVL_0].pg_arr;
259259
src_phys_ptr = hwq->pbl[PBL_LVL_1].pg_map_arr;
260-
if (hwq_attr->type == HWQ_TYPE_MR) {
261-
/* For MR it is expected that we supply only 1 contigous
262-
* page i.e only 1 entry in the PDL that will contain
263-
* all the PBLs for the user supplied memory region
264-
*/
265-
for (i = 0; i < hwq->pbl[PBL_LVL_1].pg_count;
266-
i++)
267-
dst_virt_ptr[0][i] = src_phys_ptr[i] |
268-
flag;
269-
} else {
270-
for (i = 0; i < hwq->pbl[PBL_LVL_1].pg_count;
271-
i++)
272-
dst_virt_ptr[PTR_PG(i)][PTR_IDX(i)] =
273-
src_phys_ptr[i] |
274-
PTU_PDE_VALID;
275-
}
260+
for (i = 0; i < hwq->pbl[PBL_LVL_1].pg_count; i++)
261+
dst_virt_ptr[0][i] = src_phys_ptr[i] | flag;
262+
276263
/* Alloc or init PTEs */
277264
rc = __alloc_pbl(res, &hwq->pbl[PBL_LVL_2],
278265
hwq_attr->sginfo);

0 commit comments

Comments
 (0)