Re: [PATCH] KVM: arm64: account pKVM reclaim against the VM mm
From: Marc Zyngier
Date: Mon Jun 22 2026 - 05:16:32 EST
On Mon, 22 Jun 2026 09:32:45 +0100,
Fuad Tabba <fuad.tabba@xxxxxxxxx> wrote:
>
> On Sun, 21 Jun 2026 at 22:32, Bradley Morgan <include@xxxxxxxxx> wrote:
> >
> > Protected guest faults charge long term pins to the VM's mm. Teardown
> > can run later from file release, where current->mm may be unrelated.
> >
> > Drop the charge from kvm->mm instead.
> >
> > Fixes: 4e6e03f9eadd ("KVM: arm64: Hook up reclaim hypercall to pkvm_pgtable_stage2_destroy()")
> > Signed-off-by: Bradley Morgan <include@xxxxxxxxx>
>
> Reproduced by creating a protected VM, running the vCPU to fault in a
> page, then forking and having the child close the last fd reference.
> Without the fix, the parent's VmLck leaks (the reclaim decrements the
> child's mm, which is freed on exit). With the fix the parent's VmLck
> returns to zero.
>
> One minor observation: account_locked_vm() also passes `current` as
> the task pointer to __account_locked_vm(), but on the decrement path
> that is only used in the pr_debug log line, so it is technically wrong
> but functionally harmless.
I don't think this is wrong. Awkward, maybe. It is just that the
rlimit check and the accounting may be different contexts, and the
pr_debug() call covers both inc and dec.
>
> Reviewed-by: Fuad Tabba <fuad.tabba@xxxxxxxxx>
> Tested-by: Fuad Tabba < fuad.tabba@xxxxxxxxx>
Thanks,
M.
--
Without deviation from the norm, progress is not possible.