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

[PATCH 1/6] VT-d: properly reserve DID 0 for caching mode IOMMUs


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 12 Nov 2021 10:47:59 +0100
  • 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=jEAtRMfNFzRIgov+4hJ20x/I/cYX3+PllG2qKjsHlbY=; b=cVQ9nzNWOdB6VJXDlY0Tin/BRBU+zNcLm03Hv0/kXxIerYliPrAchRTawEiBAIA+RKTElrOoSr/6QlVrqPmdRpHAfsu0gmXj/jPw6Hl0GhwZ9nXjnROXLASMh84ICOMMJZRvGDp4dYDIUragnBksqH96EdELIW7VYj7k63pFikPYZRmXxiVf7RQgYQ+VQ8fHENHxpAwq5bIQ/AFixats6eMYbta55ycqtx7xoZqy66kSyAxqnk9N/4bVbq6T3xTQeL2TOUCl67lodHKBYpQYDDO5HfdjldrrxuvCKtXZu945sT11FSSZqrZ4DhIc3SXnULsawiTapVczna1tY0PveQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ia4AD7tan9M0ibR4i5R/AvAtYphDG74NPVk9FHJc5jJ+NGS0yzMVbXBNBEA0qbbIfwhVH+vdlLeCyGAw/tzvEyQyO+MmUl7kMkUpCHbs9XbxR/IwIiD5ZSGVFHPLxLRr+RcAo99zgJK8uXPT8R2zmNCL652PnBR1VRRKf3E/Bz8g/12aHuZSqeWndVLotf7HyP8afstB9+BovLZ7nllGZpHKEy6hxcT9SBPpLb3vRt90JoDL47CJthu37PRLKwMYZuoUsUff4nhGcg3+foSF79wbafe2WS/j6wkpx0s3PyarY/rktz8njux0hbc8vbGj14p26ofslinGumt/3pZ+9A==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Kevin Tian <kevin.tian@xxxxxxxxx>
  • Delivery-date: Fri, 12 Nov 2021 09:48:13 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Merely setting bit 0 in the bitmap is insufficient, as then Dom0 will
still have DID 0 allocated to it, because of the zero-filling of
domid_map[]. Set slot 0 to DOMID_INVALID to keep DID 0 from getting
used.

Fixes: b9c20c78789f ("VT-d: per-iommu domain-id")
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -1257,16 +1257,19 @@ int __init iommu_alloc(struct acpi_drhd_
     if ( !iommu->domid_bitmap )
         return -ENOMEM;
 
+    iommu->domid_map = xzalloc_array(u16, nr_dom);
+    if ( !iommu->domid_map )
+        return -ENOMEM;
+
     /*
-     * if Caching mode is set, then invalid translations are tagged with
-     * domain id 0, Hence reserve bit 0 for it
+     * If Caching mode is set, then invalid translations are tagged with
+     * domain id 0. Hence reserve bit/slot 0.
      */
     if ( cap_caching_mode(iommu->cap) )
+    {
+        iommu->domid_map[0] = DOMID_INVALID;
         __set_bit(0, iommu->domid_bitmap);
-
-    iommu->domid_map = xzalloc_array(u16, nr_dom);
-    if ( !iommu->domid_map )
-        return -ENOMEM;
+    }
 
     return 0;
 }




 


Rackspace

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