Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4211757pxk; Tue, 22 Sep 2020 13:17:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8vKh2fbTPuRzS1uTnVRCxBR/nrQOCyO1PKy7eQ5XEkghUbXXh5HOM4Vii+oS1IzNTm61y X-Received: by 2002:a17:906:455:: with SMTP id e21mr7173671eja.170.1600805842564; Tue, 22 Sep 2020 13:17:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600805842; cv=none; d=google.com; s=arc-20160816; b=sIeEr9HZmEjikPiD8YTkkFiqFBWdUQ829s/sf3nf/e0JfdmPh1WKex2UHATFBmlpQr FkYxuFbqccoo5WrNovWjc+nZPM5+l8u5Y90Cex1DxjzmckMdNuMnKLZD23onvhiu1TKi PEfmxBV3HElNLWK0YJnKf+ucyHRB/RUNlHRI9cLjXcoobZIWDmFv0ml4sR1+mlZ/6KPl 9nEa6mmeS9iwSIGnGdU84+7Q2iHv85xTwy1ZXR4JMCXeJCrU4NIiM5pVVNKzceLaYlnv kK6y4Z7QSBzwCBggm7N1u9Qs5aDfD1QgspFqoDIcgAoVATi2B+dThjKzs+KAKQYe2YjZ qoOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=hn6et9LbYd8DuVyzW2thhcz6VZuD8GdG4uKwbIXOb50=; b=lTCgfKyrla10uBhNJd91oV8nSc8EHDV/iZTBm1wvITs/1swyMgTVPOl9DjR3aihWgn XYC0U75rUQLhpo2CZFtrf1iLMUz2wfwp4LzXGs9syruVMV0SqfE89YuAhajXXTWc4C4y vX91TsGYnLHcnPvDaF38ph9J0MH9b+dUlHu8ODLkZS364AiRh/yKeQ3Eiz3K1XPrQ8zP iK3cvzE+au0CQW4squTWQPLKLYnAb/FH5puOQYo21x/vkAJhXDhHwjypkqyX4DZb6pjW mm1urjZWeMRT1OkNqWu2YyOa6SNaErOXIuy/Yq4qXo/1u54dSRF+5uD1Kr211cZS+tZY ui3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=L1rUdoLc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id r25si11044890ejx.180.2020.09.22.13.16.57; Tue, 22 Sep 2020 13:17:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=L1rUdoLc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726607AbgIVUPd (ORCPT + 99 others); Tue, 22 Sep 2020 16:15:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726567AbgIVUPd (ORCPT ); Tue, 22 Sep 2020 16:15:33 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A87BC061755; Tue, 22 Sep 2020 13:15:33 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id n14so13487993pff.6; Tue, 22 Sep 2020 13:15:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=hn6et9LbYd8DuVyzW2thhcz6VZuD8GdG4uKwbIXOb50=; b=L1rUdoLclGSVBza/7wOpYY8ml/ZUxKH4wjY5LU820mOjsxd04jcg+HlQCmL179hWO2 JvQgv7YapT+ocwEE4i8l8H7G1tULRf7itL6VvemEh1TLT0w0uLIA6ZAd8L/TXIb7gn0m oZXfdSWFv0vZoiU/lqVHLT/bGrVxbVejElaf+26Yne/a0kz+M83FclZ6VvimMuUSLuk3 hyIMU+42B4aHSuvFAAvIvwXYIPxqDOYlGKggmpQcyn6BWTPYJsKHyxUEbL2oNiS6qzIo oN36BxQtB4xg+9LTgMJy17o8gnmzA1KxTZ4ZzJNo/6ffyucwbigoEAT6aXiFxrMfyGHB HiNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=hn6et9LbYd8DuVyzW2thhcz6VZuD8GdG4uKwbIXOb50=; b=OTWMW+2XV3okRhStDY7cBujHof+IVrphLSPjZK9HF3Gb7HcGHHEIJkocJeWceXf16K bRSj3mfu01pYIVUh3b90vieh/9/Gxvkl1NXzLsQn2Ib0nM853/VibvljpzotfENNVjXr Rhm9C+lYlV1xk4POhPbFGGTChOpAlJBoj3PPS0n73Vy99PtqGgxw+KHAXnZud0Tm82cT F9QcQQDEpbpBmw2wHLghYIOeoUvDSyxwAJtcPJmGgkekW5yoC/XR9qPKFA8CMsVAt6mC YI2CJK9O4I3PO/Ee5TCc/hvFQEPoW2OrdH7Fmy+mDKKndccPWRF44gAThPR69nildDaU SpFQ== X-Gm-Message-State: AOAM533Kqy9Jmmh68ydkROlOqYDaq1/wOH0e4YdQruC0jVEm3n+Ga/Tr +/rtc59UNKJOgZ86LT7gM+t743bnxo0= X-Received: by 2002:a17:902:a402:b029:d2:21a:d994 with SMTP id p2-20020a170902a402b02900d2021ad994mr6196232plq.52.1600805732950; Tue, 22 Sep 2020 13:15:32 -0700 (PDT) Received: from jacob-builder.jf.intel.com (jfdmzpr04-ext.jf.intel.com. [134.134.137.73]) by smtp.gmail.com with ESMTPSA id e10sm15793028pgb.45.2020.09.22.13.15.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Sep 2020 13:15:32 -0700 (PDT) From: Jacob Pan X-Google-Original-From: Jacob Pan To: iommu@lists.linux-foundation.org, LKML , Joerg Roedel , Alex Williamson , "Lu Baolu" , David Woodhouse , Jonathan Corbet Cc: linux-api@vger.kernel.org, Jean-Philippe Brucker , Eric Auger , Jacob Pan , Yi Liu , "Tian, Kevin" , Raj Ashok , Wu Hao , Yi Sun , Randy Dunlap Subject: [PATCH v10 0/7] IOMMU user API enhancement Date: Tue, 22 Sep 2020 13:16:55 -0700 Message-Id: <1600805822-1177-1-git-send-email-jacob.jun.pan@linux.intel.com> X-Mailer: git-send-email 2.7.4 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org IOMMU user API header was introduced to support nested DMA translation and related fault handling. The current UAPI data structures consist of three areas that cover the interactions between host kernel and guest: - fault handling - cache invalidation - bind guest page tables, i.e. guest PASID Future extensions are likely to support more architectures and vIOMMU features. In the previous discussion, using user-filled data size and feature flags is made a preferred approach over a unified version number. https://lkml.org/lkml/2020/1/29/45 In addition to introduce argsz field to data structures, this patchset is also trying to document the UAPI design, usage, and extension rules. VT-d driver changes to utilize the new argsz field is included, VFIO usage is to follow. This set is available at: https://github.com/jacobpan/linux.git vsva_v5.9_uapi_v10 Thanks, Jacob Changelog: v10 - Documentation grammar fixes based on Randy's review v9 - Directly pass PASID value to iommu_sva_unbind_gpasid() without the superfluous data in struct iommu_gpasid_bind_data. v8 - Rebased to v5.9-rc2 - Addressed review comments from Eric Auger 1. added a check for the unused vendor flags 2. commit message improvements v7 - Added PASID data format enum for range checking - Tidy up based on reviews from Alex W. - Removed doc section for vIOMMU fault handling v6 - Renamed all UAPI functions with iommu_uapi_ prefix - Replaced argsz maxsz checking with flag specific size checks - Documentation improvements based on suggestions by Eric Auger Replaced example code with a pointer to the actual code - Added more checks for illegal flags combinations - Added doc file to MAINTAINERS v5 - Addjusted paddings in UAPI data to be 8 byte aligned - Do not clobber argsz in IOMMU core before passing on to vendor driver - Removed pr_warn_ for invalid UAPI data check, just return -EINVAL - Clarified VFIO responsibility in UAPI data handling - Use iommu_uapi prefix to differentiate APIs has in-kernel caller - Added comment for unchecked flags of invalidation granularity - Added example in doc to show vendor data checking v4 - Added checks of UAPI data for reserved fields, version, and flags. - Removed version check from vendor driver (vt-d) - Relaxed argsz check to match the UAPI struct size instead of variable union size - Updated documentation v3: - Rewrote backward compatibility rule to support existing code re-compiled with newer kernel UAPI header that runs on older kernel. Based on review comment from Alex W. https://lore.kernel.org/linux-iommu/20200611094741.6d118fa8@w520.home/ - Take user pointer directly in UAPI functions. Perform argsz check and copy_from_user() in IOMMU driver. Eliminate the need for VFIO or other upper layer to parse IOMMU data. - Create wrapper function for in-kernel users of UAPI functions v2: - Removed unified API version and helper - Introduced argsz for each UAPI data - Introduced UAPI doc Jacob Pan (7): docs: IOMMU user API iommu/uapi: Add argsz for user filled data iommu/uapi: Introduce enum type for PASID data format iommu/uapi: Use named union for user data iommu/uapi: Rename uapi functions iommu/uapi: Handle data and argsz filled by users iommu/vt-d: Check UAPI data processed by IOMMU core Documentation/userspace-api/iommu.rst | 210 ++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + drivers/iommu/intel/iommu.c | 25 ++-- drivers/iommu/intel/svm.c | 13 ++- drivers/iommu/iommu.c | 201 ++++++++++++++++++++++++++++++-- include/linux/iommu.h | 35 ++++-- include/uapi/linux/iommu.h | 25 ++-- 7 files changed, 467 insertions(+), 43 deletions(-) create mode 100644 Documentation/userspace-api/iommu.rst -- 2.7.4