From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66E20C11D20 for ; Thu, 20 Feb 2020 21:28:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 28249208CD for ; Thu, 20 Feb 2020 21:28:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IH5X7VGH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 28249208CD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B9A5C6B0005; Thu, 20 Feb 2020 16:28:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B4A476B0006; Thu, 20 Feb 2020 16:28:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A60A06B0007; Thu, 20 Feb 2020 16:28:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0220.hostedemail.com [216.40.44.220]) by kanga.kvack.org (Postfix) with ESMTP id 8AEDE6B0005 for ; Thu, 20 Feb 2020 16:28:11 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 5193C180AD81D for ; Thu, 20 Feb 2020 21:28:11 +0000 (UTC) X-FDA: 76511793582.20.twist83_d3cb8e9b5043 X-HE-Tag: twist83_d3cb8e9b5043 X-Filterd-Recvd-Size: 4065 Received: from mail-io1-f65.google.com (mail-io1-f65.google.com [209.85.166.65]) by imf06.hostedemail.com (Postfix) with ESMTP for ; Thu, 20 Feb 2020 21:28:10 +0000 (UTC) Received: by mail-io1-f65.google.com with SMTP id s24so52864iog.5 for ; Thu, 20 Feb 2020 13:28:10 -0800 (PST) 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=TZNBm0L6Bg42NlFobzmo4jABuSk8GzGFlvLVH69HdS8=; b=IH5X7VGHc/qU7ShEssGv+FgZUljTqGk4FXPJcWd2IvU38d2E1T2E3AgfTyQmTSFBvY J0rxj650awLr9Zg62BkSpmJqxce2CR7eemzqPy5kKCTs8B8lixo6gDfEked78wldRDP8 lZYCFuZDDCAAfKDSaN+JSJQnFQiwY9lhG0PxxkI4/nDgi2eYeTjVjPq2nPPKv8flO8iR ggSxALHOd6QU3dyeoLaNalkmxv+L7qI32jIW3ywofHAZP3cdwmgneu1QfK6+B44SIetZ q2UnoHvbgWnygfPpsTO6eBg5MCBmSoyvHcSXqIUIUKK6D7xd9SWolQ79Xg2hm9eS+MCv OaBg== 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=TZNBm0L6Bg42NlFobzmo4jABuSk8GzGFlvLVH69HdS8=; b=NmmoTtaCN7tpiiVXINERgbkfvuC1fE6xL7p2WwJXIWkumORXR3dukTCdbaepej30Cm AoGGOxUj+yA/XwWcCiKO7i/S5PjlL9jQXHy0Mk4U10zcFOCctgE1nzFt4NM3XVnXtgVj xlsL3xskuwXh4JdWpFwCH/dVKGQ527JZctE/3PatyYRPjcRA459mN3gGclh05tUxRdkb HrB8wGjtrXBQct4p9p9+0MOBXpmX+LgUxBrYnJajhJTaRMAK6fT913E48oMCIR9zgzpj G//TQupdiV4AuXMe0j9aSOYxgrh60AGev4Zhq80afWa65/C+R5U0aFpUZlPvtb9PyqU9 1AhQ== X-Gm-Message-State: APjAAAWQ1bywQOWgzqdEkTUf3wnOSbA9ah3DIiwWlkZXOJfZGiQEyu46 aCDu8uU31xtiyRU4kEjYOUuNhIWZxKZucoHWXIhosnfPLew= X-Google-Smtp-Source: APXvYqxdW7x8eWvpWRCCz+fuXLt7eHXjwlkyCpZw5y3eeuvC7YLZTvD3I6RIqMuZHZ2pthyRxMlKdwGxov8wHoL6MYc= X-Received: by 2002:a02:7f54:: with SMTP id r81mr28311374jac.121.1582234090038; Thu, 20 Feb 2020 13:28:10 -0800 (PST) MIME-Version: 1.0 References: <20200218155656.01223f67f9b2d902ce975fd0@rochester.rr.com> In-Reply-To: <20200218155656.01223f67f9b2d902ce975fd0@rochester.rr.com> From: Alexander Duyck Date: Thu, 20 Feb 2020 13:27:59 -0800 Message-ID: Subject: Re: getting physical address of buffer into user space To: Marty Leisner Cc: linux-mm , maleisner@gmail.com Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000080, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Feb 18, 2020 at 12:56 PM Marty Leisner wrote: > > I've read tutorials and seen example programs on how to get page information into userspace > (eventually, I'll want to dma from a UIO driver) Instead of using a UIO driver you may want to consider a VFIO driver as you may not be able to access memory directly from the device with a UIO driver if an IOMMU is present in the system. UIO is normally only used for small embedded controllers where you just need MMIO access. > For POC, I have a simple driver with an mmap rule, which does kmalloc on a new buffer. > > The driver can read/write the memory, and the user space program can read/write the memory (and both > sides agree on the data read/written). > > It appears in /proc/self/maps, and when I try to look it up in /proc/self/pagemap, it says its > neither swapped nor present. > > This seems like a clever way -- if it works (the alternative is sloppy ioctl's or other custom > methods) I suggest you just take a look at VFIO. You can find some user documentation here: https://www.kernel.org/doc/html/latest/driver-api/vfio.html There are multiple userspace drivers out there that make use of UIO or VFIO functionality. If you are in need of examples just go take a look at the DPDK project (http://git.dpdk.org/dpdk/) as they have all of their NIC drivers implemented in userspace and are using either a igb_uio driver or vfio driver to connect to them.