Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp672761ybp; Fri, 11 Oct 2019 02:27:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqwDRSMJFEoBmVGv1R/1CbEDBTm7oZSVRwls970pY0fL7Fz6sePLZG2eNLolkilYlbeQSau5 X-Received: by 2002:a50:ab10:: with SMTP id s16mr12280403edc.118.1570786059707; Fri, 11 Oct 2019 02:27:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570786059; cv=none; d=google.com; s=arc-20160816; b=qbqRDhpdSy7k/h0HkHLFPm04sg4llTH009zCrwArmc/ywggO+A5hAxzxKq4UUVyClA n9nTvh0uTRmXyXgKJucqgbXWhA6DLDs9kt+Ka8MdUZmR/uhyrJm1z88HO4SeWGIINFEl i4Rud4e9bqLqnkYnJifQQF/WjXYO7CzkQ1MaV4DfnSgbz9wy/H5pua3MSnIb4TtoKOFd GWHbtyUX/8w0exfdOhSSLrGSaiyJfT51GCOU3qMNpK+1BNserZqQo/eFP2rGl/AhSf0c R7r066dPeazX9hsg9GGmdov2FGhbG2tf8jGHiadDbr424edduWXL070w8RPv8JmKJIyQ jG4A== 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=owurzTiNQN9tSXfLyNnDQ29PbYAu2ED+zX68t+BoR2c=; b=KkAPNU7XkaiyIP+JPxeNtXGgMtrcVcmVdyK6u/zZX1dXfT08h/cDaC3M3u0KhoTJp5 YbPHSzsaqu2RIIFfnNefSaw1fr2/lmQvkAQ8vvRaYHzu4Ogwuk/MhCe+cWH9rMtp1HEv jNlAiYORYzxqtVg2MlM0C8BQKAf+tFpEIcy4z2eD8ZoLygq6xZ4s/v52Ru81UecVdyNx C6eR4cUT9LIgU7hG7mfVyrMawpT8Hzc284XuYPKqgkZE3jWwwEnIJzZL2pT2bgGPY/tH c7MBx6an8hhh+u/zmRpH7eKrQNu45woRcI1TsA7vE1NNmSRiAuicuo6n0mK2yp0MC4a+ r39g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=pfjlXrUK; 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 j38si5506940ede.374.2019.10.11.02.27.16; Fri, 11 Oct 2019 02:27:39 -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=pfjlXrUK; 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 S1727699AbfJKJ00 (ORCPT + 99 others); Fri, 11 Oct 2019 05:26:26 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:53158 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726788AbfJKJ0Z (ORCPT ); Fri, 11 Oct 2019 05:26:25 -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=owurzTiNQN9tSXfLyNnDQ29PbYAu2ED+zX68t+BoR2c=; b=pfjlXrUKAuJ8zGoYFdMhi9E+N otnI+YxI/D2jFU5FXVOySeW4TAVmDYMQCisXIZnP7fQPRb+ba+RQVs3/Bapx75s4Gz7rq/EI0yfMc K+3aL1QIuKG/gEP3tO7dZgt6T25zTa6y+Q5Ny1xzv0rTikN3laI3g0PLrOVmoq3beEZPAwvaujXO4 YefQorUn2TkbYOPr/eQPkCkxRMQeRiGklsnmx3GmzeGg11Q9eH5TG0/A1ngr3Y9U1uXhSWbN/96ta CSvotgo+oKOPF5YsIglXJukyAnDXaLNQl9q7YROjedAAYj0Ytt+ofu86uUvP23Iz+lNxO2s7uMhBA DtktoxInw==; Received: from hch by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1iIrBm-0006kg-6h; Fri, 11 Oct 2019 09:26:22 +0000 Date: Fri, 11 Oct 2019 02:26:22 -0700 From: Christoph Hellwig To: Oded Gabbay Cc: Christoph Hellwig , Omer Shpigelman , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 1/2] habanalabs: support vmalloc memory mapping Message-ID: <20191011092622.GA19962@infradead.org> References: <20191010140615.26460-1-oshpigelman@habana.ai> <20191010140950.GA27176@infradead.org> <20191011081055.GA9052@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 Fri, Oct 11, 2019 at 12:19:36PM +0300, Oded Gabbay wrote: > We first allocate, using vmalloc_user, a certain memory block that > will be used by the ASIC and the user (ASIC is producer, user is > consumer). > After we use vmalloc_user, we map the *kernel* pointer we got from the > vmalloc_user() to the ASIC MMU. We reuse our driver's generic code > path to map host memory to ASIC MMU and that's why we need the patch > above. The user does NOT send us the pointer. He doesn't have this > pointer. It is internal to the kernel driver. To do this reuse, we > added a call to the is_vmalloc_addr(), so the function will know if it > is called to work on user pointers, or on vmalloc *kernel* pointers. But the function can't decided that. As I said before you can't just take a value that possibly contains user pointers and call is_vmalloc_addr on it, as kernel and user address can overlap on various architectures. You need to restructure your code to keep the kernel and user pointer code paths entirely separate.