On 06/05/2025 9:31 am, Roger Pau Monne wrote: > When a guest is allowed access to cache control operations such tracking > prevents having to issue a system-wide cache flush, and rather just flush > the pCPUs where the vCPU has been scheduled since the last flush. > > Note that domain-wide flushes accumulate the dirty caches from all the > vCPUs, but clearing the vCPU masks will require pausing all vCPUs, which > seems overkill. Instead leave the vCPU dirty masks as-is, worse case it > will result in redundant flushes in further calls. > > Signed-off-by: Roger Pau Monné <roger....@citrix.com>
I'm afraid this doesn't work. Unlike TLBs, dirty cacheline can move sideways, e.g. by foreign or grant mapping, but also naturally because of how cache coherency works. We need to use the guarantees given to us by the architecture to simply nop out cache flushes when safe to do so. Everything else is either a shootdown (clflush/opt/clwb, and doesn't even trap to Xen), or needs to be a global WB{NO,}INVD. Partial WBINVDs are of no value. ~Andrew