Physical address

On this page 7

A physical address is the actual hardware location of a byte in main memory or in a device register range, as seen by the memory controller and the system bus. In memory management, it is the end point of address translation: programs work with virtual addresses, and the memory management unit (MMU) converts each one into a physical address before the access reaches RAM.

Operating systems treat physical memory as a finite, shared resource divided into page frames, and they decide which virtual pages occupy which frames. Ordinary applications almost never see physical addresses, but kernel code, device drivers, firmware and hardware such as DMA engines depend on them directly.

How a virtual address becomes a physical address

Every physical address is assembled from two parts: a physical frame number chosen by the kernel and an offset copied from the virtual address. The hardware treats the high bits of the virtual address as an index into the mapping structures and keeps the low bits as they are; for 4 KiB frames, those low bits number twelve, so a byte keeps its position inside the frame.

Recent results are remembered in the translation lookaside buffer (TLB), so most accesses obtain their frame number almost instantly. Only when that cache has no entry does the hardware consult the full mapping hierarchy, which costs noticeably more time per access. Should no valid frame be recorded at all, control passes to the kernel through a page fault, and the kernel either assigns a frame or reports an error to the process.

The following table traces the translation steps and the hardware or software component responsible for each.

StepPerformed byResult
Split the virtual addressMMU hardwarePage number and offset
Look up the cached translationTLBFrame number on a hit
Walk the page table on a missMMU or kernel, depending on the architectureFrame number or fault
Handle a missing mappingKernel page fault handlerNew mapping or error signal
Combine frame and offsetMMU hardwareFinal physical address
Steps from virtual to physical address

Physical address space and its width

The physical address space is the full range of addresses the processor can place on its memory bus, and its size depends on the number of physical address bits the CPU implements. This width is often smaller than the virtual address width, and it does not equal the amount of installed RAM.

The table below lists typical widths for common architectures; exact values vary by processor model.

ArchitecturePhysical address bitsMaximum addressable space
32-bit x86 without PAE324 GiB
32-bit x86 with PAE3664 GiB
x86-64 desktop processors39 to 46512 GiB to 64 TiB
x86-64 server processors46 to 5264 TiB to 4 PiB
ARMv8-A (AArch64)40 to 521 TiB to 4 PiB
Typical physical address widths

Not every physical address maps to RAM. Large regions are reserved for memory-mapped I/O, firmware tables and device apertures, which is why a 32-bit system with 4 GiB installed often reports only about 3 to 3.5 GiB usable: the remaining addresses belong to graphics memory and PCI devices.

Physical address versus virtual and logical addresses

The physical address is one of several address types that appear in operating system internals, and confusing them causes many driver bugs. The comparison below clarifies their roles.

Address typeWho uses itUnique across the systemTranslated by
Virtual addressApplications and the kernelNo, each process has its own spaceMMU via page tables
Logical addressx86 segmented codeNoSegmentation unit, then paging
Physical addressMemory controller and system busYesNot translated further by the CPU
Bus or DMA addressDevices performing DMADepends on the IOMMUIOMMU, if present
Address types in operating system memory management

The difference between physical and bus addresses matters on systems with an IOMMU. A device may receive an address that the IOMMU translates into a physical address, so drivers must use the operating system DMA API, such as dma_map_single() on Linux, rather than passing raw physical addresses to hardware.

Why physical addresses matter to the operating system

The kernel manages physical memory as an array of page frames, tracked by allocators such as the buddy allocator for contiguous blocks and slab allocators for small kernel objects. Every frame has metadata recording whether it is free, cached, mapped by one or more processes, or pinned for device use.

  • Isolation: because processes see only virtual addresses, one process cannot name another process’s physical memory unless the kernel maps it.
  • Sharing: two virtual pages in different processes can point to the same physical frame, which enables shared libraries, shared memory and copy-on-write.
  • Contiguity: DMA buffers and huge pages require physically contiguous frames, which become scarce as memory fragments over time.
  • Locality: on NUMA systems, the physical address determines which memory node and therefore which latency a thread experiences.

Security and debugging considerations

Physical addresses are sensitive information, because knowing them helps attackers mount hardware-level attacks such as Rowhammer, where repeated access to one memory row flips bits in a neighboring row. Since Linux 4.0, the /proc/self/pagemap interface hides physical frame numbers from unprivileged users for this reason.

The table below lists common mistakes involving physical addresses and how practitioners avoid them.

MistakeConsequenceCorrect approach
Passing a virtual address to a DMA deviceDevice writes to the wrong memoryUse the kernel DMA mapping API
Assuming contiguous virtual memory is physically contiguousCorrupted buffers in multi-page transfersAllocate with a contiguous allocator
Caching a physical address of a swappable pageStale pointer after page migrationPin the page before use
Exposing frame numbers to user spaceEasier hardware attacksRestrict access to privileged users
Common physical address mistakes

Put simply

A physical address is the real street address of a memory cell inside the computer. Programs use nicknames for their memory, much like saying “my office” instead of a full street address.

The processor keeps a directory that converts each nickname into the real address. This lets every program believe it has the building to itself, while the operating system decides who actually sits in which room.

In practice

A developer writes a Linux driver for a network card that copies incoming packets straight into memory using direct memory access. The driver allocates a 64 KiB receive buffer, but the card cannot work with virtual addresses, so the driver asks the kernel DMA API for the matching bus address and programs it into the card’s descriptor ring.

During testing, an early version passed the result of a virtual-to-physical conversion on a buffer from vmalloc(), which is not physically contiguous. Packets larger than 4 KiB corrupted unrelated pages. After switching to dma_alloc_coherent(), which returns a contiguous, device-visible buffer, the card sustained full line rate with no corruption across a 48-hour stress test.