LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Wei Hu (Xavier)" <xavier.huwei@huawei.com>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: <dledford@redhat.com>, <linux-rdma@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH V2 rdma-next 4/4] RDMA/hns: Fix the illegal memory operation when cross page
Date: Fri, 25 May 2018 13:56:02 +0800 [thread overview]
Message-ID: <5B07A572.3000900@huawei.com> (raw)
In-Reply-To: <20180524214047.GF3948@ziepe.ca>
On 2018/5/25 5:40, Jason Gunthorpe wrote:
> On Wed, May 23, 2018 at 06:16:30PM +0800, Wei Hu (Xavier) wrote:
>> This patch fixed the potential illegal operation when using the
>> extend sge buffer cross page in post send operation. The bug
>> will cause the calltrace.
> Should include the oops for reference here..
OK, we will fix it in v3.
Thanks
>> Reported-by: Jie Chen <chenjie103@huawei.com>
>> Reported-by: Xiping Zhang (Francis) <zhangxiping3@huawei.com>
>> Fixes: b1c158350968("RDMA/hns: Get rid of virt_to_page and vmap calls after dma_alloc_coherent")
>> Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
>>
>> v1->v2: Modify the Fixes statement according to Leon's comment.
>> drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 70 +++++++++++++++++++++---------
>> drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 1 +
>> 2 files changed, 51 insertions(+), 20 deletions(-)
>>
>> diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
>> index a70d07b..62c1eb5 100644
>> +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
>> @@ -52,6 +52,52 @@ static void set_data_seg_v2(struct hns_roce_v2_wqe_data_seg *dseg,
>> dseg->len = cpu_to_le32(sg->length);
>> }
>>
>> +static void set_extend_sge(struct hns_roce_qp *qp, struct ib_send_wr *wr,
>> + unsigned int *sge_ind)
>> +{
>> + struct hns_roce_v2_wqe_data_seg *dseg;
>> + struct ib_sge *sg;
>> + int num_in_wqe = 0;
>> + int extend_sge_num;
>> + int fi_sge_num;
>> + int se_sge_num;
>> + int shift;
>> + int i;
>> +
>> + if (qp->ibqp.qp_type == IB_QPT_RC || qp->ibqp.qp_type == IB_QPT_UC)
>> + num_in_wqe = HNS_ROCE_V2_UC_RC_SGE_NUM_IN_WQE;
>> + extend_sge_num = wr->num_sge - num_in_wqe;
>> + sg = wr->sg_list + num_in_wqe;
>> + shift = qp->hr_buf.page_shift;
>> +
>> + /*
>> + * Check whether wr->num_sge sges are in the same page. If not, we
>> + * should calculate how many sges in the first page and the second
>> + * page.
>> + */
>> + dseg = get_send_extend_sge(qp, (*sge_ind) & (qp->sge.sge_cnt - 1));
>> + fi_sge_num = (((((u64)dseg >> shift) + 1) << shift) - (u64)dseg) /
>> + sizeof(struct hns_roce_v2_wqe_data_seg);
> desg is a pointer.. that u64 should be a uinptr_t
>
> And it is better written as
>
> (round_up((uintptr_t)dseg, 1 << shift) - (uintptr)desg)/sizeof(struct hns_roce_v2_wqe_data_seg)
>
> if I got it right..
Ok, we will fix it v3.
Thanks
Wei Hu
> Jason
>
> .
>
next prev parent reply other threads:[~2018-05-25 5:56 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-23 10:16 [PATCH V2 rdma-next 0/4] Misc update for hns driver Wei Hu (Xavier)
2018-05-23 10:16 ` [PATCH V2 rdma-next 1/4] RDMA/hns: Modify uar allocation algorithm to avoid bitmap exhaust Wei Hu (Xavier)
2018-05-23 10:16 ` [PATCH V2 rdma-next 2/4] RDMA/hns: Increase checking CMQ status timeout value Wei Hu (Xavier)
2018-05-23 10:16 ` [PATCH V2 rdma-next 3/4] RDMA/hns: Add reset process for RoCE in hip08 Wei Hu (Xavier)
2018-05-24 21:31 ` Jason Gunthorpe
2018-05-25 5:54 ` Wei Hu (Xavier)
2018-05-25 14:55 ` Jason Gunthorpe
2018-05-26 1:47 ` Wei Hu (Xavier)
2018-05-28 16:46 ` Jason Gunthorpe
2018-05-23 10:16 ` [PATCH V2 rdma-next 4/4] RDMA/hns: Fix the illegal memory operation when cross page Wei Hu (Xavier)
2018-05-24 21:40 ` Jason Gunthorpe
2018-05-25 5:56 ` Wei Hu (Xavier) [this message]
2018-05-24 21:43 ` [PATCH V2 rdma-next 0/4] Misc update for hns driver Jason Gunthorpe
2018-05-26 7:40 ` Wei Hu (Xavier)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5B07A572.3000900@huawei.com \
--to=xavier.huwei@huawei.com \
--cc=dledford@redhat.com \
--cc=jgg@ziepe.ca \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--subject='Re: [PATCH V2 rdma-next 4/4] RDMA/hns: Fix the illegal memory operation when cross page' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).