From: "Durrant, Paul" <pdurrant@amazon.co.uk>
To: Jan Beulich <jbeulich@suse.com>, Paul Durrant <paul@xen.org>
Cc: "Kevin Tian" <kevin.tian@intel.com>, "Wei Liu" <wl@xen.org>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"George Dunlap" <george.dunlap@citrix.com>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
"Roger Pau Monné" <roger.pau@citrix.com>
Subject: RE: [PATCH 5/6] iommu: remove the share_p2m operation
Date: Wed, 29 Jul 2020 08:45:52 +0000 [thread overview]
Message-ID: <319306da26bc4e848e9a46cf0caa10ea@EX13D32EUC003.ant.amazon.com> (raw)
In-Reply-To: <d005885d-d983-7328-ee36-efd6032e8c96@suse.com>
> -----Original Message-----
> From: Jan Beulich <jbeulich@suse.com>
> Sent: 26 July 2020 09:50
> To: Paul Durrant <paul@xen.org>
> Cc: xen-devel@lists.xenproject.org; Durrant, Paul <pdurrant@amazon.co.uk>; Andrew Cooper
> <andrew.cooper3@citrix.com>; George Dunlap <george.dunlap@citrix.com>; Wei Liu <wl@xen.org>; Roger Pau
> Monné <roger.pau@citrix.com>; Kevin Tian <kevin.tian@intel.com>
> Subject: RE: [EXTERNAL] [PATCH 5/6] iommu: remove the share_p2m operation
>
> CAUTION: This email originated from outside of the organization. Do not click links or open
> attachments unless you can confirm the sender and know the content is safe.
>
>
>
> On 24.07.2020 18:46, Paul Durrant wrote:
> > --- a/xen/drivers/passthrough/vtd/iommu.c
> > +++ b/xen/drivers/passthrough/vtd/iommu.c
> > @@ -313,6 +313,26 @@ static u64 addr_to_dma_page_maddr(struct domain *domain, u64 addr, int alloc)
> > return pte_maddr;
> > }
> >
> > +static u64 domain_pgd_maddr(struct domain *d)
>
> uint64_t please.
>
Ok.
> > +{
> > + struct domain_iommu *hd = dom_iommu(d);
> > +
> > + ASSERT(spin_is_locked(&hd->arch.mapping_lock));
> > +
> > + if ( iommu_use_hap_pt(d) )
> > + {
> > + mfn_t pgd_mfn =
> > + pagetable_get_mfn(p2m_get_pagetable(p2m_get_hostp2m(d)));
> > +
> > + return pagetable_get_paddr(pagetable_from_mfn(pgd_mfn));
> > + }
> > +
> > + if ( !hd->arch.vtd.pgd_maddr )
> > + addr_to_dma_page_maddr(d, 0, 1);
> > +
> > + return hd->arch.vtd.pgd_maddr;
> > +}
> > +
> > static void iommu_flush_write_buffer(struct vtd_iommu *iommu)
> > {
> > u32 val;
> > @@ -1347,22 +1367,17 @@ int domain_context_mapping_one(
> > {
> > spin_lock(&hd->arch.mapping_lock);
> >
> > - /* Ensure we have pagetables allocated down to leaf PTE. */
> > - if ( hd->arch.vtd.pgd_maddr == 0 )
> > + pgd_maddr = domain_pgd_maddr(domain);
> > + if ( !pgd_maddr )
> > {
> > - addr_to_dma_page_maddr(domain, 0, 1);
> > - if ( hd->arch.vtd.pgd_maddr == 0 )
> > - {
> > - nomem:
> > - spin_unlock(&hd->arch.mapping_lock);
> > - spin_unlock(&iommu->lock);
> > - unmap_vtd_domain_page(context_entries);
> > - return -ENOMEM;
> > - }
> > + nomem:
> > + spin_unlock(&hd->arch.mapping_lock);
> > + spin_unlock(&iommu->lock);
> > + unmap_vtd_domain_page(context_entries);
> > + return -ENOMEM;
> > }
>
> This renders all calls bogus in shared mode - the function, if
> it ended up getting called nevertheless, would then still alloc
> the root table. Therefore I'd like to suggest that at least all
> its callers get an explicit check. That's really just
> dma_pte_clear_one() as it looks.
>
Ok, I think I may move this code out into a separate function too since the nomem label is slightly awkward, so I'll re-factor it.
Paul
> Jan
next prev parent reply other threads:[~2020-07-29 8:46 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-24 16:46 [PATCH 0/6] IOMMU cleanup Paul Durrant
2020-07-24 16:46 ` [PATCH 1/6] x86/iommu: re-arrange arch_iommu to separate common fields Paul Durrant
2020-07-24 17:29 ` Andrew Cooper
2020-07-24 18:49 ` Paul Durrant
2020-07-26 8:13 ` Jan Beulich
2020-07-27 9:30 ` Durrant, Paul
2020-07-24 16:46 ` [PATCH 2/6] x86/iommu: add common page-table allocator Paul Durrant
2020-07-24 18:24 ` Andrew Cooper
2020-07-26 8:26 ` Jan Beulich
2020-07-27 9:37 ` Durrant, Paul
2020-07-27 19:41 ` Jan Beulich
2020-07-24 16:46 ` [PATCH 3/6] iommu: remove iommu_lookup_page() and the lookup_page() method Paul Durrant
2020-07-24 18:38 ` Andrew Cooper
2020-07-24 18:53 ` Paul Durrant
2020-07-26 8:27 ` Jan Beulich
2020-07-27 9:58 ` Durrant, Paul
2020-07-24 16:46 ` [PATCH 4/6] remove remaining uses of iommu_legacy_map/unmap Paul Durrant
2020-07-26 8:36 ` Jan Beulich
2020-07-29 8:12 ` Durrant, Paul
2020-07-24 16:46 ` [PATCH 5/6] iommu: remove the share_p2m operation Paul Durrant
2020-07-24 19:00 ` Andrew Cooper
2020-07-29 8:43 ` Durrant, Paul
2020-07-26 8:50 ` Jan Beulich
2020-07-29 8:45 ` Durrant, Paul [this message]
2020-07-24 16:46 ` [PATCH 6/6] iommu: stop calling IOMMU page tables 'p2m tables' Paul Durrant
2020-07-24 19:08 ` Andrew Cooper
2020-07-27 10:13 ` Durrant, Paul
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=319306da26bc4e848e9a46cf0caa10ea@EX13D32EUC003.ant.amazon.com \
--to=pdurrant@amazon.co.uk \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=jbeulich@suse.com \
--cc=kevin.tian@intel.com \
--cc=paul@xen.org \
--cc=roger.pau@citrix.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).