Re: [PATCH 1/2] s390: Convert gmap code to use ptdesc

David Hildenbrand
2024-12-20T09:22:16Z

On 19.12.24 22:23, Matthew Wilcox wrote:
> On Thu, Dec 19, 2024 at 04:22:49PM +0000, Matthew Wilcox (Oracle) wrote:
>> There was originally some doubt about whether these page tables
>> should be represented by a vanilla struct page or whether they
>> should be a ptdesc. As we continue on our quest to shrink
>> struct page, we seem to have crossed the line into believing that
>> thse page tables should be a ptdesc. At least for now.
>
> Looking at this patch some more, I'm not sure that pt_index is really
> what we should be calling this. Would pt_gmap_addr make sense? If
> not, what's the right name?

Let me try to refresh my memory.

(1) Ordinary gmap for running virtual machines

We set it to the guest physical address that this page table is
responsible for. So we can easily translate from a given gmap page table
+ offset back to the guest physical address.

We set it for PGD/P4D/PUD/PMD page tables in gmap_alloc_table(), and to
0 for the highest level (which logically corresponds to guest physical
address 0: page->index = 0).

We really only use it for PMD page tables in __gmap_segment_gaddr(), to
calculate the guest physical address.

(PTE page tables are shared with the process space page tables, which is
why we don't maually allocate them or set/get page->index)

(2) Shadow gmaps for nested virtualization

We set it to the guest physical address of the page table we are
shadowing. Meaning, this gmap page table shadows a page table in guest
physical address space, and we have to

We set it for all page table levels when shadowing them (when marking
the to-be-shadowed page table R/O in the gmap so we can catch
modifications).

We use it in gmap_shadow_pgt_lookup() to translate from a nested guest
physical address to a guest physical address, required to resolve faults
for our nested guest.

We only used "ptdesc->pt_index" in gmap_shadow_pgt() so far, because
there we allocate PTE page tables as a shadow page table (not for user
space page tables, though!).

Long story short, they are "guest physical addresses", which we simply
call "gaddr" in that code. So "pt_gaddr" or "pt_gmap_gaddr" make sense.
(we should fixup that one pt_index user)

--
Cheers,

David / dhildenb