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

RE: [PATCH 1/3] VT-d: prune SAGAW recognition


  • To: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: "Tian, Kevin" <kevin.tian@xxxxxxxxx>
  • Date: Wed, 24 Nov 2021 01:22:41 +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=TFir4j92i/Nsc8T5Q8EMFHZu+Je/aFWRCFgEtUNMpbA=; b=GDdSWX078UfmXOi0BPq06QGU0MRcMDKUvvpz7RwiAsN8SyRl3Jbx2u4OBNlad+468JkRHCNbwB0rcfwxwXaB7vb48yz+bQLoP1/7hZ35Jq9zFzUHhfOIfok8GyflrFZIm09NovEYdi3Rp35jIj5SsRA7U+d0R2UE7i4V7ZZWs7GJguh9zenpCVq0clHbmWIJk7iM2R1hQ/EB1Qxfda/DF6KHoarpBL3jSKvgoz1tHtJjtEtCnHgGTC8G4ejrH1DJ4+QYxyx2qqWIgGNdT3Kvo4hLrFXy/Tb3QwzU5mmNylBeoWZ/RInNcg7DKk6cydZWR9fclxQaSk7XDlk9WxWaZA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UXMnf1A7r+WaCbR7avGzdsSpXiVq5BYLEJnv900UHpeDBOUIxPOOT3PfNRRqCmcA5XgQJaqY1fD9nKZ2egYj/3jvPgLQTLK84u+9Donr0AH8cmm22vGfqtvhCL0mnSy30JLqjs/4K4hD9eYFezTLHaCZ7LWdy7PPNsQ6B1njG0dGZYB1toTKqCx4E+VxslGKzYEGYJL16JAHd2W493Ni1PjJz7B7eT2XSS2ARx8E8Bxeu7MaC0ut3/CIM6JHER8NtOGsguzZDI+PMTx/Z0Uw4tCnaZNwjBtt8Hp7F8Ui241Cb9Ygf8MaoeiME4IFeg1jXd2wxEAHf1hfcrHsjBEeUw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com;
  • Delivery-date: Wed, 24 Nov 2021 01:23:23 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHX4G+bK+NNsWCPc0+Q5rkWpgerr6wR4b8Q
  • Thread-topic: [PATCH 1/3] VT-d: prune SAGAW recognition

> From: Jan Beulich <jbeulich@xxxxxxxx>
> Sent: Tuesday, November 23, 2021 9:40 PM
> 
> Bit 0 of the capability register field has become reserved at or before

Bit 0 of 'SAGAW' in the capability register ...

> spec version 2.2. Treat it as such. Replace the effective open-coding of
> find_first_set_bit(). Adjust local variable types.
> 
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> ---
> Strictly speaking IOMMUs supporting only 3-level tables ought to result
> in guests seeing a suitably reduced physical address width in CPUID.
> And then the same would apply to restrictions resulting from MGAW.

Yes. I remember there was some old discussion in Qemu community
for whether guest physical addr width should be based on IOMMU
constraints when passthrough device is used. But it didn't go anywhere
(and I cannot find the link...)

anyway with above comment fixed:

        Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>

> 
> --- a/xen/drivers/passthrough/vtd/iommu.c
> +++ b/xen/drivers/passthrough/vtd/iommu.c
> @@ -356,7 +356,7 @@ static uint64_t domain_pgd_maddr(struct
>          pgd_maddr = hd->arch.vtd.pgd_maddr;
>      }
> 
> -    /* Skip top levels of page tables for 2- and 3-level DRHDs. */
> +    /* Skip top level(s) of page tables for less-than-maximum level DRHDs. */
>      for ( agaw = level_to_agaw(4);
>            agaw != level_to_agaw(nr_pt_levels);
>            agaw-- )
> @@ -1183,8 +1183,7 @@ static int __init iommu_set_interrupt(st
>  int __init iommu_alloc(struct acpi_drhd_unit *drhd)
>  {
>      struct vtd_iommu *iommu;
> -    unsigned long sagaw, nr_dom;
> -    int agaw;
> +    unsigned int sagaw, agaw = 0, nr_dom;
> 
>      iommu = xzalloc(struct vtd_iommu);
>      if ( iommu == NULL )
> @@ -1237,14 +1236,13 @@ int __init iommu_alloc(struct acpi_drhd_
>          return -ENODEV;
>      }
> 
> -    /* Calculate number of pagetable levels: between 2 and 4. */
> +    /* Calculate number of pagetable levels: 3 or 4. */
>      sagaw = cap_sagaw(iommu->cap);
> -    for ( agaw = level_to_agaw(4); agaw >= 0; agaw-- )
> -        if ( test_bit(agaw, &sagaw) )
> -            break;
> -    if ( agaw < 0 )
> +    if ( sagaw & 6 )
> +        agaw = find_first_set_bit(sagaw & 6);
> +    if ( !agaw )
>      {
> -        printk(XENLOG_ERR VTDPREFIX "IOMMU: unsupported sagaw %lx\n",
> sagaw);
> +        printk(XENLOG_ERR VTDPREFIX "IOMMU: unsupported sagaw %x\n",
> sagaw);
>          print_iommu_regs(drhd);
>          return -ENODEV;
>      }


 


Rackspace

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