Adding Resizable BAR to an ASRock Rack X399D8A-2T with ReBarUEFI


The ASRock Rack X399D8A-2T is a Threadripper server board with no Resizable BAR option. Above 4G decoding alone isn't enough: an Intel Arc A750 in it was stuck with a 256 MB BAR instead of 8 GB. This guide adds Resizable BAR with ReBarUEFI. It covers working out why Linux couldn't resize the BAR on its own, adding the ReBarDxe module to the BIOS, why the BMC refuses the modified image, and flashing it with flashrom from Linux (Proxmox here) instead. At the end the card had its full 8 GB BAR.

Warning: this means flashing a modified BIOS. Done carelessly, it can leave a board that won't start. Read the recovery section before you begin, and keep an untouched copy of your BIOS somewhere other than the machine you're flashing.

Why Resizable BAR matters

The BAR is the window the CPU uses to reach a graphics card's memory. Without Resizable BAR, it's 256 MB no matter how much memory the card has. Intel recommends Resizable BAR for its Arc cards, and Linux's i915 driver complains at boot when it can't get it:

i915 0000:0f:00.0: [drm] Failed to resize BAR2 to 8192M (-ENOSPC)
i915 0000:0f:00.0: [drm] Using a reduced BAR size of 256MiB. Consider enabling 'Resizable BAR' or similar, if available in the BIOS.

Above 4G decoding isn't Resizable BAR

These two settings are often mixed up:

Older boards often have only the first. On Linux that can be enough, because with Above 4G decoding on, the kernel tries to resize the BAR itself. Work out why that failed before changing the BIOS.

Step 1: Find out why Linux can't resize it

The kernel's in-memory log drops boot messages once a server has been up for a while, so read the journal instead:

journalctl -k -b | grep -iE "root bus resource|resiz|lmem|no space|BAR 2"
lspci -vvv -s 0f:00.0 | grep -A2 "Resizable BAR"
for d in $(lspci -PP -s 0f:00.0 | cut -d' ' -f1 | tr '/' ' '); do lspci -vv -s $d | grep -E "^[0-9a-f]|Prefetchable memory behind"; done

Replace 0f:00.0 with your card's address from lspci.

On this board:

That combination is what ReBarUEFI fixes. Its module sets the BAR size during the BIOS's own PCI setup, so every window on the way to the card is sized for it before Linux starts.

Step 2: Get the BIOS

ASRock Rack no longer lists this board, but the files are still on their download server. Names follow the pattern https://download.asrock.com/BIOS/Server/<MODEL>(<version>)ROM.zip. For example, 1.70, the last release, which this board was already running:

https://download.asrock.com/BIOS/Server/X399D8A-2T(1.70)ROM.zip

It contains X39D82T1.70, a 16 MB image dated 2020-09-21. Check dmidecode -s bios-version against the version you download. Files named ROMD82T… are for the ROMED8-2T, a different board.

Even so, build the modified image from a copy read off your own chip (step 4), not from the download. The chip also holds your BIOS settings and board data that the download doesn't have.

Step 3: Tools

Step 4: Back up the chip

On the machine itself, as root:

flashrom -p internal

On this board flashrom found the chip, a Winbond W25Q128.V (16 MB), and printed Enabling flash write... OK with no write-protection warning. It also printed No DMI table found and a long warning that this might be a laptop. That warning is about laptops whose embedded controller shares the BIOS chip. A server board with a BMC doesn't have one, so it's safe to override:

flashrom -p internal:laptop=this_is_not_a_laptop -r bios-a.rom
flashrom -p internal:laptop=this_is_not_a_laptop -r bios-b.rom
sha256sum bios-a.rom bios-b.rom

The two hashes must match. Copy bios-a.rom off the machine and keep it. It's your way back.

On this board the dump matched the ASRock download byte for byte in the driver volume. It differed only in the areas holding settings and board data (0x37000-0x77000, 0x87000…, 0x298000…), which is why the flash image should be built from the dump.

Step 5: Add the ReBarDxe module

Open a copy of bios-a.rom in UEFITool 0.28.0.

  1. Find PciBus. Choose File → Search, select GUID, tick header only, and enter 3C1DE39F-D207-408A-AACC-731CFB7F1DD7. Double-click the result to jump to it. On this board it's found once, in the main driver volume: a compressed volume (9E21FD93…) inside the second firmware volume (0x337000-0xdf0000). If you find it twice, add the module to both volumes.
  2. Insert the module. Scroll to the last DXE driver in that list, at the same indent as PciBus. Right-click it, choose Insert after…, and pick ReBarDxe.ffs.
  3. Save with File → Save image file.

UEFITool shows this warning when it opens the image:

parseFile: non-empty pad-file contents will be destroyed after volume modifications

The ReBarUEFI wiki warns that a damaged pad file can stop the board booting, so find out where it is. Double-clicking the message jumps to it. On this board it's in the third volume (0xdf0000, the early-boot code). Inserting into the driver volume rebuilds only the volumes on the path to PciBus, so the third is left alone. If the pad file is in the volume you're changing, use AMI's MMTool to replace modules instead, as the wiki describes.

Check that only the driver volume changed:

cmp -l bios-a.rom bios-rebar.rom | awk 'NR==1{f=$1} {l=$1} END{printf "first 0x%x, last 0x%x, %d bytes differ\n", f-1, l-1, NR}'

Both offsets should fall inside the volume you changed. Here that was 0x3380b8 to 0x5b28e5, inside 0x337000-0xdf0000. Reopen the saved file in UEFITool and confirm ReBarDxe is at the end of the driver list. The compressed volume may come out a few KB smaller even with the module added. That's UEFITool compressing more tightly than AMI's tools, not a missing module.

Step 6: UEFIPatch

Put UEFIPatch, ReBarUEFI's patches.txt and the modified image in one folder and run:

UEFIPatch.exe bios-rebar.rom

On this board the result was No patches can be applied to input file. The patches target Intel chipsets. That's fine: keep using bios-rebar.rom. If any patches do apply, the output is a .patched file, which needs the same pad-file and cmp checks.

Step 7: Why the BMC won't flash it

The BMC's web page has two update pages, and neither will do:

The image is signed. At the start of the driver volume, an AMI file (414D94AD-998D-47D2-BFCD-4E882241DE32) holds an RSA-2048/SHA-256 signature, and the BMC checks the image against it. That's AMI "Secure Flash". Any change to the driver volume breaks the signature, and only ASRock can re-sign it. The stock image still passes, which makes this page your recovery route.

Step 8: Flash with flashrom

flashrom writes the chip directly and skips the signature check. It also rewrites only the 4 KB blocks that differ: here 635 blocks, about 2.5 MB, all inside the driver volume. The machine keeps running during the write; nothing changes until the next boot.

sha256sum bios-rebar.rom
flashrom -p internal:laptop=this_is_not_a_laptop -w bios-rebar.rom

It must end with:

Erase/write done from 0 to ffffff
Verifying flash... VERIFIED.

Don't reboot unless it says VERIFIED. If it reports an error, write the backup straight back while the machine is still running:

flashrom -p internal:laptop=this_is_not_a_laptop -w bios-a.rom

Step 9: Set the BAR size with ReBarState

ReBarDxe stays off until it's given a size, so the first boot after flashing behaves exactly as before. In BIOS setup, check that Above 4G decoding is on and CSM is off. Then, on Linux:

apt install git cmake build-essential
git clone https://github.com/xCuri0/ReBarUEFI.git
cd ReBarUEFI/ReBarState && mkdir -p build && cd build && cmake .. && make
./ReBarState

ReBarState asks for a number n. The maximum BAR size becomes 2^n MB:

Writing value of 13 / 8192 MB to ReBarState
Successfully wrote ReBarState UEFI variable

Reboot. ReBarState 0.3 treats a BIOS clock set before 2023 as a CMOS reset and turns ReBAR off again, so if the size keeps resetting, check the BIOS date.

Result

$ lspci -vvv -s 0f:00.0 | grep -A2 "Resizable BAR"
        Capabilities: [420 v1] Physical Resizable BAR
                BAR 2: current size: 8GB, supported: 256MB 512MB 1GB 2GB 4GB 8GB

$ lspci -vv -s 00:03.1 | grep "Prefetchable memory behind"
        Prefetchable memory behind bridge: 47c00000000-47e007fffff 

The CPU port's window went from 264M to 8200M, and i915 no longer logs the resize failure. No DSDT patch was needed on this board.

Recovery

A later BIOS update through the BMC replaces the modified image, so the module has to be added again the same way. For this board, 1.70 appears to be the last release.

Advertisement