From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jason Gunthorpe Subject: Re: [PATCH v16 12/16] IB, arm64: untag user pointers in ib_uverbs_(re)reg_mr() Date: Tue, 4 Jun 2019 09:27:14 -0300 Message-ID: <20190604122714.GA15385@ziepe.ca> References: <20190603174619.GC11474@ziepe.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org 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 List-Id: amd-gfx.lists.freedesktop.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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: jgg at ziepe.ca (Jason Gunthorpe) Date: Tue, 4 Jun 2019 09:27:14 -0300 Subject: [PATCH v16 12/16] IB, arm64: untag user pointers in ib_uverbs_(re)reg_mr() In-Reply-To: References: <20190603174619.GC11474@ziepe.ca> Message-ID: <20190604122714.GA15385@ziepe.ca> 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: jgg@ziepe.ca (Jason Gunthorpe) Date: Tue, 4 Jun 2019 09:27:14 -0300 Subject: [PATCH v16 12/16] IB, arm64: untag user pointers in ib_uverbs_(re)reg_mr() In-Reply-To: References: <20190603174619.GC11474@ziepe.ca> Message-ID: <20190604122714.GA15385@ziepe.ca> Content-Type: text/plain; charset="UTF-8" Message-ID: <20190604122714.QARYxXjsYk7LkY3VseLJHaV6RN6vp3dW9I1rBkKRxrI@z> On Tue, Jun 04, 2019@02:18:19PM +0200, Andrey Konovalov wrote: > On Mon, Jun 3, 2019@7:46 PM Jason Gunthorpe wrote: > > > > On Mon, Jun 03, 2019@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 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.5 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,T_DKIMWL_WL_HIGH,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 C19DAC282CE for ; Tue, 4 Jun 2019 12:27:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 96B8424107 for ; Tue, 4 Jun 2019 12:27:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="nUcdriIe"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="dcNC7Umt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 96B8424107 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Qk3G/ED1AzaYpKqmqPGeBqjdER0Ykg/Z0/51Fb9KELE=; b=nUcdriIeSnBKN8 iVlk2HG9aHxxsFqWXwrtqrMClNHBmjf9j9wWJc826Zo//R8v3rDOyVm+nCF4EIZ+zpJJ0s9ZydyRN uC/UhwHYw/QnvDrxGJSjrHIxXDL07nJvBvWW8NlKJqCqG095Lq8CgvD6+lJ4sMUyIdsbbLZtyeebr BmgpsflRbTYstkEU3VAmNYD7t99RQCoirk5VLxT1rjdLFwtKIYXZHz4RvI7+nYYUWN4QZPCRis+Ak g83UR52PmnkwaR+HJAwAYa2YOp1N1ISNAygn9ZAU+8GKPs2JFqMj7+w5QyPZ0eoyGcbE4Bs0Jslun YY0yxciUOPX5fmodhF1w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hY8XD-0004fR-G7; Tue, 04 Jun 2019 12:27:23 +0000 Received: from mail-qt1-x841.google.com ([2607:f8b0:4864:20::841]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hY8X8-0004eX-Ly for linux-arm-kernel@lists.infradead.org; Tue, 04 Jun 2019 12:27:20 +0000 Received: by mail-qt1-x841.google.com with SMTP id j19so9708856qtr.12 for ; Tue, 04 Jun 2019 05:27:18 -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=GMIlxi57/9yk+8Y3xW6nhMtJmwnNTGji0098SFEUdIUqWhJNYAkaREjaeUCVpFz0/4 3U0o33Ml5WQeic41jfsR3OWuPqeH6MBpIvYtDHOPsmig8uCqq5rVh+NFwuueKjcURMN8 nc3Zo6PRXwdvZ+KHooFzoQSenPnI+Bga6MPG5MxJOjhq3kWP2uhld0K5mwJ2Q2cpW5yl SGqw1HN/InYCYlYZdrc5rSUg5LVW3elHKx6BWnHzNwdkApIj8UsYEVpVu7lcUUP7jpAc 4tpd7qXcTpRCPWAmAQr18MGH+XC5eR1x/AWBl+T7yXrtsWH+DyYsaPz96y9q0yDH4MWL 03Og== X-Gm-Message-State: APjAAAWGfDfaQsJdPiq5IM5GsxYCAVJ7sC8n5DcF4DWPsVNsucYaiHll ZX4zC6Hr53KL30XM8VO89zXpWg== 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 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-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190604_052718_833079_FDDED957 X-CRM114-Status: GOOD ( 25.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , kvm@vger.kernel.org, Szabolcs Nagy , Catalin Marinas , Will Deacon , dri-devel@lists.freedesktop.org, Linux Memory Management List , Khalid Aziz , "open list:KERNEL SELFTEST FRAMEWORK" , Felix Kuehling , Vincenzo Frascino , Jacob Bramley , Leon Romanovsky , linux-rdma@vger.kernel.org, amd-gfx@lists.freedesktop.org, Christoph Hellwig , Dmitry Vyukov , Dave Martin , Evgeniy Stepanov , linux-media@vger.kernel.org, Kevin Brodsky , Kees Cook , Ruben Ayrapetyan , Ramana Radhakrishnan , Alex Williamson , Mauro Carvalho Chehab , Linux ARM , Kostya Serebryany , Greg Kroah-Hartman , Yishai Hadas , LKML , Jens Wiklander , Lee Smith , Alexander Deucher , Andrew Morton , enh , Robin Murphy , Christian Koenig , Luc Van Oostenryck Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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 101D4C282CE for ; Tue, 4 Jun 2019 12:27:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DB50923E96 for ; Tue, 4 Jun 2019 12:27:21 +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 S1727814AbfFDM1R (ORCPT ); Tue, 4 Jun 2019 08:27:17 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:33172 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726994AbfFDM1R (ORCPT ); Tue, 4 Jun 2019 08:27:17 -0400 Received: by mail-qt1-f193.google.com with SMTP id 14so13468118qtf.0 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=e7vLYhtbmktqJbOMbhvcFm+JKqRNFxrHH74E+wKYdle5W9HaDyRefxc5y/S5hqDTFB urkFq2mki7mGsUJ53F37YTYHYspXlCGYeLkpwzJAFcvDC+C0TZBZnxmg4HnPUGOe/Zht 83b1OIzICqnDDcuILkayzPfSBLCWv0laQXGfeHdTO8EGWmcydb6De0TMKpnBxiEnN3Ob /KlY9iEJFPAkAhiQVkWUd2vICjz8ZfhimDam7YcbQE8/2CdvAarTNeGmjmkaiz5DBUDq XKyB3UZo1MobMhmbbxXFSj0FF1mPfqGA2u3SeoX7iVnTnDTvTTzC5aOEdrIjyi+3KWyX MsCA== X-Gm-Message-State: APjAAAXmjVvD+IM9hOXXpBe5dUq+buBp74zazknLyaH9m8mjaDEFaRxm uXsJaofpiOYTLXCprqyw7kYozg== 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: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@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