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

Re: [PATCH 4/5] VT-d: restrict iommu_flush_all() to cache writeback


  • To: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Wed, 19 Apr 2023 21:46:08 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=c77FjfaBuZdj5rwIN+hqJQqXOUBWPnGOnHHzw1Z7E5M=; b=PJGCRYG02Xe0nws0qk0sZgKO3jlBt12NnhVLHYBOmX1t8aUg5ct7VzWhpjQV4XWKnAQnQgCYZb4ZiM/9acbkLJuw9Iiiup/NklemL7ZpDC+mSclopiigpcEeVZVI89TsItS6I/MSWAsAok6QNGiKYSPIpBFbqE/9YM7IgGD+ciYuvqtzvHc2Hpgybfl68Kc4R6KXYPum4jyQxvo6reCXRlJSFsR9Pc96cv0hRJjOOikrHUfFG0Q/DvOX2UL4hdInn8eGCJIe9WN+uWGvzUwUtgPzyVZ+09IcdIvUfLGqMqLw9DaQgOwzKjUlv4AhvO+HlyOKSv36hJzOok74sfoSTw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H7CqOKPamWW7vVBs/lOrg1I9DiBJcNgBJxqCG0qMGMA5tk7Ja4eeK+6tRogxPXL+gYp1L1wJvSYqMISSS5naIsShBenMeZdXQcMZRn/638jTlqBEsRnpyhWYYl9mIj86V3oqtcouSiSh0Tmg+0LZ9c0bdCj1gN9WHZvrMoc8yttx/1r+Huuxt+p7yJFfPvr+bH9r0joRQqz0orGuzgi5oaeqYYk+wNxcx1WysitgGNI7nY/+YaKqL/LyXalRI3lh3PZ0y1IJqzxxwVnVMdgKwa7REtl/5lzTJXbF5Bzp0KevZ3OSPGB6l9BcfJa11aR0T11mHftJvGfu/Q5bVlHJHg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Kevin Tian <kevin.tian@xxxxxxxxx>
  • Delivery-date: Wed, 19 Apr 2023 20:46:49 +0000
  • Ironport-data: A9a23:22t8aaBARMG6chVW/xHiw5YqxClBgxIJ4kV8jS/XYbTApGhx0j1Sz GQWWGuBMv3eN2byLdlwaduwoR9U65TRy9dnQQY4rX1jcSlH+JHPbTi7wuUcHAvJd5GeExg3h yk6QoOdRCzhZiaE/n9BCpC48T8nk/nOHuGmYAL9EngZbRd+Tys8gg5Ulec8g4p56fC0GArIs t7pyyHlEAbNNwVcbyRFuspvlDs15K6p4G9B7wRkDRx2lAS2e0c9Xcp3yZ6ZdxMUcqEMdsamS uDKyq2O/2+x13/B3fv8z94X2mVTKlLjFVDmZkh+AsBOsTAbzsAG6Y4pNeJ0VKtio27hc+ada jl6ncfYpQ8BZsUgkQmGOvVSO3kW0aZuoNcrLZUj2CA6IoKvn3bEmp1T4E8K0YIw/t0pC35St twiBjkAVTmS2uWznLuRc7w57igjBJGD0II3nFhFlGucKMl8BJfJTuPN+MNS2yo2ioZWB/HCa sEFaD1pKhPdfxlIPVRRA5U79AuqriCnL3sE9xTL++xrvgA/zyQouFTpGPPTdsaHWoN+mUGAq 3id12/4HgsbJJqUzj/tHneE37eSwHuhCdpCfFG+3vtPuFms2jNCNDgbFgKrgKKiiFKDYesKf iT4/QJr98De7neDTNPwQhm5q36spQMHVpxbFOhSwBGAzO/Y7hiUAkAATyVdc5o2uckuXzso2 1SV2dTzClRHr7m9WX+bsLCOoluaOiULLGlEeS4NSyME5cXupMc4iRenczp4OKu8j9mwHC6qx TmP9XI6n+9L0ZNN0Lin91fahT7qvoLOUgM++gTQWCSi8x99Y4mmIYev7DA38Mp9EWpQdXHZ1 FBspiRUxLlm4U2l/MBVfNgwIQ==
  • Ironport-hdrordr: A9a23:aM6fta+7/ZzpYYuS50Buk+AcI+orL9Y04lQ7vn2ZKSY5TiX4rb HKoB1/73XJYVkqN03I9ervBEDiewK/yXcW2+ks1N6ZNWGLhILBFupfBODZsl7d8kPFl9K01c 1bAtJD4N+bNykGsS4tijPIb+rJw7O8gd+Vbf+19QYIcenzAZsQlzuQDGygYypLbTgDP7UVPr yG6PFKojKxEE5nFfhSVhE+Lo7+T8SgruOeXSI7
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 19/04/2023 11:46 am, Jan Beulich wrote:
> We don't need to invalidate caches here; all we're after is that earlier
> writes have made it to main memory (and aiui even that just in case).
>
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> ---
> This, aiui, being an analogue to uses of iommu_sync_cache() (just not
> range restricted), I wonder whether it shouldn't be conditional upon
> iommu_non_coherent. Then again I'm vaguely under the impression that
> we had been here before, possibly even as far as questioning the need
> for this call altogether.

I'd far rather we fix it property than continue to massage around the
sides of known-broken logic.

Coherency, or not, of the memory accesses of an IOMMU is a per-IOMMU
property, not a system-wide property.  What the iommu_non_coherent
global boolean currently does for us is enforce cache maintenance on all
IOMMUs, even the coherent ones, when any single IOMMU in the system is
non-coherent.

Inside the IOMMU driver, cache maintenance should depend on iommu->ecap
alone, disregarding anything else.  This will improve the performance on
any system with mixed coherent and non-coherent IOMMUs, without any
other behavioural impact.

The complication comes in in p2m-ept when we're sharing EPT and IOMMU
pagetables, because the EPT can be accessed by more than one IOMMU if
the guest has devices behind different IOMMUs.

But we know the devices assigned to the domain.  They're almost always
static for the lifetime of the domain, and generally single device only,
so there may be value in considering a per-domain "I've got a
non-coherent IOMMU" flag, because we absolutely don't want to be walking
the list of attached IOMMUs on each EPT update.


But...

SandyBridge era systems are the only ones I'm aware of where the IOMMUs
advertise themselves as non-coherent.  And on that generation we quirk
the superpage capability off anyway, meaning they are ineligible for
HAP-PT sharing anyway.

And if we are doing HAP-PT sharing, the cache maintenance for regular
EPT updates will be crippling for CPU performance, especially as the
software bit updates are not relevant to the IOMMU anyway.

A better option would be to simply disallow HAP-PT sharing when there's
a non-coherent IOMMU in the system, or (slightly more fine grained) to
disallow adding a device behind a non-coherent IOMMU to a domain using
HAP-PT sharing (as there's a disable now anyway).

Either will reduce the complexity of Xen's code without any loss of
functionality in real systems AFAICT.

~Andrew



 


Rackspace

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