From patchwork Fri Aug 25 02:30:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolu Lu X-Patchwork-Id: 13364926 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5DD28C3DA6F for ; Fri, 25 Aug 2023 02:34:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240453AbjHYCdw (ORCPT ); Thu, 24 Aug 2023 22:33:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236390AbjHYCdT (ORCPT ); Thu, 24 Aug 2023 22:33:19 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85F6A1AD; Thu, 24 Aug 2023 19:33:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692930797; x=1724466797; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=CuGojWCN1Q3oMFDKhD2YkAF8gHfytrzxJhYuhDOxwBI=; b=Smpj+QBRfQLOeXHwGOCvuhKF/0FQxzKDwi6/7DW4JWmQmw948nUVgJPW uoTnwnTZVMW7Q0VmtyEBQIcDE3bDjuU/vCNO4+icBGFHBXRCW1WWHler1 /zTA5NG98jUlSqbhg6E2xe2sWAMxBj6HkG3V6CTUZujs0Oni09hy5u9f6 +hxqwHmiXmQxIfU0LCnxfq7gfLFKbyWNGkGkkzwm/8cFCGz3G39buPZwU HKtGH+xtsNvDPzXRzxElgie8SZpuM5of2kfMIxtwhoYmIhaTiwVKBgG67 xAFhu8+S+BbYJ9mKdmKAk7FjT8SFreZPU9Qqh5KbMbbDepJek3jSVIL+7 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10812"; a="372009374" X-IronPort-AV: E=Sophos;i="6.02,195,1688454000"; d="scan'208";a="372009374" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2023 19:33:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10812"; a="730874987" X-IronPort-AV: E=Sophos;i="6.02,195,1688454000"; d="scan'208";a="730874987" Received: from allen-box.sh.intel.com ([10.239.159.127]) by orsmga007.jf.intel.com with ESMTP; 24 Aug 2023 19:33:12 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian , Jean-Philippe Brucker , Nicolin Chen Cc: Yi Liu , Jacob Pan , iommu@lists.linux.dev, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v4 00/10] iommu: Prepare to deliver page faults to user space Date: Fri, 25 Aug 2023 10:30:16 +0800 Message-Id: <20230825023026.132919-1-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org When a user-managed page table is attached to an IOMMU, it is necessary to deliver IO page faults to user space so that they can be handled appropriately. One use case for this is nested translation, which is currently being discussed in the mailing list. I have posted a RFC series [1] that describes the implementation of delivering page faults to user space through IOMMUFD. This series has received several comments on the IOMMU refactoring, which I am trying to address in this series. The major refactoring includes: - [PATCH 01 ~ 04] Move include/uapi/linux/iommu.h to include/linux/iommu.h. Remove the unrecoverable fault data definition. - [PATCH 05 ~ 06] Remove iommu_[un]register_device_fault_handler(). - [PATCH 07 ~ 10] Separate SVA and IOPF. Make IOPF a generic page fault handling framework. This is also available at github [2]. I would appreciate your feedback on this series. [1] https://lore.kernel.org/linux-iommu/20230530053724.232765-1-baolu.lu@linux.intel.com/ [2] https://github.com/LuBaolu/intel-iommu/commits/preparatory-io-pgfault-delivery-v4 Change log: v4: - Merge iommu_fault_event and iopf_fault. They are duplicate. - Move iommu_report_device_fault() and iommu_page_response() to io-pgfault.c. - Move iommu_sva_domain_alloc() to iommu-sva.c. - Add group->domain and use it directly in sva fault handler. - Misc code refactoring and refining. v3: https://lore.kernel.org/linux-iommu/20230817234047.195194-1-baolu.lu@linux.intel.com/ - Convert the fault data structures from uAPI to kAPI. - Merge iopf_device_param into iommu_fault_param. - Add debugging on domain lifetime for iopf. - Remove patch "iommu: Change the return value of dev_iommu_get()". - Remove patch "iommu: Add helper to set iopf handler for domain". - Misc code refactoring and refining. v2: https://lore.kernel.org/linux-iommu/20230727054837.147050-1-baolu.lu@linux.intel.com/ - Remove unrecoverable fault data definition as suggested by Kevin. - Drop the per-device fault cookie code considering that doesn't make much sense for SVA. - Make the IOMMU page fault handling framework generic. So that it can avaible for use cases other than SVA. v1: https://lore.kernel.org/linux-iommu/20230711010642.19707-1-baolu.lu@linux.intel.com/ Lu Baolu (10): iommu: Move iommu fault data to linux/iommu.h iommu/arm-smmu-v3: Remove unrecoverable faults reporting iommu: Remove unrecoverable fault data iommu: Cleanup iopf data structure definitions iommu: Merge iopf_device_param into iommu_fault_param iommu: Remove iommu_[un]register_device_fault_handler() iommu: Merge iommu_fault_event and iopf_fault iommu: Prepare for separating SVA and IOPF iommu: Make iommu_queue_iopf() more generic iommu: Separate SVA and IOPF include/linux/iommu.h | 255 ++++++++++---- drivers/iommu/intel/iommu.h | 2 +- drivers/iommu/iommu-sva.h | 71 ---- include/uapi/linux/iommu.h | 161 --------- .../iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 14 +- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 51 +-- drivers/iommu/intel/iommu.c | 25 +- drivers/iommu/intel/svm.c | 6 +- drivers/iommu/io-pgfault.c | 322 +++++++++++------- drivers/iommu/iommu-sva.c | 82 ++++- drivers/iommu/iommu.c | 255 ++------------ MAINTAINERS | 1 - drivers/iommu/Kconfig | 4 + drivers/iommu/Makefile | 3 +- drivers/iommu/intel/Kconfig | 1 + 15 files changed, 504 insertions(+), 749 deletions(-) delete mode 100644 drivers/iommu/iommu-sva.h delete mode 100644 include/uapi/linux/iommu.h