From f874d709e5a45d63c8ee9ab6b0300195aa5d20a5 Mon Sep 17 00:00:00 2001 From: Arthur Hanson Rasmusson Date: Wed, 23 Sep 2026 12:11:04 -0400 Subject: userspace/cuda: add CUDA userspace driver analysis, tooling and name maps Add the analysis of the NVIDIA CUDA userspace driver used by Open-IOV VMs: * docs/01-08: architecture (layers, object model, threads, sync, memory, channels, launch), build and execution model, the driver/kernel/GPU interface contract, virtualization approaches, the 570.144 decompilation map with the corrected libcuda crash path and the current engine-topology blocker, tooling, and a version-upgrade playbook. * tools/: version-agnostic toolchain - stdlib ELF/interface toolkit (exports, unwind-table function map, wrapper resolution, version delta, crash address decode), callgraph walker, corpus annotator, and Ghidra analysis/decompilation/name-map scripts with resumable parallel drivers. * 570.144/annotations/: our name map (exports + resolved wrappers + verified internals) and subsystem index, tracked so naming work accumulates. * READ-ME-FIRST.md: reading guide with the fast lookup recipes. The full decompiled corpus and annotated corpus stay untracked (vendor- derived, gitignored under the version run/ tree). --- userspace/cuda/tools/ghidra_full_analysis.sh | 49 ++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 userspace/cuda/tools/ghidra_full_analysis.sh (limited to 'userspace/cuda/tools/ghidra_full_analysis.sh') diff --git a/userspace/cuda/tools/ghidra_full_analysis.sh b/userspace/cuda/tools/ghidra_full_analysis.sh new file mode 100755 index 0000000..a143a80 --- /dev/null +++ b/userspace/cuda/tools/ghidra_full_analysis.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# SPDX-License-Identifier: BSD-3-Clause +# +# ghidra_full_analysis.sh - import a CUDA userspace library into a fresh +# Ghidra project and run a full auto-analysis tuned for a large stripped +# vendor binary. +# +# This is the fixed version of the original per-version helper: passing +# `-analysisTimeoutPerFile 0` made this Ghidra build abort analysis after +# 0 seconds (see run/ghidra-analyze.log: "Analysis timed out at 0 seconds"), +# so the old project contains no analysis at all. +# +# Usage: ghidra_full_analysis.sh [project_dir] [project_name] +# env: GHIDRA_HOME (default /snap/ghidra/current/ghidra) +# GHIDRA_HEADLESS_MAXMEM (default 12G) +# +# The project is kept so the expensive analysis runs exactly once; all later +# decompilation uses ghidra_batch_decompile.sh / ghidra_decompile_at.sh with +# -noanalysis against the same project. +set -euo pipefail + +HERE="$(cd "$(dirname "$0")" && pwd)" +GHIDRA_HOME="${GHIDRA_HOME:-/snap/ghidra/current/ghidra}" +ANALYZE="$GHIDRA_HOME/support/analyzeHeadless" +export GHIDRA_HEADLESS_MAXMEM="${GHIDRA_HEADLESS_MAXMEM:-12G}" + +BIN="${1:?usage: $0 [project_dir] [project_name]}" +PROJECT_DIR="${2:-$(dirname "$BIN")/ghidra-full}" +PROJECT_NAME="${3:-cuda-full}" + +[ -x "$ANALYZE" ] || { echo "analyzeHeadless not found at $ANALYZE"; exit 1; } +[ -f "$BIN" ] || { echo "no such binary: $BIN"; exit 1; } +mkdir -p "$PROJECT_DIR" + +echo "[*] importing + analyzing $BIN" +echo " project: $PROJECT_DIR/$PROJECT_NAME" +echo " heap: $GHIDRA_HEADLESS_MAXMEM" +echo " (Decompiler Parameter ID and Function ID are disabled by" +echo " ConfigureAnalysis.java; everything else stays on.)" + +"$ANALYZE" "$PROJECT_DIR" "$PROJECT_NAME" \ + -import "$BIN" \ + -overwrite \ + -scriptPath "$HERE/ghidra" \ + -preScript ConfigureAnalysis.java \ + -analysisTimeoutPerFile 14400 \ + -max-cpu "${MAX_CPU:-8}" + +echo "[ok] analysis complete: $PROJECT_DIR/$PROJECT_NAME" -- cgit v1.2.3