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

RE: [PATCH 2/4] VT-d: consider hidden devices when unmapping


  • To: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: "Tian, Kevin" <kevin.tian@xxxxxxxxx>
  • Date: Thu, 16 Sep 2021 08:18:36 +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; bh=kR67ruO5MPOO583+5PiBZ7zctYx+2qamf/UvRNENmYM=; b=kWtzGvbGU2yovDoOSCzdUGLc/M+1frO1JddjZgabdBfnbAHdXkDMXPfqdASN3m8t7raHnZh/iDsua4lOyvqqGEPgAn8dkpDK/6UNfiL6u2XgzFJtS+yizHwtApi+rmP87y3RXlqsY3P6/+LbnsSwcg2ghY5zmDJQ8J52aF9nAudWhiKTrLhIdCVWiiluVTjFJJhhTcV5KoODphZWU38TREDb3fwEVd9/kfNK4uTGVcyslYUSAp3R8rE8Pz5e16mb9eNf08WllCJYennBVibQAsZU4oI6DtqN7Vd/b/FfnmV34yq/mf7g/K/W6RDYoEBVTR3ZlnR0O1dXnSJrhcXnhg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T7GYBkMeVM1XkZ813CXLbv9YQJWCEh3X2Z31aXgZ5efBllZoQX9MxaREuHjnxXKh30NtrvBBcUCmokNUvQA7mhGkiof0gQvSl9QrKeFTGVrb970PbxHy//9jpZR4ofPpqJTqR92KKVJz/An2lu2KDadsBP9xyFfhcr2dtHB4R3VUCwUmEaNxJ/6FYXC2yt1StTGFlyi0Im8uVeCtewIpRCcYy18tHxWhQvCUIyOAHV/zc0jE8PU3c0atfgbLt+1b1VETAX9tEVe5yeWLzUlaw13XGGjEvdbY8A/oogKol1YlYlOiBEDZrjvdC5pOLxv2xThnRCmlZcSzJW7eE8LKAA==
  • Authentication-results: suse.com; dkim=none (message not signed) header.d=none;suse.com; dmarc=none action=none header.from=intel.com;
  • Cc: Paul Durrant <paul@xxxxxxx>
  • Delivery-date: Thu, 16 Sep 2021 08:18:55 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHXqhHtqP8x4M7szkGHc+SOfkqrHKumTyiA
  • Thread-topic: [PATCH 2/4] VT-d: consider hidden devices when unmapping

> From: Jan Beulich
> Sent: Wednesday, September 15, 2021 5:13 PM
> 
> Whether to clear an IOMMU's bit in the domain's bitmap should depend on
> all devices the domain can control. For the hardware domain this
> includes hidden devices, which are associated with DomXEN.
> 
> While touching related logic, convert "found" to "bool".
> 
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> 
> --- a/xen/drivers/passthrough/vtd/iommu.c
> +++ b/xen/drivers/passthrough/vtd/iommu.c
> @@ -1657,7 +1657,7 @@ static int domain_context_unmap(struct d
>      struct vtd_iommu *iommu = drhd ? drhd->iommu : NULL;
>      int ret;
>      u8 seg = pdev->seg, bus = pdev->bus, tmp_bus, tmp_devfn, secbus;
> -    int found = 0;
> +    bool found;
> 
>      switch ( pdev->type )
>      {
> @@ -1737,23 +1737,33 @@ static int domain_context_unmap(struct d
>          return ret;
> 
>      /*
> -     * if no other devices under the same iommu owned by this domain,
> -     * clear iommu in iommu_bitmap and clear domain_id in domid_bitmp
> +     * If no other devices under the same iommu owned by this domain,
> +     * clear iommu in iommu_bitmap and clear domain_id in domid_bitmap.

what is changed above?

>       */
> -    for_each_pdev ( domain, pdev )
> +    for ( found = false; ; domain = dom_xen )

honesty speaking I had to read several times to understand the break
condition of this loop. It'd be easier to understand if putting for_each_
pdev(){} into a function and then:

        found = func(domain);
        if (!found && is_hardware_domain(domain))
                found = func(dom_xen);

>      {
> -        if ( pdev->seg == seg && pdev->bus == bus && pdev->devfn == devfn )
> -            continue;
> -
> -        drhd = acpi_find_matched_drhd_unit(pdev);
> -        if ( drhd && drhd->iommu == iommu )
> +        for_each_pdev ( domain, pdev )
>          {
> -            found = 1;
> -            break;
> +            if ( pdev->seg == seg && pdev->bus == bus && pdev->devfn == 
> devfn )
> +                continue;
> +
> +            drhd = acpi_find_matched_drhd_unit(pdev);
> +            if ( drhd && drhd->iommu == iommu )
> +            {
> +                found = true;
> +                break;
> +            }
>          }
> +
> +        /*
> +         * Hidden devices are associated with DomXEN but usable by the
> +         * hardware domain. Hence they need considering here as well.
> +         */
> +        if ( found || !is_hardware_domain(domain) )
> +            break;
>      }
> 
> -    if ( found == 0 )
> +    if ( !found )
>      {
>          clear_bit(iommu->index, &dom_iommu(domain)-
> >arch.vtd.iommu_bitmap);
>          cleanup_domid_map(domain, iommu);
> 


 


Rackspace

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