Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'iommu-fixes-v5.5-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu

Pull iommu fixes from Joerg Roedel:
"Two fixes:

- Fix NULL-ptr dereference bug in Intel IOMMU driver

- Properly save and restore AMD IOMMU performance counter registers
when testing if they are writable"

* tag 'iommu-fixes-v5.5-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu:
iommu/amd: Fix IOMMU perf counter clobbering during init
iommu/vt-d: Call __dmar_remove_one_dev_info with valid pointer

+20 -7
+18 -6
drivers/iommu/amd_iommu_init.c
··· 1655 1655 static void init_iommu_perf_ctr(struct amd_iommu *iommu) 1656 1656 { 1657 1657 struct pci_dev *pdev = iommu->dev; 1658 - u64 val = 0xabcd, val2 = 0; 1658 + u64 val = 0xabcd, val2 = 0, save_reg = 0; 1659 1659 1660 1660 if (!iommu_feature(iommu, FEATURE_PC)) 1661 1661 return; 1662 1662 1663 1663 amd_iommu_pc_present = true; 1664 1664 1665 + /* save the value to restore, if writable */ 1666 + if (iommu_pc_get_set_reg(iommu, 0, 0, 0, &save_reg, false)) 1667 + goto pc_false; 1668 + 1665 1669 /* Check if the performance counters can be written to */ 1666 1670 if ((iommu_pc_get_set_reg(iommu, 0, 0, 0, &val, true)) || 1667 1671 (iommu_pc_get_set_reg(iommu, 0, 0, 0, &val2, false)) || 1668 - (val != val2)) { 1669 - pci_err(pdev, "Unable to write to IOMMU perf counter.\n"); 1670 - amd_iommu_pc_present = false; 1671 - return; 1672 - } 1672 + (val != val2)) 1673 + goto pc_false; 1674 + 1675 + /* restore */ 1676 + if (iommu_pc_get_set_reg(iommu, 0, 0, 0, &save_reg, true)) 1677 + goto pc_false; 1673 1678 1674 1679 pci_info(pdev, "IOMMU performance counters supported\n"); 1675 1680 1676 1681 val = readl(iommu->mmio_base + MMIO_CNTR_CONF_OFFSET); 1677 1682 iommu->max_banks = (u8) ((val >> 12) & 0x3f); 1678 1683 iommu->max_counters = (u8) ((val >> 7) & 0xf); 1684 + 1685 + return; 1686 + 1687 + pc_false: 1688 + pci_err(pdev, "Unable to read/write to IOMMU perf counter.\n"); 1689 + amd_iommu_pc_present = false; 1690 + return; 1679 1691 } 1680 1692 1681 1693 static ssize_t amd_iommu_show_cap(struct device *dev,
+2 -1
drivers/iommu/intel-iommu.c
··· 5163 5163 5164 5164 spin_lock_irqsave(&device_domain_lock, flags); 5165 5165 info = dev->archdata.iommu; 5166 - if (info) 5166 + if (info && info != DEFER_DEVICE_DOMAIN_INFO 5167 + && info != DUMMY_DEVICE_DOMAIN_INFO) 5167 5168 __dmar_remove_one_dev_info(info); 5168 5169 spin_unlock_irqrestore(&device_domain_lock, flags); 5169 5170 }