xen-devel.lists.xenproject.org archive mirror
 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>,
	VolodymyrBabchuk <Volodymyr_Babchuk@epam.com>,
	Wei Liu <wl@xen.org>, Jun Nakajima <jun.nakajima@intel.com>,
	Andrew Cooper <Andrew.Cooper3@citrix.com>,
	George Dunlap <George.Dunlap@citrix.com>,
	Julien Grall <julien.grall@arm.com>,
	Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	Brian Woods <brian.woods@amd.com>,
	Roger Pau Monne <roger.pau@citrix.com>
Subject: Re: [Xen-devel] [PATCH 2/6] use is_iommu_enabled() where appropriate...
Date: Mon, 12 Aug 2019 14:53:35 +0000	[thread overview]
Message-ID: <4f7bc9db8dc34b5bbe392eb76546b230@AMSPEX02CL03.citrite.net> (raw)
In-Reply-To: <d96b7a8b-4668-576f-84d2-e0a382d86c87@suse.com>

> -----Original Message-----
> From: Jan Beulich <jbeulich@suse.com>
> Sent: 07 August 2019 10:56
> To: Paul Durrant <Paul.Durrant@citrix.com>
> Cc: xen-devel@lists.xenproject.org; Brian Woods <brian.woods@amd.com>; Suravee Suthikulpanit
> <suravee.suthikulpanit@amd.com>; Julien Grall <julien.grall@arm.com>; Andrew Cooper
> <Andrew.Cooper3@citrix.com>; Roger Pau Monne <roger.pau@citrix.com>; VolodymyrBabchuk
> <Volodymyr_Babchuk@epam.com>; George Dunlap <George.Dunlap@citrix.com>; Jun Nakajima
> <jun.nakajima@intel.com>; Kevin Tian <kevin.tian@intel.com>; Stefano Stabellini
> <sstabellini@kernel.org>; Wei Liu <wl@xen.org>
> Subject: Re: [PATCH 2/6] use is_iommu_enabled() where appropriate...
> 
> On 30.07.2019 15:44, Paul Durrant wrote:
> > --- a/xen/arch/arm/p2m.c
> > +++ b/xen/arch/arm/p2m.c
> > @@ -1531,8 +1531,7 @@ int p2m_init(struct domain *d)
> >        * shared with the CPU, Xen has to make sure that the PT changes have
> >        * reached the memory
> >        */
> > -    p2m->clean_pte = iommu_enabled &&
> > -        !iommu_has_feature(d, IOMMU_FEAT_COHERENT_WALK);
> > +    p2m->clean_pte = !iommu_has_feature(d, IOMMU_FEAT_COHERENT_WALK);
> 
> I can't tell if the original code was meant to be this way, but I'm
> afraid your transformation is not correct: The prior construct,
> expanding iommu_has_feature(), was
> 
> iommu_enabled && !(iommu_enabled && test_bit(feature, dom_iommu(d)->features))
> 
> which transforms through
> 
> iommu_enabled && (!iommu_enabled || !test_bit(feature, dom_iommu(d)->features))
> 
> to
> 
> (iommu_enabled && !iommu_enabled) || (iommu_enabled && !test_bit(feature, dom_iommu(d)->features))
> 
> and hence
> 
> iommu_enabled && !test_bit(feature, dom_iommu(d)->features)
> 
> whereas the new code simply is
> 
> !(iommu_enabled && test_bit(feature, dom_iommu(d)->features))
> 
> i.e.
> 
> !iommu_enabled || !test_bit(feature, dom_iommu(d)->features)

Yes, somehow I'd read that the iommu_enabled was inverted in the first instance. I'll add a check of is_iommu_enabled() back into p2m_init().

> 
> > @@ -766,7 +766,7 @@ ept_set_entry(struct p2m_domain *p2m, gfn_t gfn_, mfn_t mfn,
> >           new_entry.sp = !!i;
> >           new_entry.sa_p2mt = p2mt;
> >           new_entry.access = p2ma;
> > -        new_entry.snp = (iommu_enabled && iommu_snoop);
> > +        new_entry.snp = is_iommu_enabled(p2m->domain) && iommu_snoop;
> 
> Please use d here.
> 
> Seeing that this is the last change in x86/mm/, did you overlook
> the use in p2m_pt_set_entry()? Or is this meant to go on top of
> Alexandru's "x86/mm: Clean IOMMU flags from p2m-pt code" (which
> should then be noted in a post-commit-message remark)?

Yes, it needs to go on top of Alexandru's patch. I said the series is based on that patch in the cover letter but I can state it here as well if it helps.

> 
> > @@ -556,7 +556,7 @@ int iommu_do_domctl(
> >   {
> >       int ret = -ENODEV;
> >
> > -    if ( !iommu_enabled )
> > +    if ( !is_iommu_enabled(d) )
> >           return -ENOSYS;
> 
> ENOSYS was wrong here from the beginning, but it certainly gets
> worse with this no longer being a system wide property. Please
> change to EOPNOTSUPP or some other suitable one.

Sure. I'll go with EOPNOTSUPP.

> 
> > --- a/xen/drivers/passthrough/pci.c
> > +++ b/xen/drivers/passthrough/pci.c
> > @@ -864,7 +864,7 @@ static int pci_clean_dpci_irqs(struct domain *d)
> 
> Above here there's another use in pci_enable_acs(), which should
> imo act on pdev->domain.

Oh yes, I'll fix that.

> 
> There's another use in flask_iommu_resource_use_perm(). All
> callers of the function hold a struct domain * in their hands,
> which I think they should pass into this function such that the
> conditional can be replaced.

I wasn't sure about this one. It looks more like the perm passed back is based on the hardware features available but I guess it will DTRT if the IOMMU is not enabled for the domain.

  Paul

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

  parent reply	other threads:[~2019-08-12 14:54 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-30 13:44 [Xen-devel] [PATCH 0/6] per-domain IOMMU control Paul Durrant
2019-07-30 13:44 ` [Xen-devel] [PATCH 1/6] domain: introduce XEN_DOMCTL_CDF_iommu Paul Durrant
2019-08-07  9:21   ` Jan Beulich
2019-08-12 12:22     ` Paul Durrant
2019-07-30 13:44 ` [Xen-devel] [PATCH 2/6] use is_iommu_enabled() where appropriate Paul Durrant
2019-08-07  9:55   ` Jan Beulich
2019-08-07 10:22     ` Julien Grall
2019-08-12 14:53     ` Paul Durrant [this message]
2019-07-30 13:44 ` [Xen-devel] [PATCH 3/6] remove late (on-demand) construction of IOMMU page tables Paul Durrant
2019-08-01  8:05   ` Alexandru Stefan ISAILA
2019-08-07 10:31   ` Jan Beulich
2019-08-12 15:41     ` Paul Durrant
2019-08-12 16:26       ` Paul Durrant
2019-08-14  9:39         ` Paul Durrant
2019-08-27  7:48           ` Jan Beulich
2019-08-29  9:33             ` Paul Durrant
2019-08-29  9:52               ` Jan Beulich
2019-08-29 10:20                 ` Paul Durrant
2019-08-29 10:33                   ` Jan Beulich
2019-08-27  7:47         ` Jan Beulich
2019-08-27  7:45       ` Jan Beulich
2019-08-29  9:28         ` Paul Durrant
2019-07-30 13:44 ` [Xen-devel] [PATCH 4/6] make passthrough/pci.c:deassign_device() static Paul Durrant
2019-08-06 15:54   ` Jan Beulich
2019-08-14  9:42     ` Paul Durrant
2019-07-30 13:44 ` [Xen-devel] [PATCH 5/6] iommu: tidy up iommu_us_hap_pt() and need_iommu_pt_sync() macros Paul Durrant
2019-08-07 10:41   ` Jan Beulich
2019-08-14 10:13     ` Paul Durrant
2019-08-14 10:20       ` Julien Grall
2019-08-14 10:27         ` Paul Durrant
2019-08-14 10:44           ` Julien Grall
2019-08-14 11:11             ` Paul Durrant
2019-08-14 12:28               ` Julien Grall
2019-08-14 12:35                 ` Paul Durrant
2019-08-27  7:53       ` Jan Beulich
2019-07-30 13:44 ` [Xen-devel] [PATCH 6/6] introduce a 'passthrough' configuration option to xl.cfg Paul Durrant
2019-08-07 12:12   ` Jan Beulich
2019-08-14 10:40     ` Paul Durrant

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=4f7bc9db8dc34b5bbe392eb76546b230@AMSPEX02CL03.citrite.net \
    --to=paul.durrant@citrix.com \
    --cc=Andrew.Cooper3@citrix.com \
    --cc=George.Dunlap@citrix.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=brian.woods@amd.com \
    --cc=jbeulich@suse.com \
    --cc=julien.grall@arm.com \
    --cc=jun.nakajima@intel.com \
    --cc=kevin.tian@intel.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=suravee.suthikulpanit@amd.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).