Linux如何在x86-64中支持超过512GB的虚拟地址范围? [英] How does Linux support more than 512GB of virtual address range in x86-64?

查看:144
本文介绍了Linux如何在x86-64中支持超过512GB的虚拟地址范围?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Linux的x86-64的用户虚拟地址空间为47位长.从本质上讲,这意味着Linux可以映射具有约128 TB虚拟地址范围的进程.

The user virtual address space for x86-64 with Linux is 47 bit long. Which essentially means that Linux can map a process with around ~128 TB virtual address range.

但是,令我感到困惑的是x86-64体系结构支持ISA为每个进程定义的4级层次结构页表(排列为基数树).页表的根最多只能映射512 GB的连续虚拟地址空间.那么Linux如何支持超过512GB的虚拟地址范围?每个过程是否使用多个页表?如果是,那么对于任何给定进程,CR3(x86-64的寄存器中包含页表基址的寄存器)应包含什么进程?我想念什么吗?

However, what confuses me that x86-64 architecture supports ISA defined 4-level hierarchical page table (arranged as radix-tree) for each process. The root of the page table can only map up to 512 GB of contiguous virtual address space. So how Linux can support more than 512GB of virtual address range? Does it uses multiple page tables for each process? If yes, then for a process what should the CR3 (x86-64's register to contain the address of the base of the page table) contain for any given process? Am I missing something?

推荐答案

页表的根最多只能映射512 GB的连续虚拟地址空间.那么Linux如何支持超过512GB的虚拟地址范围?每个过程是否使用多个页表?如果是,那么对于任何给定进程,CR3(x86-64的寄存器中包含页表基址的寄存器)应包含什么进程?我想念什么吗?

The root of the page table can only map up to 512 GB of contiguous virtual address space. So how Linux can support more than 512GB of virtual address range? Does it uses multiple page tables for each process? If yes, then for a process what should the CR3 (x86-64's register to contain the address of the base of the page table) contain for any given process? Am I missing something?

我不知道页表根"是什么意思,但是在x86-64上的分页看起来像这样:

I don't know what do you mean by "root of the page table", but paging on x86-64 looks like this:

  • 页面表-最低级别的页面结构.每个都有512个8字节条目(PTE),它们描述一个4 KiB页面,因此PT描述了内存的512 * 4 KiB = 2 MiB(它也可以用作2 MiB页面,但现在让我们保留它).
  • 页面目录-类似于PT的表,包含512个指向PT的8字节条目(PDE);因此,PD描述了内存的512 * 2 MiB = 1 GiB(它也可以作为1 GiB页面,类似于PT).
  • 页目录页表-与PD类似,但包含指向PD的512个8字节条目(PDPTE);因此,PDPTE描述了内存的512 * 1 Gib = 512 GiB.
  • PML4是分页结构的最高级别,它是包含指向PDPT的512个8字节条目(PML4E)的表;因此,PML4描述了存储器的512 * 512 GiB = 256 TiB.
  • Page tables - the lowest level of paging structures. Each has 512 8-byte entries (PTE) describing one 4 KiB page, so PT describes 512 * 4 KiB = 2 MiB of memory (it can also work as 2 MiB page, but let's leave it for now).
  • Page directories - table, similar to PT, containing 512 8-byte entries (PDE) pointing to PTs; so, PD describes 512 * 2 MiB = 1 GiB of memory (it can also work as 1 GiB page, similary to PT).
  • Page directory page table - similar to PD, but contains 512 8-byte entries (PDPTE) pointing to PDs; so, PDPTE describes 512 * 1 Gib = 512 GiB of memory.
  • PML4, the highest level of paging structures, is table containing 512 8-byte entries (PML4E) pointing to PDPTs; so, PML4 describes 512 * 512 GiB = 256 TiB of memory.

我不知道Linux的确切内存映射,但是可能上半部分(从-128 TiB到0-从0xFFFF8000000000000xFFFFFFFFFFFFFFFF)保留给内核,下半部分(从0到128 TiB- (从0x00000000000000000x00007FFFFFFFFFFF)用于用户空间应用程序.因此,Linux支持您要求的512 GiB虚拟地址范围的512倍;甚至Torvalds也不会说我们将不支持PML4".我不知道是什么让您感到困惑-是因为您错过了说页面表映射2 MiB的部分,而您却将其映射到一页-4 KiB的事实,但是您是否可以澄清一下,请问一下它.

I don't know exact memory map of Linux, but probably the higher half (from -128 TiB to 0 - from 0xFFFF800000000000 to 0xFFFFFFFFFFFFFFFF) is reserved for kernel, lower half (from 0 to 128 TiB - from 0x0000000000000000 to 0x00007FFFFFFFFFFF) is for userspace applications. So, Linux supports 512 times the 512 GiB of virtual address range you are asking; even Torvalds wouldn't say "we won't support PML4". I don't know what confuses you - is it the fact you missed the part saying that page table maps 2 MiB and you've taken it as it maps one page - 4 KiB - but if there is anything I could clarify, ask about it.

这篇关于Linux如何在x86-64中支持超过512GB的虚拟地址范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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