linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/3] KVM: arm64: Consistently use free_removed_table() for stage-2
@ 2023-06-08 22:05 Chun-Tse Shao
  2023-06-08 22:05 ` [PATCH v1 2/3] KVM: arm64: Only initiate walk if page_count() > 1 in free_removed_table() Chun-Tse Shao
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Chun-Tse Shao @ 2023-06-08 22:05 UTC (permalink / raw)
  To: linux-kernel, yuzhao, oliver.upton
  Cc: Chun-Tse Shao, Marc Zyngier, James Morse, Suzuki K Poulose,
	Zenghui Yu, Catalin Marinas, Will Deacon, Ben Gardon, Gavin Shan,
	linux-arm-kernel, kvmarm

From: Oliver Upton <oliver.upton@linux.dev>

free_removed_table() is essential to the RCU-protected parallel walking
scheme, as behind the scenes the cleanup is deferred until an RCU grace
period. Nonetheless, the stage-2 unmap path calls put_page() directly,
which leads to table memory being freed inline with the table walk.

This is safe for the time being, as the stage-2 unmap walker is called
while holding the write lock. A future change to KVM will further relax
the locking mechanics around the stage-2 page tables to allow lock-free
walkers protected only by RCU. As such, switch to the RCU-safe mechanism
for freeing table memory.

Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
Signed-off-by: Chun-Tse Shao <ctshao@google.com>
---
 arch/arm64/kvm/hyp/pgtable.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c
index 5282cb9ca4cf..cc1af0286755 100644
--- a/arch/arm64/kvm/hyp/pgtable.c
+++ b/arch/arm64/kvm/hyp/pgtable.c
@@ -1042,7 +1042,7 @@ static int stage2_unmap_walker(const struct kvm_pgtable_visit_ctx *ctx,
 					       kvm_granule_size(ctx->level));
 
 	if (childp)
-		mm_ops->put_page(childp);
+		mm_ops->free_removed_table(childp, ctx->level);
 
 	return 0;
 }
-- 
2.41.0.162.gfafddb0af9-goog


_______________________________________________
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] 7+ messages in thread

end of thread, other threads:[~2023-06-09 22:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-08 22:05 [PATCH v1 1/3] KVM: arm64: Consistently use free_removed_table() for stage-2 Chun-Tse Shao
2023-06-08 22:05 ` [PATCH v1 2/3] KVM: arm64: Only initiate walk if page_count() > 1 in free_removed_table() Chun-Tse Shao
2023-06-08 22:05 ` [PATCH v1 3/3] KVM: arm64: Using rcu_read_lock() for kvm_pgtable_stage2_mkyoung() Chun-Tse Shao
2023-06-09  7:44   ` Marc Zyngier
2023-06-09 22:58     ` Chun-Tse Shao
2023-06-09 14:51   ` Oliver Upton
2023-06-08 22:13 ` [PATCH v1 1/3] KVM: arm64: Consistently use free_removed_table() for stage-2 Yu Zhao

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).