Kernel: Workaround broken bios affecting iommu

Problem:
Broken bios creates inaccurate DMAR tables,
reporting some bridges as having endpoint types.
This causes IOMMU initialization to bail
out early with an error code, the result of
which is vfio not working correctly.
This is seen on some Skylake based Wolfpass
server platforms with up-to-date bios installed.

Solution:
Instead of just bailing out of IOMMU
initialization when such a condition is found,
we report it and continue.  The IOMMU ends
up successfully initialized anyway.  We do this
only on platforms that have the Skylake bridges
where this issue has been seen.

This change is inspired by a similar one posted by
Lu Baolu of Intel Corp to lkml

https://lkml.org/lkml/2019/12/24/15

Change-Id: Ief2df7099b6118eab7f99d5531616926a7a3eb27
Closes-Bug: 1847335
Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
This commit is contained in:
Jim Somerville 2020-03-20 10:36:14 -04:00
parent 1435fe178a
commit a745a5b6f8
8 changed files with 207 additions and 43 deletions

View File

@ -1,4 +1,4 @@
COPY_LIST="files/*"
TIS_PATCH_VER=4
TIS_PATCH_VER=5
BUILD_IS_BIG=11
BUILD_IS_SLOW=12

View File

@ -1,7 +1,7 @@
From fd3288457759c51746ad1c6cf26c883be36da86e Mon Sep 17 00:00:00 2001
Message-Id: <fd3288457759c51746ad1c6cf26c883be36da86e.1584131446.git.Jim.Somerville@windriver.com>
In-Reply-To: <212f8edf21d8053d99c37d2ebfe3d723fb166bf7.1584131446.git.Jim.Somerville@windriver.com>
References: <212f8edf21d8053d99c37d2ebfe3d723fb166bf7.1584131446.git.Jim.Somerville@windriver.com>
From 611efdc47a31f229612fd324925c76f6fb204d9c Mon Sep 17 00:00:00 2001
Message-Id: <611efdc47a31f229612fd324925c76f6fb204d9c.1584650624.git.Jim.Somerville@windriver.com>
In-Reply-To: <0a8e423b2d06a4604c51a1e5bfcc305203d49a62.1584650624.git.Jim.Somerville@windriver.com>
References: <0a8e423b2d06a4604c51a1e5bfcc305203d49a62.1584650624.git.Jim.Somerville@windriver.com>
From: Jim Somerville <Jim.Somerville@windriver.com>
Date: Fri, 13 Mar 2020 16:15:29 -0400
Subject: [PATCH 2/2] Compile issues
@ -12,25 +12,25 @@ Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
1 file changed, 8 insertions(+)
diff --git a/SPECS/kernel-rt.spec b/SPECS/kernel-rt.spec
index 5660f0b..c37c238 100644
index c549d7e..f8fe5be 100644
--- a/SPECS/kernel-rt.spec
+++ b/SPECS/kernel-rt.spec
@@ -424,6 +424,11 @@ Patch1031: epoll-fix-use-after-free-in-eventpoll_release_file.patch
Patch1032: ipvs-fix-memory-leak-in-ip_vs_ctl.c.patch
Patch1033: rh-ext4-release-leaked-posix-acl-in-ext4_acl_chmod.patch
@@ -426,6 +426,11 @@ Patch1033: rh-ext4-release-leaked-posix-acl-in-ext4_acl_chmod.patch
Patch1034: rh-ext4-release-leaked-posix-acl-in-ext4_xattr_set_a.patch
+Patch1035: fix-compilation-issues.patch
# Workaround for broken bios causing IOMMU issues
Patch1035: Allow-dmar-quirks-for-broken-bioses.patch
+Patch1100: fix-compilation-issues.patch
+# Fix CentOS 7.6 upgrade compile error
+Patch1036: fix-CentOS-7.6-upgrade-compile-error.patch
+Patch1101: fix-CentOS-7.6-upgrade-compile-error.patch
+# Compile fix for disabling CONFIG_MEMCG_KMEM
+Patch1037: compile-fix-for-disabling-CONFIG_MEMCG_KMEM.patch
+Patch1102: compile-fix-for-disabling-CONFIG_MEMCG_KMEM.patch
BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root
@@ -796,6 +801,9 @@ ApplyPatch epoll-fix-use-after-free-in-eventpoll_release_file.patch
ApplyPatch ipvs-fix-memory-leak-in-ip_vs_ctl.c.patch
@@ -799,6 +804,9 @@ ApplyPatch ipvs-fix-memory-leak-in-ip_vs_ctl.c.patch
ApplyPatch rh-ext4-release-leaked-posix-acl-in-ext4_acl_chmod.patch
ApplyPatch rh-ext4-release-leaked-posix-acl-in-ext4_xattr_set_a.patch
ApplyPatch Allow-dmar-quirks-for-broken-bioses.patch
+ApplyPatch fix-compilation-issues.patch
+ApplyPatch fix-CentOS-7.6-upgrade-compile-error.patch
+ApplyPatch compile-fix-for-disabling-CONFIG_MEMCG_KMEM.patch

View File

@ -1,19 +1,19 @@
From 212f8edf21d8053d99c37d2ebfe3d723fb166bf7 Mon Sep 17 00:00:00 2001
Message-Id: <212f8edf21d8053d99c37d2ebfe3d723fb166bf7.1584131446.git.Jim.Somerville@windriver.com>
From 0a8e423b2d06a4604c51a1e5bfcc305203d49a62 Mon Sep 17 00:00:00 2001
Message-Id: <0a8e423b2d06a4604c51a1e5bfcc305203d49a62.1584650624.git.Jim.Somerville@windriver.com>
From: Jim Somerville <Jim.Somerville@windriver.com>
Date: Fri, 13 Mar 2020 16:15:29 -0400
Subject: [PATCH 1/2] Kernel source patches for TiC
Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
---
SPECS/kernel-rt.spec | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 69 insertions(+)
SPECS/kernel-rt.spec | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 72 insertions(+)
diff --git a/SPECS/kernel-rt.spec b/SPECS/kernel-rt.spec
index c48b73e..5660f0b 100644
index c48b73e..c549d7e 100644
--- a/SPECS/kernel-rt.spec
+++ b/SPECS/kernel-rt.spec
@@ -388,6 +388,42 @@ Source30002: kernel-3.10.0-x86_64-rt-trace.config.tis_extra
@@ -388,6 +388,44 @@ Source30002: kernel-3.10.0-x86_64-rt-trace.config.tis_extra
# Empty final patch file to facilitate testing of kernel patches
Patch999999: linux-kernel-test.patch
@ -53,10 +53,12 @@ index c48b73e..5660f0b 100644
+Patch1032: ipvs-fix-memory-leak-in-ip_vs_ctl.c.patch
+Patch1033: rh-ext4-release-leaked-posix-acl-in-ext4_acl_chmod.patch
+Patch1034: rh-ext4-release-leaked-posix-acl-in-ext4_xattr_set_a.patch
+# Workaround for broken bios causing IOMMU issues
+Patch1035: Allow-dmar-quirks-for-broken-bioses.patch
BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root
@@ -727,6 +763,39 @@ cp %{SOURCE38} .
@@ -727,6 +765,40 @@ cp %{SOURCE38} .
## Apply Patches here
ApplyPatch linux-kernel-test.patch
@ -93,6 +95,7 @@ index c48b73e..5660f0b 100644
+ApplyPatch ipvs-fix-memory-leak-in-ip_vs_ctl.c.patch
+ApplyPatch rh-ext4-release-leaked-posix-acl-in-ext4_acl_chmod.patch
+ApplyPatch rh-ext4-release-leaked-posix-acl-in-ext4_xattr_set_a.patch
+ApplyPatch Allow-dmar-quirks-for-broken-bioses.patch
# move off upstream version mechanism
if [ -e localversion-rt ]; then

View File

@ -0,0 +1,79 @@
From 340fbe20b7ede7b9a6dca8c3d03cead97257a99d Mon Sep 17 00:00:00 2001
Message-Id: <340fbe20b7ede7b9a6dca8c3d03cead97257a99d.1584649859.git.Jim.Somerville@windriver.com>
From: Jim Somerville <Jim.Somerville@windriver.com>
Date: Wed, 29 Jan 2020 14:19:22 -0500
Subject: [PATCH 1/1] Allow dmar quirks for broken bioses
Problem:
Broken bios creates inaccurate DMAR tables,
reporting some bridges as having endpoint types.
This causes IOMMU initialization to bail
out early with an error code, the result of
which is vfio not working correctly.
This is seen on some Skylake based Wolfpass
server platforms with up-to-date bios installed.
Solution:
Instead of just bailing out of IOMMU
initialization when such a condition is found,
we report it and continue. The IOMMU ends
up successfully initialized anyway. We do this
only on platforms that have the Skylake bridges
where this issue has been seen.
This change is inspired by a similar one posted by
Lu Baolu of Intel Corp to lkml
https://lkml.org/lkml/2019/12/24/15
Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
---
drivers/iommu/dmar.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
index 4658dc3..eeaef2e 100644
--- a/drivers/iommu/dmar.c
+++ b/drivers/iommu/dmar.c
@@ -75,6 +75,26 @@ static unsigned long dmar_seq_ids[BITS_TO_LONGS(DMAR_UNITS_SUPPORTED)];
static int alloc_iommu(struct dmar_drhd_unit *drhd);
static void free_iommu(struct intel_iommu *iommu);
+static int scope_mismatch_quirk;
+static void quirk_dmar_scope_mismatch(struct pci_dev *dev)
+{
+ pci_info(dev, "scope mismatch ignored\n");
+ scope_mismatch_quirk = 1;
+}
+
+/*
+ * We expect devices with endpoint scope to have normal PCI
+ * headers, and devices with bridge scope to have bridge PCI
+ * headers. However some PCI devices may be listed in the
+ * DMAR table with bridge scope, even though they have a
+ * normal PCI header and vice versa. We don't declare a
+ * scope mismatch for the special cases below, even though
+ * the bios creates broken tables.
+ */
+/* Sky Lake-E PCI Express Root Port A */
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2030,
+ quirk_dmar_scope_mismatch);
+
static void dmar_register_drhd_unit(struct dmar_drhd_unit *drhd)
{
/*
@@ -257,7 +277,10 @@ int dmar_insert_dev_scope(struct dmar_pci_notify_info *info,
info->dev->class >> 8 != PCI_CLASS_BRIDGE_OTHER))) {
pr_warn("Device scope type does not match for %s\n",
pci_name(info->dev));
- return -EINVAL;
+ if (!scope_mismatch_quirk)
+ return -EINVAL;
+ else
+ pr_warn("but continuing anyway\n");
}
for_each_dev_scope(devices, devices_cnt, i, tmp)
--
1.8.3.1

View File

@ -1,4 +1,4 @@
COPY_LIST="files/*"
TIS_PATCH_VER=3
TIS_PATCH_VER=4
BUILD_IS_BIG=11
BUILD_IS_SLOW=12

View File

@ -1,7 +1,7 @@
From 6c41acf7c1a4f5f3437e474505193bb353d241e6 Mon Sep 17 00:00:00 2001
Message-Id: <6c41acf7c1a4f5f3437e474505193bb353d241e6.1584125537.git.Jim.Somerville@windriver.com>
In-Reply-To: <47c970e28e2adfd6483fa8d861eeb338492297bf.1584125537.git.Jim.Somerville@windriver.com>
References: <47c970e28e2adfd6483fa8d861eeb338492297bf.1584125537.git.Jim.Somerville@windriver.com>
From 3073ab68b8a27cdaf31213778d029669f50e2632 Mon Sep 17 00:00:00 2001
Message-Id: <3073ab68b8a27cdaf31213778d029669f50e2632.1584644494.git.Jim.Somerville@windriver.com>
In-Reply-To: <55a6b125fab32183cbabee1e436197242f926c0c.1584644493.git.Jim.Somerville@windriver.com>
References: <55a6b125fab32183cbabee1e436197242f926c0c.1584644493.git.Jim.Somerville@windriver.com>
From: "zhao.shuai" <zhaos@neusoft.com>
Date: Tue, 6 Aug 2019 16:18:04 +0800
Subject: [PATCH 2/2] Compile issues
@ -13,26 +13,26 @@ Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
1 file changed, 9 insertions(+)
diff --git a/SPECS/kernel.spec b/SPECS/kernel.spec
index 012ddbd..6595a38 100644
index 5f23982..640f872 100644
--- a/SPECS/kernel.spec
+++ b/SPECS/kernel.spec
@@ -496,6 +496,12 @@ Patch40027: epoll-fix-use-after-free-in-eventpoll_release_file.patch
Patch40028: ipvs-fix-memory-leak-in-ip_vs_ctl.c.patch
Patch40029: rh-ext4-release-leaked-posix-acl-in-ext4_acl_chmod.patch
@@ -498,6 +498,12 @@ Patch40029: rh-ext4-release-leaked-posix-acl-in-ext4_acl_chmod.patch
Patch40030: rh-ext4-release-leaked-posix-acl-in-ext4_xattr_set_a.patch
# Workaround for broken bios causing IOMMU issues
Patch40031: Allow-dmar-quirks-for-broken-bioses.patch
+# Fix assorted compilation issues
+Patch40031: fix-compilation-issues.patch
+Patch40100: fix-compilation-issues.patch
+# Fix CentOS 7.6 upgrade compile error
+Patch40032: fix-CentOS-7.6-upgrade-compile-error.patch
+Patch40101: fix-CentOS-7.6-upgrade-compile-error.patch
+# Compile fix for disabling CONFIG_MEMCG_KMEM
+Patch40033: compile-fix-for-disabling-CONFIG_MEMCG_KMEM.patch
+Patch40102: compile-fix-for-disabling-CONFIG_MEMCG_KMEM.patch
BuildRoot: %{_tmppath}/kernel-%{KVRA}-root
@@ -879,6 +885,9 @@ ApplyOptionalPatch epoll-fix-use-after-free-in-eventpoll_release_file.patch
ApplyOptionalPatch ipvs-fix-memory-leak-in-ip_vs_ctl.c.patch
@@ -882,6 +888,9 @@ ApplyOptionalPatch ipvs-fix-memory-leak-in-ip_vs_ctl.c.patch
ApplyOptionalPatch rh-ext4-release-leaked-posix-acl-in-ext4_acl_chmod.patch
ApplyOptionalPatch rh-ext4-release-leaked-posix-acl-in-ext4_xattr_set_a.patch
ApplyOptionalPatch Allow-dmar-quirks-for-broken-bioses.patch
+ApplyOptionalPatch fix-compilation-issues.patch
+ApplyOptionalPatch fix-CentOS-7.6-upgrade-compile-error.patch
+ApplyOptionalPatch compile-fix-for-disabling-CONFIG_MEMCG_KMEM.patch

View File

@ -1,21 +1,21 @@
From 47c970e28e2adfd6483fa8d861eeb338492297bf Mon Sep 17 00:00:00 2001
Message-Id: <47c970e28e2adfd6483fa8d861eeb338492297bf.1584125537.git.Jim.Somerville@windriver.com>
From 55a6b125fab32183cbabee1e436197242f926c0c Mon Sep 17 00:00:00 2001
Message-Id: <55a6b125fab32183cbabee1e436197242f926c0c.1584644493.git.Jim.Somerville@windriver.com>
From: "zhao.shuai" <zhaos@neusoft.com>
Date: Mon, 5 Aug 2019 17:55:01 +0800
Subject: [PATCH 1/2] Kernel-source-patches-for-TiC
Subject: [PATCH 1/2] Kernel source patches for TiC
Signed-off-by: zhao.shuai <zhaos@neusoft.com>
Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
Signed-off-by: Robin Lu <bin1.lu@intel.com>
---
SPECS/kernel.spec | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 64 insertions(+)
SPECS/kernel.spec | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)
diff --git a/SPECS/kernel.spec b/SPECS/kernel.spec
index 0b2ff2e..012ddbd 100644
index 0b2ff2e..5f23982 100644
--- a/SPECS/kernel.spec
+++ b/SPECS/kernel.spec
@@ -463,6 +463,40 @@ Patch1002: debrand-rh-i686-cpu.patch
@@ -463,6 +463,42 @@ Patch1002: debrand-rh-i686-cpu.patch
Source30000: kernel-3.10.0-x86_64.config.tis_extra
Source30001: ima_signing_key.pub
@ -52,11 +52,13 @@ index 0b2ff2e..012ddbd 100644
+Patch40028: ipvs-fix-memory-leak-in-ip_vs_ctl.c.patch
+Patch40029: rh-ext4-release-leaked-posix-acl-in-ext4_acl_chmod.patch
+Patch40030: rh-ext4-release-leaked-posix-acl-in-ext4_xattr_set_a.patch
+# Workaround for broken bios causing IOMMU issues
+Patch40031: Allow-dmar-quirks-for-broken-bioses.patch
+
BuildRoot: %{_tmppath}/kernel-%{KVRA}-root
%description
@@ -816,6 +850,36 @@ ApplyOptionalPatch debrand-single-cpu.patch
@@ -816,6 +852,37 @@ ApplyOptionalPatch debrand-single-cpu.patch
ApplyOptionalPatch debrand-rh_taint.patch
ApplyOptionalPatch debrand-rh-i686-cpu.patch
@ -89,6 +91,7 @@ index 0b2ff2e..012ddbd 100644
+ApplyOptionalPatch ipvs-fix-memory-leak-in-ip_vs_ctl.c.patch
+ApplyOptionalPatch rh-ext4-release-leaked-posix-acl-in-ext4_acl_chmod.patch
+ApplyOptionalPatch rh-ext4-release-leaked-posix-acl-in-ext4_xattr_set_a.patch
+ApplyOptionalPatch Allow-dmar-quirks-for-broken-bioses.patch
+
# Any further pre-build tree manipulations happen here.

View File

@ -0,0 +1,79 @@
From 3ea9b69ea4e791797b42d73b609b2e1f4fdb9882 Mon Sep 17 00:00:00 2001
Message-Id: <3ea9b69ea4e791797b42d73b609b2e1f4fdb9882.1584647338.git.Jim.Somerville@windriver.com>
From: Jim Somerville <Jim.Somerville@windriver.com>
Date: Wed, 29 Jan 2020 14:19:22 -0500
Subject: [PATCH 1/1] Allow dmar quirks for broken bioses
Problem:
Broken bios creates inaccurate DMAR tables,
reporting some bridges as having endpoint types.
This causes IOMMU initialization to bail
out early with an error code, the result of
which is vfio not working correctly.
This is seen on some Skylake based Wolfpass
server platforms with up-to-date bios installed.
Solution:
Instead of just bailing out of IOMMU
initialization when such a condition is found,
we report it and continue. The IOMMU ends
up successfully initialized anyway. We do this
only on platforms that have the Skylake bridges
where this issue has been seen.
This change is inspired by a similar one posted by
Lu Baolu of Intel Corp to lkml
https://lkml.org/lkml/2019/12/24/15
Signed-off-by: Jim Somerville <Jim.Somerville@windriver.com>
---
drivers/iommu/dmar.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
index 4658dc3..eeaef2e 100644
--- a/drivers/iommu/dmar.c
+++ b/drivers/iommu/dmar.c
@@ -75,6 +75,26 @@ static unsigned long dmar_seq_ids[BITS_TO_LONGS(DMAR_UNITS_SUPPORTED)];
static int alloc_iommu(struct dmar_drhd_unit *drhd);
static void free_iommu(struct intel_iommu *iommu);
+static int scope_mismatch_quirk;
+static void quirk_dmar_scope_mismatch(struct pci_dev *dev)
+{
+ pci_info(dev, "scope mismatch ignored\n");
+ scope_mismatch_quirk = 1;
+}
+
+/*
+ * We expect devices with endpoint scope to have normal PCI
+ * headers, and devices with bridge scope to have bridge PCI
+ * headers. However some PCI devices may be listed in the
+ * DMAR table with bridge scope, even though they have a
+ * normal PCI header and vice versa. We don't declare a
+ * scope mismatch for the special cases below, even though
+ * the bios creates broken tables.
+ */
+/* Sky Lake-E PCI Express Root Port A */
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2030,
+ quirk_dmar_scope_mismatch);
+
static void dmar_register_drhd_unit(struct dmar_drhd_unit *drhd)
{
/*
@@ -257,7 +277,10 @@ int dmar_insert_dev_scope(struct dmar_pci_notify_info *info,
info->dev->class >> 8 != PCI_CLASS_BRIDGE_OTHER))) {
pr_warn("Device scope type does not match for %s\n",
pci_name(info->dev));
- return -EINVAL;
+ if (!scope_mismatch_quirk)
+ return -EINVAL;
+ else
+ pr_warn("but continuing anyway\n");
}
for_each_dev_scope(devices, devices_cnt, i, tmp)
--
1.8.3.1