linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: arm64: Do not flush memslot if FWB is supported
@ 2020-09-15 17:04 Alexandru Elisei
  2020-09-18 15:56 ` Marc Zyngier
  0 siblings, 1 reply; 2+ messages in thread
From: Alexandru Elisei @ 2020-09-15 17:04 UTC (permalink / raw)
  To: linux-arm-kernel, kvmarm
  Cc: yuzenghui, maz, james.morse, julien.thierry.kdev, suzuki.poulose

As a result of a KVM_SET_USER_MEMORY_REGION ioctl, KVM flushes the
dcache for the memslot being changed to ensure a consistent view of memory
between the host and the guest: the host runs with caches enabled, and
it is possible for the data written by the hypervisor to still be in the
caches, but the guest is running with stage 1 disabled, meaning data
accesses are to Device-nGnRnE memory, bypassing the caches entirely.

Flushing the dcache is not necessary when KVM enables FWB, because it
forces the guest to uses cacheable memory accesses.

The current behaviour does not change, as the dcache flush helpers execute
the cache operation only if FWB is not enabled, but walking the stage 2
table is avoided.

Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
---
 arch/arm64/kvm/mmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
index 9a636b8064f1..c29105c6e975 100644
--- a/arch/arm64/kvm/mmu.c
+++ b/arch/arm64/kvm/mmu.c
@@ -2537,7 +2537,7 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,
 	spin_lock(&kvm->mmu_lock);
 	if (ret)
 		unmap_stage2_range(&kvm->arch.mmu, mem->guest_phys_addr, mem->memory_size);
-	else
+	else if (!cpus_have_final_cap(ARM64_HAS_STAGE2_FWB))
 		stage2_flush_memslot(kvm, memslot);
 	spin_unlock(&kvm->mmu_lock);
 out:
-- 
2.28.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] KVM: arm64: Do not flush memslot if FWB is supported
  2020-09-15 17:04 [PATCH] KVM: arm64: Do not flush memslot if FWB is supported Alexandru Elisei
@ 2020-09-18 15:56 ` Marc Zyngier
  0 siblings, 0 replies; 2+ messages in thread
From: Marc Zyngier @ 2020-09-18 15:56 UTC (permalink / raw)
  To: linux-arm-kernel, Alexandru Elisei, kvmarm

On Tue, 15 Sep 2020 18:04:42 +0100, Alexandru Elisei wrote:
> As a result of a KVM_SET_USER_MEMORY_REGION ioctl, KVM flushes the
> dcache for the memslot being changed to ensure a consistent view of memory
> between the host and the guest: the host runs with caches enabled, and
> it is possible for the data written by the hypervisor to still be in the
> caches, but the guest is running with stage 1 disabled, meaning data
> accesses are to Device-nGnRnE memory, bypassing the caches entirely.
> 
> [...]

Applied to next, thanks!

[1/1] KVM: arm64: Do not flush memslot if FWB is supported
      commit: ada329e6b5b406f33fae665e62caff7814409906

Cheers,

	M.
-- 
Without deviation from the norm, progress is not possible.



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-18 15:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-15 17:04 [PATCH] KVM: arm64: Do not flush memslot if FWB is supported Alexandru Elisei
2020-09-18 15:56 ` Marc Zyngier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).