]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.13/iommu-arm-smmu-v3-cope-with-duplicated-stream-ids.patch
Fix up backported ptrace patch
[thirdparty/kernel/stable-queue.git] / releases / 4.14.13 / iommu-arm-smmu-v3-cope-with-duplicated-stream-ids.patch
1 From 563b5cbe334e9503ab2b234e279d500fc4f76018 Mon Sep 17 00:00:00 2001
2 From: Robin Murphy <robin.murphy@arm.com>
3 Date: Tue, 2 Jan 2018 12:33:14 +0000
4 Subject: iommu/arm-smmu-v3: Cope with duplicated Stream IDs
5
6 From: Robin Murphy <robin.murphy@arm.com>
7
8 commit 563b5cbe334e9503ab2b234e279d500fc4f76018 upstream.
9
10 For PCI devices behind an aliasing PCIe-to-PCI/X bridge, the bridge
11 alias to DevFn 0.0 on the subordinate bus may match the original RID of
12 the device, resulting in the same SID being present in the device's
13 fwspec twice. This causes trouble later in arm_smmu_write_strtab_ent()
14 when we wind up visiting the STE a second time and find it already live.
15
16 Avoid the issue by giving arm_smmu_install_ste_for_dev() the cleverness
17 to skip over duplicates. It seems mildly counterintuitive compared to
18 preventing the duplicates from existing in the first place, but since
19 the DT and ACPI probe paths build their fwspecs differently, this is
20 actually the cleanest and most self-contained way to deal with it.
21
22 Fixes: 8f78515425da ("iommu/arm-smmu: Implement of_xlate() for SMMUv3")
23 Reported-by: Tomasz Nowicki <tomasz.nowicki@caviumnetworks.com>
24 Tested-by: Tomasz Nowicki <Tomasz.Nowicki@cavium.com>
25 Tested-by: Jayachandran C. <jnair@caviumnetworks.com>
26 Signed-off-by: Robin Murphy <robin.murphy@arm.com>
27 Signed-off-by: Will Deacon <will.deacon@arm.com>
28 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
29
30 ---
31 drivers/iommu/arm-smmu-v3.c | 9 ++++++++-
32 1 file changed, 8 insertions(+), 1 deletion(-)
33
34 --- a/drivers/iommu/arm-smmu-v3.c
35 +++ b/drivers/iommu/arm-smmu-v3.c
36 @@ -1646,7 +1646,7 @@ static __le64 *arm_smmu_get_step_for_sid
37
38 static void arm_smmu_install_ste_for_dev(struct iommu_fwspec *fwspec)
39 {
40 - int i;
41 + int i, j;
42 struct arm_smmu_master_data *master = fwspec->iommu_priv;
43 struct arm_smmu_device *smmu = master->smmu;
44
45 @@ -1654,6 +1654,13 @@ static void arm_smmu_install_ste_for_dev
46 u32 sid = fwspec->ids[i];
47 __le64 *step = arm_smmu_get_step_for_sid(smmu, sid);
48
49 + /* Bridged PCI devices may end up with duplicated IDs */
50 + for (j = 0; j < i; j++)
51 + if (fwspec->ids[j] == sid)
52 + break;
53 + if (j < i)
54 + continue;
55 +
56 arm_smmu_write_strtab_ent(smmu, sid, step, &master->ste);
57 }
58 }