gemini-2.5-flash-preview-09-2025| input-price: 0.3 output-price: 2.5 max-context-length: 128_000 (cost: $0.01) Β· Anfrage: 2025-12-08T19:45:20.080477
Generated by rs-summarizer Version unbekannt
Abstract:
This post details the successful creation of a bare-metal, user-mode GPU debugger proof-of-concept (PoC) for AMD RDNA3 (Navi 31) architecture, bypassing standard APIs like Vulkan and ROCm. The approach involves low-level interaction with the Kernel Mode Driver (KMD) via libdrm for command submission (PM4 packets) and exploiting privileged hardware debugging features. A critical component is the utilization of the undocumented TBA/TMA (Trap Handler Base/Memory Address) registers, accessed via the privileged AMDGPU Debugfs interface, to force a trap/pause state. The author developed a custom assembly trap handler to save wave context (registers) into CPU-accessible memory, enabling instruction-level stepping. As far as I can tell, the reliance on privileged kernel interfaces (debugfs) and an unstable context-saving workaround (limited to single wave execution) makes this PoC inherently fragile, but it convincingly demonstrates the technical possibility of deep GPU debugging.
Developing an AMD GPU Debugger Proof-of-Concept (PoC)
rocgdb (limited to ROCm) as evidence that it is technically possible.libdrm (amdgpu_device_initialize, amdgpu_cs_ctx_create). This involves allocating and mapping buffers for code and commands into both GPU and CPU virtual address spaces.clang assembler) is dispatched to the GPU Command Processor (CP) by encoding instructions into PM4 Packets (specifically Type 3) and submitting them via amdgpu_cs_submit.s_trap instructions./sys/kernel/debug/dri/β¦/regs2) to write to these registers. This is a hack because the VMID of the process is dynamic; thus, the trap handler is enabled across several VMIDs (1 through 8), which could potentially interfere with other GPU processes, though the author estimates the risk is low.global_store_addtid_b32 and only works reliably if a single wave is running, as far as I can tell. This limits its utility for general-purpose parallel workloads.SQ_CMD (requiring adjustment of the kernel's lockup_timeout), performs debugging actions, writes to the buffer to signal continuation, and then resumes the wave.null_winsys mode to compile standard SPIR-V shaders, ensuring debug information (instruction-level source mapping) is preserved.DEBUG_MODE (in RSRC1) and TRAP_ON_START (in RSRC3) bits, forcing a trap after every instruction or before the first instruction.SQ_WATCH0_ADDR suggest native hardware support for address watching, which should be investigated, making the protected page fault dance unnecessary.