On Wed, Sep 06, 2023, Robin Murphy wrote: > On 2023-09-06 15:44, Sean Christopherson wrote: > > On Wed, Sep 06, 2023, Robin Murphy wrote: > > > Even non-virtualised, SWIOTLB is pretty horrible for I/O performance by its > > > very nature - avoiding it if at all possible should always be preferred. > > > > Yeah. The main reason I didn't just sweep this under the rug is the confidential > > VM use case, where SWIOTLB is used to bounce data from guest private memory into > > shread buffers. There's also a good argument that anyone that cares about I/O > > performance in confidential VMs should put in the effort to enlighten their device > > drivers to use shared memory directly, but practically speaking that's easier said > > than done. > > Indeed a bunch of work has gone into SWIOTLB recently trying to make it a > bit more efficient for such cases where it can't be avoided, so it is > definitely still interesting to learn about impacts at other levels like > this. Maybe there's a bit of a get-out for confidential VMs though, since > presumably there's not much point COW-ing encrypted private memory, so > perhaps KVM might end up wanting to optimise that out and thus happen to end > up less sensitive to unavoidable SWIOTLB behaviour anyway? CoW should be a non-issue for confidential VMs, at least on x86. SEV and SEV-ES are effectively forced to pin memory as writable before it can be mapped into the guest. TDX and SNP and will have a different implementation, but similar behavior. Confidential VMs would benefit purely by either eliminating or reducing the cost of "initializing" memory, i.e. by eliminating the memcpy() or replacing it with a memset(). I most definitely don't care enough about confidential VM I/O performance to try and micro-optimize that behavior, their existence was simply what made me look more closely instead of just telling Yan to stop using IDE :-)