All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Xu, Quan" <quan.xu@intel.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Julien Grall <julien.grall@arm.com>,
	Stefano Stabellini <stefano.stabellini@citrix.com>,
	"dario.faggioli@citrix.com" <dario.faggioli@citrix.com>,
	"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: Re: [PATCH v2 07/11] IOMMU/MMU: propagate IOMMU Device-TLB flush error up to iommu_iotlb_flush{, _all} (top level ones).
Date: Wed, 27 Apr 2016 06:21:19 +0000	[thread overview]
Message-ID: <945CA011AD5F084CBEA3E851C0AB28894B894F62@SHSMSX101.ccr.corp.intel.com> (raw)
In-Reply-To: <571F7FCA02000078000E5D83@prv-mh.provo.novell.com>

On April 26, 2016 8:49 PM, Jan Beulich <JBeulich@suse.com> wrote:
> >>> On 26.04.16 at 14:23, <quan.xu@intel.com> wrote:
> > On April 25, 2016 6:19 PM,  Jan Beulich <JBeulich@suse.com> wrote:
> >> >>> On 18.04.16 at 16:00, <quan.xu@intel.com> wrote:
> >> > --- a/xen/common/memory.c
> >> > +++ b/xen/common/memory.c
> >> > @@ -678,8 +678,9 @@ static int xenmem_add_to_physmap(struct
> domain
> >> *d,
> >> >      if ( need_iommu(d) )
> >> >      {
> >> >          this_cpu(iommu_dont_flush_iotlb) = 0;
> >> > -        iommu_iotlb_flush(d, xatp->idx - done, done);
> >> > -        iommu_iotlb_flush(d, xatp->gpfn - done, done);
> >> > +        rc = iommu_iotlb_flush(d, xatp->idx - done, done);
> >> > +        if ( !rc )
> >> > +            rc = iommu_iotlb_flush(d, xatp->gpfn - done, done);
> >>
> >> And again - best effort flushing in all cases. I.e. you shouldn't
> >> bypass the second one if the first one failed, but instead properly
> >> accumulate the return value, and also again not clobber any negative value
> rc may already hold.
> >
> >
> > Thanks for correcting me. I did like accumulating the return value.
> > :( I will follow your suggestion in next v3.
> >
> >> What's worse (and makes me wonder whether this got tested) - you also
> >> clobber the positive return value this function may produce, even in
> >> the case the flushes succeed (and hence the function as a whole was
> successful).
> >>
> > I have tested it with previous patches (i.e.  1st patch), launching a
> > VM with PT ATS device to invoke this call tree.
> > btw, I fix the positive issue in 1st patch.
> > I know this is not strict, as I assume this patch set will be
> > committed at the same time.
> 
> Hmm, the "positive" here has nothing to do with the "positive" in patch 1.
> Please just have a look at xenmem_add_to_physmap() as a whole.
> 

Thanks for reminding me. The 'positive'  is ' rc = start + done'..

Think twice, I found I need two other new return values for this  function  (correct me if I am wrong!).
If the first iommu_iotlb_flush() is failed, I shouldn't  accumulate the return value of
the second iommu_iotlb_flush() -- but instead properly accumulate the return value.

The following is my modification:

--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -640,6 +640,10 @@ static int xenmem_add_to_physmap(struct domain *d,
     unsigned int done = 0;
     long rc = 0;

+#ifdef CONFIG_HAS_PASSTHROUGH
+    int ret, rv;
+#endif
+
     if ( xatp->space != XENMAPSPACE_gmfn_range )
         return xenmem_add_to_physmap_one(d, xatp->space, DOMID_INVALID,
                                          xatp->idx, xatp->gpfn);
@@ -678,8 +682,15 @@ static int xenmem_add_to_physmap(struct domain *d,
     if ( need_iommu(d) )
     {
         this_cpu(iommu_dont_flush_iotlb) = 0;
-        iommu_iotlb_flush(d, xatp->idx - done, done);
-        iommu_iotlb_flush(d, xatp->gpfn - done, done);
+        ret = iommu_iotlb_flush(d, xatp->idx - done, done);
+
+        if ( rc >= 0 && ret < 0 )
+            rc = ret;
+
+        rv = iommu_iotlb_flush(d, xatp->gpfn - done, done);
+
+        if ( rc >=0 && ret == 0 && rv < 0 )
+            rc = rv;
     }
 #endif


Quan

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  reply	other threads:[~2016-04-27  6:21 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-18 14:00 [PATCH v2 00/11] Check VT-d Device-TLB flush error Quan Xu
2016-04-18 14:00 ` [PATCH v2 01/11] vt-d: fix the IOMMU flush issue Quan Xu
2016-04-19  6:33   ` Tian, Kevin
2016-04-19  8:33     ` Xu, Quan
2016-04-25  9:22   ` Jan Beulich
2016-04-26  1:17     ` Xu, Quan
2016-04-26  2:18     ` Xu, Quan
2016-04-26  9:10       ` Jan Beulich
2016-04-26 10:15         ` Xu, Quan
2016-04-26 10:52           ` Jan Beulich
2016-04-26 10:58             ` Xu, Quan
2016-04-18 14:00 ` [PATCH v2 02/11] IOMMU: handle IOMMU mapping and unmapping failures Quan Xu
2016-04-19  6:36   ` Tian, Kevin
2016-04-19  6:40     ` Xu, Quan
2016-04-25  9:26   ` Jan Beulich
2016-04-27 14:26     ` Xu, Quan
2016-04-27 15:02       ` Jan Beulich
2016-04-28  1:23         ` Xu, Quan
2016-04-18 14:00 ` [PATCH v2 03/11] IOMMU/MMU: enhance the call trees of IOMMU unmapping and mapping Quan Xu
2016-04-19  6:44   ` Tian, Kevin
2016-04-20  5:27     ` Xu, Quan
2016-04-20  5:44       ` Tian, Kevin
2016-04-20  6:11       ` Jan Beulich
2016-04-20  6:26         ` Xu, Quan
2016-04-25  9:50   ` Jan Beulich
2016-04-27  8:49     ` Xu, Quan
2016-04-27  9:36       ` Jan Beulich
2016-04-27 13:10         ` Xu, Quan
2016-04-27 14:06           ` Jan Beulich
2016-04-27 15:48   ` George Dunlap
2016-04-28  1:18     ` Xu, Quan
2016-04-18 14:00 ` [PATCH v2 04/11] grant_table: avoid unnecessary work during grant table unmapping Quan Xu
2016-04-19  6:46   ` Tian, Kevin
2016-04-19 13:27     ` Xu, Quan
2016-04-20  5:35       ` Tian, Kevin
2016-04-25  9:55   ` Jan Beulich
2016-04-26  6:48     ` Xu, Quan
2016-04-18 14:00 ` [PATCH v2 05/11] vt-d: propagate IOMMU Device-TLB flush error up to IOMMU unmapping Quan Xu
2016-04-19  6:51   ` Tian, Kevin
2016-04-19  7:01     ` Xu, Quan
2016-04-25 10:06   ` Jan Beulich
2016-04-26  6:49     ` Xu, Quan
2016-04-18 14:00 ` [PATCH v2 06/11] vt-d: propagate IOMMU Device-TLB flush error up to IOMMU mapping Quan Xu
2016-04-19  6:53   ` Tian, Kevin
2016-04-18 14:00 ` [PATCH v2 07/11] IOMMU/MMU: propagate IOMMU Device-TLB flush error up to iommu_iotlb_flush{, _all} (top level ones) Quan Xu
2016-04-25 10:19   ` Jan Beulich
2016-04-26 12:23     ` Xu, Quan
2016-04-26 12:48       ` Jan Beulich
2016-04-27  6:21         ` Xu, Quan [this message]
2016-04-27  6:31           ` Jan Beulich
2016-04-27  9:08             ` Xu, Quan
2016-04-27  9:38               ` Jan Beulich
2016-04-18 14:00 ` [PATCH v2 08/11] IOMMU: propagate IOMMU Device-TLB flush error up to iommu_iotlb_flush{, _all} (leaf ones) Quan Xu
2016-04-19  6:58   ` Tian, Kevin
2016-04-19  8:58     ` Xu, Quan
2016-04-25 11:39   ` Jan Beulich
2016-04-26 11:50     ` Xu, Quan
2016-04-26 12:51       ` Jan Beulich
2016-04-26 13:20         ` Xu, Quan
2016-04-18 14:00 ` [PATCH v2 09/11] IOMMU: propagate IOMMU Device-TLB flush error up to IOMMU suspending Quan Xu
2016-04-25 11:52   ` Jan Beulich
2016-04-25 13:58     ` Julien Grall
2016-04-25 14:50       ` Xu, Quan
2016-04-26  9:40         ` Julien Grall
2016-04-26 11:28     ` Xu, Quan
2016-04-28 14:14     ` Xu, Quan
2016-04-28 14:36       ` Jan Beulich
2016-04-28 15:03         ` Xu, Quan
2016-04-28 15:12           ` Jan Beulich
2016-04-28 16:08             ` Xu, Quan
2016-04-29  2:20               ` Tian, Kevin
2016-04-29  2:41                 ` Xu, Quan
2016-04-29  7:13                   ` Jan Beulich
2016-04-29  8:23                     ` Xu, Quan
2016-04-18 14:00 ` [PATCH v2 10/11] vt-d: propagate IOMMU Device-TLB flush error up to vt-d hardware initialization Quan Xu
2016-04-18 14:00 ` [PATCH v2 11/11] vt-d: propagate error up to ME phantom function mapping and unmapping Quan Xu
2016-04-25 12:00   ` Jan Beulich
2016-04-26 10:48     ` Xu, Quan

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=945CA011AD5F084CBEA3E851C0AB28894B894F62@SHSMSX101.ccr.corp.intel.com \
    --to=quan.xu@intel.com \
    --cc=JBeulich@suse.com \
    --cc=dario.faggioli@citrix.com \
    --cc=julien.grall@arm.com \
    --cc=stefano.stabellini@citrix.com \
    --cc=xen-devel@lists.xen.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.