Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp674708ybp; Fri, 11 Oct 2019 02:29:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqx6G6bmczyyWoMe4hwhg8zV7qdqMIk8zQKcxhrqrl9d2BdLPjzWUIJaH++I6UVtiwoKwZoS X-Received: by 2002:aa7:db59:: with SMTP id n25mr12780893edt.288.1570786194427; Fri, 11 Oct 2019 02:29:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570786194; cv=none; d=google.com; s=arc-20160816; b=NIiH9fYOF3DawQnZqB+3/Czr3bQfJ11Jev225UTTP62abLSAsN/ImwuyfzCiiwv/xq 0w6dRk8ss3hjaXCyDBihHQy0TodFJUBE3Gsu8YKlB8JYJID/9RvJ+6peJUeQj/sQnTPx 9eyb4+Q0CgD/S0rugjK8TZG0Ljn/qsW31ClTRu3D+fl2gxkfb3V+wkKoVgdAeUNUGdqq l4j/oMIG2lAordye44ebHOQVrPYViF9QbHJrpH7AKbJg8vEm2KjHvW92R5IGeOXOH6h9 xxdd6KQBDl7mTmcY+whN2TF8+1M2E8l3K5CAdNdrakXxECJzTQZlRJKnyxibG/+7r44h WpUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=8BmKLeZeuNnWZ0vB8RCIluQXj9AINL2+YVjFlcN3HKc=; b=icNyIwnhTqKzUXp7fQBTOaoQCU5rHEEBX6jwseAWL/mzHdfWWUHtmBvFJLHKficUWk DWsnAQf28wE3WDCaLRTuzqTx2HnhdaDDUUl/Z/5zz9UDyVggBP4Xowdx6hrQPEFaIw4+ qLY+zXI0R5IXI8yfoVI9DFKHOilTSGeslT0CvuSsoEkp+u9lw6wjr33HmwVoZYWpZ5vg Lf/Kpdm2TM2JQvSR9/9ZyA67mOnk79UOC4pG+ee5r8DDH0dvDsMo87SIx4murKgXnty/ tFhx8hnHbl6IgfhJMpAHVnNr8SV/QILCWnb0f1yY/kbDYC4YTgAf6CUzzIRlqjcnl9SR UiQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DpWhssyj; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f1si4714101eje.338.2019.10.11.02.29.30; Fri, 11 Oct 2019 02:29:54 -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=pass header.i=@gmail.com header.s=20161025 header.b=DpWhssyj; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727794AbfJKJ2V (ORCPT + 99 others); Fri, 11 Oct 2019 05:28:21 -0400 Received: from mail-vk1-f194.google.com ([209.85.221.194]:34082 "EHLO mail-vk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727314AbfJKJ2U (ORCPT ); Fri, 11 Oct 2019 05:28:20 -0400 Received: by mail-vk1-f194.google.com with SMTP id d126so1988997vkb.1 for ; Fri, 11 Oct 2019 02:28:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8BmKLeZeuNnWZ0vB8RCIluQXj9AINL2+YVjFlcN3HKc=; b=DpWhssyjr3YP7xbhtfyz31xwLpO7rpJYmXd8bk84u1JSEyzjKdD0b/Q1IHBHNSTtwQ 0RBMqNG5TFT5/JCX7FfpTfn65TVF8quxvCoOy9sGtRZdRKLAIiTvbkm2i9/K/yEk/y7y jA3spCZVdatjHMdRGAMLeX9X6B+Hw+WP9CmOBvkewPbrznoqMHLhHlhhN8cQUK+VpuRw 3nrfWZ5XGhYIwKW2tRkZD5zDXtdnuyYcUuRIMFfE8yDhCvisRl4/O07fJZFM0kWd+Boa 8PM9pRtHDIxbDBsDUa8ad25uoDaa9WQ824Y3wl8L7WF91xhMptpLQttILeh9BRvYE6Vn VSgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8BmKLeZeuNnWZ0vB8RCIluQXj9AINL2+YVjFlcN3HKc=; b=Eeqd7AotuDTp+vya7BOXI1OiXoV5C9Re9LDugF/El0guSukfc0iS3SFJUr7Va+gYZB atn1OXkrOQS2GPAQDxTJF4TpkuZpQt2KrIvJKTo0ZRO9OZtKGhhQKvyIcs58NdvaOajc bAkZqDWJUCKf1HGOvv2OAM97ufvoiSl//3oR2eggmBL15JBHc14HWNC0yEWWgJtwrtzR 0wSzqBr41KAkgR/CDW+Op/P/przXIQy+R13gnspIWzOv6ibaaaQYzWV95Bf70bpXrf0l AcpFIVAbPQ97kwyrTEZXFL1JobhkW02hYK2Z5ApCtWpma9454++ToSjKKvq3JuiAuKyJ b67g== X-Gm-Message-State: APjAAAUb2yFJHxLV1I4HtsPFswjpDyYax5i7DeosIaX6vIST0PSe2RKM aA9bbXN4iIpGNtZGxJf9IVceN1IGna0IKugMHwo= X-Received: by 2002:a1f:3fd6:: with SMTP id m205mr8128679vka.21.1570786099598; Fri, 11 Oct 2019 02:28:19 -0700 (PDT) MIME-Version: 1.0 References: <20191010140615.26460-1-oshpigelman@habana.ai> <20191010140950.GA27176@infradead.org> <20191011081055.GA9052@infradead.org> <20191011092622.GA19962@infradead.org> In-Reply-To: <20191011092622.GA19962@infradead.org> From: Oded Gabbay Date: Fri, 11 Oct 2019 12:27:53 +0300 Message-ID: Subject: Re: [PATCH 1/2] habanalabs: support vmalloc memory mapping To: Christoph Hellwig Cc: Omer Shpigelman , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" 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:26 PM Christoph Hellwig wrote: > > 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. ah, ok. I didn't know that. Now I understand your point. We will do that, thanks for the review and help. Oded