Re: [PATCH v2 11/12] KVM: arm64: CCA: Support runtime faulting of memory

From: Fuad Tabba

Date: Tue Nov 17 2026 - 11:19:43 EST


Hi Suzuki,

(sorry for the resend, my email client mangled the first one)

On Mon, 16 Nov 2026 18:36:29 +0000, Suzuki K Poulose
<suzuki.poulose@xxxxxxx> wrote:
> On 11/11/2026 14:57, Steven Price wrote:
[...]
> > diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
[...]
> > @@ -1791,12 +1799,18 @@ static int gmem_abort(const struct kvm_s2_fault_desc *s2fd,
> > void *memcache = NULL;
> > gfn_t canonical_gfn;
> > int ret;
> > + bool is_private = false;
> >
> > - if (!perm_fault) {
> > + if (KVM_BUG_ON(!kvm_slot_has_gmem(s2fd->memslot), kvm))
> > + return -EINVAL;
> > +
> > + if (!perm_fault || kvm_arch_has_private_mem(kvm)) {
>
> should this be s/kvm_arch_has_private_mem/kvm_vm_is_realm ? I dont think
> this would be required for pKVM yet ?
>
> Also, I wonder why pKVM doesnt need mmu cache pages with permission
> faults with gmem. They do for user_mem_abort().
> (may be because they assume Gmem is always single page ? in which case
> we could also have the same behavior)

gmem_abort() only maps single pages, so a permission fault there just
relaxes permissions and doesn't use the memcache. In user_mem_abort(),
a pKVM permission fault can map a block, and that uses the memcache.
So yes, the top-up on a permission fault here is only for Realms.

[...]
> > @@ -1817,13 +1831,35 @@ static int gmem_abort(const struct kvm_s2_fault_desc *s2fd,
> > /* Pairs with the smp_wmb() in kvm_mmu_invalidate_end(). */
> > smp_rmb();
> >
> > + if (kvm_arch_has_private_mem(kvm)) {
>
> --8>--
>
> > + switch (kvm->arch.vm_flavor) {
> > + case VM_REALM:
> > + is_private = kvm_realm_is_private_address(&kvm->arch.realm,
> > + s2fd->fault_ipa);
>
> Could we for now use
> is_private = private_ipa_fault(kvm, s2fd->fault_ipa);
>
> In other words use a wrapper for detecting if a given ipa is private or
> not ? May be something like: kvm_ipa_is_private(kvm, ipa)? (choose ipa
> to make it explicit, it is arm64 thing).
>
> Where, pKVM could hook in its own check.
I'd keep the switch. pKVM can add its own case when it uses this path.

Cheers,
/fuad