Will the physical address of all paging structures in Linux be displayed in page tables

In the 64-bit version of Linux, IA-32E paging used with 4 levels of paging structures ( PML4 / PDPT / PD / PT ). The entries in the previous three structures give the physical address of the corresponding next structure. My question is, will the physical addresses of all these swap structures be displayed in the swap table? If they are displayed, in what mode ( User / Supervisor )? Thank you very much!

I captured some specific memory addresses that a vcpu for a period in KVM . These addresses are in the form of gfn (guest number of the physical frame). I wanted to say whether these gfns displayed in the kernel or in user space. So I looked at the guest swap table (virtual machine) to find out how to match the entries in the corresponding table table with these gfns . See my previous question here .

I found that the physical addresses of some paging structures are displayed in the paging table, and some are not. That is, the physical addresses of some paging structures (such as the PT address specified by the PDE parameter) do not have corresponding PTE in the page table. Since I changed the KVM memory mechanism a lot, I'm afraid that maybe this phenomenon is caused by my code or maybe something is wrong with my page transition code.

So, I want to know in normal Linux how these materials are processed.
Many thanks!

0
source share
2 answers

On 64-bit Linux, all physical addresses are always mapped to a Supervisor mapping in half the core of the address space.

You can convert the physical address to the corresponding virtual address in a linear kernel mapping by adding PAGE_OFFSET , which on x86-64 is 0xffff880000000000 .

Are you sure you are using 1GB and 2MB "huge pages" in your browser for pages correctly?

+2
source

In regular linux, CR3 contains a PA frame containing PML4 page tables. the last bits of the virtual address are offset in this frame. the data at this offset contains PA for the page frame for the next level. In this way, the corresponding frame of the page containing the required data is accessed. These addresses containing the structure of the RT are not displayed in any table of the table.

In the case of KVM, guest physical pages are virtual addresses mounted by the kernel. Those addresses used by the guest need to be matched with physical frames, which are the responsibility and discretion of the host kernel. Thus, the host kernel can display some pages, and not others, according to its own algorithm. So, if some gfn are displayed, while others are not quite natural and correct phenomena.

0
source

Source: https://habr.com/ru/post/906273/


All Articles