Re: [RFC PATCH v2 12/23] KVM: x86/mmu: Introduce kvm_split_cross_boundary_leafs()
From: Huang, Kai
Date: Thu Nov 13 2025 - 06:40:36 EST
On Thu, 2025-11-13 at 11:02 +0000, Huang, Kai wrote:
> I am thinking dropping both "Hunk 1" and "Hunk 3". This at least makes
> kvm_split_cross_boundary_leafs() more reasonable, IMHO.
>
> Something like below:
>
> @@ -1558,7 +1558,9 @@ static int tdp_mmu_split_huge_page(struct kvm *kvm, struct
> tdp_iter *iter,
> static int tdp_mmu_split_huge_pages_root(struct kvm *kvm,
> struct kvm_mmu_page *root,
> gfn_t start, gfn_t end,
> - int target_level, bool shared)
> + int target_level, bool shared,
> + bool only_cross_boundary,
> + bool *split)
> {
> struct kvm_mmu_page *sp = NULL;
> struct tdp_iter iter;
> @@ -1584,6 +1586,9 @@ static int tdp_mmu_split_huge_pages_root(struct kvm *kvm,
> if (!is_shadow_present_pte(iter.old_spte) ||
> !is_large_pte(iter.old_spte))
> continue;
>
> + if (only_cross_boundary && !iter_cross_boundary(&iter, start,
> end))
> + continue;
> +
> if (!sp) {
> rcu_read_unlock();
>
> @@ -1618,6 +1623,7 @@ static int tdp_mmu_split_huge_pages_root(struct kvm *kvm,
> goto retry;
>
> sp = NULL;
> + *split = true;
> }
Forgot to say, if needed, we can update @split only when it is a valid pointer:
if (split)
*split = true;
This allows the caller to be able to just pass NULL when it doesn't care about
whether split has been done.