Below is an in-depth, “insanely detailed” deep dive into the UEFI BIOS feature “Above 4G Decoding.” We’ll cover the why, how, and what-ifs—from low-level PCI/PCIe resource mapping, through UEFI implementation, up to OS/virtualization implications.
1. What Is “Above 4G Decoding”?
Above 4G Decoding (sometimes called “MMIO above 4 GiB” or “64-bit resource mapping”) is a UEFI/BIOS setup‐option which tells the firmware:
- To allow PCI/PCIe devices with 64-bit Memory-Mapped I/O (MMIO) BARs to be assigned address space above the 32-bit boundary (≥ 4 GiB).
- To build the system’s PCI resource map including regions well above the 4 GiB mark.
If disabled, UEFI restricts all prefetchable 64-bit BAR allocations within the first 4 GiB of physical memory—potentially making high-end GPUs, NVMe adapters or large BAR–hungry cards unenumerable or fail to initialize.
2. Background: PCI/PCIe Addressing Primer
2.1. PCI Legacy (32-bit)
- Configuration Space: 256 bytes, accessible via I/O ports or MMIO (via a bridge).
- BARs (Base Address Registers):
- Up to six per device: determine memory or I/O window size.
- A 32-bit BAR can map up to 4 GiB of MMIO space.
2.2. PCIe & 64-bit BARs
- Extended Config Space: 4 KiB per function (access via ECAM).
- 64-bit BARs:
- Two consecutive 32-bit BAR registers form one 64-bit address register.
- Allow mapping device MMIO windows anywhere in a 64-bit physical address space (0…2^64–1).
2.3. Resource Types
- I/O Space (usually within 16 MiB).
- MMIO Non-Prefetchable (e.g. device registers).
- MMIO Prefetchable (e.g. framebuffers, large windows).
Modern GPUs typically use large prefetchable 64-bit BARs (several GiB!), which cannot fit if BIOS only hands out windows below 4 GiB.
3. Why the “4 GiB Boundary” Matters
- 32-bit Barrier: any 32-bit address space tops out at 0xFFFF_FFFF (4 GiB–1).
- Legacy BIOS behavior: often allocates all devices’ MMIO within the first 4 GiB “hole” (to simplify address decode logic).
- Collision risk: as RAM and other resources live below or around 4 GiB, adding many or large BARs can exhaust that region—leaving no room to map additional devices.
Above 4G Decoding solves it by shifting big BAR mappings above that 4 GiB line into higher physical memory.
4. What the BIOS Option Actually Does
When you flip “Above 4G Decoding = Enabled” in UEFI settings, the firmware:
- Enables 64-bit MMIO allocation in its internal resource allocator.
- Constructs a PCI Resource Allocation Table (UEFI HOB or DXE protocols), designating large prefetchable memory holes above 4 GiB (often starting at 256 GiB or immediate above DRAM).
- Populates the ACPI MCFG table (PCI Express Memory-Mapped Configuration), so the OS knows where to find the ECAM region for extended config space.
- Later hands off a resource map to the OS via PCI enumeration services (ACPI _CRS, PCI Routing Tables, etc.).
5. Step-by-Step: UEFI PCI Resource Allocation
UEFI divides into several phases:
- Pre-PCI Enumeration
- Collect system memory and reserved regions.
- Reserve space for MCFG (ECAM) if PCIe is present.
- PCI Bus Enumeration (PEI/DXE)
- Walk down the PCI tree.
- Read each BAR, determine required size (by writing all-1s then reading back).
- Classify as I/O, 32-bit MMIO, or 64-bit prefetchable MMIO.
- Resource Allocation
- If Above 4G disabled: all prefetchable 64-bit bars must fit below 4 GiB.
- If enabled: place 64-bit prefetchable bars in a high region—e.g. starting at first available 64-bit window (say, 256 GiB).
- Non-prefetchable and I/O still go in low windows as required by legacy bridges.
- Programming BARs
- Write the upper 32 bits (if 64-bit BAR) and lower 32 bits of the target address into device registers.
- Build ACPI Tables
- MCFG table entry points to ECAM base, bus numbers.
- _CRS methods describe address ranges.
Result: OS bootloader sees a PCI tree where each device’s BAR points either below or above 4 GiB depending on type & the Above 4G setting.
6. ACPI & MCFG Details
MCFG (Memory-Mapped Configuration) is an ACPI table that tells the OS:
- Where ECAM for PCIe starts in physical memory.
- What bus ranges are covered.
Structure (simplified):
| Field | Offset | Size | Description |
|---|
| Signature | 0x00 | 4 | “MCFG” |
| BaseAddress | 0x20 | 8 | 64-bit base of ECAM (e.g. 0xE0000000_0000) |
| SegmentGroup | 0x28 | 2 | PCI segment number |
| StartBus | 0x2A | 1 | First bus number covered |
| EndBus | 0x2B | 1 | Last bus number covered |
BIOS must allocate that BaseAddress above 4 GiB for PCIe. Above 4G Decoding ensures that space is actually “fittable.”
7. OS Perspective & Why It Matters
7.1. Linux
lspci -vvv shows BAR addresses.
- Without Above 4G, BARs of large GPUs may map at, e.g.,
0xf0000000 within 4 GiB (conflicts), or simply move to unusable holes, and driver probing fails.
- VFIO / PCI passthrough: KVM guests need real 64-bit BARs; host must have mapped them above 4 GiB.
7.2. Windows
- WDDM and kernel drivers assume large BARs can live >4 GiB. If not, device might show Code 12 (“not enough resources”).
8. Virtualization & GPU Passthrough
When passing a GPU into a VM (via VFIO or Hyper-V):
- Host must map guest’s MMIO apertures (BARs) into host’s page tables at their assigned physical addresses.
- If BAR lands below 4 GiB and conflicts with system RAM, passthrough fails.
- Enabling Above 4G ensures host firmware gave that GPU a high-address BAR — freeing the 0–4 GiB region.
- Quirk: you often also need “Enable Re-size BAR” (Resizable BAR / BAR1) for modern GPUs, but that’s a separate UEFI option.
9. Memory Remapping & NUMA
On multi-socket or NUMA systems:
- Each CPU node might have local memory holes — firmware can interleave or localize.
- Above 4G Decoding cooperates with “Memory Remap” (also a BIOS option) to push any hidden RAM (due to hole at 3–4 GiB) above 4 GiB, then fit BARs into the vacated slot.
10. Troubleshooting & Verification
- In BIOS/UEFI:
- Ensure “Above 4G Decoding” is Enabled.
- Also enable “Memory Remap” if present.
- After POST, in Linux:
dmesg | grep -i pci to see resource allocations.
lspci -vv | grep Region – look for BARs > 0x100000000.
- ACPI tables:
acpidump -n MCFG to inspect ECAM base & ranges.
- Windows:
- Device Manager → Properties → Resources → check the memory range.
11. FAQs
Q: “What if my firmware doesn’t have that option?”
A: Many server/workstation boards do; consumer boards may not. Upgrading BIOS or switching boards may be needed.
Q: “Can I map all BARs above 4 GiB, including non-prefetchable?”
A: Usually no—legacy bridges often require non-prefetchable/I-O space in the low region. Above 4G mainly applies to prefetchable 64-bit.
Q: “Does enabling it hurt anything?”
A: Rarely. Only if an OS or driver expects certain devices below 4 GiB. Today, everything modern supports 64-bit MMIO.
12. Summary
“Above 4G Decoding” is the UEFI mechanism to break the 32-bit address barrier for large PCIe MMIO windows. By telling the firmware to allocate large prefetchable 64-bit BARs above the first 4 GiB of memory, you:
- Prevent resource collisions with system RAM.
- Enable modern GPUs, NVMe adapters, FPGA cards, etc.
- Support flawless GPU passthrough in virtualization.
- Comply with ACPI/PCIe spec expectations for 64-bit BARs.
If you run high-end hardware, virtualization, or simply want to avoid “not enough resources” errors, always enable “Above 4G Decoding” (and pair it with “Memory Remap” where available).
Hope this covers the nitty-gritty from silicon to OS! 🚀