All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Durrant <Paul.Durrant@citrix.com>
To: 'Jan Beulich' <JBeulich@suse.com>
Cc: Kevin Tian <kevin.tian@intel.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Wei Liu <wei.liu2@citrix.com>,
	Jun Nakajima <jun.nakajima@intel.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	Andrew Cooper <Andrew.Cooper3@citrix.com>,
	"Tim (Xen.org)" <tim@xen.org>,
	George Dunlap <George.Dunlap@citrix.com>,
	Julien Grall <julien.grall@arm.com>,
	Tamas K Lengyel <tamas@tklengyel.com>,
	Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
	xen-devel <xen-devel@lists.xenproject.org>,
	Ian Jackson <Ian.Jackson@citrix.com>,
	Brian Woods <brian.woods@amd.com>
Subject: Re: [PATCH v11 9/9] mm / iommu: split need_iommu() into has_iommu_pt() and need_iommu_pt_sync()
Date: Thu, 27 Sep 2018 13:01:25 +0000	[thread overview]
Message-ID: <8716716ecee94aa0a8d22d903facc651@AMSPEX02CL03.citrite.net> (raw)
In-Reply-To: <5BAA0FD902000078001EB875@prv1-mh.provo.novell.com>

> -----Original Message-----
> From: Jan Beulich [mailto:JBeulich@suse.com]
> Sent: 25 September 2018 11:37
> To: Paul Durrant <Paul.Durrant@citrix.com>
> Cc: Brian Woods <brian.woods@amd.com>; Suravee Suthikulpanit
> <suravee.suthikulpanit@amd.com>; Julien Grall <julien.grall@arm.com>;
> Andrew Cooper <Andrew.Cooper3@citrix.com>; Wei Liu <wei.liu2@citrix.com>;
> George Dunlap <George.Dunlap@citrix.com>; Ian Jackson
> <Ian.Jackson@citrix.com>; Jun Nakajima <jun.nakajima@intel.com>; Kevin
> Tian <kevin.tian@intel.com>; Stefano Stabellini <sstabellini@kernel.org>;
> xen-devel <xen-devel@lists.xenproject.org>; Konrad Rzeszutek Wilk
> <konrad.wilk@oracle.com>; Tamas K Lengyel <tamas@tklengyel.com>; Tim
> (Xen.org) <tim@xen.org>
> Subject: Re: [PATCH v11 9/9] mm / iommu: split need_iommu() into
> has_iommu_pt() and need_iommu_pt_sync()
> 
> >>> On 21.09.18 at 12:56, <paul.durrant@citrix.com> wrote:
> > --- a/xen/arch/x86/hvm/mtrr.c
> > +++ b/xen/arch/x86/hvm/mtrr.c
> > @@ -783,7 +783,8 @@ HVM_REGISTER_SAVE_RESTORE(MTRR, hvm_save_mtrr_msr,
> hvm_load_mtrr_msr, 1,
> >
> >  void memory_type_changed(struct domain *d)
> >  {
> > -    if ( need_iommu(d) && d->vcpu && d->vcpu[0] )
> > +    if ( (has_iommu_pt(d) || iommu_use_hap_pt(d)) &&
> > +         d->vcpu && d->vcpu[0] )
> >      {
> >          p2m_memory_type_changed(d);
> >          flush_all(FLUSH_CACHE);
> > @@ -831,7 +832,7 @@ int epte_get_entry_emt(struct domain *d, unsigned
> long gfn, mfn_t mfn,
> >          return MTRR_TYPE_UNCACHABLE;
> >      }
> >
> > -    if ( !need_iommu(d) && !cache_flush_permitted(d) )
> > +    if ( !has_iommu_pt(d) && !cache_flush_permitted(d) )
> >      {
> >          *ipat = 1;
> >          return MTRR_TYPE_WRBACK;
> 
> Considering how closely the two functions are related I'm struggling to
> understand why the conditions are no longer the inverse of one another.
> With iommu_use_hap_pt() including a has_iommu_pt() check I think the
> former can and should be simplified.

Ok.

> 
> > --- a/xen/arch/x86/x86_64/mm.c
> > +++ b/xen/arch/x86/x86_64/mm.c
> > @@ -1426,8 +1426,13 @@ int memory_add(unsigned long spfn, unsigned long
> epfn, unsigned int pxm)
> >      if ( ret )
> >          goto destroy_m2p;
> >
> > -    if ( iommu_enabled && !iommu_hwdom_passthrough &&
> > -         !need_iommu(hardware_domain) )
> > +    /*
> > +     * If hardware domain has IOMMU mappings but page tables are not
> > +     * shared, and are not being kept in sync (which is the case when
> > +     * in strict mode) then newly added memory needs to be mapped here.
> > +     */
> > +    if ( has_iommu_pt(hardware_domain) &&
> > +         !iommu_use_hap_pt(hardware_domain) && !iommu_hwdom_strict )
> 
> iommu_use_hap_pt() includes a hap_enabled() check, but that is valid
> to be used on HVM domains only. It looks like there are other similar
> improper uses elsewhere - all new and pre-existing uses need auditing.
> 

Yes... I will check.

> > --- a/xen/drivers/passthrough/pci.c
> > +++ b/xen/drivers/passthrough/pci.c
> > @@ -1416,7 +1416,7 @@ static int assign_device(struct domain *d, u16
> seg, u8 bus, u8 devfn, u32 flag)
> >
> >      /* Prevent device assign if mem paging or mem sharing have been
> >       * enabled for this domain */
> > -    if ( unlikely(!need_iommu(d) &&
> > +    if ( unlikely(!has_iommu_pt(d) &&
> >              (d->arch.hvm.mem_sharing_enabled ||
> >               vm_event_check_ring(d->vm_event_paging) ||
> >               p2m_get_hostp2m(d)->global_logdirty)) )
> 
> This need_iommu() check looks rather unmotivated to me - wouldn't
> you better delete it instead of finding a suitable replacement?

Yes, it's not clear why need_iommu() is here. I can only guess it's to avoid re-checking the second clause once the domain has pagetables, but nothing in the second clause seems to be computationally expensive.

  Paul

> 
> Jan
> 


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

      reply	other threads:[~2018-09-27 13:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-21 10:56 [PATCH v11 0/9] paravirtual IOMMU pre-requisites and clean-up Paul Durrant
2018-09-21 10:56 ` [PATCH v11 1/9] iommu: introduce the concept of DFN Paul Durrant
2018-09-21 10:56 ` [PATCH v11 2/9] iommu: make use of type-safe DFN and MFN in exported functions Paul Durrant
2018-09-21 10:56 ` [PATCH v11 3/9] iommu: push use of type-safe DFN and MFN into iommu_ops Paul Durrant
2018-09-21 10:56 ` [PATCH v11 4/9] iommu: don't domain_crash() inside iommu_map/unmap_page() Paul Durrant
2018-09-21 10:56 ` [PATCH v11 5/9] memory: add check_get_page_from_gfn() as a wrapper Paul Durrant
2018-09-21 10:56 ` [PATCH v11 6/9] vtd: add missing check for shared EPT Paul Durrant
2018-09-21 10:56 ` [PATCH v11 7/9] vtd: add lookup_page method to iommu_ops Paul Durrant
2018-09-21 10:56 ` [PATCH v11 8/9] mm / iommu: include need_iommu() test in iommu_use_hap_pt() Paul Durrant
2018-09-21 10:56 ` [PATCH v11 9/9] mm / iommu: split need_iommu() into has_iommu_pt() and need_iommu_pt_sync() Paul Durrant
2018-09-25 10:37   ` Jan Beulich
2018-09-27 13:01     ` Paul Durrant [this message]

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=8716716ecee94aa0a8d22d903facc651@AMSPEX02CL03.citrite.net \
    --to=paul.durrant@citrix.com \
    --cc=Andrew.Cooper3@citrix.com \
    --cc=George.Dunlap@citrix.com \
    --cc=Ian.Jackson@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=brian.woods@amd.com \
    --cc=julien.grall@arm.com \
    --cc=jun.nakajima@intel.com \
    --cc=kevin.tian@intel.com \
    --cc=konrad.wilk@oracle.com \
    --cc=sstabellini@kernel.org \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=tamas@tklengyel.com \
    --cc=tim@xen.org \
    --cc=wei.liu2@citrix.com \
    --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.