xen/arm: mm: flush_page_to_ram() only need to clean to PoC
authorJulien Grall <jgrall@amazon.com>
Sat, 20 Feb 2021 17:54:13 +0000 (17:54 +0000)
committerJulien Grall <jgrall@amazon.com>
Thu, 1 Apr 2021 16:12:05 +0000 (17:12 +0100)
At the moment, flush_page_to_ram() is both cleaning and invalidate to
PoC the page.

The goal of flush_page_to_ram() is to prevent corruption when the guest
has disabled the cache (the cache line may be dirty) and the guest to
read previous content.

Per this definition, the invalidating the line is not necessary. So
invalidating the cache is unnecessary. In fact, it may be counter-
productive as the line may be (speculatively) accessed a bit after.
So this will incurr an expensive access to the memory.

More generally, we should avoid interferring too much with cache.
Therefore, flush_page_to_ram() is updated to only clean to PoC the page.

The performance impact of this change will depend on your
workload/processor.

Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
xen/arch/arm/mm.c

index 59f8a3f15fd1c4880cb2a91498122578f619b0dd..2f11d214e1848e38d313bfe5d8b0c3486438ba2b 100644 (file)
@@ -529,7 +529,7 @@ void flush_page_to_ram(unsigned long mfn, bool sync_icache)
 {
     void *v = map_domain_page(_mfn(mfn));
 
-    clean_and_invalidate_dcache_va_range(v, PAGE_SIZE);
+    clean_dcache_va_range(v, PAGE_SIZE);
     unmap_domain_page(v);
 
     /*