From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D9B318E03A; Mon, 28 Oct 2024 06:33:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730097190; cv=none; b=HtADeMo3UK5dPLSSAAQczvAeJ8//UG42D0vc1iQl6a49Nk2VT2/LXgYx34389FywoCXuHyK8oEuV4aWXBnb5war+wvxbcS7qpjOjXYQL9IiTeso9t8ksu8n/mjrXkArcM65aYg0bat4twwCPQiBRG8hXx90GKrM1MdXCD9nHYKc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730097190; c=relaxed/simple; bh=z73PyksYqszyqDo0umROvnNoyGCCfNfd1viVXddjXUg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g2k0oDT2Qa8xeUhf4x82OhOZihWpjuO0p6MQVQdnkvAZnVCnToNH9AeNP3YQ2Hk38jdIz0iy2tQlLQki4EwXda9yimapYjB+V3jMsjOOw8zhT0sdsUxTAIymRgXw09rg5ULIOIM3PMQ1SBMDl4SNkY7HjJSOIracTBUeLskZ2Kg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=qtkZx4w9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="qtkZx4w9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFA7EC4CEC7; Mon, 28 Oct 2024 06:33:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1730097190; bh=z73PyksYqszyqDo0umROvnNoyGCCfNfd1viVXddjXUg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qtkZx4w95y4IQcE4rBCSBrAGomUyun2kYuHW7zvuILq3mkLHeI7HAohHtY8mJqCSs uZnJv7aMfSTHQYt7BEgxCewMZSK5iq5IXeqaeb4AKPFCBSsV3UR4EorKOKV+aBPnMe sdMGDrLkvKA7p53KOVN2p3vFgZqc5F7xC3Qn7QTA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Bhargava Chenna Marreddy , Selvin Xavier , Jason Gunthorpe , Sasha Levin Subject: [PATCH 6.1 022/137] RDMA/bnxt_re: Fix a bug while setting up Level-2 PBL pages Date: Mon, 28 Oct 2024 07:24:19 +0100 Message-ID: <20241028062259.344698595@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241028062258.708872330@linuxfoundation.org> References: <20241028062258.708872330@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bhargava Chenna Marreddy [ Upstream commit 7988bdbbb85ac85a847baf09879edcd0f70521dc ] 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: 0c4dcd602817 ("RDMA/bnxt_re: Refactor hardware queue memory allocation") Link: https://patch.msgid.link/r/1728373302-19530-10-git-send-email-selvin.xavier@broadcom.com Signed-off-by: Bhargava Chenna Marreddy Signed-off-by: Selvin Xavier Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/hw/bnxt_re/qplib_res.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/drivers/infiniband/hw/bnxt_re/qplib_res.c b/drivers/infiniband/hw/bnxt_re/qplib_res.c index 1dd36af9e68f2..203350c6e00f5 100644 --- a/drivers/infiniband/hw/bnxt_re/qplib_res.c +++ b/drivers/infiniband/hw/bnxt_re/qplib_res.c @@ -257,22 +257,9 @@ int bnxt_qplib_alloc_init_hwq(struct bnxt_qplib_hwq *hwq, dst_virt_ptr = (dma_addr_t **)hwq->pbl[PBL_LVL_0].pg_arr; src_phys_ptr = hwq->pbl[PBL_LVL_1].pg_map_arr; - if (hwq_attr->type == HWQ_TYPE_MR) { - /* For MR it is expected that we supply only 1 contigous - * page i.e only 1 entry in the PDL that will contain - * all the PBLs for the user supplied memory region - */ - for (i = 0; i < hwq->pbl[PBL_LVL_1].pg_count; - i++) - dst_virt_ptr[0][i] = src_phys_ptr[i] | - flag; - } else { - for (i = 0; i < hwq->pbl[PBL_LVL_1].pg_count; - i++) - dst_virt_ptr[PTR_PG(i)][PTR_IDX(i)] = - src_phys_ptr[i] | - PTU_PDE_VALID; - } + for (i = 0; i < hwq->pbl[PBL_LVL_1].pg_count; i++) + dst_virt_ptr[0][i] = src_phys_ptr[i] | flag; + /* Alloc or init PTEs */ rc = __alloc_pbl(res, &hwq->pbl[PBL_LVL_2], hwq_attr->sginfo); -- 2.43.0