All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Tian, Kevin" <kevin.tian@intel.com>
To: Jan Beulich <jbeulich@suse.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: Paul Durrant <paul@xen.org>
Subject: RE: [PATCH 2/4] VT-d: consider hidden devices when unmapping
Date: Thu, 16 Sep 2021 08:18:36 +0000	[thread overview]
Message-ID: <BN9PR11MB5433706BE0A6C4B915D3707D8CDC9@BN9PR11MB5433.namprd11.prod.outlook.com> (raw)
In-Reply-To: <5cf392cf-09a2-b23c-2a25-610c64f20707@suse.com>

> 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@suse.com>
> 
> --- 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);
> 


  reply	other threads:[~2021-09-16  8:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-15  9:11 [PATCH 0/4] IOMMU/PCI: respect device specifics Jan Beulich
2021-09-15  9:12 ` [PATCH 1/4] VT-d: defer "no DRHD" check when (un)mapping devices Jan Beulich
2021-09-16  8:05   ` Tian, Kevin
2021-09-15  9:12 ` [PATCH 2/4] VT-d: consider hidden devices when unmapping Jan Beulich
2021-09-16  8:18   ` Tian, Kevin [this message]
2021-09-16  8:31     ` Jan Beulich
2021-09-15  9:13 ` [PATCH 3/4] VT-d: skip IOMMU bitmap cleanup for phantom devices Jan Beulich
2021-09-16  8:19   ` Tian, Kevin
2021-09-15  9:13 ` [PATCH 4/4] AMD/IOMMU: consider hidden devices when flushing device I/O TLBs Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BN9PR11MB5433706BE0A6C4B915D3707D8CDC9@BN9PR11MB5433.namprd11.prod.outlook.com \
    --to=kevin.tian@intel.com \
    --cc=jbeulich@suse.com \
    --cc=paul@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.