Commit c7c4e130 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'iommu-fixes-v6.9-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu

Pull iommu fixes from Joerg Roedel:

 - Intel VT-d Fixes:
     - Allocate local memory for PRQ page
     - Fix WARN_ON in iommu probe path
     - Fix wrong use of pasid config

 - AMD IOMMU Fixes:
     - Lock inversion fix
     - Log message severity fix
     - Disable SNP when v2 page-tables are used

 - Mediatek driver:
     - Fix module autoloading

* tag 'iommu-fixes-v6.9-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu:
  iommu/amd: Change log message severity
  iommu/vt-d: Fix WARN_ON in iommu probe path
  iommu/vt-d: Allocate local memory for page request queue
  iommu/vt-d: Fix wrong use of pasid config
  iommu: mtk: fix module autoloading
  iommu/amd: Do not enable SNP when V2 page table is enabled
  iommu/amd: Fix possible irq lock inversion dependency issue
parents b3812ff0 b8246a2a
Loading
Loading
Loading
Loading
+13 −12
Original line number Diff line number Diff line
@@ -3232,28 +3232,29 @@ static void iommu_snp_enable(void)
		return;
	/*
	 * The SNP support requires that IOMMU must be enabled, and is
	 * not configured in the passthrough mode.
	 * configured with V1 page table (DTE[Mode] = 0 is not supported).
	 */
	if (no_iommu || iommu_default_passthrough()) {
		pr_err("SNP: IOMMU disabled or configured in passthrough mode, SNP cannot be supported.\n");
		cc_platform_clear(CC_ATTR_HOST_SEV_SNP);
		return;
		pr_warn("SNP: IOMMU disabled or configured in passthrough mode, SNP cannot be supported.\n");
		goto disable_snp;
	}

	if (amd_iommu_pgtable != AMD_IOMMU_V1) {
		pr_warn("SNP: IOMMU is configured with V2 page table mode, SNP cannot be supported.\n");
		goto disable_snp;
	}

	amd_iommu_snp_en = check_feature(FEATURE_SNP);
	if (!amd_iommu_snp_en) {
		pr_err("SNP: IOMMU SNP feature not enabled, SNP cannot be supported.\n");
		cc_platform_clear(CC_ATTR_HOST_SEV_SNP);
		return;
		pr_warn("SNP: IOMMU SNP feature not enabled, SNP cannot be supported.\n");
		goto disable_snp;
	}

	pr_info("IOMMU SNP support enabled.\n");
	return;

	/* Enforce IOMMU v1 pagetable when SNP is enabled. */
	if (amd_iommu_pgtable != AMD_IOMMU_V1) {
		pr_warn("Forcing use of AMD IOMMU v1 page table due to SNP.\n");
		amd_iommu_pgtable = AMD_IOMMU_V1;
	}
disable_snp:
	cc_platform_clear(CC_ATTR_HOST_SEV_SNP);
#endif
}

+7 −4
Original line number Diff line number Diff line
@@ -1692,26 +1692,29 @@ int amd_iommu_complete_ppr(struct pci_dev *pdev, u32 pasid,

static u16 domain_id_alloc(void)
{
	unsigned long flags;
	int id;

	spin_lock(&pd_bitmap_lock);
	spin_lock_irqsave(&pd_bitmap_lock, flags);
	id = find_first_zero_bit(amd_iommu_pd_alloc_bitmap, MAX_DOMAIN_ID);
	BUG_ON(id == 0);
	if (id > 0 && id < MAX_DOMAIN_ID)
		__set_bit(id, amd_iommu_pd_alloc_bitmap);
	else
		id = 0;
	spin_unlock(&pd_bitmap_lock);
	spin_unlock_irqrestore(&pd_bitmap_lock, flags);

	return id;
}

static void domain_id_free(int id)
{
	spin_lock(&pd_bitmap_lock);
	unsigned long flags;

	spin_lock_irqsave(&pd_bitmap_lock, flags);
	if (id > 0 && id < MAX_DOMAIN_ID)
		__clear_bit(id, amd_iommu_pd_alloc_bitmap);
	spin_unlock(&pd_bitmap_lock);
	spin_unlock_irqrestore(&pd_bitmap_lock, flags);
}

static void free_gcr3_tbl_level1(u64 *tbl)
+7 −4
Original line number Diff line number Diff line
@@ -4299,9 +4299,11 @@ static struct iommu_device *intel_iommu_probe_device(struct device *dev)
	}

	dev_iommu_priv_set(dev, info);
	if (pdev && pci_ats_supported(pdev)) {
		ret = device_rbtree_insert(iommu, info);
		if (ret)
			goto free;
	}

	if (sm_supported(iommu) && !dev_is_real_dma_subdevice(dev)) {
		ret = intel_pasid_alloc_table(dev);
@@ -4336,6 +4338,7 @@ static void intel_iommu_release_device(struct device *dev)
	struct intel_iommu *iommu = info->iommu;

	mutex_lock(&iommu->iopf_lock);
	if (dev_is_pci(dev) && pci_ats_supported(to_pci_dev(dev)))
		device_rbtree_remove(info);
	mutex_unlock(&iommu->iopf_lock);

+1 −1
Original line number Diff line number Diff line
@@ -438,7 +438,7 @@ static int iommu_pmu_assign_event(struct iommu_pmu *iommu_pmu,
	iommu_pmu_set_filter(domain, event->attr.config1,
			     IOMMU_PMU_FILTER_DOMAIN, idx,
			     event->attr.config1);
	iommu_pmu_set_filter(pasid, event->attr.config1,
	iommu_pmu_set_filter(pasid, event->attr.config2,
			     IOMMU_PMU_FILTER_PASID, idx,
			     event->attr.config1);
	iommu_pmu_set_filter(ats, event->attr.config2,
+1 −1
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ int intel_svm_enable_prq(struct intel_iommu *iommu)
	struct page *pages;
	int irq, ret;

	pages = alloc_pages(GFP_KERNEL | __GFP_ZERO, PRQ_ORDER);
	pages = alloc_pages_node(iommu->node, GFP_KERNEL | __GFP_ZERO, PRQ_ORDER);
	if (!pages) {
		pr_warn("IOMMU: %s: Failed to allocate page request queue\n",
			iommu->name);
Loading