Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp1530850ybg; Wed, 29 Jul 2020 17:16:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6avrK5w6FM45P3IAstCpIVi+zgO4kFdRQw9hKvWFshfzTQY0H1DOtFvIenuok3PifYi9r X-Received: by 2002:a17:906:5346:: with SMTP id j6mr114011ejo.311.1596068206473; Wed, 29 Jul 2020 17:16:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596068206; cv=none; d=google.com; s=arc-20160816; b=1IUg1f7z6pu9iXZzU5TjFkVNGxbU6qtkmFry916uMdFIC2AU+9l0Q7RVB2K9AQcQFA wGFLJfF3IXm11OVoft+PSpobKMCxh0HYhsoU22pC3JC+cC3e2jPbb8LxYw/s4YBMCOmG whhYInZW+eI3u2vvDh0QfBPJa6atvfzbYFEoC1+qZwgZWF4BGcAjGbNYo7Q/im/+fYn+ rXzNw6QzskC+CwjCYoXI1A7Cz68Es6DtXvQBMFurJ/l2CsNPgcG62zJjwgK7V02sKCvG jy2rPtPQz60wJ2MSJAhoiqoXGV8QAmz5DVfgWZuBUAX1sfQ/bk3prQV4kEDpbqEZaoUL CRNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=lE2p9QIKMVUiebS5IOE1aZIojc1/QRBbjLiNLIy4svg=; b=m8dTiArXzKP0TnrgjKBMs52yL/grVSF886ZoSYipdajQIFTfIQvVdTAvhoclEROC9I KNMUOn1OPfZ5X+trCX2ZAxJ2FKsLMmucvzQpMAYFbAhKIDuJp7wEe/SAR8o5YEO23O8P 9kCreCUW1lGkNhnxG4hrMLgGXN7fkw+dskNUJH/KwhBD1xdiQtvide9rwNiFCuvWskAl V4yuIcaedodadT/viflBnYtyGGBF5IFz20mruG8x9tq8/rWiXlmoz1iyAJ6ZjDZ6vEmB qDbRYmUtmzMqf6+EGD+z0nSXBlNEwecGovbo+a/HCUts8OZ8YoEuD2QtwoU9k/nqknmE 7UCA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s26si2011131ejv.28.2020.07.29.17.16.23; Wed, 29 Jul 2020 17:16:46 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728182AbgG3AOV (ORCPT + 99 others); Wed, 29 Jul 2020 20:14:21 -0400 Received: from mga09.intel.com ([134.134.136.24]:33261 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727072AbgG3AOV (ORCPT ); Wed, 29 Jul 2020 20:14:21 -0400 IronPort-SDR: aOxqKlTQ0wjsQYVL/HvSPGgxFK83OlAaQRgB6TqNKEZ7HtUAake+I1gLRZvrxvzTREOvblWEmq DHiiTRmU18/w== X-IronPort-AV: E=McAfee;i="6000,8403,9697"; a="152748850" X-IronPort-AV: E=Sophos;i="5.75,412,1589266800"; d="scan'208";a="152748850" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jul 2020 17:14:20 -0700 IronPort-SDR: lLkOeERMcTSW7/4jwMcGETbRO9EUC/CNYsRMxF40HDqvyH7dLXyFbRq2EfRfCQxCAp4u4T2bJR wyiZ7N4lql5Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,412,1589266800"; d="scan'208";a="286680241" Received: from jacob-builder.jf.intel.com ([10.7.199.155]) by orsmga003.jf.intel.com with ESMTP; 29 Jul 2020 17:14:19 -0700 From: Jacob Pan To: iommu@lists.linux-foundation.org, LKML , Joerg Roedel , Alex Williamson Cc: "Lu Baolu" , David Woodhouse , Yi Liu , "Tian, Kevin" , Raj Ashok , "Christoph Hellwig" , Jean-Philippe Brucker , Eric Auger , Jonathan Corbet , Jacob Pan Subject: [PATCH v7 0/7] IOMMU user API enhancement Date: Wed, 29 Jul 2020 17:21:00 -0700 Message-Id: <1596068467-49322-1-git-send-email-jacob.jun.pan@linux.intel.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org 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.8_uapi_v7 Thanks, Jacob Changeog: 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 | 212 ++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + drivers/iommu/intel/iommu.c | 25 ++-- drivers/iommu/intel/svm.c | 9 +- drivers/iommu/iommu.c | 205 ++++++++++++++++++++++++++++++-- include/linux/iommu.h | 35 ++++-- include/uapi/linux/iommu.h | 24 ++-- 7 files changed, 466 insertions(+), 45 deletions(-) create mode 100644 Documentation/userspace-api/iommu.rst -- 2.7.4