[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 4/8] VT-d: refuse to use IOMMU with reserved CAP.ND value


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 11 Apr 2022 11:37:28 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QrdD3qAeqW/aeTb5B3y1/J7DaT6w+fqGApWyQhpbnKk=; b=VlYb5LIF8UwdTDCtiRgc1LPc2FbVRjVOylJ5KlfpT5RkDQ/SzFGPNZFArsexdwX+jas2xFwEWU+WAgW6U21geCeJyGojYMsBOftKG2pyE/MS7MEFSveVXj+kQJNZVbADyIQoMwrHTM3PJcBUAfrxOo45sKysxft9XiiQi311vFt5fT6gsBIsbJ8vspi9GQTz55yX1le7mO1oJ98uWbZjuyXW4CCsCIFKRk+8x7PuVQ63p0VLBhPx4WxdUqyrA8ffkVp1SAoL6HQ/tVti8mSalFf+9g0t9p6exe6eFx0+PAza1r78KBu2gRv0+i0rqbSNT76DTgeRaGXVPuFocoqWoA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QgTBgvpR63PNgKhgJ0nQKAd5MNxT7StX6ijlbl1NRG+6QIkeYLqhFfra5FH08k7x2bmvf0PGXfVCKXkz3pjoHkIb+zWY7ateUxnjA+ymQpVPHpbF9qufg4QckXstczQszcY8kqxfzpeLxHvVg+kGOipUkOLWlRRaEqkDYE1cBKSvkSehBBTiSn+TKIItllYUK0qcg2iQ2GR8zsrB87JQ9kq1EV5yq+MboqiuPJJEQn9NnEKCadIHpC9Z1dHErM0ejiTvSFXkjyk1qBSiD7lI/+RZTTZUc9xEYju5n5LDozp01AbCStk3ufDWMoQ+BVWJHtUwJoJt57NnLPFLxCzL/Q==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Kevin Tian <kevin.tian@xxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Mon, 11 Apr 2022 09:37:40 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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@xxxxxxxx>

--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -1267,8 +1267,11 @@ int __init iommu_alloc(struct acpi_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 */ ||
          (has_register_based_invalidation(iommu) &&
           ecap_iotlb_offset(iommu->ecap) >= PAGE_SIZE) )
     {
@@ -1294,8 +1297,6 @@ int __init iommu_alloc(struct acpi_drhd_
     if ( !ecap_coherent(iommu->ecap) )
         iommu_non_coherent = true;
 
-    nr_dom = cap_ndoms(iommu->cap);
-
     if ( nr_dom <= DOMID_MASK * 2 + cap_caching_mode(iommu->cap) )
     {
         /* Allocate domain id (bit) maps. */




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.