Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp194869pjb; Thu, 16 Jul 2020 11:40:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz37TKSLU/5mvrJuxkNkD0iRbuv5CEx7qNjO6nIDLluyXT/79eYbN3kesJOcCUdEeGsaLMV X-Received: by 2002:a17:906:d784:: with SMTP id pj4mr4839128ejb.405.1594924821573; Thu, 16 Jul 2020 11:40:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594924821; cv=none; d=google.com; s=arc-20160816; b=JTVd+unSsXRp2l85DN4J7FHpYMA2lH31DJr0od5BilDdu3C19lwEi+IhN6rcMwyN/f ZiD8rr6jSrT0vl/7P6o0264/AL7xPh28qnVY+/sEgy311zLaOhgGln/3vTFd15nwInpQ ERGzuMkfqremNvygrAxQq2u6oZBAJMngGh48+KfXg1CwRU/APfvuY35c6MUUA99JMugK T7MRI12ANA4hB5r9MPBS00YepZYdNwrSlwpPPgXnr7YjfGrXqgtMz5KKGf2ojDsASE4j YsCMdjINjHz3KgEac4mtZ69km72yNrpvH13u4pqVF2T197wcYScFCIVnUHO5eRfkTXP7 9fOw== 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=+coITXiimNsb5nBzhFzYlUsUzyr8GjmEEn5UXQLx90o=; b=IlXHSzwbQRnjXdeCQzaOHaQSEGO3wQsl714wlAwZRNykF5TcufbPcL+AZLzkRMHoPw +VXbW3LYAmN6d6XrIi94hH1OzbAd+v+2gSDzNWqi5c3KwN7nSmUt7OG1pw7md+v7hSwm rUk8vSQjA3UYYHyMFx4Gd/7vKpJkyuOaJYpFDZkk8jOi7ykmhg0++T2UGsP77U9ItgK2 e9wutjfTWUaQZFzz+1wQuo/s90YoY3/6NSQkGCGh3QyN/XW/v3iy52RjeL3LuSGSX7Rz CJlXxhN5IYtdxM3uE5gbLsorkzidRU7fI4iPE6W25CFNmpNQBATFNM6Z/1GG5ab03KEr eayg== 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 p1si3650571edm.302.2020.07.16.11.39.58; Thu, 16 Jul 2020 11:40:21 -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 S1729455AbgGPSiz (ORCPT + 99 others); Thu, 16 Jul 2020 14:38:55 -0400 Received: from mga09.intel.com ([134.134.136.24]:21175 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729375AbgGPSir (ORCPT ); Thu, 16 Jul 2020 14:38:47 -0400 IronPort-SDR: OOEzES67mRG5cBGCOZ4ed52CTYex78A89QGvTi1H03fxPfhVYgpKo/QQl1ubF2a4Nl22j23CMC oMZ7cCMYewZw== X-IronPort-AV: E=McAfee;i="6000,8403,9684"; a="150857722" X-IronPort-AV: E=Sophos;i="5.75,360,1589266800"; d="scan'208";a="150857722" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jul 2020 11:38:42 -0700 IronPort-SDR: z8Ew0b81oas8yLjwSo5w6RLRZbA0wqTJQ+8rNB1pHIBIuzERmAZKT7/gS3ix2RB6gIFO+8kK5v Ip0YI8mUBo5A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,360,1589266800"; d="scan'208";a="460572041" Received: from jacob-builder.jf.intel.com ([10.7.199.155]) by orsmga005.jf.intel.com with ESMTP; 16 Jul 2020 11:38:34 -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 v5 0/5] IOMMU user API enhancement Date: Thu, 16 Jul 2020 11:45:12 -0700 Message-Id: <1594925117-64892-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. Thanks, Jacob Changeog: 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 (5): docs: IOMMU user API iommu/uapi: Add argsz for user filled data iommu/uapi: Use named union for user data iommu/uapi: Handle data and argsz filled by users iommu/vt-d: Check UAPI data processed by IOMMU core Documentation/userspace-api/iommu.rst | 338 ++++++++++++++++++++++++++++++++++ drivers/iommu/intel/iommu.c | 27 ++- drivers/iommu/intel/svm.c | 9 +- drivers/iommu/iommu.c | 192 ++++++++++++++++++- include/linux/iommu.h | 20 +- include/uapi/linux/iommu.h | 16 +- 6 files changed, 568 insertions(+), 34 deletions(-) create mode 100644 Documentation/userspace-api/iommu.rst -- 2.7.4