Thread (3 messages) 3 messages, 2 authors, 2023-05-31

Re: [PATCH mm-unstable v2 04/10] kvm/arm64: make stage2 page tables RCU safe

From: Yu Zhao <hidden>
Date: 2023-05-31 23:11:37
Also in: kvm, kvmarm, linux-arm-kernel, linux-doc, linux-trace-kernel, lkml
Subsystem: arm64 port (aarch64 architecture), kernel virtual machine for arm64 (kvm/arm64), the rest · Maintainers: Catalin Marinas, Will Deacon, Marc Zyngier, Oliver Upton, Linus Torvalds

Possibly related (same subject, not in this thread)

On Wed, May 31, 2023 at 1:28 PM Oliver Upton [off-list ref] wrote:
On Tue, May 30, 2023 at 02:06:55PM -0600, Yu Zhao wrote:
quoted
On Tue, May 30, 2023 at 1:37 PM Oliver Upton [off-list ref] wrote:
quoted
Hi Yu,

On Sat, May 27, 2023 at 02:13:07PM -0600, Yu Zhao wrote:
quoted
On Sat, May 27, 2023 at 12:08 PM Oliver Upton [off-list ref] wrote:
quoted
diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c
index 3d61bd3e591d..bfbebdcb4ef0 100644
--- a/arch/arm64/kvm/hyp/pgtable.c
+++ b/arch/arm64/kvm/hyp/pgtable.c
@@ -1019,7 +1019,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);
Thanks, Oliver.

A couple of things I haven't had the chance to verify -- I'm hoping
you could help clarify:
1. For unmapping, with free_removed_table(), wouldn't we have to look
into the table we know it's empty unnecessarily?
As it is currently implemented, yes. But, there's potential to fast-path
the implementation by checking page_count() before starting the walk.
Do you mind posting another patch? I'd be happy to ack it, as well as
the one you suggested above.
I'd rather not take such a patch independent of the test_clear_young
series if you're OK with that. Do you mind implementing something
similar to the above patch w/ the proposed optimization if you need it?
No worries. I can take the above together with the following, which
would form a new series with its own merits, since apparently you
think the !AF case is important.
diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
index 26a8d955b49c..6ce73ce9f146 100644
--- a/arch/arm64/kvm/mmu.c
+++ b/arch/arm64/kvm/mmu.c
@@ -1453,10 +1453,10 @@ static void handle_access_fault(struct
kvm_vcpu *vcpu, phys_addr_t fault_ipa)

        trace_kvm_access_fault(fault_ipa);

-       read_lock(&vcpu->kvm->mmu_lock);
+       rcu_read_lock();
        mmu = vcpu->arch.hw_mmu;
        pte = kvm_pgtable_stage2_mkyoung(mmu->pgt, fault_ipa);
-       read_unlock(&vcpu->kvm->mmu_lock);
+       rcu_read_unlock();

        if (kvm_pte_valid(pte))
                kvm_set_pfn_accessed(kvm_pte_to_pfn(pte));
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help