mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Cheng Xu <chengyou@linux.alibaba.com>
To: "Ваторопин Андрей" <a.vatoropin@crpt.ru>,
	"Kai Shen" <kaishen@linux.alibaba.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>,
	Wei Yongjun <weiyongjun1@huawei.com>,
	Yang Li <yang.lee@linux.alibaba.com>,
	"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"lvc-project@linuxtesting.org" <lvc-project@linuxtesting.org>
Subject: Re: [PATCH] RDMA/erdma: handle ib_umem_find_best_pgsz() return value
Date: Fri, 21 Feb 2025 15:55:24 +0800	[thread overview]
Message-ID: <a02b09d9-8b95-354f-dade-67240200d4fc@linux.alibaba.com> (raw)
In-Reply-To: <20250221070301.18010-1-a.vatoropin@crpt.ru>



On 2/21/25 3:03 PM, Ваторопин Андрей wrote:
> From: Andrey Vatoropin <a.vatoropin@crpt.ru>
> 
> The ib_umem_find_best_pgsz function is necessary for obtaining the optimal
> hardware page size. In the comment above, function has statement: 
> "Drivers always supporting PAGE_SIZE or smaller will never see a 0 result."
> 
> But it's hard to prove this holds true for the erdma driver.
> 
> Similar to other drivers that use ib_umem_find_best_pgsz, it is essential 
> to add an error handler to manage potential error situations in the future.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: 155055771704 ("RDMA/erdma: Add verbs implementation")
> Signed-off-by: Andrey Vatoropin <a.vatoropin@crpt.ru>
> ---
>  drivers/infiniband/hw/erdma/erdma_verbs.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/infiniband/hw/erdma/erdma_verbs.c b/drivers/infiniband/hw/erdma/erdma_verbs.c
> index 51d619edb6c5..7ad38fb84661 100644
> --- a/drivers/infiniband/hw/erdma/erdma_verbs.c
> +++ b/drivers/infiniband/hw/erdma/erdma_verbs.c
> @@ -781,6 +781,10 @@ static int get_mtt_entries(struct erdma_dev *dev, struct erdma_mem *mem,
>  	mem->page_size = ib_umem_find_best_pgsz(mem->umem, req_page_size, virt);
> +	if (!mem->page_size) {
> +		ret = -EINVAL;
> +		goto error_ret;
> +	}

Thanks,

I think ib_umem_find_best_pgsz won't fail in erdma, because we always set the corresponding bit
of PAGE_SIZE in the req_page_size, which can let ib_umem_find_best_pgsz find an answer at least.

If fixing it can make SVACE happy, I'm OK with this patch.

Acked-by: Cheng Xu <chengyou@linux.alibaba.com>

Regards,
Cheng Xu

>  	mem->page_offset = start & (mem->page_size - 1);
>  	mem->mtt_nents = ib_umem_num_dma_blocks(mem->umem, mem->page_size);
>  	mem->page_cnt = mem->mtt_nents;
>  	mem->mtt = erdma_create_mtt(dev, MTT_SIZE(mem->page_cnt),
>  				    force_continuous);

      reply	other threads:[~2025-02-21  7:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-21  7:03 Ваторопин Андрей
2025-02-21  7:55 ` Cheng Xu [this message]

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=a02b09d9-8b95-354f-dade-67240200d4fc@linux.alibaba.com \
    --to=chengyou@linux.alibaba.com \
    --cc=a.vatoropin@crpt.ru \
    --cc=jgg@ziepe.ca \
    --cc=kaishen@linux.alibaba.com \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=weiyongjun1@huawei.com \
    --cc=yang.lee@linux.alibaba.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®