From nobody Sun May 10 15:05:35 2026 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 E5302C433EF for ; Sun, 1 May 2022 11:28:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345855AbiEALbT (ORCPT ); Sun, 1 May 2022 07:31:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345774AbiEALbN (ORCPT ); Sun, 1 May 2022 07:31:13 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0849E6D1A2 for ; Sun, 1 May 2022 04:27:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651404468; x=1682940468; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6JDcNykVMFEeo9gQEenBDZWl7d/DyNiEOKcrygbNnmA=; b=bWya1ZafWr6/hrbNWndBJedp6cjEH60MRaMy/MzXR+fUHr5EAbIem6yw HL72/6wn4CC9t2E346J0n9QB0KkYf3QY8UVLRbj2jacO+4VW4z5nhi8B1 yUSeprFsvSIew0mDEtZ8I7dTTmPcf9a7enw6+KJzgNuhVzSJDaoerT/f9 fW8IK8479OGBycwqv2rrzGcsoLuzxh7EJ8glHnFYHKqhAs15AtcnNW/o2 bLpYzMWlmJMKANdDHaw6sz0B3XFGZDdpcFnfT9VBVK5KmqZBw27fydTUL V1ov0eNL6uZRCSo7L7p5do1KYwSnl9NF8Ge405Jr/dxastW3LpYY/CW2I Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10333"; a="246912712" X-IronPort-AV: E=Sophos;i="5.91,189,1647327600"; d="scan'208";a="246912712" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 May 2022 04:27:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,189,1647327600"; d="scan'208";a="545114784" Received: from allen-box.sh.intel.com ([10.239.159.48]) by orsmga002.jf.intel.com with ESMTP; 01 May 2022 04:27:46 -0700 From: Lu Baolu To: Joerg Roedel , Jason Gunthorpe , Alex Williamson , Kevin Tian Cc: Jacob jun Pan , Liu Yi L , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 1/5] iommu/vt-d: Block force-snoop domain attaching if no SC support Date: Sun, 1 May 2022 19:24:30 +0800 Message-Id: <20220501112434.874236-2-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220501112434.874236-1-baolu.lu@linux.intel.com> References: <20220501112434.874236-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In the attach_dev callback of the default domain ops, if the domain has been set force_snooping, but the iommu hardware of the device does not support SC(Snoop Control) capability, the callback should block it and return a corresponding error code. Signed-off-by: Lu Baolu Reviewed-by: Jason Gunthorpe --- drivers/iommu/intel/iommu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index cf43e8f9091b..d68f5bbf3e93 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -4354,6 +4354,9 @@ static int prepare_domain_attach_device(struct iommu_= domain *domain, if (!iommu) return -ENODEV; =20 + if (dmar_domain->force_snooping && !ecap_sc_support(iommu->ecap)) + return -EOPNOTSUPP; + /* check if this iommu agaw is sufficient for max mapped address */ addr_width =3D agaw_to_width(iommu->agaw); if (addr_width > cap_mgaw(iommu->cap)) --=20 2.25.1 From nobody Sun May 10 15:05:35 2026 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 128B8C433FE for ; Sun, 1 May 2022 11:28:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345979AbiEALbX (ORCPT ); Sun, 1 May 2022 07:31:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345776AbiEALbQ (ORCPT ); Sun, 1 May 2022 07:31:16 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 749906D383 for ; Sun, 1 May 2022 04:27:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651404471; x=1682940471; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5zmR7Xs8756n/cIviDuKs63tUWLeK4DQi3HgXVUT7kk=; b=XYa98z4mv6EDmR/wrAeeo/AhUENEhHqnDAIn4bO7tJNa1WQXAxNznv4c L3KvbF5mifM9qdT7VEKx7DgVl5moV0DOPm4oDysqACvp+GKMw57BDKk0b RJmZ27hkWTh5z3uRH23LBi7sMopqMgYiENQmPr/EhYHpSZvW8cE8bVjwL 0tt+REcGIClxuYA1DnpT1zQevZsTIUoSLUCHRb2oE3qHuF8iC4Ck+K4yw onl/tdcIplrZU0fAw81w0EGTngD5XSecge+RNSIhPtnE90ihNWgQCFpwC iNL7fcEWZWZnCCC6AuTW0TKsVB/B9RB23U27n8ClGA/kfGQuHPv77owsT A==; X-IronPort-AV: E=McAfee;i="6400,9594,10333"; a="246912718" X-IronPort-AV: E=Sophos;i="5.91,189,1647327600"; d="scan'208";a="246912718" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 May 2022 04:27:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,189,1647327600"; d="scan'208";a="545114827" Received: from allen-box.sh.intel.com ([10.239.159.48]) by orsmga002.jf.intel.com with ESMTP; 01 May 2022 04:27:48 -0700 From: Lu Baolu To: Joerg Roedel , Jason Gunthorpe , Alex Williamson , Kevin Tian Cc: Jacob jun Pan , Liu Yi L , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 2/5] iommu/vt-d: Set SNP bit only in second-level page table entries Date: Sun, 1 May 2022 19:24:31 +0800 Message-Id: <20220501112434.874236-3-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220501112434.874236-1-baolu.lu@linux.intel.com> References: <20220501112434.874236-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The SNP bit is only valid for second-level PTEs. Setting this bit in the first-level PTEs has no functional impact because the Intel IOMMU always ignores the same bit in first-level PTEs. Anyway, let's check the page table type before setting SNP bit in PTEs to make the code more readable. Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index d68f5bbf3e93..98050943d863 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -4431,7 +4431,7 @@ static int intel_iommu_map(struct iommu_domain *domai= n, prot |=3D DMA_PTE_READ; if (iommu_prot & IOMMU_WRITE) prot |=3D DMA_PTE_WRITE; - if (dmar_domain->force_snooping) + if (dmar_domain->force_snooping && !domain_use_first_level(dmar_domain)) prot |=3D DMA_PTE_SNP; =20 max_addr =3D iova + size; --=20 2.25.1 From nobody Sun May 10 15:05:35 2026 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 13F64C433F5 for ; Sun, 1 May 2022 11:28:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345912AbiEALb3 (ORCPT ); Sun, 1 May 2022 07:31:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345853AbiEALbT (ORCPT ); Sun, 1 May 2022 07:31:19 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 489016D1BB for ; Sun, 1 May 2022 04:27:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651404474; x=1682940474; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eBk8SSzqPwKYdz2VHD0pbb/cRZp4F9pvvxxdY6ELU6U=; b=R9xxm9JN5nojBijjI25F7pisCBs9f2YCAYqezFC5r1U63CbFc4ypbxDf s+C0e3Yp9M2S/3S4P/7kH573uAeAuWaknlk5BcnywxmOrQffKliH1xkcq Fx+4zROO6WTuT6Nop5pyBJhkR4iWVL+5Wa3o9Bxi62nHNlhfAQ1MapCCh rGJfFWgodrM/E5pZThOAJFg6Yr2idoi7aqrbRZzunoHL+nO+KaDyVjWIL IYZqHm7LhdafM7MlNcjqCNLIbzjzTUyzi5tICrOEXHiZGjoBp08X1mw/g 9RRhh4n2L5OtwvHQPcYFQhv3wSffnBf62OER9mYK15DVNcTn4CDGgB7QW g==; X-IronPort-AV: E=McAfee;i="6400,9594,10333"; a="246912726" X-IronPort-AV: E=Sophos;i="5.91,189,1647327600"; d="scan'208";a="246912726" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 May 2022 04:27:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,189,1647327600"; d="scan'208";a="545114870" Received: from allen-box.sh.intel.com ([10.239.159.48]) by orsmga002.jf.intel.com with ESMTP; 01 May 2022 04:27:51 -0700 From: Lu Baolu To: Joerg Roedel , Jason Gunthorpe , Alex Williamson , Kevin Tian Cc: Jacob jun Pan , Liu Yi L , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 3/5] iommu/vt-d: Check domain force_snooping against attached devices Date: Sun, 1 May 2022 19:24:32 +0800 Message-Id: <20220501112434.874236-4-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220501112434.874236-1-baolu.lu@linux.intel.com> References: <20220501112434.874236-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" As domain->force_snooping only impacts the devices attached with the domain, there's no need to check against all IOMMU units. At the same time, for a brand new domain (hasn't been attached to any device), the force_snooping field could be set, but the attach_dev callback will return failure if it wants to attach to a device which IOMMU has no snoop control capability. Signed-off-by: Lu Baolu --- drivers/iommu/intel/pasid.h | 2 ++ drivers/iommu/intel/iommu.c | 50 ++++++++++++++++++++++++++++++++++++- drivers/iommu/intel/pasid.c | 18 +++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel/pasid.h b/drivers/iommu/intel/pasid.h index ab4408c824a5..583ea67fc783 100644 --- a/drivers/iommu/intel/pasid.h +++ b/drivers/iommu/intel/pasid.h @@ -123,4 +123,6 @@ void intel_pasid_tear_down_entry(struct intel_iommu *io= mmu, bool fault_ignore); int vcmd_alloc_pasid(struct intel_iommu *iommu, u32 *pasid); void vcmd_free_pasid(struct intel_iommu *iommu, u32 pasid); +void intel_pasid_setup_page_snoop_control(struct intel_iommu *iommu, + struct device *dev, u32 pasid); #endif /* __INTEL_PASID_H */ diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 98050943d863..3c1c228f9031 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -4554,13 +4554,61 @@ static phys_addr_t intel_iommu_iova_to_phys(struct = iommu_domain *domain, return phys; } =20 +static bool domain_support_force_snooping(struct dmar_domain *domain) +{ + struct device_domain_info *info; + unsigned long flags; + bool support =3D true; + + spin_lock_irqsave(&device_domain_lock, flags); + if (list_empty(&domain->devices)) + goto out; + + list_for_each_entry(info, &domain->devices, link) { + if (!ecap_sc_support(info->iommu->ecap)) { + support =3D false; + break; + } + } +out: + spin_unlock_irqrestore(&device_domain_lock, flags); + return support; +} + +static void domain_set_force_snooping(struct dmar_domain *domain) +{ + struct device_domain_info *info; + unsigned long flags; + + /* + * Second level page table supports per-PTE snoop control. The + * iommu_map() interface will handle this by setting SNP bit. + */ + if (!domain_use_first_level(domain)) + return; + + spin_lock_irqsave(&device_domain_lock, flags); + if (list_empty(&domain->devices)) + goto out_unlock; + + list_for_each_entry(info, &domain->devices, link) + intel_pasid_setup_page_snoop_control(info->iommu, info->dev, + PASID_RID2PASID); + +out_unlock: + spin_unlock_irqrestore(&device_domain_lock, flags); +} + static bool intel_iommu_enforce_cache_coherency(struct iommu_domain *domai= n) { struct dmar_domain *dmar_domain =3D to_dmar_domain(domain); =20 - if (!domain_update_iommu_snooping(NULL)) + if (!domain_support_force_snooping(dmar_domain)) return false; + + domain_set_force_snooping(dmar_domain); dmar_domain->force_snooping =3D true; + return true; } =20 diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c index f8d215d85695..815c744e6a34 100644 --- a/drivers/iommu/intel/pasid.c +++ b/drivers/iommu/intel/pasid.c @@ -762,3 +762,21 @@ int intel_pasid_setup_pass_through(struct intel_iommu = *iommu, =20 return 0; } + +/* + * Set the page snoop control for a pasid entry which has been set up. + */ +void intel_pasid_setup_page_snoop_control(struct intel_iommu *iommu, + struct device *dev, u32 pasid) +{ + struct pasid_entry *pte; + u16 did; + + pte =3D intel_pasid_get_entry(dev, pasid); + if (WARN_ON(!pte || !pasid_pte_is_present(pte))) + return; + + pasid_set_pgsnp(pte); + did =3D pasid_get_domain_id(pte); + pasid_flush_caches(iommu, pte, pasid, did); +} --=20 2.25.1 From nobody Sun May 10 15:05:35 2026 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 582FEC433F5 for ; Sun, 1 May 2022 11:28:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346109AbiEALbd (ORCPT ); Sun, 1 May 2022 07:31:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345933AbiEALbV (ORCPT ); Sun, 1 May 2022 07:31:21 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3CDE6D393 for ; Sun, 1 May 2022 04:27:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651404476; x=1682940476; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8Ab0hXVeJPQFxGivZE668c+wGDeZdo9BvU5oRO/0WGA=; b=nywwvmZWA6tyTi5d5M0IV66sqjT/MUglShO3T+BScG3xwJmWsAfh9UNM vEeka1OlSqbfq1DdwD9rRfUSIEmYzxMAbNNuqON9G7Hb79Al5mV6HFeM/ EGOKogimeJ7Tfu2Jz2qwjqweBvXqAVGRqP+h1BqNgKtbPvAPtCJKh+vEs t0jduBysmfR99z+a7NZsHpqra+Yv+0e7qaeGnVsM6cHoqOKm5A1torPam bkiwFN73ejh+oqCXPPXL7FEVClFSFarIDR+626OuvrCuA4jJxd0+FSfzu 75pO4V0WgoMDzJVSDSmi07FFPSAIZlo/iwnkKqYJzfvnY7PBPv7CaTUfC Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10333"; a="246912730" X-IronPort-AV: E=Sophos;i="5.91,189,1647327600"; d="scan'208";a="246912730" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 May 2022 04:27:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,189,1647327600"; d="scan'208";a="545114906" Received: from allen-box.sh.intel.com ([10.239.159.48]) by orsmga002.jf.intel.com with ESMTP; 01 May 2022 04:27:54 -0700 From: Lu Baolu To: Joerg Roedel , Jason Gunthorpe , Alex Williamson , Kevin Tian Cc: Jacob jun Pan , Liu Yi L , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 4/5] iommu/vt-d: Remove domain_update_iommu_snooping() Date: Sun, 1 May 2022 19:24:33 +0800 Message-Id: <20220501112434.874236-5-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220501112434.874236-1-baolu.lu@linux.intel.com> References: <20220501112434.874236-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The IOMMU force snooping capability is not required to be consistent among all the IOMMUs anymore. Remove force snooping capability check in the IOMMU hot-add path and domain_update_iommu_snooping() becomes a dead code now. Signed-off-by: Lu Baolu Reviewed-by: Jason Gunthorpe --- drivers/iommu/intel/iommu.c | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 3c1c228f9031..d5808495eb64 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -533,33 +533,6 @@ static void domain_update_iommu_coherency(struct dmar_= domain *domain) rcu_read_unlock(); } =20 -static bool domain_update_iommu_snooping(struct intel_iommu *skip) -{ - struct dmar_drhd_unit *drhd; - struct intel_iommu *iommu; - bool ret =3D true; - - rcu_read_lock(); - for_each_active_iommu(iommu, drhd) { - if (iommu !=3D skip) { - /* - * If the hardware is operating in the scalable mode, - * the snooping control is always supported since we - * always set PASID-table-entry.PGSNP bit if the domain - * is managed outside (UNMANAGED). - */ - if (!sm_supported(iommu) && - !ecap_sc_support(iommu->ecap)) { - ret =3D false; - break; - } - } - } - rcu_read_unlock(); - - return ret; -} - static int domain_update_iommu_superpage(struct dmar_domain *domain, struct intel_iommu *skip) { @@ -3593,12 +3566,7 @@ static int intel_iommu_add(struct dmar_drhd_unit *dm= aru) iommu->name); return -ENXIO; } - if (!ecap_sc_support(iommu->ecap) && - domain_update_iommu_snooping(iommu)) { - pr_warn("%s: Doesn't support snooping.\n", - iommu->name); - return -ENXIO; - } + sp =3D domain_update_iommu_superpage(NULL, iommu) - 1; if (sp >=3D 0 && !(cap_super_page_val(iommu->cap) & (1 << sp))) { pr_warn("%s: Doesn't support large page.\n", --=20 2.25.1 From nobody Sun May 10 15:05:35 2026 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 C8D13C433EF for ; Sun, 1 May 2022 11:28:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346134AbiEALbi (ORCPT ); Sun, 1 May 2022 07:31:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346104AbiEALb2 (ORCPT ); Sun, 1 May 2022 07:31:28 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95C3D6D38F for ; Sun, 1 May 2022 04:27:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651404479; x=1682940479; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qUZYbemYGfqX6UdR8vYw2GY0BXDxcZJ9d/Mb3z7FWrs=; b=S8HKWubqDQbjTXMNVljA59OTwY/1h29/pRa/UKpG01lMH/+8yCSjJi/x AbDkMvfmGj1FQ9s9sc+gbp/R0bMFZZ09J8YVva6lKVtYeADHSYGQ5MYSs uQAsQ8x3bO+Eybo8s1zRZUGN9S+FRUVzXurxlUhHGZFQ2F+88ZL1gb+Ht TEU9HUg7454u7+JAVdZKARoYbon78lwm4h2zno06hpAaMPx7WDxoqfBtt r4FQJspyP2vM4PJDo6Bqrxc+ilfGKMQnMHv2h8iFy4wDspIswkXgrfphk NtqmRZlF9PhSBMRrGIDpiyLPljwj28f9RDo5J/xNbT6MmFyggpZuzaWyn A==; X-IronPort-AV: E=McAfee;i="6400,9594,10333"; a="246912737" X-IronPort-AV: E=Sophos;i="5.91,189,1647327600"; d="scan'208";a="246912737" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 May 2022 04:27:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,189,1647327600"; d="scan'208";a="545114953" Received: from allen-box.sh.intel.com ([10.239.159.48]) by orsmga002.jf.intel.com with ESMTP; 01 May 2022 04:27:56 -0700 From: Lu Baolu To: Joerg Roedel , Jason Gunthorpe , Alex Williamson , Kevin Tian Cc: Jacob jun Pan , Liu Yi L , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 5/5] iommu/vt-d: Remove hard coding PGSNP bit in PASID entries Date: Sun, 1 May 2022 19:24:34 +0800 Message-Id: <20220501112434.874236-6-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220501112434.874236-1-baolu.lu@linux.intel.com> References: <20220501112434.874236-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" As enforce_cache_coherency has been introduced into the iommu_domain_ops, the kernel component which owns the iommu domain is able to opt-in its requirement for force snooping support. The iommu driver has no need to hard code the page snoop control bit in the PASID table entries anymore. Signed-off-by: Lu Baolu --- drivers/iommu/intel/pasid.h | 1 - drivers/iommu/intel/iommu.c | 3 --- drivers/iommu/intel/pasid.c | 6 ------ 3 files changed, 10 deletions(-) diff --git a/drivers/iommu/intel/pasid.h b/drivers/iommu/intel/pasid.h index 583ea67fc783..394e6284ce1f 100644 --- a/drivers/iommu/intel/pasid.h +++ b/drivers/iommu/intel/pasid.h @@ -48,7 +48,6 @@ */ #define PASID_FLAG_SUPERVISOR_MODE BIT(0) #define PASID_FLAG_NESTED BIT(1) -#define PASID_FLAG_PAGE_SNOOP BIT(2) =20 /* * The PASID_FLAG_FL5LP flag Indicates using 5-level paging for first- diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index d5808495eb64..edd3d940eb25 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -2432,9 +2432,6 @@ static int domain_setup_first_level(struct intel_iomm= u *iommu, if (level =3D=3D 5) flags |=3D PASID_FLAG_FL5LP; =20 - if (domain->domain.type =3D=3D IOMMU_DOMAIN_UNMANAGED) - flags |=3D PASID_FLAG_PAGE_SNOOP; - return intel_pasid_setup_first_level(iommu, dev, (pgd_t *)pgd, pasid, domain->iommu_did[iommu->seq_id], flags); diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c index 815c744e6a34..dc5020320323 100644 --- a/drivers/iommu/intel/pasid.c +++ b/drivers/iommu/intel/pasid.c @@ -625,9 +625,6 @@ int intel_pasid_setup_first_level(struct intel_iommu *i= ommu, } } =20 - if (flags & PASID_FLAG_PAGE_SNOOP) - pasid_set_pgsnp(pte); - pasid_set_domain_id(pte, did); pasid_set_address_width(pte, iommu->agaw); pasid_set_page_snoop(pte, !!ecap_smpwc(iommu->ecap)); @@ -710,9 +707,6 @@ int intel_pasid_setup_second_level(struct intel_iommu *= iommu, pasid_set_fault_enable(pte); pasid_set_page_snoop(pte, !!ecap_smpwc(iommu->ecap)); =20 - if (domain->domain.type =3D=3D IOMMU_DOMAIN_UNMANAGED) - pasid_set_pgsnp(pte); - /* * Since it is a second level only translation setup, we should * set SRE bit as well (addresses are expected to be GPAs). --=20 2.25.1