diff mbox series

[v2,3/5] KVM: arm64: pkvm: Document the side effects of kvm_flush_dcache_to_poc()

Message ID 20230408160427.10672-4-maz@kernel.org (mailing list archive)
State New, archived
Headers show
Series KVM: arm64: Synchronise speculative page table walks on translation regime change | expand

Commit Message

Marc Zyngier April 8, 2023, 4:04 p.m. UTC
We rely on the presence of a DSB at the end of kvm_flush_dcache_to_poc()
that, on top of ensuring completion of the cache clean, also covers
the speculative page table walk started from EL1.

Document this dependency.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 arch/arm64/kvm/hyp/nvhe/mem_protect.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Oliver Upton April 13, 2023, 12:10 a.m. UTC | #1
On Sat, Apr 08, 2023 at 05:04:25PM +0100, Marc Zyngier wrote:
> We rely on the presence of a DSB at the end of kvm_flush_dcache_to_poc()
> that, on top of ensuring completion of the cache clean, also covers
> the speculative page table walk started from EL1.
> 
> Document this dependency.
> 
> Signed-off-by: Marc Zyngier <maz@kernel.org>

Reviewed-by: Oliver Upton <oliver.upton@linux.dev>
diff mbox series

Patch

diff --git a/arch/arm64/kvm/hyp/nvhe/mem_protect.c b/arch/arm64/kvm/hyp/nvhe/mem_protect.c
index 552653fa18be..2e9ec4a2a4a3 100644
--- a/arch/arm64/kvm/hyp/nvhe/mem_protect.c
+++ b/arch/arm64/kvm/hyp/nvhe/mem_protect.c
@@ -297,6 +297,13 @@  int __pkvm_prot_finalize(void)
 	params->vttbr = kvm_get_vttbr(mmu);
 	params->vtcr = host_mmu.arch.vtcr;
 	params->hcr_el2 |= HCR_VM;
+
+	/*
+	 * The CMO below not only cleans the updated params to the
+	 * PoC, but also provides the DSB that ensures ongoing
+	 * page-table walks that have started before we trapped to EL2
+	 * have completed.
+	 */
 	kvm_flush_dcache_to_poc(params, sizeof(*params));
 
 	write_sysreg(params->hcr_el2, hcr_el2);