summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Schmaus <flow@gentoo.org>2022-07-01 20:20:49 +0200
committerFlorian Schmaus <flow@gentoo.org>2022-07-01 20:26:39 +0200
commita16128cfac11b2f6462bbbc993cced2636abb312 (patch)
tree19b04c0f36afd341ba8a0ffbedf91ada49a332f1 /0004-VT-d-refuse-to-use-IOMMU-with-reserved-CAP.ND-value.patch
downloadxen-upstream-patches-a16128cfac11b2f6462bbbc993cced2636abb312.tar.gz
xen-upstream-patches-a16128cfac11b2f6462bbbc993cced2636abb312.tar.bz2
xen-upstream-patches-a16128cfac11b2f6462bbbc993cced2636abb312.zip
Xen 4.16.2-pre-patchset-04.16.2-pre-patchset-0
Signed-off-by: Florian Schmaus <flow@gentoo.org>
Diffstat (limited to '0004-VT-d-refuse-to-use-IOMMU-with-reserved-CAP.ND-value.patch')
-rw-r--r--0004-VT-d-refuse-to-use-IOMMU-with-reserved-CAP.ND-value.patch49
1 files changed, 49 insertions, 0 deletions
diff --git a/0004-VT-d-refuse-to-use-IOMMU-with-reserved-CAP.ND-value.patch b/0004-VT-d-refuse-to-use-IOMMU-with-reserved-CAP.ND-value.patch
new file mode 100644
index 0000000..c566888
--- /dev/null
+++ b/0004-VT-d-refuse-to-use-IOMMU-with-reserved-CAP.ND-value.patch
@@ -0,0 +1,49 @@
+From b378ee56c7e0bb5eeb35dcc55b3d29e5f50eb566 Mon Sep 17 00:00:00 2001
+From: Jan Beulich <jbeulich@suse.com>
+Date: Tue, 7 Jun 2022 13:58:16 +0200
+Subject: [PATCH 04/32] VT-d: refuse to use IOMMU with reserved CAP.ND value
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+The field taking the value 7 (resulting in 18-bit DIDs when using the
+calculation in cap_ndoms(), when the DID fields are only 16 bits wide)
+is reserved. Instead of misbehaving in case we would encounter such an
+IOMMU, refuse to use it.
+
+Signed-off-by: Jan Beulich <jbeulich@suse.com>
+Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
+Reviewed-by: Kevin Tian <kevin.tian@intel.com>
+master commit: a1545fbf45c689aff39ce76a6eaa609d32ef72a7
+master date: 2022-04-20 10:54:26 +0200
+---
+ xen/drivers/passthrough/vtd/iommu.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c
+index 93dd8aa643aa..8975c1de61bc 100644
+--- a/xen/drivers/passthrough/vtd/iommu.c
++++ b/xen/drivers/passthrough/vtd/iommu.c
+@@ -1279,8 +1279,11 @@ int __init iommu_alloc(struct acpi_drhd_unit *drhd)
+
+ quirk_iommu_caps(iommu);
+
++ nr_dom = cap_ndoms(iommu->cap);
++
+ if ( cap_fault_reg_offset(iommu->cap) +
+ cap_num_fault_regs(iommu->cap) * PRIMARY_FAULT_REG_LEN >= PAGE_SIZE ||
++ ((nr_dom - 1) >> 16) /* I.e. cap.nd > 6 */ ||
+ ecap_iotlb_offset(iommu->ecap) >= PAGE_SIZE )
+ {
+ printk(XENLOG_ERR VTDPREFIX "IOMMU: unsupported\n");
+@@ -1305,7 +1308,6 @@ int __init iommu_alloc(struct acpi_drhd_unit *drhd)
+ vtd_ops.sync_cache = sync_cache;
+
+ /* allocate domain id bitmap */
+- nr_dom = cap_ndoms(iommu->cap);
+ iommu->domid_bitmap = xzalloc_array(unsigned long, BITS_TO_LONGS(nr_dom));
+ if ( !iommu->domid_bitmap )
+ return -ENOMEM;
+--
+2.35.1
+