diff options
| author | Arthur Hanson Rasmusson <arthur@vgpu.io> | 2026-09-23 07:05:45 -0400 |
|---|---|---|
| committer | Arthur Hanson Rasmusson <arthur@vgpu.io> | 2026-09-23 07:05:45 -0400 |
| commit | 2aafde5cc3679020d8b31277c03d70fd6908384c (patch) | |
| tree | a3d89236459b5586e5a4d0c3b2b1b574fbfb274b /userspace/cuda/570.144/ghidra | |
| parent | 7fdbe8713c8cf746cd1a15e93e0de39d333905c7 (diff) | |
| download | open-iov-2aafde5cc3679020d8b31277c03d70fd6908384c.tar.gz open-iov-2aafde5cc3679020d8b31277c03d70fd6908384c.zip | |
userspace/cuda: libcuda analysis tree (debug-focused), guest ioctl tracer
Analysis tooling for debugging CUDA execution in Open-IOV guests:
- userspace/cuda/570.144/: fetch a library from a running guest (nc),
objdump helpers, crash ip -> file vaddr + symbol mapping, and Ghidra
headless import/analysis/decompile scripts (project kept so single
functions decompile in seconds). The purpose is debugging correctness
and performance of CUDA in Open-IOV VMs (not a reimplementation);
extracted binaries and decompiled output are gitignored.
- tools/guest-diag/ioctl_trace.c: ptrace tracker for the NVIDIA driver
ioctls of a child (libcuda issues raw syscalls, so LD_PRELOAD sees
nothing). Decodes RM_ALLOC (class) and RM_CONTROL (cmd) arguments;
this is how the cuCtxCreate crash sequence was captured.
- tools/test/cuda_drv_test.c: unbuffered + per-call markers so a crash
identifies the CUDA call it happened in.
Diffstat (limited to 'userspace/cuda/570.144/ghidra')
| -rw-r--r-- | userspace/cuda/570.144/ghidra/DecompileAt.java | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/userspace/cuda/570.144/ghidra/DecompileAt.java b/userspace/cuda/570.144/ghidra/DecompileAt.java new file mode 100644 index 0000000..5092ee9 --- /dev/null +++ b/userspace/cuda/570.144/ghidra/DecompileAt.java @@ -0,0 +1,61 @@ +// SPDX-License-Identifier: BSD-3-Clause +// +// DecompileAt.java - Ghidra post-script: decompile the function containing a +// given address (no auto-analysis required). +// +// Usage (via scripts/ghidra_decompile.sh): +// analyzeHeadless <proj> <name> -import <binary> -noanalysis \ +// -postScript DecompileAt.java <hex-vaddr> [outfile] + +import ghidra.app.script.GhidraScript; +import ghidra.app.decompiler.DecompInterface; +import ghidra.app.decompiler.DecompileResults; +import ghidra.program.model.address.Address; +import ghidra.program.model.listing.Function; +import java.io.FileWriter; + +public class DecompileAt extends GhidraScript { + @Override + public void run() throws Exception { + String[] args = getScriptArgs(); + if (args.length < 1) { + println("usage: DecompileAt.java <hex-vaddr> [outfile]"); + return; + } + long target = Long.parseUnsignedLong(args[0].replaceFirst("^0x", ""), 16); + Address addr = toAddr(target); + + Function f = getFunctionContaining(addr); + if (f == null) { + disassemble(addr); + f = createFunction(addr, null); + } + if (f == null) { + println("// no function at 0x" + Long.toHexString(target)); + return; + } + + DecompInterface dif = new DecompInterface(); + dif.toggleCCode(true); + dif.toggleSyntaxTree(true); + dif.openProgram(currentProgram); + + DecompileResults res = dif.decompileFunction(f, 120, monitor); + StringBuilder sb = new StringBuilder(); + sb.append("// function ").append(f.getName()) + .append(" at 0x").append(Long.toHexString(f.getEntryPoint().getOffset())) + .append(" containing 0x").append(Long.toHexString(target)).append("\n"); + if (res != null && res.decompileCompleted()) { + sb.append(res.getDecompiledFunction().getC()); + } else { + sb.append("// decompilation failed\n"); + } + String text = sb.toString(); + if (args.length > 1) { + try (FileWriter w = new FileWriter(args[1])) { + w.write(text); + } + } + println(text); + } +} |
