From: Artemy Kovalyov <artemyko@mellanox.com>
To: Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>
Cc: Doug Ledford <dledford@redhat.com>,
Leon Romanovsky <leonro@mellanox.com>,
RDMA mailing list <linux-rdma@vger.kernel.org>,
Aviad Yehezkel <aviadye@mellanox.com>,
Yishai Hadas <yishaih@mellanox.com>
Subject: RE: [PATCH rdma-rc 3/3] IB/core: Fix ODP with IB_ACCESS_HUGETLB handling
Date: Fri, 20 Dec 2019 04:51:00 +0000 [thread overview]
Message-ID: <AM6PR0502MB3638228D4DD3E713A5AE8951B72D0@AM6PR0502MB3638.eurprd05.prod.outlook.com> (raw)
In-Reply-To: <20191219183237.GJ17227@ziepe.ca>
-----Original Message-----
From: Jason Gunthorpe <jgg@ziepe.ca>
Sent: Thursday, December 19, 2019 8:33 PM
To: Leon Romanovsky <leon@kernel.org>
Cc: Doug Ledford <dledford@redhat.com>; Leon Romanovsky <leonro@mellanox.com>; RDMA mailing list <linux-rdma@vger.kernel.org>; Artemy Kovalyov <artemyko@mellanox.com>; Aviad Yehezkel <aviadye@mellanox.com>; Yishai Hadas <yishaih@mellanox.com>
Subject: Re: [PATCH rdma-rc 3/3] IB/core: Fix ODP with IB_ACCESS_HUGETLB handling
On Thu, Dec 19, 2019 at 03:46:46PM +0200, Leon Romanovsky wrote:
> @@ -403,6 +390,7 @@ int ib_umem_odp_map_dma_pages(struct ib_umem_odp *umem_odp, u64 user_virt,
> int j, k, ret = 0, start_idx, npages = 0;
> unsigned int flags = 0, page_shift;
> phys_addr_t p = 0;
> + struct vm_area_struct **vmas;
>
> if (access_mask == 0)
> return -EINVAL;
> @@ -415,6 +403,12 @@ int ib_umem_odp_map_dma_pages(struct ib_umem_odp *umem_odp, u64 user_virt,
> if (!local_page_list)
> return -ENOMEM;
>
> + vmas = (struct vm_area_struct **)__get_free_page(GFP_KERNEL);
> + if (!vmas) {
> + ret = -ENOMEM;
> + goto out_free_page_list;
> + }
I'd rather not do this on the fast path
> + if ((1 << page_shift) > vma_kernel_pagesize(vmas[j])) {
> + ret = -EFAULT;
> + break;
> + }
And vma's cannot be de-refenced outside the mmap_sem
There is already logic checking for linear contiguous pages:
if (user_virt & ~page_mask) {
p += PAGE_SIZE;
if (page_to_phys(local_page_list[j]) != p) {
ret = -EFAULT;
break;
}
Why do we need to add the vma check?
AK: checking for linear contiguity may be not enough, page may be transparent huge page, so in addition we also ensure its indeed persistent.
Jason
next prev parent reply other threads:[~2019-12-20 4:51 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-19 13:46 [PATCH rdma-rc 0/3] ODP Fixes Leon Romanovsky
2019-12-19 13:46 ` [PATCH rdma-rc 1/3] IB/mlx5: Unify ODP MR code paths to allow extra flexibility Leon Romanovsky
2019-12-19 19:07 ` Jason Gunthorpe
2019-12-20 4:54 ` Artemy Kovalyov
2019-12-19 13:46 ` [PATCH rdma-rc 2/3] IB/core: Fix ODP get user pages flow Leon Romanovsky
2019-12-19 19:05 ` Jason Gunthorpe
2019-12-19 13:46 ` [PATCH rdma-rc 3/3] IB/core: Fix ODP with IB_ACCESS_HUGETLB handling Leon Romanovsky
2019-12-19 18:32 ` Jason Gunthorpe
2019-12-20 4:51 ` Artemy Kovalyov [this message]
2019-12-20 13:35 ` Jason Gunthorpe
2019-12-22 9:56 ` Yishai Hadas
2020-01-08 12:56 ` Geert Uytterhoeven
2020-01-08 15:24 ` Yishai Hadas
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=AM6PR0502MB3638228D4DD3E713A5AE8951B72D0@AM6PR0502MB3638.eurprd05.prod.outlook.com \
--to=artemyko@mellanox.com \
--cc=aviadye@mellanox.com \
--cc=dledford@redhat.com \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=leonro@mellanox.com \
--cc=linux-rdma@vger.kernel.org \
--cc=yishaih@mellanox.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;
as well as URLs for NNTP newsgroup(s).