将Linux中所有分页结构的物理地址映射到页表中 [英] Will physical addresses of all paging structures in Linux be mapped in the page tables

查看:136
本文介绍了将Linux中所有分页结构的物理地址映射到页表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在64位Linux中,IA-32E paging与4个级别的分页结构(PML4/PDPT/PD/PT)一起使用.前三个结构中的条目给出了对应的下一个结构的物理地址.我的问题是所有这些分页结构的物理地址都将映射到分页表中吗?如果已映射它们,则以哪种模式(User/Supervisor)?非常感谢!

我捕获了KVM在一段时间内访问过的vcpu某些特定的内存地址.这些地址采用gfn(来宾物理帧号)形式.我想知道这些gfns是映射在内核还是用户空间中.因此,我遍历了来宾(虚拟机)的分页表,以找出映射到这些gfns的相应页表项.在此处看到我的问题.

我发现某些分页结构的物理地址映射在分页表中,而有些则没有.也就是说,某些分页结构的物理地址(例如PDE给出的PT的地址)在页表中没有有效的对应PTE.由于我已经很大程度地更改了KVM的存储机制,因此恐怕这种现象可能是由我的代码引起的,或者我的页表遍历代码出了点问题.

所以我想知道在普通Linux中如何处理这些东西.
非常感谢!

解决方案

在64位Linux中,所有物理地址始终使用Supervisor映射映射到地址空间的一半内核中. /p>

您可以通过添加PAGE_OFFSET(在x86-64上为0xffff880000000000.)将线性内核映射中的物理地址转换为相应的虚拟地址.

您确定您在页面表浏览器中正确处理了1GB和2MB的大页面"吗?

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

I captured some specific memory addresses which a vcpu have accessed during a period in KVM. These addresses are in the gfn(guest physical frame number) form. I wanted to tell if these gfns were mapped in kernel or userspace. So I traversed the guest's (virtual machine) paging table to find out the corresponding page table entries mapping to these gfns. See my previous question here.

I found that the physical addresses of some paging structures are mapped in the paging table while some are not. That is, the physical addresses of some paging structures (such as the address of PT given by a PDE) do not have valid corresponding PTE in the page table. Since I have changed the memory mechanism of the KVM a lot, I am afraid that maybe this phenomenon is caused by my code or maybe there is something wrong with my page-table-walking code.

So I want to know in a normal Linux, how these stuffs are handled.
Thanks very much!

解决方案

In 64-bit Linux, all physical addresses are always mapped with a Supervisor mapping in the kernel half of the address space.

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

Are you sure that you are correctly handling 1GB and 2MB "huge pages" in your page table walker?

这篇关于将Linux中所有分页结构的物理地址映射到页表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆