[PATCH v5 01/25] KVM: arm64: Prefault host stage-2 entries on block split
Oliver Upton
oupton at kernel.org
Mon Nov 30 23:34:46 PST 2026
Hi Vincent,
On Mon, Nov 30, 2026 at 03:56:45PM +0000, Vincent Donnefort wrote:
> + pa = ALIGN_DOWN(ctx->addr, kvm_granule_size(ctx->level));
> + for (i = 0; i < PTRS_PER_PTE; ++i, ++ptep, pa += kvm_granule_size(ctx->level + 1)) {
> + kvm_pte_t pte = kvm_init_valid_leaf_pte(pa, block_pte, ctx->level + 1);
> +
> + /*
> + * Skip ptes in the range being modified by the caller if we're
> + * installing last level entries. Otherwise, we need to
> + * temporarily put in a valid mapping to make sure the
> + * prefaulting logic is triggered on the next
> + * stage2_map_walk_leaf(). This adds an unnecessary TLBI as
> + * we'll presumably re-break the freshly installed block, but
> + * that should happen very infrequently.
> + */
> + if ((ctx->level < (KVM_PGTABLE_LAST_LEVEL - 1)) ||
> + (pa < ctx->addr) || (pa >= ctx->end)) {
> + *ptep = pte;
> + if (counted)
> + ctx->mm_ops->get_page(ptep);
> + }
So the aim of doing a custom split function rather than reusing
kvm_pgtable_stage2_split() is eliding the temporary mappings? I'd
rather we have a single implementation of "replace block with fully
mapped table".
Thanks,
Oliver
> + }
> +}
> +
> static int stage2_map_walk_leaf(const struct kvm_pgtable_visit_ctx *ctx,
> struct stage2_map_data *data)
> {
> struct kvm_pgtable_mm_ops *mm_ops = ctx->mm_ops;
> + struct kvm_pgtable *pgt = data->mmu->pgt;
> kvm_pte_t *childp, new;
> int ret;
>
> @@ -1053,6 +1095,9 @@ static int stage2_map_walk_leaf(const struct kvm_pgtable_visit_ctx *ctx,
> if (!childp)
> return -ENOMEM;
>
> + if (pgt->flags & KVM_PGTABLE_S2_IDMAP)
> + stage2_map_prefault_idmap(ctx, childp);
> +
> if (!stage2_try_break_pte(ctx, data->mmu)) {
> mm_ops->put_page(childp);
> return -EAGAIN;
> @@ -1151,6 +1196,7 @@ int kvm_pgtable_stage2_annotate(struct kvm_pgtable *pgt, u64 addr, u64 size,
> return -EINVAL;
>
> ret = kvm_pgtable_walk(pgt, addr, size, &walker);
> + dsb(ishst);
> return ret;
> }
>
> --
> 2.56.1.839.g22a8290db9-goog
>
>
More information about the linux-arm-kernel
mailing list