Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp610328ybp; Fri, 11 Oct 2019 01:14:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqzFYhbBiKcArdSdPvzMvaV1fR7CsU4HHvBnjPxs4jv2w+CoMxbq4m9xQ+QNQyLaND6zY7SX X-Received: by 2002:a17:907:10dc:: with SMTP id rv28mr12415462ejb.7.1570781669247; Fri, 11 Oct 2019 01:14:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570781669; cv=none; d=google.com; s=arc-20160816; b=gwrItD5+jiAX+Nl4vVxVvYzYoc0z2cUF9i4fOSQBEC2xQSpAG00XIhZdvo2pkF39GR RVRNEqwPFMH6moXil21c3sEqvhfr/ZtKAzbBsmsY4FTkAoRIIqDg97PXdgOS0ItNL5ZZ 10jsyicMc+cF0vLZiA+RKkxOUfqQFS6EsrHEhdmhkJQF8vCDQ0rOGcCsQZNkQl3Skq2m tZrpxlbWYGgjXBCQ9MLfn9YNQpQxjkjA+hfn/72K98SimgFdRDgTfY+sMrJtiBmyiEca VS1PCsSTlinQLOJ20qAL/2LOrO+Ia979T3GEbCrsGSzPA+4EgwK7Q/89wS6sAFFxXZOw GHyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=3Qe2lZY4ZZrWpv+4LF899RtGu/VaZYr/ykWfcEi0R6M=; b=aKEoPsNk2SgBZFpdNxDn8kxXdquD1pK8GZz5WdPC4JnbWIpNjpP9lkCu9q7HMtLVx7 SX3DPqbSLjCc5K2u+sKoug3RJ8/NicsZsc3V+kQQfY4xmKVdGKQzBqVfKfsfSl+wztbH Tk1Eyo3KPl3jHM2+eDcFl1UgHChBeDDfES9Rvriv668EQHa0j05FswC5zdqDiTyubQsa NQDn2YNhHH/S+aqEqyZLgwf0HU27+KY41MA0Xg/Lv+ieiMQpvapypWqLo8MqlvcLpGvv RISWO403WTblo0VrJ1n8MhxXM96Fdq0XYx8UY6Yc2qbwhZGvaa1cglM7Ki5XsbBLw/Yq JfTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=lt7Yz68T; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b9si5017218edj.0.2019.10.11.01.14.05; Fri, 11 Oct 2019 01:14:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=lt7Yz68T; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727585AbfJKIK5 (ORCPT + 99 others); Fri, 11 Oct 2019 04:10:57 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:38114 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726461AbfJKIK4 (ORCPT ); Fri, 11 Oct 2019 04:10:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=3Qe2lZY4ZZrWpv+4LF899RtGu/VaZYr/ykWfcEi0R6M=; b=lt7Yz68TrZMqWMcyEn5RSTbot ZdeUJ4MsI9CEM7qsxCqfbr0mYX/3fVtIU+Su8MhykCJNbGRV193gMolOew4Q43UhiemzfOBCRGzPR UG7vLYDu6AqG5f2UeG6HEAAKw3Bdy/cB3CYStk8v2L2WHUaO4kzVdnfayRsgaHPN7+TPg1KICm9F3 huFkJe18MZATPw5Dsr2Ly9vugTjHeWOMcA/s9U6MTO2Lz5mhqero5xH6ujc5KqK6ZXFjSUM2awE30 UjJuJKd3dPhG+z3GM9OB/Zhir6UyiCEZRcvHMyF5O8Rq0gsQ2IEx4PAQ0sBS156/enjvTCXrZDeyw gXV4kn78Q==; Received: from hch by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1iIq0l-0008KH-Ui; Fri, 11 Oct 2019 08:10:55 +0000 Date: Fri, 11 Oct 2019 01:10:55 -0700 From: Christoph Hellwig To: Omer Shpigelman Cc: Christoph Hellwig , "oded.gabbay@gmail.com" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 1/2] habanalabs: support vmalloc memory mapping Message-ID: <20191011081055.GA9052@infradead.org> References: <20191010140615.26460-1-oshpigelman@habana.ai> <20191010140950.GA27176@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 10, 2019 at 07:54:07PM +0000, Omer Shpigelman wrote: > The is_vmalloc_addr checks are for user pointers and for memory which was allocated by the driver with vmalloc_user. This does not make any sense whatsoever. vmalloc_user returns a kernel address, it just does a GFP_USER instead of GFP_KERNEL allocation, which is just accounting differences. > > > Mapping vmalloc memory is needed for Gaudi ASIC. > > > > How does that ASIC pass in the vmalloc memory? I don't fully understand > > the code, but it seems like the addresses are fed from ioctl, which means > > they only come from userspace. > > The user pointers are indeed fed from ioctl for DMA purpose, but as I wrote above the vmalloc memory is allocated by the driver with vmalloc_user which will be mmapped later on in order to create a shared buffer between the driver and the userspace process. Again, you can't pass pointers obtained from vmalloc* to userspace. You can map the underlying pages into user pagetables, but is_vmalloc_addr won't know that. I think you guys need to read up on virtual memory 101 first and then come back and actually explain what you are trying to do.