]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
KVM: arm/arm64: Clean dcache to PoC when changing PTE due to CoW
authorMarc Zyngier <marc.zyngier@arm.com>
Thu, 23 Aug 2018 08:58:27 +0000 (09:58 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Sep 2018 20:41:21 +0000 (22:41 +0200)
commit9e7e9f25ef3e91790d6ecc900d3548cebfd0f221
tree894729e7e57f9b999ebc99a0aad519cb8ca2b454
parenta2359d3d80fe242394513d2e4ac568d071537e16
KVM: arm/arm64: Clean dcache to PoC when changing PTE due to CoW

commit 694556d54f354d3fe43bb2e61fd6103cca2638a4 upstream.

When triggering a CoW, we unmap the RO page via an MMU notifier
(invalidate_range_start), and then populate the new PTE using another
one (change_pte). In the meantime, we'll have copied the old page
into the new one.

The problem is that the data for the new page is sitting in the
cache, and should the guest have an uncached mapping to that page
(or its MMU off), following accesses will bypass the cache.

In a way, this is similar to what happens on a translation fault:
We need to clean the page to the PoC before mapping it. So let's just
do that.

This fixes a KVM unit test regression observed on a HiSilicon platform,
and subsequently reproduced on Seattle.

Fixes: a9c0e12ebee5 ("KVM: arm/arm64: Only clean the dcache on translation fault")
Cc: stable@vger.kernel.org # v4.16+
Reported-by: Mike Galbraith <efault@gmx.de>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
virt/kvm/arm/mmu.c