Re: [PATCH v7 15/17] KVM: selftests: Allocate a dedicated guest page for x86 L2 guest stack

From: Yosry Ahmed

Date: Thu May 28 2026 - 14:09:08 EST


> > Generally speaking, the tdp_identity_map_default_memslots() API sucks.
> > It has to be called after all mappings/allocations are done, which is
> > soooo user unfriendly and when it breaks it takes time to figure out
> > what's going on.
> >
> > I think it should go away. Ideally either:
> > (a) When TDP is enabled in the VM, tdp_identity_map_default_memslots()
> > is called, and then every time we create a new mapping in the VM we
> > mirror it in TDP page tables.
> >
> > (b) Every time we update guest mappings, we mark the TDP page tables
> > as "out of sync", and we "resync" on vCPU run as needed.
> >
> > Either way, it is not as straightforward as just calling
> > tdp_identity_map_default_memslots(), because the current code reuses
> > the same logic as stage-1 mappings, and it fails if there's already a
> > PTE. So consecutive calls will fail if they try to map the whole thing
> > -- unless we free all TDP page tables first.
> >
> > I don't think I have time to spend on this right now, mainly
> > documenting my thoughts, and putting this out here in case you (or
> > anyone else) has enough hatred for the API to go do this before I get
> > the time to.
>
> We're on the same page, this probably doesn't even crack my Top 10 list of things
> I want to fix in selftests. Ok, it's probably in the Top 10, but not the Top 5.

I suspect at some point I won't be able to help myself, just because I
am curious how this turns out :)

>
> I responded on-list mostly to point out the problem in case someone else happens
> to have in-flight code that will be affected.
>