[PATCH v4 21/23] KVM: arm64: Add PKVM_HYP_REQ_SPLIT

Vincent Donnefort vdonnefort at google.com
Thu Nov 26 12:04:28 PST 2026


On Mon, Nov 23, 2026 at 08:49:00PM +0000, Fuad Tabba wrote:
> Hi Vincent,
> 
> On Tue, 17 Nov 2026 17:44:00 +0000, Vincent Donnefort
> <vdonnefort at google.com> wrote:
> [...]
> > diff --git a/arch/arm64/kvm/pkvm.c b/arch/arm64/kvm/pkvm.c
> > index c55b6d442d0e..58ca7ffa68e3 100644
> > --- a/arch/arm64/kvm/pkvm.c
> > +++ b/arch/arm64/kvm/pkvm.c
> [...]
> > +static int __pkvm_pgtable_stage2_split(struct kvm_vcpu *vcpu, phys_addr_t ipa, u64 size)
> > +{
> [...]
> > +        ret = folio_add_pins(page_folio(pfn_to_page(mapping->pfn)), nr_pages);
> > +        if (ret)
> > +                goto unlock_mmu;
> > +
> > +        ret = kvm_call_hyp_nvhe(__pkvm_host_split_guest, gpa_to_gfn(ipa), size / PAGE_SIZE);
> > +        if (ret) {
> > +                for (int i = 0; i < nr_pages; i++)
> > +                        unpin_user_page(pfn_to_page(mapping->pfn + 1 + i));
> > +                goto unlock_mmu;
> > +        }
> 
> Could you use unpin_user_folio() here, to mirror folio_add_pins()?

Ack.

> 
> [...]
> > @@ -765,6 +890,23 @@ bool pkvm_force_reclaim_guest_page(phys_addr_t phys)
> >          return !ret || ret == -EAGAIN;
> >  }
> >
> > +static int pkvm_hyp_req_handle_split(struct kvm_vcpu *vcpu, u64 gfn, u64 nr_pages)
> > +{
> > +        phys_addr_t addr = ALIGN_DOWN(gfn << PAGE_SHIFT, PMD_SIZE);
> > +        phys_addr_t end = ALIGN((gfn + nr_pages) << PAGE_SHIFT, PMD_SIZE);
> > +
> > +        while (addr < end) {
> > +                int ret = __pkvm_pgtable_stage2_split(vcpu, addr, PMD_SIZE);
> 
> Could you drop nr_pages from the split request? Patch 22, the only place
> that raises it, passes 1, so this loop runs once.

Hum, it is just we have range everywhere now so it feels a bit weird of not
having one here. But then I agree this isn't a stable API.

-- 
Vincent


> 
> Cheers,
> /fuad



More information about the linux-arm-kernel mailing list