Skip to content

Commit b3a4bca

Browse files
committed
Merge tag 'iommu-updates-v3.14' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu
Pull IOMMU Updates from Joerg Roedel: "A few patches have been queued up for this merge window: - improvements for the ARM-SMMU driver (IOMMU_EXEC support, IOMMU group support) - updates and fixes for the shmobile IOMMU driver - various fixes to generic IOMMU code and the Intel IOMMU driver - some cleanups in IOMMU drivers (dev_is_pci() usage)" * tag 'iommu-updates-v3.14' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu: (36 commits) iommu/vt-d: Fix signedness bug in alloc_irte() iommu/vt-d: free all resources if failed to initialize DMARs iommu/vt-d, trivial: clean sparse warnings iommu/vt-d: fix wrong return value of dmar_table_init() iommu/vt-d: release invalidation queue when destroying IOMMU unit iommu/vt-d: fix access after free issue in function free_dmar_iommu() iommu/vt-d: keep shared resources when failed to initialize iommu devices iommu/vt-d: fix invalid memory access when freeing DMAR irq iommu/vt-d, trivial: simplify code with existing macros iommu/vt-d, trivial: use defined macro instead of hardcoding iommu/vt-d: mark internal functions as static iommu/vt-d, trivial: clean up unused code iommu/vt-d, trivial: check suitable flag in function detect_intel_iommu() iommu/vt-d, trivial: print correct domain id of static identity domain iommu/vt-d, trivial: refine support of 64bit guest address iommu/vt-d: fix resource leakage on error recovery path in iommu_init_domains() iommu/vt-d: fix a race window in allocating domain ID for virtual machines iommu/vt-d: fix PCI device reference leakage on error recovery path drm/msm: Fix link error with !MSM_IOMMU iommu/vt-d: use dedicated bitmap to track remapping entry allocation status ...
2 parents 17c7f85 + dd1a175 commit b3a4bca

17 files changed

Lines changed: 279 additions & 280 deletions

‎drivers/gpu/drm/msm/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ config DRM_MSM
44
depends on DRM
55
depends on ARCH_MSM
66
depends on ARCH_MSM8960
7+
depends on MSM_IOMMU
78
select DRM_KMS_HELPER
89
select SHMEM
910
select TMPFS

‎drivers/iommu/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ config SHMOBILE_IOMMU
207207
bool "IOMMU for Renesas IPMMU/IPMMUI"
208208
default n
209209
depends on ARM
210+
depends on SH_MOBILE || COMPILE_TEST
210211
select IOMMU_API
211212
select ARM_DMA_USE_IOMMU
212213
select SHMOBILE_IPMMU

‎drivers/iommu/amd_iommu.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ static bool check_device(struct device *dev)
248248
if (!dev || !dev->dma_mask)
249249
return false;
250250

251-
/* No device or no PCI device */
252-
if (dev->bus != &pci_bus_type)
251+
/* No PCI device */
252+
if (!dev_is_pci(dev))
253253
return false;
254254

255255
devid = get_device_id(dev);

‎drivers/iommu/arm-smmu.c‎

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* - v7/v8 long-descriptor format
2525
* - Non-secure access to the SMMU
2626
* - 4k and 64k pages, with contiguous pte hints.
27-
* - Up to 39-bit addressing
27+
* - Up to 42-bit addressing (dependent on VA_BITS)
2828
* - Context fault reporting
2929
*/
3030

@@ -61,12 +61,13 @@
6161
#define ARM_SMMU_GR1(smmu) ((smmu)->base + (smmu)->pagesize)
6262

6363
/* Page table bits */
64-
#define ARM_SMMU_PTE_PAGE (((pteval_t)3) << 0)
64+
#define ARM_SMMU_PTE_XN (((pteval_t)3) << 53)
6565
#define ARM_SMMU_PTE_CONT (((pteval_t)1) << 52)
6666
#define ARM_SMMU_PTE_AF (((pteval_t)1) << 10)
6767
#define ARM_SMMU_PTE_SH_NS (((pteval_t)0) << 8)
6868
#define ARM_SMMU_PTE_SH_OS (((pteval_t)2) << 8)
6969
#define ARM_SMMU_PTE_SH_IS (((pteval_t)3) << 8)
70+
#define ARM_SMMU_PTE_PAGE (((pteval_t)3) << 0)
7071

7172
#if PAGE_SIZE == SZ_4K
7273
#define ARM_SMMU_PTE_CONT_ENTRIES 16
@@ -1205,7 +1206,7 @@ static int arm_smmu_alloc_init_pte(struct arm_smmu_device *smmu, pmd_t *pmd,
12051206
unsigned long pfn, int flags, int stage)
12061207
{
12071208
pte_t *pte, *start;
1208-
pteval_t pteval = ARM_SMMU_PTE_PAGE | ARM_SMMU_PTE_AF;
1209+
pteval_t pteval = ARM_SMMU_PTE_PAGE | ARM_SMMU_PTE_AF | ARM_SMMU_PTE_XN;
12091210

12101211
if (pmd_none(*pmd)) {
12111212
/* Allocate a new set of tables */
@@ -1244,7 +1245,9 @@ static int arm_smmu_alloc_init_pte(struct arm_smmu_device *smmu, pmd_t *pmd,
12441245
}
12451246

12461247
/* If no access, create a faulting entry to avoid TLB fills */
1247-
if (!(flags & (IOMMU_READ | IOMMU_WRITE)))
1248+
if (flags & IOMMU_EXEC)
1249+
pteval &= ~ARM_SMMU_PTE_XN;
1250+
else if (!(flags & (IOMMU_READ | IOMMU_WRITE)))
12481251
pteval &= ~ARM_SMMU_PTE_PAGE;
12491252

12501253
pteval |= ARM_SMMU_PTE_SH_IS;
@@ -1494,6 +1497,13 @@ static int arm_smmu_add_device(struct device *dev)
14941497
{
14951498
struct arm_smmu_device *child, *parent, *smmu;
14961499
struct arm_smmu_master *master = NULL;
1500+
struct iommu_group *group;
1501+
int ret;
1502+
1503+
if (dev->archdata.iommu) {
1504+
dev_warn(dev, "IOMMU driver already assigned to device\n");
1505+
return -EINVAL;
1506+
}
14971507

14981508
spin_lock(&arm_smmu_devices_lock);
14991509
list_for_each_entry(parent, &arm_smmu_devices, list) {
@@ -1526,13 +1536,23 @@ static int arm_smmu_add_device(struct device *dev)
15261536
if (!master)
15271537
return -ENODEV;
15281538

1539+
group = iommu_group_alloc();
1540+
if (IS_ERR(group)) {
1541+
dev_err(dev, "Failed to allocate IOMMU group\n");
1542+
return PTR_ERR(group);
1543+
}
1544+
1545+
ret = iommu_group_add_device(group, dev);
1546+
iommu_group_put(group);
15291547
dev->archdata.iommu = smmu;
1530-
return 0;
1548+
1549+
return ret;
15311550
}
15321551

15331552
static void arm_smmu_remove_device(struct device *dev)
15341553
{
15351554
dev->archdata.iommu = NULL;
1555+
iommu_group_remove_device(dev);
15361556
}
15371557

15381558
static struct iommu_ops arm_smmu_ops = {
@@ -1730,7 +1750,6 @@ static int arm_smmu_device_cfg_probe(struct arm_smmu_device *smmu)
17301750
* allocation (PTRS_PER_PGD).
17311751
*/
17321752
#ifdef CONFIG_64BIT
1733-
/* Current maximum output size of 39 bits */
17341753
smmu->s1_output_size = min(39UL, size);
17351754
#else
17361755
smmu->s1_output_size = min(32UL, size);
@@ -1745,7 +1764,7 @@ static int arm_smmu_device_cfg_probe(struct arm_smmu_device *smmu)
17451764
} else {
17461765
#ifdef CONFIG_64BIT
17471766
size = (id >> ID2_UBS_SHIFT) & ID2_UBS_MASK;
1748-
size = min(39, arm_smmu_id_size_to_bits(size));
1767+
size = min(VA_BITS, arm_smmu_id_size_to_bits(size));
17491768
#else
17501769
size = 32;
17511770
#endif

0 commit comments

Comments
 (0)