All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: Paul Durrant <paul@xen.org>,
	Andrew Cooper <andrew.cooper3@citrix.com>, Wei Liu <wl@xen.org>,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH v3 5/7] x86/iommu: remove regions not to be mapped
Date: Wed, 20 Dec 2023 11:22:26 +0100	[thread overview]
Message-ID: <ZYLAYtenu3bWOfUU@macbook> (raw)
In-Reply-To: <2966f31a-8390-46fd-84c5-c424382dff29@suse.com>

On Tue, Dec 19, 2023 at 05:18:39PM +0100, Jan Beulich wrote:
> On 15.12.2023 15:18, Roger Pau Monne wrote:
> > Introduce the code to remove regions not to be mapped from the rangeset
> > that will be used to setup the IOMMU page tables for the hardware domain.
> > 
> > This change also introduces two new functions: remove_xen_ranges() and
> > vpci_subtract_mmcfg() that copy the logic in xen_in_range() and
> > vpci_is_mmcfg_address() respectively and remove the ranges that would otherwise
> > be intercepted by the original functions.
> > 
> > Note that the rangeset is still not populated.
> > 
> > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> 
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
> 
> > @@ -533,6 +541,62 @@ void __hwdom_init arch_iommu_hwdom_init(struct domain *d)
> >              goto commit;
> >      }
> >  
> > +    /* Remove any areas in-use by Xen. */
> > +    rc = remove_xen_ranges(map);
> > +    if ( rc )
> > +        panic("IOMMU failed to remove Xen ranges: %d\n", rc);
> > +
> > +    /* Remove any overlap with the Interrupt Address Range. */
> > +    rc = rangeset_remove_range(map, 0xfee00, 0xfeeff);
> > +    if ( rc )
> > +        panic("IOMMU failed to remove Interrupt Address Range: %d\n",
> > +              rc);
> > +
> > +    /* If emulating IO-APIC(s) make sure the base address is unmapped. */
> > +    if ( has_vioapic(d) )
> > +    {
> > +        for ( i = 0; i < d->arch.hvm.nr_vioapics; i++ )
> > +        {
> > +            rc = rangeset_remove_singleton(map,
> > +                PFN_DOWN(domain_vioapic(d, i)->base_address));
> > +            if ( rc )
> > +                panic("IOMMU failed to remove IO-APIC: %d\n",
> > +                      rc);
> > +        }
> > +    }
> > +
> > +    if ( is_pv_domain(d) )
> > +    {
> > +        /*
> > +         * Be consistent with CPU mappings: Dom0 is permitted to establish r/o
> > +         * ones there (also for e.g. HPET in certain cases), so it should also
> > +         * have such established for IOMMUs.  Remove any read-only ranges here,
> > +         * since ranges in mmio_ro_ranges are already explicitly mapped below
> > +         * in read-only mode.
> > +         */
> > +        rc = rangeset_report_ranges(mmio_ro_ranges, 0, ~0UL, map_subtract, map);
> 
> I find it a little odd that you iterate over mmio_ro_ranges twice (once
> here, once in what the earlier patch added), but I guess overall it's
> easier this way.

Given the number of ranges in the MMIO RO rangeset, I'm not sure
there's much reason to attempt to optimize this at the cost of making
the code harder to read.

> Also, nit: Either this line is too long, or ...
> 
> > +        if ( rc )
> > +            panic("IOMMU failed to remove read-only regions: %d\n",
> > +                  rc);
> 
> ... there's no need to wrap lines here.

No need to wrap indeed.

Thanks, Roger.


  reply	other threads:[~2023-12-20 10:22 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-15 14:18 [PATCH v3 0/7] x86/iommu: improve setup time of hwdom IOMMU Roger Pau Monne
2023-12-15 14:18 ` [PATCH v3 1/7] iommu/vt-d: do not assume page table levels for quarantine domain Roger Pau Monne
2023-12-15 14:18 ` [PATCH v3 2/7] x86/p2m: move and rename paging_max_paddr_bits() Roger Pau Monne
2023-12-19 15:38   ` Jan Beulich
2023-12-15 14:18 ` [PATCH v3 3/7] amd-vi: set IOMMU page table levels based on guest reported paddr width Roger Pau Monne
2023-12-19 15:40   ` Jan Beulich
2023-12-15 14:18 ` [PATCH v3 4/7] x86/iommu: introduce a rangeset to perform hwdom IOMMU setup Roger Pau Monne
2023-12-19 16:06   ` Jan Beulich
2023-12-20  9:52     ` Roger Pau Monné
2023-12-15 14:18 ` [PATCH v3 5/7] x86/iommu: remove regions not to be mapped Roger Pau Monne
2023-12-19 16:18   ` Jan Beulich
2023-12-20 10:22     ` Roger Pau Monné [this message]
2023-12-15 14:18 ` [PATCH v3 6/7] x86/iommu: switch hwdom IOMMU to use a rangeset Roger Pau Monne
2023-12-19 16:21   ` Jan Beulich
2023-12-15 14:18 ` [PATCH v3 7/7] x86/iommu: cleanup unused functions Roger Pau Monne
2023-12-19 16:23   ` Jan Beulich
2023-12-20 10:31     ` Roger Pau Monné
2023-12-20 10:36       ` 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=ZYLAYtenu3bWOfUU@macbook \
    --to=roger.pau@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=paul@xen.org \
    --cc=wl@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.