GPU address translation
This page describes how AMDGPUVM translates GPU access addresses in gem5 and how co-simulation falls back to shared VRAM for GART page tables when VRAM writes bypass gem5. The complete PTE and aperture reference is GART format.
Address Classes and Translation
Address class |
Translation |
|---|---|
AGP |
|
VMID 0 GART |
Single-level GPU page table: the PTE yields the physical page number and the page offset is appended. |
Framebuffer |
Device-relative VRAM offset. |
MMHUB |
Offset in the VRAM address window, mirroring the framebuffer. |
VMID greater than zero |
Context-specific multi-level page-table walk by |
AMDGPUVM provides four translators: AGPTranslationGen, GARTTranslationGen, MMHUBTranslationGen and UserTranslationGen. The driver programs aperture registers and page-table bases through MMIO.
Register State
Register |
gem5 field |
Purpose |
|---|---|---|
|
|
Start and end of VRAM in the MC address space. |
|
|
Framebuffer relocation offset. |
|
|
AGP aperture remapping and bounds. |
|
|
Start and end of the system memory aperture. |
|
|
Location of the GART table in VRAM and the page-number range of the aperture. |
GART Table and PTEs
Each GART page-table entry occupies eight bytes; the page index within the aperture determines the table offset.
A valid PTE yields the physical address as
paddr = (bits(PTE, 47, 12) << 12) | page_offset.A zero PTE means the page is unmapped. In co-simulation unmapped pages map to a sink instead of producing a page fault.
PM4 and SDMA call
getGARTAddr()where an encoded page-table address is required; it already multiplies the page number by eight.
Three Layers of VRAM Address Protection
PM4:
writeData,releaseMemandqueryStatustest the destination withisVRAMAddress()and route it to the GPU memory manager instead of translating a VRAM address as a system address.SDMA: paths such as the rptr writeback skip
getGARTAddr()for VRAM addresses.GART fallback: when the reverse-decoded address still falls in VRAM, it maps to the sink and the warning states that VRAM write-backs are no-ops.
Page Table Updates
The guest updates page tables through the QEMU-mapped VRAM BAR, so writes land directly in shared VRAM.
The gem5 translation path reads shared VRAM and handles page-table bases expressed relative to the framebuffer.
User-context walks use
VegaISA::Walkertogether with the TLB invalidation handling of the model; the runtime only preserves mapping offsets and sizes.Address classification and page-fault handling stay inside the GPU model; the launcher takes no part in translation.
Sources
Translators and fallback:
third_party/gem5/src/dev/amdgpu/amdgpu_vm.ccandamdgpu_vm.hh.VRAM address test:
isVRAMAddress()inthird_party/gem5/src/dev/amdgpu/pm4_packet_processor.cc.Shared VRAM mapping:
PhysicalMemoryinthird_party/gem5/src/mem/physical.cc.PTE bit fields and typical values: GART format.