arm/arm64: KVM: Use kernel mapping to perform invalidation on page fault
authorMarc Zyngier <marc.zyngier@arm.com>
Mon, 4 May 2015 01:25:22 +0000 (09:25 +0800)
committerSasha Levin <sasha.levin@oracle.com>
Mon, 11 May 2015 11:07:36 +0000 (07:07 -0400)
commita49ecf872ec8870c32f5d9d412edae4033e87f12
tree25cea1b38112b9e477355499fa789987a3449bf0
parenta412dc06d66e6f32269b3825221dc323dcc2ede0
arm/arm64: KVM: Use kernel mapping to perform invalidation on page fault

commit 0d3e4d4fade6b04e933b11e69e80044f35e9cd60 upstream.

When handling a fault in stage-2, we need to resync I$ and D$, just
to be sure we don't leave any old cache line behind.

That's very good, except that we do so using the *user* address.
Under heavy load (swapping like crazy), we may end up in a situation
where the page gets mapped in stage-2 while being unmapped from
userspace by another CPU.

At that point, the DC/IC instructions can generate a fault, which
we handle with kvm->mmu_lock held. The box quickly deadlocks, user
is unhappy.

Instead, perform this invalidation through the kernel mapping,
which is guaranteed to be present. The box is much happier, and so
am I.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
arch/arm/include/asm/kvm_mmu.h
arch/arm/kvm/mmu.c
arch/arm64/include/asm/kvm_mmu.h