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=unavailable 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 7FCE6C282CE for ; Tue, 4 Jun 2019 13:02:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4DE7621537 for ; Tue, 4 Jun 2019 13:02:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="Yjg83FKm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727618AbfFDNCO (ORCPT ); Tue, 4 Jun 2019 09:02:14 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:41882 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727551AbfFDNCK (ORCPT ); Tue, 4 Jun 2019 09:02:10 -0400 Received: by mail-qt1-f194.google.com with SMTP id s57so6434077qte.8 for ; Tue, 04 Jun 2019 06:02:09 -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=ROjiC3s0siagx/fi+MGJXNVgc6kDjODdOY/lcLdmBIY=; b=Yjg83FKmLcCoTK1qNZRWt/34Ia4Vlgl4OzEswRBoqTA1q96rWHjxDfVIh6O7xWTGYS eTwCJcntFH46Tx+/cfSa7gWeHuAwOuGBn+X1jMdn5S6DRrFvNPM6afZ9JtFGwDFoFWKd IItwYcOZFv/0waUdBmD+9vX5g+lauIFC8gWQwZqeWZqiLI8MWTWgKqH10ZguaFNyDwaJ a6BouIbR+z5GvWPUxO/910/OPmm0It1HqckTeip+hRX/UhVQAxatTT7lXUHm0zw2yFJW DkwJjMsTV0HME+BgheyUHlaQClPbcE8mHooI7fCmf534f4AYixHfdR0GOmoGClDBYuEf l/5g== 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=ROjiC3s0siagx/fi+MGJXNVgc6kDjODdOY/lcLdmBIY=; b=M6G0uGNbJvXdfxKmYfpex2cfUQCtvHNnTKjHIcwhjHtEJEowIJe70v6OKkxQVSQESg es2aa67+hxrtAue0TN1rTbpd2iWewq4DXP9gxt/rj/zWd1jsf4w1Gag4AJWWwkhIFR4w /29kDek8ktJyxuD6davhpDkyHQgyuoo8zTeZuMgxBk1FRxFipp6+r/h208Iz7JQY7rU3 ywubwc5CVQQguQQFwV3Jo8JHZiwE5RDKuR+i4WYXUqYA+Qj0iCqZaVn2zvc8qZi+saCw RI/Mw32yRgkUgCm9mvAUroc9Zui8XKVHkWrNkPRDeP7pG0tJ6pLlcefMmYQJcbd20qzZ TpUg== X-Gm-Message-State: APjAAAW5dZI33IpxVkaT8CjbtgNUbAYAKchrQoyXxBqrXEOQJlSBU2u9 IHwdidolmmIkFN84+AaJk8Rg1Q== X-Google-Smtp-Source: APXvYqz5RimUEjNtxNzzaaY0SoKGmFHRAnKhf0PPTePbHdJhsA1MCZNciExOvF95WwVoO+r2X/Sqlw== X-Received: by 2002:a0c:c94d:: with SMTP id v13mr706065qvj.211.1559653328976; Tue, 04 Jun 2019 06:02:08 -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 m5sm10984580qke.25.2019.06.04.06.02.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Jun 2019 06:02:08 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1hY94p-0004U3-JD; Tue, 04 Jun 2019 10:02:07 -0300 Date: Tue, 4 Jun 2019 10:02:07 -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: <20190604130207.GD15385@ziepe.ca> References: <20190603174619.GC11474@ziepe.ca> <20190604122714.GA15385@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:45:32PM +0200, Andrey Konovalov wrote: > On Tue, Jun 4, 2019 at 2:27 PM Jason Gunthorpe wrote: > > > > 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. > > How do you think we should do untagging (or something else) to deal > with this 'weird duck' case? mlx4 should handle it around the call to find_vma like other patches do, ideally as part of the cast from a void __user * to the unsigned long that find_vma needs Jason