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

RE: [PATCH] IOMMU: avoid double flushing in shared page table case


  • To: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: "Tian, Kevin" <kevin.tian@xxxxxxxxx>
  • Date: Fri, 23 Oct 2020 06:28:02 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.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=f8XxxAvJfuAo9wQvDsy7omotezTw048hqHDi1GsBNPI=; b=VSvQRoE6rsRX8wLCwgBihczCCQVLQA+JjN15QuGAMJiG1dSB8mvKyz8yPlqyH0oVzYRUR/qf1vlhBuGcTpPD4Pbes0bBrJ8qvqzsH4hSC/JdF9QEX7j8ddes3tiM7qh3ygF4ha55A5ESpIWI+kTfDCTTOn48vw/QRHVZPE4MSDPVlS4faTHjvvQveqgvjkJH5Kt0eXcApXPI/CGYoIhofblH/8rXN1DQsQE8wkv4MVkNfEfCjyO/SW8MXQVp1VdWSna81sRWX5yH0AI04eQf9qbHIfBnf0++Fs0vNQHOCLpmrifHJ8LLtN1vWFJdEIufWEe12FU/NW+TQPH6vzKeiw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c1OQ72WkfJFzQKu5sXnSD2bf2L0ISTvgHZhOcBM5NUZNIvrgsTbbBu/4sJS9N5RTqqtzEA5tnn6nyN/UZfRnLbE1ASaC+dPUNDWJYKpF3303+67hTD4QrheRt7WDM8jB8rwWRMPLsmdnEqn+7a51uppZgG/PGNZFc/23NQeswZCVOZSxhBYBgRC1SxseYstjGMyri02LX3HXTbV9/MPBLn9/Z9pHOzgtuUh/TgDvTvx4EgG5A24d+fkyNQwcWAjir86WJVVWtN1lJ+8LpInvA+Cdh72v4pEUG+4dQ6NIlcmTZ/hLqZU16FRxKyai4Pd4wLb+ZRVriK1wy21oYZQ4Zw==
  • Authentication-results: suse.com; dkim=none (message not signed) header.d=none;suse.com; dmarc=none action=none header.from=intel.com;
  • Cc: "Cooper, Andrew" <andrew.cooper3@xxxxxxxxxx>, George Dunlap <George.Dunlap@xxxxxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Wei Liu <wl@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "Nakajima, Jun" <jun.nakajima@xxxxxxxxx>, "Paul Durrant" <paul@xxxxxxx>
  • Delivery-date: Fri, 23 Oct 2020 06:28:24 +0000
  • Dlp-product: dlpe-windows
  • Dlp-reaction: no-action
  • Dlp-version: 11.5.1.3
  • Ironport-sdr: qgP7VG7/f8BrYJsRkYUIP35PVdvsYFX4XxfuKxMJtfd9qvpYZftsQhkVFiakONLmiG95O8q7eK IxLGF49REC4w==
  • Ironport-sdr: lf498Q5QhkfcmkxGIUFxXi66Ge+t9y1l8e5Y6TgWOkBF9qDl0NVboAtNpz1GwqaAHE53v2a/OR 7hlgMRvNxYHA==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHWpuhdf0WK+guU3Ei2udEaPDozGamkvWZg
  • Thread-topic: [PATCH] IOMMU: avoid double flushing in shared page table case

> From: Jan Beulich <jbeulich@xxxxxxxx>
> Sent: Tuesday, October 20, 2020 9:53 PM
> 
> While the flush coalescing optimization has been helping the non-shared
> case, it has actually lead to double flushes in the shared case (which
> ought to be the more common one nowadays at least): Once from
> *_set_entry() and a second time up the call tree from wherever the
> overriding flag gets played with. In alignment with XSA-346 suppress
> flushing in this case.
> 
> Similarly avoid excessive setting of IOMMU_FLUSHF_added on the batched
> flushes: "idx" hasn't been added a new mapping for.
> 
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>

> ---
> TBD: The Arm part really is just for completeness (and hence could also
>      be dropped) - the affected mapping spaces aren't currently
>      supported there.
> 
> --- a/xen/arch/arm/p2m.c
> +++ b/xen/arch/arm/p2m.c
> @@ -1045,7 +1045,7 @@ static int __p2m_set_entry(struct p2m_do
>          p2m->lowest_mapped_gfn = gfn_min(p2m->lowest_mapped_gfn, sgfn);
>      }
> 
> -    if ( is_iommu_enabled(p2m->domain) &&
> +    if ( is_iommu_enabled(p2m->domain)
> && !this_cpu(iommu_dont_flush_iotlb) &&
>           (lpae_is_valid(orig_pte) || lpae_is_valid(*entry)) )
>      {
>          unsigned int flush_flags = 0;
> --- a/xen/arch/x86/mm/p2m-ept.c
> +++ b/xen/arch/x86/mm/p2m-ept.c
> @@ -842,7 +842,7 @@ out:
>      if ( rc == 0 && p2m_is_hostp2m(p2m) &&
>           need_modify_vtd_table )
>      {
> -        if ( iommu_use_hap_pt(d) )
> +        if ( iommu_use_hap_pt(d) && !this_cpu(iommu_dont_flush_iotlb) )
>              rc = iommu_iotlb_flush(d, _dfn(gfn), 1ul << order,
>                                     (iommu_flags ? IOMMU_FLUSHF_added : 0) |
>                                     (vtd_pte_present ? IOMMU_FLUSHF_modified
> --- a/xen/common/memory.c
> +++ b/xen/common/memory.c
> @@ -870,7 +870,7 @@ int xenmem_add_to_physmap(struct domain
>          this_cpu(iommu_dont_flush_iotlb) = 0;
> 
>          ret = iommu_iotlb_flush(d, _dfn(xatp->idx - done), done,
> -                                IOMMU_FLUSHF_added | IOMMU_FLUSHF_modified);
> +                                IOMMU_FLUSHF_modified);
>          if ( unlikely(ret) && rc >= 0 )
>              rc = ret;
> 

 


Rackspace

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