Received: by 10.213.65.68 with SMTP id h4csp2973593imn; Mon, 2 Apr 2018 18:29:08 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+30N0sJUlg5xFt9WOTh+/0HeMHBqlLCM/EgLEi229fe5uBNRTavg91wvOSLePOIk3ppjts X-Received: by 10.101.70.8 with SMTP id v8mr7635393pgq.336.1522718948533; Mon, 02 Apr 2018 18:29:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522718948; cv=none; d=google.com; s=arc-20160816; b=olX0+1RhfRjH6qWwt66uLOLiMfKsDeg5vRqJRb7m4zrvEK4TnU/tFHO8cScPFJRhW7 i86tqkh7FyHGJxKu0kvWn/lw3bFw0BLutYt0CF2g22jasjKsbj85KnTuTcquBdw+m3xJ YnbEOxI5Ite8K9AqtuxTQEnWM4kkCVAsZzWjf/Gf6XYoqSRtDS/WGBPo4Lo6fKYMDev4 i4JQLEJneBjDVoh9WOeNmIQwUSZQoVighAB051dnYE5jG4ZVcXvAB78cQaqYqPOI3yBa jfdqu+1LmDBCI/ShMUzuLCELOQNi0GX5AsVCEl19wl4AdzsX6yCJelwZF0EhimAH1EYX 2QXg== 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 :mime-version:dkim-signature:arc-authentication-results; bh=bJIUuanqjk46F3ToD8j4gAopeUJoZ9oMRDshHke6Rbw=; b=MXb5cs5OFlNzIMxkZxKT9rpEz1RfpfiekB04KzQnBkKEzFXFNzXuVfRK1qxXrJthfY I/J8gU5mBMBMfXj+0uOAlcG1w9UerPmLv1/15CdwQwz8mi0Mmkt35ayWvKN3IHiEQyOM AfDjBD1DOrig4brlMYJ9SYK3eIyDl9QZuyGjp5BTEcVbT1mmxZNB6kk44Y4+S36wCGPK Rcl+FeohRrbwwi82P9Wth3IVwrEegnwx/vWrkNTxAbcvCp5bcHieEgx4bMe/4ESjjyXF rGwuhkvJSS0EjT0Ei3CJDKXGdAffPW1PYisjz8xmuX9wmuPu0UfgDDa7uUI8BV/VCPQL 8gTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=TfbMz80n; 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=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u25si1079856pgn.488.2018.04.02.18.28.54; Mon, 02 Apr 2018 18:29:08 -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=@chromium.org header.s=google header.b=TfbMz80n; 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=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754751AbeDCB1u (ORCPT + 99 others); Mon, 2 Apr 2018 21:27:50 -0400 Received: from mail-yb0-f173.google.com ([209.85.213.173]:40000 "EHLO mail-yb0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754675AbeDCB1s (ORCPT ); Mon, 2 Apr 2018 21:27:48 -0400 Received: by mail-yb0-f173.google.com with SMTP id y15-v6so5641247ybb.7 for ; Mon, 02 Apr 2018 18:27:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:from:date:message-id:subject:to:cc; bh=bJIUuanqjk46F3ToD8j4gAopeUJoZ9oMRDshHke6Rbw=; b=TfbMz80nUQ6hw60P26MIbS3/k8/WZCIaipIwOf0oy0WqC2jHSrXmXA3M16xbu1X0Zn 5qZZWO0B9a3wxEchrj2oh6JArcUawTTtApgCSnM55fkdFzVLR7UB9xZXW2QqUgEUBYRz Y9MnaevdRW/fTOzSXHgfIwM2h5VlQwCU08Kpg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=bJIUuanqjk46F3ToD8j4gAopeUJoZ9oMRDshHke6Rbw=; b=DXLhlQndf2jy43rZQZS0JsnwsdQmc+iIxOL0JbwoOzDp/J8sC0WAv47XdcWC2vYTuy hQCYHnihLz8+1Jt7gR4WkkdTTege6lPpM0vTtE6rmFq8n4VoRs5dL0oBJ0/E5OlS1O/b BE9tWa+ZERVwkFq8vhJuUzhQhxLKeGHN++3XVsitZqTDnUn+7pThyIhzw5OAmI1jCNUf c/+ApV9vg0pG9WC7BmW+kE/u6ajV/fAN62dkWKDemP9+zMKRGFuNk4EEZQFrwOvhIFr0 FyQFgAqMmG7UU21izEipm/exzIqWxOryqJ/HtnVv3QWaaKOfs0pBIzOomf11HPpFNnCr clig== X-Gm-Message-State: AElRT7FIM2VyCEngjEa8UubgTe/EqIxfD1g7s+E2PMqCl3JROuaICME+ tOcNIdONykHSCtDO09OaTaYNaV2BoGzreirM+EYqWSQd X-Received: by 2002:a25:9b42:: with SMTP id u2-v6mr6591640ybo.481.1522718867701; Mon, 02 Apr 2018 18:27:47 -0700 (PDT) MIME-Version: 1.0 From: Simon Que Date: Tue, 03 Apr 2018 01:27:36 +0000 Message-ID: Subject: Looking for way to program external MMU from userspace (or viable alternative) To: linux-kernel@vger.kernel.org Cc: frankhu@chromium.org, John Joseph , Rob Springer 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 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 Simon