From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C00C6C282CE for ; Tue, 4 Jun 2019 12:27:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 93C9620665 for ; Tue, 4 Jun 2019 12:27:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="dcNC7Umt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727823AbfFDM1S (ORCPT ); Tue, 4 Jun 2019 08:27:18 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:46627 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727522AbfFDM1R (ORCPT ); Tue, 4 Jun 2019 08:27:17 -0400 Received: by mail-qt1-f193.google.com with SMTP id z19so13380233qtz.13 for ; Tue, 04 Jun 2019 05:27:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=wnsJg5IBUcpd0uvGih9L7zWjhXAHb1EJO0yOEExZSzo=; b=dcNC7UmtypwgYv25SVviVAOUG7URTCQh95rjKD+gc1HkGG0jrMjWKvaHqgOqnkLXCe CmoljchytuIVIDVbprMz3tL0S5wF3BfmVPwpXMEcKwEKuopvqQDwmPbpLySBrTe+5P0P +zjXSkVABYGjw15OrEI3UNK6X3hEEYJ5lmU4VodgY1OGgetHeu4xf6gu/Drrr5PoUFZD NGszqORq933qFqUy4wxVOf9PkDJzNBd6Vt6SxvMrx9KcQhBJruI+UAnsanyndNgyFsW8 SfJHC+U7tiqZ4PP8CoYnZCXFGYoMymsmvspjQbzELX76TfLMwbqeFyJLFyTuqJIB4Dhp ZF+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=wnsJg5IBUcpd0uvGih9L7zWjhXAHb1EJO0yOEExZSzo=; b=h8lnQ9NQu6mZHYI+SjjH6EHpeOviBEayoxlvk/QWvRPrcVFVIO5mWyGWEXUjoUiDgl Ek45sxB7NUjEQFb0XQmWDr0NRIQFH40RkHxodSnHAO69ugMZfAyTIgEPEKVDpNiNP7gl atyGLUNnzzpFiZAG6MHRbwsQYwKFzO+p6Wtb6BO8gB05RRy63Fffb6RYgR7FV6+VjtS2 26vwaujUmbe+Jbxi4hLXnn1VcD7qTjUgypD6oJSpuL87MG7p8YHrH4/lTwXm4A248A5C ZQCaUBebVuDzm45HdfgHBA9Gvttpwja2Tft2rsCew4Byu1zZq/okxE6OLbf9Qs68JfKi BcYQ== X-Gm-Message-State: APjAAAVEDf1zuYBQftn3q9JPKFS5fA+MCN17AvQVPV5ftljDCMSDLquV ZwymYwN/gKXBIKSlw9Tl4Nhm/g== X-Google-Smtp-Source: APXvYqyQKZsajkt/gWb5hfUpWdj5TzMt6KfoFh/bz/W6aTLwqi1dm4Rk21CH5MrcGrt3uoh1Lu64hg== X-Received: by 2002:aed:3a87:: with SMTP id o7mr27583430qte.310.1559651236150; Tue, 04 Jun 2019 05:27:16 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-156-34-55-100.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.55.100]) by smtp.gmail.com with ESMTPSA id c18sm4454633qkm.78.2019.06.04.05.27.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Jun 2019 05:27:15 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1hY8X4-000416-LN; Tue, 04 Jun 2019 09:27:14 -0300 Date: Tue, 4 Jun 2019 09:27:14 -0300 From: Jason Gunthorpe To: Andrey Konovalov Cc: Linux ARM , Linux Memory Management List , LKML , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-rdma@vger.kernel.org, linux-media@vger.kernel.org, kvm@vger.kernel.org, "open list:KERNEL SELFTEST FRAMEWORK" , Catalin Marinas , Vincenzo Frascino , Will Deacon , Mark Rutland , Andrew Morton , Greg Kroah-Hartman , Kees Cook , Yishai Hadas , Felix Kuehling , Alexander Deucher , Christian Koenig , Mauro Carvalho Chehab , Jens Wiklander , Alex Williamson , Leon Romanovsky , Luc Van Oostenryck , Dave Martin , Khalid Aziz , enh , Christoph Hellwig , Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Robin Murphy , Kevin Brodsky , Szabolcs Nagy Subject: Re: [PATCH v16 12/16] IB, arm64: untag user pointers in ib_uverbs_(re)reg_mr() Message-ID: <20190604122714.GA15385@ziepe.ca> References: <20190603174619.GC11474@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 04, 2019 at 02:18:19PM +0200, Andrey Konovalov wrote: > On Mon, Jun 3, 2019 at 7:46 PM Jason Gunthorpe wrote: > > > > On Mon, Jun 03, 2019 at 06:55:14PM +0200, 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. > > > > > > ib_uverbs_(re)reg_mr() use provided user pointers for vma lookups (through > > > e.g. mlx4_get_umem_mr()), which can only by done with untagged pointers. > > > > > > Untag user pointers in these functions. > > > > > > Signed-off-by: Andrey Konovalov > > > drivers/infiniband/core/uverbs_cmd.c | 4 ++++ > > > 1 file changed, 4 insertions(+) > > > > > > diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c > > > index 5a3a1780ceea..f88ee733e617 100644 > > > +++ b/drivers/infiniband/core/uverbs_cmd.c > > > @@ -709,6 +709,8 @@ static int ib_uverbs_reg_mr(struct uverbs_attr_bundle *attrs) > > > if (ret) > > > return ret; > > > > > > + cmd.start = untagged_addr(cmd.start); > > > + > > > if ((cmd.start & ~PAGE_MASK) != (cmd.hca_va & ~PAGE_MASK)) > > > return -EINVAL; > > > > I feel like we shouldn't thave to do this here, surely the cmd.start > > should flow unmodified to get_user_pages, and gup should untag it? > > > > ie, this sort of direction for the IB code (this would be a giant > > patch, so I didn't have time to write it all, but I think it is much > > saner): > > Hi Jason, > > ib_uverbs_reg_mr() passes cmd.start to mlx4_get_umem_mr(), which calls > find_vma(), which only accepts untagged addresses. Could you explain > how your patch helps? That mlx4 is just a 'weird duck', it is not the normal flow, and I don't think the core code should be making special consideration for it. Jason