]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.7.4/intel-iommu-prevent-devices-with-rmrrs-from-being-placed.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.7.4 / intel-iommu-prevent-devices-with-rmrrs-from-being-placed.patch
1 From ea2447f700cab264019b52e2b417d689e052dcfd Mon Sep 17 00:00:00 2001
2 From: Tom Mingarelli <thomas.mingarelli@hp.com>
3 Date: Tue, 20 Nov 2012 19:43:17 +0000
4 Subject: intel-iommu: Prevent devices with RMRRs from being placed
5 into SI Domain
6
7 From: Tom Mingarelli <thomas.mingarelli@hp.com>
8
9 commit ea2447f700cab264019b52e2b417d689e052dcfd upstream.
10
11 This patch is to prevent non-USB devices that have RMRRs associated with them from
12 being placed into the SI Domain during init. This fixes the issue where the RMRR info
13 for devices being placed in and out of the SI Domain gets lost.
14
15 Signed-off-by: Thomas Mingarelli <thomas.mingarelli@hp.com>
16 Tested-by: Shuah Khan <shuah.khan@hp.com>
17 Reviewed-by: Donald Dutile <ddutile@redhat.com>
18 Reviewed-by: Alex Williamson <alex.williamson@redhat.com>
19 Signed-off-by: Joerg Roedel <joro@8bytes.org>
20 Cc: CAI Qian <caiqian@redhat.com>
21 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22
23 ---
24 drivers/iommu/intel-iommu.c | 31 +++++++++++++++++++++++++++++++
25 1 file changed, 31 insertions(+)
26
27 --- a/drivers/iommu/intel-iommu.c
28 +++ b/drivers/iommu/intel-iommu.c
29 @@ -2327,8 +2327,39 @@ static int domain_add_dev_info(struct dm
30 return 0;
31 }
32
33 +static bool device_has_rmrr(struct pci_dev *dev)
34 +{
35 + struct dmar_rmrr_unit *rmrr;
36 + int i;
37 +
38 + for_each_rmrr_units(rmrr) {
39 + for (i = 0; i < rmrr->devices_cnt; i++) {
40 + /*
41 + * Return TRUE if this RMRR contains the device that
42 + * is passed in.
43 + */
44 + if (rmrr->devices[i] == dev)
45 + return true;
46 + }
47 + }
48 + return false;
49 +}
50 +
51 static int iommu_should_identity_map(struct pci_dev *pdev, int startup)
52 {
53 +
54 + /*
55 + * We want to prevent any device associated with an RMRR from
56 + * getting placed into the SI Domain. This is done because
57 + * problems exist when devices are moved in and out of domains
58 + * and their respective RMRR info is lost. We exempt USB devices
59 + * from this process due to their usage of RMRRs that are known
60 + * to not be needed after BIOS hand-off to OS.
61 + */
62 + if (device_has_rmrr(pdev) &&
63 + (pdev->class >> 8) != PCI_CLASS_SERIAL_USB)
64 + return 0;
65 +
66 if ((iommu_identity_mapping & IDENTMAP_AZALIA) && IS_AZALIA(pdev))
67 return 1;
68