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

RE: [PATCH 6/6] VT-d: avoid allocating domid_{bit,}map[] when possible


  • To: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: "Tian, Kevin" <kevin.tian@xxxxxxxxx>
  • Date: Mon, 15 Nov 2021 06:18:00 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.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=0vJYdC9UmRXVosbZeop0uhLXUgUNFr4BZOaFjHp9LKI=; b=NzFfxX1X742z7crdvpwWUyK6awMmKcX8FfE7xJGQxGsSNN6r86toCPFN6sRFRT7oE2aVvAa3z9x02IT1g7HJoQNGlhPjiggFG+LmQEviH+w9f2iVteA+SJFO4sKDZvSISpGomopMy5/GAw0q7uCubAVD+TUpcI1XBiM6SE+YV7YhrW4duUnREvHNo6wjbek/tua9Fe3aFOBptPp9x92ZIfhNT21gwS8K09ozfwLbJXvsMuZzRfUoQNuUjYIMI/YGvxc9QIJm0gY8GfhlDWLBisjNtuuiItLUExuIUu5x1CY5dItfsq0bSakAq5VwyXKYg37oCpuiKh7AMpXvNrkd7g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VJkFpouZiJlUNJI7krCoGfYqFJj1SMMuD/k1Qzm7SVCd/efysMehMFjlDfMKdFnmCdV6ITweWys5JdXR5JR/MCexfpY+FIRW/Hozd+839aldaXrPcZnTE/n2VPLxgyo3rNsMmd8xu8bwaD5pmlvza++GSp6H/GHH+Tgv+sYn/Q4FeHLOhmgpLV4I+R5QV68FAz69U8XcnmZYD8DtRu51Q5GV9i5HKPCVPNBqR/beTMDA5MlOVYo4DuREFMg5pJNlw0ps1VDd5++eA6hJ7AoqMaFwaA9vSkDeSdQWEN2VetcJ6uZkVFUQD76I/Q5JSbwPi1fgl7eQs7YnfioTgEKxSw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com;
  • Delivery-date: Mon, 15 Nov 2021 06:18:36 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHX16q9WmxQsBgQrkWPsFUCOcTQhKwEGx2A
  • Thread-topic: [PATCH 6/6] VT-d: avoid allocating domid_{bit,}map[] when possible

> From: Jan Beulich <jbeulich@xxxxxxxx>
> Sent: Friday, November 12, 2021 5:50 PM
> 
> When an IOMMU implements the full 16 bits worth of DID in context
> entries, there's no point going through a memory base translation table.
> For IOMMUs not using Caching Mode we can simply use the domain IDs
> verbatim, while for Caching Mode we need to avoid DID 0.
> 
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> ---
> For the case where the memory tables are needed, xvzalloc_array() would
> of course be an option to use here as well, despite this being boot time
> allocations. Yet the introduction of xvmalloc() et al continues to be
> stuck ...
> 
> --- a/xen/drivers/passthrough/vtd/iommu.c
> +++ b/xen/drivers/passthrough/vtd/iommu.c
> @@ -62,11 +62,32 @@ static struct tasklet vtd_fault_tasklet;
>  static int setup_hwdom_device(u8 devfn, struct pci_dev *);
>  static void setup_hwdom_rmrr(struct domain *d);
> 
> +static bool domid_mapping(const struct vtd_iommu *iommu)
> +{
> +    return (const void *)iommu->domid_bitmap != (const void *)iommu-
> >domid_map;
> +}
> +
> +static domid_t convert_domid(const struct vtd_iommu *iommu, domid_t
> domid)
> +{
> +    /*
> +     * While we need to avoid DID 0 for caching-mode IOMMUs, maintain
> +     * the property of the transformation being the same in either
> +     * direction. By clipping to 16 bits we ensure that the resulting
> +     * DID will fit in the respective context entry field.
> +     */
> +    BUILD_BUG_ON(sizeof(domid_t) > sizeof(uint16_t));
> +
> +    return !cap_caching_mode(iommu->cap) ? domid : ~domid;

If DOMID_MASK grows to 0xFFFF (though unlikely), then it translates 
to '0' when caching mode is true. We need extend BUILD_BUG_ON() to 
check DOMID_MASK in this case, since caching mode implies
total_size minus one for available domain IDs 

Thanks
Kevin

 


Rackspace

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