From patchwork Mon Nov 20 11:29:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolu Lu X-Patchwork-Id: 16790 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp2135566vqn; Mon, 20 Nov 2023 03:38:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IE1yJMtiVc8+fLWeIByrKV8WzqH1I1ylaU8mH9s4XmuM9K78V0BF4sgbmqcbQ/nWNaU4QQk X-Received: by 2002:a05:6a20:9797:b0:187:c496:898b with SMTP id hx23-20020a056a20979700b00187c496898bmr4346973pzc.3.1700480322722; Mon, 20 Nov 2023 03:38:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700480322; cv=none; d=google.com; s=arc-20160816; b=qGashHiTuCaqhC1JsV/AVBxVVEMLgahz38lFjNodkRDmyvq+QPK8szmz2r02jiFOT5 xCGOvwAqsfUm3LmFAla/PBNeM/+SHqivh+AKQm0sKKVoebyq7eameqCp3L/CgafiD4hb 2jC8t/b5ROxFn3lROqNKV0vXYMPWHWYXfbJ4PA9JkqaqhkfTL7gl3FrUfVH0S7oC4wZO 717h6qEIQzG/wtSIrVu83wdAtSOxbNTyEZGLyz4OtKFpVNIgoORwZ8U3YEBEop5vdbHB RBAFLVNt/sDLdLdMuRs9RYVxOQFcfbojtlLpKXDKPEDUVopRIMkkVoE8rMOr0C9QWxm6 XtoQ== 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=aFHH+bqzYCEz02UlSgcCJa4mhaQY4UQvOWzYoWvlxHE=; fh=5K4v/0ku97kpa0vTvhWLyUEWwXZiIFVMmzwLLirrjJ4=; b=iDhUmPRlddtv6EQl0xWh04Mhl2oSz/bzUp7SqtcPWog/Zt02VuU3QoXzmGdnxRik2i HQtmQw3FjOqg3pDbxh9/76xcAou5bJQtcXTSXMBxzxN3CZmzl7SuSJxkb1EI1v5pLMV4 YIUOYDo7q54uceawu04z9ozt/e1U4mK0fd3uURNYceUjaywvfJHZPf0XMMKku3ZtX9Bq 7wtRC6zJE6LfP/BNaTUu+lBTEDhHM3x4Z4OMYirrbnCuFknloxUTlRUnULwAJ7lVgDlz X8qdteTWNn4Z5M1a+OFxLu5c9J4AGwys9PrGF3yKecgetE3AiPKqMuU8oiXWp5GkN4c9 cHLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZvVKTsZq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id f15-20020a056a00228f00b006cbb132d4c3si940399pfe.252.2023.11.20.03.38.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 03:38:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZvVKTsZq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 4F4C1806CC1B; Mon, 20 Nov 2023 03:34:31 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233226AbjKTLeW (ORCPT + 27 others); Mon, 20 Nov 2023 06:34:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233199AbjKTLeU (ORCPT ); Mon, 20 Nov 2023 06:34:20 -0500 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F3D29C for ; Mon, 20 Nov 2023 03:34:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700480057; x=1732016057; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=OrCX94Gi20FAuTMva6n9USU5rVLYqIjivGDRZZq68Ic=; b=ZvVKTsZqTZ5DWApeY+N2KZL7HkNXCmvxfL807PQp/Cx78vwjnrZxCKt0 lvECBzLCGug92CQFUupBZmlQ79iwGAzDmbLgJB4P4AfQ4K4xk7VcwFOnd c7yQpV43UdCVuloUOYcblkD6QsYuzzlktf3G6wj86/v/JLW01ecozl1cJ BRsNIlVdUwx547OhnhzhYQqy6ZBLElzxY9KIuCqHj6cnjQaiF7JkPdZlW NHTIYvqObQwr16UM4GIPlzr2FxiTF0O2yjknFPjpo0jClnVTTDrNgiG9o tWbbktzkLhCRX85nDqYMBDzcjxF+OIbYLRYAK+XgIw+8krAbrgZxdQxMn Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10899"; a="376634963" X-IronPort-AV: E=Sophos;i="6.04,213,1695711600"; d="scan'208";a="376634963" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 03:34:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10899"; a="856963592" X-IronPort-AV: E=Sophos;i="6.04,213,1695711600"; d="scan'208";a="856963592" Received: from allen-box.sh.intel.com ([10.239.159.127]) by FMSMGA003.fm.intel.com with ESMTP; 20 Nov 2023 03:34:03 -0800 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 0/5] iommu/vt-d: Convert to use static identity domain Date: Mon, 20 Nov 2023 19:29:39 +0800 Message-Id: <20231120112944.142741-1-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Mon, 20 Nov 2023 03:34:31 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783082855096051598 X-GMAIL-MSGID: 1783082855096051598 Intel's IOMMU driver used a special domain called 1:1 mapping domain to support the domain of type IOMMU_DOMAIN_IDENTITY, which enables device drivers to directly utilize physical addresses for DMA access despite the presence of IOMMU units. The implementation of the 1:1 mapping domain is influenced by hardware differences. While modern Intel VT-d implementations support hardware passthrough translation mode, earlier versions lacked this feature, which requires a more complex implementation approach. The 1:1 mapping domain for earlier hardware was implemented by associating a DMA domain with an IOVA (IO Virtual Address) equivalent to the physical address. While, for most hardware supporting passthrough mode, simply setting the hardware's passthrough mode is sufficient. These two modes were merged together in si_domain, which is a special DMA domain sharing the domain ops of an ordinary DMA domain. As the iommu core has evolved, it has introduced global static identity domain with "never fail" attach semantics. This means that the domain is always available and cannot fail to attach. The iommu driver now assigns this domain directly at iommu_ops->identity_domain instead of allocating it through the domain allocation interface. This converts the Intel IOMMU driver to embrace the global static identity domain. For early legacy hardwares that don't support passthrough translation mode, ask the iommu core to use a DMA type of default domain. For modern hardwares that support passthrough translation mode, implement a static global identity domain. The whole series is also avaiable at https://github.com/LuBaolu/intel-iommu/commits/vtd-static-identity-domain-v1 Very appreciated for your review comments and suggestions. Lu Baolu (5): iommu/vt-d: Setup scalable mode context entry in probe path iommu/vt-d: Remove scalable mode context entry setup from attach_dev iommu/vt-d: Refactor domain_context_mapping_one() to be reusable iommu/vt-d: Add support for static identity domain iommu/vt-d: Remove si_domain drivers/iommu/intel/pasid.h | 1 + drivers/iommu/intel/iommu.c | 565 +++++++++++++++--------------------- drivers/iommu/intel/pasid.c | 180 ++++++++++++ drivers/iommu/intel/svm.c | 2 +- 4 files changed, 414 insertions(+), 334 deletions(-)