Received: by 10.213.65.68 with SMTP id h4csp3744941imn; Tue, 3 Apr 2018 09:58:51 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+q5U7ycGURY3ua5f3t45qdzEQSaaV+KLjt1OMPkPQ41w5jb+61aCtqKp/jUxUtekrhyitU X-Received: by 10.98.157.6 with SMTP id i6mr11304191pfd.52.1522774731851; Tue, 03 Apr 2018 09:58:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522774731; cv=none; d=google.com; s=arc-20160816; b=SY3k6iboJWo170hsiljY77SAeecJlivacAAjPrQruCsT4eHAByg0OU3uL1unPbf/6U H7YORkyHJtM6l5tTvajUoPhj2JRXOvku5gt3hfmyswFlyUwrSSyt/2fxPvWeMlJM+HXO Z4CqoFElHbWmo+G/2Njn9/POxiwGTyhx/4KCQs5xNdTT5H3onsSm092LP3VrvvkhUV4G IZABhKeTWE/Gk4SNC6uUuzbMMvtVLLQisuZ2Ul8SK9y+2QlytbasRpGFhqaxQZTU5wj1 G8gttRe2OzIlv3VLkOV/FeyYcmIJnIKLkPmbmAT4obUZgdQ7cCTQMw73tKXXeWkuCNWO r63g== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=IgbJpRSwhGZwxyZhhlpx8jesrf7eRMyuys0mAfQDU4s=; b=Y4SjgZ/gA84eerf1dGwNdqTnzzaRMpUaUlg/ZY83+AloqPmEmmiHhVlRT7wic07q4q S3eZX7IlCdfdLSlW+1skE31kzd/wH8X6pVcp5m/e1s02kkEjdYupVaTLby5qWcO0rjJu G6e803JDR/aR9FD/VFtlVhtstp4v2Dm0z9bwrc1fiA9uM4cMifOxOpcLRkXK56Ui6+NH 1LjCu66rUHIvZ4hLwfHLWpCCfRsRtwSVRoF+MkxyV7hxdFjtOu+aPMk/gFQ5+p4amdlk b92WHxGJ54QOOQIPIH2qqQ3iuQg4c8HSvV9IjJ+iKXipAVvubBw7EQn+W0tLJTuuX4Bx Q8gg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 2-v6si927066pla.436.2018.04.03.09.58.38; Tue, 03 Apr 2018 09:58:51 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752870AbeDCQ5O (ORCPT + 99 others); Tue, 3 Apr 2018 12:57:14 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:33832 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752171AbeDCQ5K (ORCPT ); Tue, 3 Apr 2018 12:57:10 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2B754EAEA9; Tue, 3 Apr 2018 16:57:10 +0000 (UTC) Received: from redhat.com (ovpn-121-77.rdu2.redhat.com [10.10.121.77]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D3FED1134CD6; Tue, 3 Apr 2018 16:57:09 +0000 (UTC) Date: Tue, 3 Apr 2018 12:57:08 -0400 From: Jerome Glisse To: Simon Que Cc: linux-kernel@vger.kernel.org, frankhu@chromium.org, John Joseph , Rob Springer Subject: Re: Looking for way to program external MMU from userspace (or viable alternative) Message-ID: <20180403165708.GA5935@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 03 Apr 2018 16:57:10 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 03 Apr 2018 16:57:10 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jglisse@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 03, 2018 at 01:27:36AM +0000, Simon Que wrote: > Hi kernel community, > > We have an external PCIe board with a custom coprocessor on it. We also > have code for a kernel driver for it. We have thought about upstreaming it, > but we realized that we can instead convert the driver to a userspace > driver using UIO. > > However, there's one aspect of the system and driver that doesn't seem to > be covered by UIO. The external board has a MMU and a DMA interface that > allows it to copy data between the host system's RAM and its own internal > memory. > > The current kernel driver code looks up the physical address of a page of > user-allocated memory by traversing the page table, and then writing the > physical address to the external MMU. If we were to move the driver to > userspace, this procedure would require exposing the physical address to > user space, which insecure and thus a no-go. > > What possibilities are there for programming the MMU from a userspace > driver? > > For reference, here is the existing kernel driver code -- start from > apex_driver.c. > https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/981313 AFAIK not do-able and not something you want to do. UIO is for very very basic device, no MMU or DMA. Allowing any such thing from user space is wide opening the door to random DMA exploitation especialy if there is no IOMMU. Cheers, J?r?me