Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3809762rdb; Thu, 14 Sep 2023 03:27:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF8GpwjimCjzaukzkbM6vxe3uQcERkdM46nAeXsKQ5JvmC4M2FNo6PtCxVzEuQnlEtZtCRK X-Received: by 2002:a05:6a00:2d1e:b0:68f:ba5d:c7c8 with SMTP id fa30-20020a056a002d1e00b0068fba5dc7c8mr5674640pfb.10.1694687253505; Thu, 14 Sep 2023 03:27:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694687253; cv=none; d=google.com; s=arc-20160816; b=uMC7o6Ug2ztB9G9O6JhlYLz1mxPOrPAMj5UepeHvukWAQgdrxCgfiQtRhTwuxQaBfx zoKIk+PABa+QraZP8l/Y9eKL7P1TudlQfEYW5ddX6qiQTIhPnZDL+hsHYqruMGb1MgZE pxo7g5BGbboxhR/ohhc+0+QT0zXehkySLPohe3xxX30ynnK++Wo3Ayq4YENSGfOp/LlO MZZ5OqFdaSTRCmb/6s3j8u4OQd5CnrTcnsZ234nVoY1OUNYwMS5XCYphyHT973pFC2O5 T6Wh88r05satKokH8QF1H54o8DievWSrRegDmNesE+yUkMEr2OLdHVS0LKKaSVtLJ2Ek IJiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=SXf40nvWF6SRZJEMW6q7DsJE+sok11mDfrEsCajG3Xw=; fh=nYlV1hExaZQmlcfIklAKMTX16av7Bt28QTvLP0QH32I=; b=b7fl1/GSQM1PGlyPfWWbcUCVvJxvNiOoPNYvUdjV6ap/oSpEuS+ss5tnEF/DcT1OO6 9Pc510SPwmyTJJ7hDBy+F1ZGAxwpQo57q3Jdg/H0eMjUjkVKqPpnrEvdFXFFga3G3zN+ He190schPFPa7cDDCo6gGcZdMiNUzpss0Si3wGCeH5e5MS65wmMZSSeRUgeJfrftP07U F8PTrmEqwe6rfIqaUNwaBD6K0vNI69tzuoAL4qvaleN7ges31XCHd2mVxn9e1hyNujpY tiPr9uqfK1hJGZ8JTx/H5pTTLgq7OUnSDTznRx9A0NUa7HomVpxvYK+1816P+CvWZyD5 qezw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lLFwGLrV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id be10-20020a056a001f0a00b0068a692b67b0si1318808pfb.104.2023.09.14.03.27.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 03:27:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lLFwGLrV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id BE6D18095648; Thu, 14 Sep 2023 02:00:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236621AbjINJAJ (ORCPT + 99 others); Thu, 14 Sep 2023 05:00:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236018AbjINJAI (ORCPT ); Thu, 14 Sep 2023 05:00:08 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DF96CC7; Thu, 14 Sep 2023 02:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694682004; x=1726218004; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=uN8KuX2E3zT70MY15JenTBxvRQFNjaVLVn3Ku4Z23X0=; b=lLFwGLrVlzl50eM+8Kin1RCV5TQtlgkiHhAwrURn5olD+gLq1vXwTVns peQIcnXO5qOmMlB7w40OJfJj49CNoM8RgPgJPiN+lCZYeDr7LXhj3O3kC EE9nxFnjh2LYiLeiQrI/QA4T5VqcIG1vEwjnaZpJvcSMIlmSuR+tffkib R+6kokgPAJfPS8VXKUt5Bp6haTx1N6WLL9nBlpezqGOjbt7u6bOQ0KZPQ MjeFV6GOrMKAIZIlY63SHlDP3uVni8Cqg80VFZMa97muJYqgN1L6a5mk5 MQxFeKeAl54FdO3fxilzc+wtcc0A6/FXqRbbBkMFCBbuuPYBCeLMHIpG2 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="465266285" X-IronPort-AV: E=Sophos;i="6.02,145,1688454000"; d="scan'208";a="465266285" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2023 01:59:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="859612707" X-IronPort-AV: E=Sophos;i="6.02,145,1688454000"; d="scan'208";a="859612707" Received: from allen-box.sh.intel.com ([10.239.159.127]) by fmsmga002.fm.intel.com with ESMTP; 14 Sep 2023 01:59:42 -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 v5 00/12] iommu: Prepare to deliver page faults to user space Date: Thu, 14 Sep 2023 16:56:26 +0800 Message-Id: <20230914085638.17307-1-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 14 Sep 2023 02:00:13 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email 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. - [PATCH 11 ~ 12] Improve iopf framework for iommufd use. 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-v5 Change log: v5: - Consolidate per-device fault data management. (New patch 11) - Improve iopf_queue_flush_dev(). (New patch 12) v4: https://lore.kernel.org/linux-iommu/20230825023026.132919-1-baolu.lu@linux.intel.com/ - 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 available for use cases other than SVA. v1: https://lore.kernel.org/linux-iommu/20230711010642.19707-1-baolu.lu@linux.intel.com/ Lu Baolu (12): 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 iommu: Consolidate per-device fault data management iommu: Improve iopf_queue_flush_dev() include/linux/iommu.h | 258 ++++++++--- 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 | 8 +- drivers/iommu/io-pgfault.c | 424 ++++++++++++------ drivers/iommu/iommu-sva.c | 82 +++- drivers/iommu/iommu.c | 233 ---------- MAINTAINERS | 1 - drivers/iommu/Kconfig | 4 + drivers/iommu/Makefile | 3 +- drivers/iommu/intel/Kconfig | 1 + 15 files changed, 571 insertions(+), 767 deletions(-) delete mode 100644 drivers/iommu/iommu-sva.h delete mode 100644 include/uapi/linux/iommu.h -- 2.34.1