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

Re: [Xen-devel] [PATCH] x86/iommu: remove usage of {set/clear}_identity_p2m_entry against PV domains


  • To: Roger Pau Monne <roger.pau@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxxxxx>
  • From: Jan Beulich <JBeulich@xxxxxxxx>
  • Date: Fri, 2 Aug 2019 13:09:44 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=suse.com;dmarc=pass action=none header.from=suse.com;dkim=pass header.d=suse.com;arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FXMGA8PJ9tktVGuoQm3bDAkUzzk7gqKlPjf/UKum6zA=; b=Z+xrrnJe+Frs1UBzrvOKjOV5MOthPnOMT4bvnIKe7COGTDjrsZJOF7g4kcm7Ord2jAaiXuYsjkgUWo65jo8M3DNgKxhOGrMRCWLOz0bejn5SaY1NH9yLumur3qhjxDFNdi9gT1Mr3EN4Lh1q+A+IZhyS5UI2hOw4uBXjmBjtNg0NZKArpKnE3BMA+FnA3JnCjwZyCYqiXGswZ9rHm36ZmHEPveiOJURA0J7ysV1WP6YZ1gnTlL2W+qtMDt5gs/xWE5l8vESOs+zKuyYgdzDpjLfqsHANibPB2wjs1zif5ZRP6Df7V9xLgpBJt+CCueknyc6g4WyEc4gzztfwaIeHtg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jfmpxBPp5QUB0dBy5ZQJcc/kw9k2uwbx6bB2RDO1NvRDaRA9rC4Ry5Pj64okX9pnO/U6zbt0Nbu3QL0RPc5YWSPhGeNjl9Mkoypr5q5BZJDmuvtAvTmndFgZ4El7BjrHAYG865sGWvq1dKpUi45noklO80QvIfc7m3BG8Rho8obzv4h59tCyEqotutkJ/6mMCeC0rNR/k9Jj1eY39MDogIVVrlpJNaplc6cOTG/lLMAGbWDtcGsuJnVM14yDc2hGgLG8Z7U4EVr/d7N6fhIgjE002qAn61d7CkEiclgCuXJY0/lj9yoRvBTkOPFvWqnW9UfsaW8gEuv18XBpU2voxA==
  • Authentication-results: spf=none (sender IP is ) smtp.mailfrom=JBeulich@xxxxxxxx;
  • Cc: Kevin Tian <kevin.tian@xxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roman Shaposhnik <roman@xxxxxxxxxx>, Paul Durrant <paul.durrant@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 02 Aug 2019 13:10:29 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHVSRQDW2EdzX2lDkO70Tmpo913oabn1O0A
  • Thread-topic: [Xen-devel] [PATCH] x86/iommu: remove usage of {set/clear}_identity_p2m_entry against PV domains

On 02.08.2019 11:22, Roger Pau Monne wrote:
> Switch rmrr_identity_mapping to use iommu_{un}map in order to
> establish RMRR mappings for PV domains, like it's done in
> arch_iommu_hwdom_init. This solves the issue of a PV hardware domain
> not getting RMRR mappings because {set/clear}_identity_p2m_entry was
> not properly updating the iommu page tables.

In which was this was not happening properly is still not really
understood, yet I think this (or at least a plausible theory) is
a prereq for any kind of fix. The code paths for PV and HVM are
probably different enough such that we don't need to be afraid
of there being a similar problem on the HVM side, but what if
there's a more general problem that we would better take care of,
rather perhaps than getting into a similarly puzzling situation
again later on.

> As rmrr_identity_mapping was the last user of
> {set/clear}_identity_p2m_entry against PV domains modify the function
> so it's only usable against translated domains, as the other p2m
> related functions.

Looking at the resulting code I'm actually not convinced that
this is a good move. I would, however, specifically like to
hear George's opinion here.

> @@ -1995,13 +1996,20 @@ static int rmrr_identity_mapping(struct domain *d, 
> bool_t map,
>   
>               while ( base_pfn < end_pfn )
>               {
> -                if ( clear_identity_p2m_entry(d, base_pfn) )
> -                    ret = -ENXIO;
> +                if ( paging_mode_translate(d) )
> +                    ret = clear_identity_p2m_entry(d, base_pfn);
> +                else
> +                    ret = iommu_unmap(d, _dfn(base_pfn), PAGE_ORDER_4K,
> +                                      &flush_flags);
>                   base_pfn++;
>               }
>   
>               list_del(&mrmrr->list);
>               xfree(mrmrr);
> +            /* Keep the previous error code if there's one. */
> +            err = iommu_iotlb_flush_all(d, flush_flags);
> +            if ( !ret )
> +                ret = err;
>               return ret;
>           }
>       }
> @@ -2011,8 +2019,13 @@ static int rmrr_identity_mapping(struct domain *d, 
> bool_t map,
>   
>       while ( base_pfn < end_pfn )
>       {
> -        int err = set_identity_p2m_entry(d, base_pfn, p2m_access_rw, flag);
> +        int err;
>   
> +        if ( paging_mode_translate(d) )
> +            err = set_identity_p2m_entry(d, base_pfn, p2m_access_rw, flag);
> +        else
> +            err = iommu_map(d, _dfn(base_pfn), _mfn(base_pfn), PAGE_ORDER_4K,
> +                            IOMMUF_readable | IOMMUF_writable, &flush_flags);
>           if ( err )
>               return err;
>           base_pfn++;
> @@ -2026,7 +2039,7 @@ static int rmrr_identity_mapping(struct domain *d, 
> bool_t map,
>       mrmrr->count = 1;
>       list_add_tail(&mrmrr->list, &hd->arch.mapped_rmrrs);
>   
> -    return 0;
> +    return iommu_iotlb_flush_all(d, flush_flags);

This is VT-d code - is there a particular reason why you go through
the generic code wrappers everywhere here?

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

 


Rackspace

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