From: Catalin Marinas <catalin.marinas@arm.com>
To: Leon Romanovsky <leon@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Szabolcs Nagy <Szabolcs.Nagy@arm.com>,
Will Deacon <will.deacon@arm.com>,
Kostya Serebryany <kcc@google.com>,
Eric Dumazet <edumazet@google.com>,
Vincenzo Frascino <vincenzo.frascino@arm.com>,
linux-arch@vger.kernel.org, linux-rdma@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Dave Martin <Dave.Martin@arm.com>,
Evgeniy Stepanov <eugenis@google.com>,
Kees Cook <keescook@chromium.org>,
Ruben Ayrapetyan <Ruben.Ayrapetyan@arm.com>,
Andrey Konovalov <andreyknvl@google.com>,
Kevin Brodsky <kevin.brodsky@arm.com>,
Dmitry Vyukov <dvyukov@google.com>,
linux-mm@kvack.org, netdev@vger.kernel.org,
Yishai Hadas <yishaih@mellanox.com>,
linux-kernel@vger.kernel.org,
Ramana Radhakrishnan <Ramana.Radhakrishnan@arm.com>,
Andrew Morton <akpm@linux-foundation.org>,
Robin Murphy <robin.murphy@arm.com>,
"David S. Miller" <davem@davemloft.net>,
Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: Re: [PATCH v13 16/20] IB/mlx4, arm64: untag user pointers in mlx4_get_umem_mr
Date: Tue, 30 Apr 2019 12:16:25 +0100 [thread overview]
Message-ID: <20190430111625.GD29799@arrakis.emea.arm.com> (raw)
In-Reply-To: <20190429180915.GZ6705@mtr-leonro.mtl.com>
(trimmed down the cc list slightly as the message bounces)
On Mon, Apr 29, 2019 at 09:09:15PM +0300, Leon Romanovsky wrote:
> On Wed, Mar 20, 2019 at 03:51:30PM +0100, Andrey Konovalov wrote:
> > This patch is a part of a series that extends arm64 kernel ABI to allow to
> > pass tagged user pointers (with the top byte set to something else other
> > than 0x00) as syscall arguments.
> >
> > mlx4_get_umem_mr() uses provided user pointers for vma lookups, which can
> > only by done with untagged pointers.
> >
> > Untag user pointers in this function.
> >
> > Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
> > ---
> > drivers/infiniband/hw/mlx4/mr.c | 7 ++++---
> > 1 file changed, 4 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/infiniband/hw/mlx4/mr.c b/drivers/infiniband/hw/mlx4/mr.c
> > index 395379a480cb..9a35ed2c6a6f 100644
> > --- a/drivers/infiniband/hw/mlx4/mr.c
> > +++ b/drivers/infiniband/hw/mlx4/mr.c
> > @@ -378,6 +378,7 @@ static struct ib_umem *mlx4_get_umem_mr(struct ib_udata *udata, u64 start,
> > * again
> > */
> > if (!ib_access_writable(access_flags)) {
> > + unsigned long untagged_start = untagged_addr(start);
> > struct vm_area_struct *vma;
> >
> > down_read(¤t->mm->mmap_sem);
> > @@ -386,9 +387,9 @@ static struct ib_umem *mlx4_get_umem_mr(struct ib_udata *udata, u64 start,
> > * cover the memory, but for now it requires a single vma to
> > * entirely cover the MR to support RO mappings.
> > */
> > - vma = find_vma(current->mm, start);
> > - if (vma && vma->vm_end >= start + length &&
> > - vma->vm_start <= start) {
> > + vma = find_vma(current->mm, untagged_start);
> > + if (vma && vma->vm_end >= untagged_start + length &&
> > + vma->vm_start <= untagged_start) {
> > if (vma->vm_flags & VM_WRITE)
> > access_flags |= IB_ACCESS_LOCAL_WRITE;
> > } else {
> > --
>
> Thanks,
> Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Thanks for the review.
> Interesting, the followup question is why mlx4 is only one driver in IB which
> needs such code in umem_mr. I'll take a look on it.
I don't know. Just using the light heuristics of find_vma() shows some
other places. For example, ib_umem_odp_get() gets the umem->address via
ib_umem_start(). This was previously set in ib_umem_get() as called from
mlx4_get_umem_mr(). Should the above patch have just untagged "start" on
entry?
BTW, what's the provenience of such "start" address here? Is it
something that the user would have malloc()'ed? We try to impose some
restrictions one what is allowed to be tagged in user so that we don't
have to untag the addresses in the kernel. For example, if it was the
result of an mmap() on the device file, we don't allow tagging.
Thanks.
--
Catalin
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-04-30 11:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1553093420.git.andreyknvl@google.com>
[not found] ` <44ad2d0c55dbad449edac23ae46d151a04102a1d.1553093421.git.andreyknvl@google.com>
[not found] ` <20190322114357.GC13384@arrakis.emea.arm.com>
[not found] ` <CAAeHK+xE-ywfpVHRhBJVGiqOe0+BYW9awUa10ZP4P6Ggc8nxMg@mail.gmail.com>
[not found] ` <20190328141934.38960af0@gandalf.local.home>
2019-03-29 10:30 ` [PATCH v13 04/20] mm, arm64: untag user pointers passed to memory syscalls Catalin Marinas
2019-04-02 12:47 ` Andrey Konovalov
2019-04-11 16:40 ` Andrey Konovalov
2019-04-26 14:17 ` Catalin Marinas
2019-04-29 14:22 ` Andrey Konovalov
[not found] ` <1e2824fd77e8eeb351c6c6246f384d0d89fd2d58.1553093421.git.andreyknvl@google.com>
[not found] ` <20190429180915.GZ6705@mtr-leonro.mtl.com>
2019-04-30 11:16 ` Catalin Marinas [this message]
2019-04-30 12:03 ` [PATCH v13 16/20] IB/mlx4, arm64: untag user pointers in mlx4_get_umem_mr Leon Romanovsky
2019-05-02 18:44 ` Jason Gunthorpe
2019-05-03 16:28 ` Catalin Marinas
2019-05-03 23:52 ` Jason Gunthorpe
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=20190430111625.GD29799@arrakis.emea.arm.com \
--to=catalin.marinas@arm.com \
--cc=Dave.Martin@arm.com \
--cc=Ramana.Radhakrishnan@arm.com \
--cc=Ruben.Ayrapetyan@arm.com \
--cc=Szabolcs.Nagy@arm.com \
--cc=akpm@linux-foundation.org \
--cc=andreyknvl@google.com \
--cc=davem@davemloft.net \
--cc=dvyukov@google.com \
--cc=edumazet@google.com \
--cc=eugenis@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=kcc@google.com \
--cc=keescook@chromium.org \
--cc=kevin.brodsky@arm.com \
--cc=leon@kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-rdma@vger.kernel.org \
--cc=luc.vanoostenryck@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=vincenzo.frascino@arm.com \
--cc=will.deacon@arm.com \
--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).