linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jerome Glisse <jglisse@redhat.com>
To: Simon Que <sque@chromium.org>
Cc: linux-kernel@vger.kernel.org, frankhu@chromium.org,
	John Joseph <jnjoseph@google.com>,
	Rob Springer <rspringer@google.com>
Subject: Re: Looking for way to program external MMU from userspace (or viable alternative)
Date: Tue, 3 Apr 2018 12:57:08 -0400	[thread overview]
Message-ID: <20180403165708.GA5935@redhat.com> (raw)
In-Reply-To: <CANV8Hs0XsCnLRwOdC=r4sot+iKkivofMzEg-kA_b5UjRw9Xmng@mail.gmail.com>

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

  reply	other threads:[~2018-04-03 16:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-03  1:27 Looking for way to program external MMU from userspace (or viable alternative) Simon Que
2018-04-03 16:57 ` Jerome Glisse [this message]
2018-04-06 12:01 ` Alan Cox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180403165708.GA5935@redhat.com \
    --to=jglisse@redhat.com \
    --cc=frankhu@chromium.org \
    --cc=jnjoseph@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rspringer@google.com \
    --cc=sque@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).