Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp1580405rdb; Sun, 19 Nov 2023 01:45:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IEHH7ZVeodtFqpNMsKrH2k8K7uMP/fdMCSP/K9/rvpm0RQRwvIRXImOrswvZdM9KOG80Ir9 X-Received: by 2002:a17:90b:38c1:b0:280:ff37:8981 with SMTP id nn1-20020a17090b38c100b00280ff378981mr2744897pjb.44.1700387126478; Sun, 19 Nov 2023 01:45:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700387126; cv=none; d=google.com; s=arc-20160816; b=Q2WpRN0SY725w6NK/imvqwex1DaBfg1Bc2YtqWkNAZ80tSkGyZ9I8pe4CdicyE1ANb zEw3sUZOFurgy/bwYMViUuYav5SefLROKe/Ohl0CcZXp3IBIixjf2fzy2LWzk9T3Aj3E t2Lq+tKwb/NpW9YlWYR2q4v5KSKXmDI3detiDihEe66nA1m8h9VG28CPEsR0+LbC2kYS gMF406ynAxbQbTaRbm4rT0cma3KcpApw8UAcwWZpkIy4AksUUxQReNrsMa6yd1DSAAv5 xGh5KfATNbJLM/n9MzhzTT8zaG0vOqA64oNhuf+O7V9hOfVNMOQ6GPwgYUpVc/+/ZX0a 1W1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Y+ddbxgHBVfTZWZ3XSVZeGJCP1yHOkuWfBRWxWAUDgc=; fh=W5zkk8CeHHzGK8FSeth1oAzHyKyt4oKqTAMTWgExGSQ=; b=tqR4nBDdD4VFX14meBdsxXuBh3kvjn1KUHTcPCTW9W3uTE0+zBST6aNX5VgOcnsuEU GcmcMzckO5wGCrc8uKx6YX/b95y454m513YY5lolCVPD8Gzv+E++k8fg/ybdWnSMp/6w anP82gc3SOhQHJd6pXz1NP697nXhG8/MgGAON6jWMpv2LG+gz56lxPfA3/OCjoHalXSE EERTJlxp4ArLpmvhwP92fTs9QpgzgHc1V6Yi90I3iobeTqafJsRASkyl5yumheD7PnUB zi3zdm7+1hYzq6tRGEL/ndvrWRpQ9/sRQEKLOX+9NsIF/Or6sgL7/hfUKXTgNfMNsYg/ x93g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=d24DvuWG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id ls10-20020a17090b350a00b002810ae70420si8484731pjb.121.2023.11.19.01.45.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 01:45:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=d24DvuWG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 95967808001F; Sun, 19 Nov 2023 01:45:13 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230324AbjKSJpI (ORCPT + 99 others); Sun, 19 Nov 2023 04:45:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230366AbjKSJpG (ORCPT ); Sun, 19 Nov 2023 04:45:06 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25162D7A for ; Sun, 19 Nov 2023 01:44:39 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7DF8C433C7; Sun, 19 Nov 2023 09:44:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700387078; bh=Fl4ApciDc/jv8fxMx5Ald8QojByY2Q5XIcdQaqIWnqI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=d24DvuWG5nnomn6ZcMnBP2nbOjCiNdMm70OXeqzQoySFksT9fJCiTPzdWukrGOArn wVn6p0hK7CF2dXFhK3QhWRSINdO7XHWwnWWaE2zdg/URqiNM2GMxY5fFAqeHFULTYu /AAst56Ec9sqRksSTM6+KfPlBOwv/8PK6Ewkjbxri1LWI3oKTf/dmgPjgtokZ/qET3 t4AiOpiS0bZQAdTwcoqYpapWECVDoFYodnlR0Ys5cDvhq311ycNlr5Xsd4QgVg+9j9 zkWGZ5s4EKSsZriMaZABDx7lmD0HxR6lF1fsIp+/jAZ0SCU9Cjo893ywZfEqn8VNvW mZ0IbEtoWqkog== Date: Sun, 19 Nov 2023 01:44:37 -0800 From: Saeed Mahameed To: Arnd Bergmann Cc: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Leon Romanovsky , Jason Gunthorpe , Jiri Pirko , Saeed Mahameed Subject: Re: [PATCH 5/5] misc: mlx5ctl: Add umem reg/unreg ioctl Message-ID: References: <20231018081941.475277-1-saeed@kernel.org> <20231018081941.475277-6-saeed@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sun, 19 Nov 2023 01:45:13 -0800 (PST) On 18 Oct 11:30, Arnd Bergmann wrote: >On Wed, Oct 18, 2023, at 10:19, Saeed Mahameed wrote: >> From: Saeed Mahameed > >> >> To do so this patch introduces two ioctls: >> >> MLX5CTL_IOCTL_UMEM_REG(va_address, size): >> - calculate page fragments from the user provided virtual address >> - pin the pages, and allocate a sg list >> - dma map the sg list >> - create a UMEM device object that points to the dma addresses >> - add a driver umem object to an xarray data base for bookkeeping >> - return UMEM ID to user so it can be used in subsequent rpcs >> >> MLX5CTL_IOCTL_UMEM_UNREG(umem_id): >> - user provides a pre allocated umem ID >> - unwinds the above >> > [...] >> + >> + umem_id = mlx5ctl_umem_reg(mfd->umem_db, (unsigned >> long)umem_reg.addr, umem_reg.len); > >umem_reg.addr seems to be a user space address, so I would >suggest consistently passing it as a 'void __user *' instead >of casting to (unsigned long) here. You can use u64_to_user_ptr() >to handle the pointer conversion correctly across all >architectures that way, and get better type checking. > Hi Arnd, I handled all of your comments in V2 except this one, since here we use the user address for arithmetic calculations only, so it is easier to convert it to (unsigned long) early on ..