[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v2 03/11] IOMMU/MMU: enhance the call trees of IOMMU unmapping and mapping



On April 25, 2016 5:51 PM, Jan Beulich <JBeulich@xxxxxxxx> wrote:
> >>> On 18.04.16 at 16:00, <quan.xu@xxxxxxxxx> wrote:
> > --- a/xen/arch/x86/mm.c
> > +++ b/xen/arch/x86/mm.c
> > @@ -2467,7 +2467,7 @@ static int __get_page_type(struct page_info
> *page, unsigned long type,
> >                             int preemptible)  {
> >      unsigned long nx, x, y = page->u.inuse.type_info;
> > -    int rc = 0;
> > +    int rc = 0, ret = 0;
> >
> >      ASSERT(!(type & ~(PGT_type_mask | PGT_pae_xen_l2)));
> >
> > @@ -2578,11 +2578,11 @@ static int __get_page_type(struct page_info
> *page, unsigned long type,
> >          if ( d && is_pv_domain(d) && unlikely(need_iommu(d)) )
> >          {
> >              if ( (x & PGT_type_mask) == PGT_writable_page )
> > -                iommu_unmap_page(d, mfn_to_gmfn(d, page_to_mfn(page)));
> > +                ret = iommu_unmap_page(d, mfn_to_gmfn(d,
> > + page_to_mfn(page)));
> >              else if ( type == PGT_writable_page )
> > -                iommu_map_page(d, mfn_to_gmfn(d, page_to_mfn(page)),
> > -                               page_to_mfn(page),
> > -                               IOMMUF_readable|IOMMUF_writable);
> > +                ret = iommu_map_page(d, mfn_to_gmfn(d, page_to_mfn(page)),
> > +                                     page_to_mfn(page),
> > +
> > + IOMMUF_readable|IOMMUF_writable);
> >          }
> >      }
> >
> > @@ -2599,6 +2599,9 @@ static int __get_page_type(struct page_info
> *page, unsigned long type,
> >      if ( (x & PGT_partial) && !(nx & PGT_partial) )
> >          put_page(page);
> >
> > +    if ( unlikely(ret) )
> > +        rc = ret;
> 
> Please don't overwrite the more relevant "rc" value in situations like this in
> case that is already non-zero. In this specific case you can actually get away
> without introducing a second error code variable, since the only place rc gets
> altered is between the two hunks above, and overwriting the rc value from
> map/unmap is then exactly what we want (but I'd much appreciate if you
> added a comment to this effect).
> 


Make sense. 
I hope I have got your point.. then, I will modify it as below:


--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -2578,11 +2578,11 @@ static int __get_page_type(struct page_info *page, 
unsigned long type,
         if ( d && is_pv_domain(d) && unlikely(need_iommu(d)) )
         {
             if ( (x & PGT_type_mask) == PGT_writable_page )
-                iommu_unmap_page(d, mfn_to_gmfn(d, page_to_mfn(page)));
+                rc = iommu_unmap_page(d, mfn_to_gmfn(d, page_to_mfn(page)));
             else if ( type == PGT_writable_page )
-                iommu_map_page(d, mfn_to_gmfn(d, page_to_mfn(page)),
-                               page_to_mfn(page),
-                               IOMMUF_readable|IOMMUF_writable);
+                rc = iommu_map_page(d, mfn_to_gmfn(d, page_to_mfn(page)),
+                                    page_to_mfn(page),
+                                    IOMMUF_readable|IOMMUF_writable);
         }
     }

@@ -2593,6 +2593,8 @@ static int __get_page_type(struct page_info *page, 
unsigned long type,
             page->nr_validated_ptes = 0;
             page->partial_pte = 0;
         }
+
+        /* Overwrite the rc value from IOMMU map and unmap. */
         rc = alloc_page_type(page, type, preemptible);
     }


btw, I am clumsy at comment, I'd be pleased if you could help me enhance it.


> > --- a/xen/arch/x86/mm/p2m-ept.c
> > +++ b/xen/arch/x86/mm/p2m-ept.c
> > @@ -665,7 +665,7 @@ ept_set_entry(struct p2m_domain *p2m, unsigned
> long gfn, mfn_t mfn,
> >      ept_entry_t *table, *ept_entry = NULL;
> >      unsigned long gfn_remainder = gfn;
> >      unsigned int i, target = order / EPT_TABLE_ORDER;
> > -    int ret, rc = 0;
> > +    int ret, err = 0, rc = 0;
> 
> Just like Kevin, and despite your reply to him I do not see the need fir the 
> 3rd
> error indicator variable here:
> 
Agreed.

> > @@ -182,10 +184,20 @@ void __hwdom_init iommu_hwdom_init(struct
> domain *d)
> >                   ((page->u.inuse.type_info & PGT_type_mask)
> >                    == PGT_writable_page) )
> >                  mapping |= IOMMUF_writable;
> > -            hd->platform_ops->map_page(d, gfn, mfn, mapping);
> > +
> > +            ret = hd->platform_ops->map_page(d, gfn, mfn, mapping);
> > +
> > +            if ( unlikely(ret) )
> > +                rc = ret;
> > +
> >              if ( !(i++ & 0xfffff) )
> >                  process_pending_softirqs();
> >          }
> > +
> > +        if ( rc )
> > +            printk(XENLOG_G_ERR
> > +                   "dom%d: IOMMU mapping is failed for hardware domain.",
> > +                   d->domain_id);
> 
> Leaving the admin / developer with no indication of at least one specific case
> of a page where a failure occurred. As said in various places before: Log
> messages should provide useful information for at least getting started at
> investigating the issue, without first of all having to further instrument the
> code.
> 
> In any event the "is" should be dropped from the text.
> 

What about:

+        if ( rc )
+            printk(XENLOG_WARNING
+                   "iommu_hwdom_init: IOMMU mapping failed for dom%d.",
+                   d->domain_id);

If this is still not what you want, could you help me enhance it and I can
follow it as a pattern. Sorry to bother you with such a case.


Quan

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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.