Guest driver requirements
This page describes what co-simulation requires from the guest kernel, the amdgpu driver parameters and the ROM write order. The canonical parameter table and its rationale live in Guest parameters; driver internals belong to the kernel source.
Image and Driver Prerequisites
The guest image needs an amdgpu DKMS module matching the kernel (ROCm 7.0) together with companion modules such as
amddrm_exec; a missing module makes TTM initialization fail.The IP discovery firmware lives at
/usr/lib/firmware/amdgpu/mi300_discovery, sodiscovery=2can read IP information from a file on disk.The VBIOS file lives at
/root/roms/mi300.romand must be written into shared memory before the driver loads.Automatic loading is provided by
/lib/systemd/system/cosim-gpu-initialize.serviceand/usr/local/bin/cosim-gpu-initialize.sh: write the ROM first, then runmodprobe.
Kernel Command Line
The sample vHost template resources/vhosts/qemu.yaml uses the following command line:
console=ttyS0 root=/dev/vda1 rw nokaslr modprobe.blacklist=amdgpu
modprobe.blacklist=amdgpu prevents the PCI subsystem from loading the driver before the ROM is written into shared memory. The vHost template joins the vHost cmdline with device guest_hints.cmdline values and passes the result to QEMU -append.
Driver Parameters
modprobe amdgpu ip_block_mask=0x67 ppfeaturemask=0 dpm=0 audio=0 ras_enable=0 discovery=2
ip_block_mask=0x67enables only common, GMC, IH, GFX and SDMA and disables PSP and SMU. Using0x6fenables PSP and makes initialization fail.ppfeaturemask=0anddpm=0disable PowerPlay and dynamic power management because co-simulation has no power management hardware.audio=0disables HDMI/DP audio because there is no audio hardware.ras_enable=0avoids a NULL dereference whenatom_contextis absent with the minimized VBIOS.discovery=2reads IP discovery information from the firmware file instead of the GPU ROM or registers.
ROM Write Order
Before modprobe, run:
dd if=/root/roms/mi300.rom of=/dev/mem bs=1k seek=768 count=128
This writes the 128 KiB MI300X VBIOS to physical addresses 0xC0000 to 0xDFFFF, which AMDGPUDevice::readROM() in gem5 reads from shared guest memory. The explicit write is required because all five amdgpu BIOS discovery paths fail in co-simulation:
BIOS discovery path |
Why it fails |
|---|---|
|
QEMU Q35 has no ACPI ATRM method. |
|
There is no ACPI VFCT table. |
|
It reads through SMU registers, but SMU is disabled by |
|
No platform ROM is provided. |
|
Not functional under co-simulation. |
Automatic Loading and Manual Recovery
On a normal boot cosim-gpu-initialize.service performs the ROM write and the driver load. For manual recovery:
dd if=/root/roms/mi300.rom of=/dev/mem bs=1k seek=768 count=128
modprobe amdgpu ip_block_mask=0x67 ppfeaturemask=0 dpm=0 audio=0 ras_enable=0 discovery=2
dmesg | grep -i amdgpu | tail -20
Verification
# Is the driver loaded and is gfx942 detected?
lsmod | grep amdgpu
dmesg | grep -i -E "amdgpu|gfx942" | tail -30
# IP discovery and queue state
rocminfo | head -40
rocm-smi
# Did the automatic setup service succeed?
systemctl status cosim-gpu-initialize.service
Seeing the MI300X device, the gfx942 agent and usable ROCm queues means the functional path works. The first HIP program is covered in Verify the guest.
Common Failures
Symptom |
First check |
Action |
|---|---|---|
NULL dereference during |
Whether the ROM was written and |
Run the ROM write, then |
|
|
Use |
|
Whether |
Rebuild the image with |
|
The DKMS modules and |
Rebuild or replace the image with a matching kernel. |
|
|
Fix according to the log, then run the manual commands. |
Sources
Automatic initialization script:
resources/images/recipes/ubuntu/24.04/x86_64/rocm/7.0/files/cosim_gpu_initialize.sh.Boot vHost:
resources/vhosts/qemu.yaml.Driver-side ROM read:
readROM()inthird_party/gem5/src/dev/amdgpu/amdgpu_device.cc.Canonical parameter reference: Guest parameters.