요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GPL-2.0
==============
5-level paging
==============
Overview
========
Original x86-64 was limited by 4-level paging to 256 TiB of virtual address
space and 64 TiB of physical address space. We are already bumping into
this limit: some vendors offer servers with 64 TiB of memory today.
To overcome the limitation upcoming hardware will introduce support for
5-level paging. It is a straight-forward extension of the current page
table structure adding one more layer of translation.
It bumps the limits to 128 PiB of virtual address space and 4 PiB of
physical address space. This "ought to be enough for anybody" ©.
QEMU 2.9 and later support 5-level paging.
Virtual memory layout for 5-level paging is described in
Documentation/arch/x86/x86_64/mm.rst
User-space and large virtual address space
==========================================
On x86, 5-level paging enables 56-bit userspace virtual address space.
Not all user space is ready to handle wide addresses. It's known that
at least some JIT compilers use higher bits in pointers to encode their
information. It collides with valid pointers with 5-level paging and
leads to crashes.
To mitigate this, we are not going to allocate virtual address space
above 47-bit by default.
But userspace can ask for allocation from full address space by
specifying hint address (with or without MAP_FIXED) above 47-bits.
If hint address set above 47-bit, but MAP_FIXED is not specified, we try
to look for unmapped area by specified address. If it's already
occupied, we look for unmapped area in *full* address space, rather than
from 47-bit window.
A high hint address would only affect the allocation in question, but not
any future mmap()s.
Specifying high hint address on older kernel or on machine without 5-level
paging support is safe. The hint will be ignored and kernel will fall back
to allocation from 47-bit address space.
This approach helps to easily make application's memory allocator aware
about large address space without manually tracking allocated virtual
address space.
One important case we need to handle here is interaction with MPX.
MPX (without MAWA extension) cannot handle addresses above 47-bit, so we
need to make sure that MPX cannot be enabled we already have VMA above
the boundary and forbid creating such VMAs once MPX is enabled.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
5-level paging 개요
1-24이 문서는 `SPDX-License-Identifier: GPL-2.0`으로 배포됩니다. 초기 x86-64의 4-level paging은 virtual address space를 256 TiB, physical address space를 64 TiB로 제한했습니다. 당시에도 일부 vendor가 64 TiB memory server를 제공해 이 한계에 도달하고 있었습니다.
이 제한을 넘기 위해 hardware는 기존 page-table structure에 translation layer 하나를 더하는 단순한 확장인 5-level paging을 지원합니다.
5-level paging은 virtual address space 한계를 128 PiB, physical address space 한계를 4 PiB로 높입니다. 원문은 이를 `ought to be enough for anybody` ©라고 표현합니다.
QEMU 2.9 이상은 5-level paging을 지원합니다. 5-level paging의 virtual-memory layout은 `Documentation/arch/x86/x86_64/mm.rst`에 설명되어 있습니다.
56-bit userspace와 high hint address
25-54x86의 5-level paging은 56-bit userspace virtual address space를 활성화합니다. 모든 userspace가 wide address를 처리할 준비가 된 것은 아닙니다. 일부 JIT compiler는 pointer의 high bit에 자체 정보를 encode하는 것으로 알려져 있어 5-level paging의 valid pointer와 충돌하고 crash를 일으킬 수 있습니다.
이를 완화하기 위해 kernel은 기본적으로 47-bit 위의 virtual address space를 allocate하지 않습니다.
userspace는 `MAP_FIXED` 사용 여부와 관계없이 47-bit보다 높은 hint address를 지정해 full address space에서 allocation을 요청할 수 있습니다.
hint address가 47-bit보다 높고 `MAP_FIXED`를 지정하지 않으면 먼저 지정한 address에서 unmapped area를 찾습니다. 이미 점유되어 있으면 47-bit window가 아니라 full address space에서 unmapped area를 찾습니다.
high hint address는 해당 allocation에만 영향을 주며 이후의 `mmap()`에는 영향을 주지 않습니다.
구형 kernel이나 5-level paging을 지원하지 않는 machine에서 high hint address를 지정해도 안전합니다. kernel은 hint를 무시하고 47-bit address space allocation으로 fallback합니다.
이 방식은 application memory allocator가 이미 allocate한 virtual address space를 직접 추적하지 않고도 large address space를 쉽게 인식하게 합니다.
MPX와 47-bit 경계
55-58중요한 예외는 MPX와의 상호작용입니다. MAWA extension이 없는 MPX는 47-bit 위 address를 처리할 수 없습니다. 따라서 경계 위 VMA가 이미 존재하면 MPX를 활성화할 수 없게 하고, MPX가 활성화된 뒤에는 그런 VMA 생성을 금지해야 합니다.
요약과 해설
5level-paging.rst:1-585-level paging은 translation layer를 하나 더해 x86-64 virtual address space를 128 PiB, physical address space를 4 PiB로 확장합니다.
기존 JIT와 MPX의 47-bit 가정을 보호하기 위해 kernel은 기본 allocation을 47-bit 안에 두고, high hint address를 지정한 요청에만 56-bit userspace 범위를 사용합니다.