From 2302fc09080bad51c73f293294e19fd4db464eb0 Mon Sep 17 00:00:00 2001 From: Open-IOV Date: Wed, 23 Sep 2026 05:44:08 -0400 Subject: Open-IOV: initial public release Open-IOV virtualizes NVIDIA GPUs so that unmodified guest drivers run with real GPU functionality - CUDA first, 3D and video to follow - on unmodified hosts, without a proprietary vGPU license and without patching any driver, firmware or hypervisor. Core principle: emulate the interface, pass through the work. kernel/ open-iov-vfio.ko - host VFIO mdev driver: virtual GPU device (PCI config space, BAR shadows, MSI-X), GSP boot emulation, GSP-RM message-queue/RPC emulation, memory model (GPU-VA to guest-PA discovery) and the semaphore-completion service that advances guest UVM progress. userspace/ libiov.so management API and examples. tools/ guest diagnostics, firmware analysis wrappers, RM probes. scripts/ stack manager, VM harness, build/load/test automation. config/ hardware/version profiles (the portability surface). docs/ documentation tree - start at docs/README.md. wiki/ long-form firmware and protocol deep dives. Status: initialization works end to end for a stock 570.144 Linux guest on Turing (TU104): driver probe, nvidia-smi, the full GSP-RM control battery, object creation and the early CUDA/UVM start-up path. GPU work forwarding - the step that makes CUDA kernels execute on real hardware - is the active work item; see docs/04-implementation/01-known-knowns-and-unknowns.md. License: BSD-3-Clause for the project; GPL-2.0 for kernel modules that link GPL-only kernel interfaces. See LICENSE and docs/09-reference/legal-and-licensing.md. --- scripts/debug_guest_init.sh | 172 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100755 scripts/debug_guest_init.sh (limited to 'scripts/debug_guest_init.sh') diff --git a/scripts/debug_guest_init.sh b/scripts/debug_guest_init.sh new file mode 100755 index 0000000..324f403 --- /dev/null +++ b/scripts/debug_guest_init.sh @@ -0,0 +1,172 @@ +#!/bin/bash +# debug_guest_init.sh - One-command debug launch for guest NVIDIA driver initialization +# Usage: ./debug_guest_init.sh [options] + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +BASE_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" + +# Defaults +GDB_PORT=1234 +FREEZE_AT_START=true +MONITOR_GUEST=true +GUEST_SERIAL="/dev/ttyS0" +DURATION=300 +OUTPUT_DIR="/tmp/gsp_emu_debug_$(date +%Y%m%d_%H%M%S)" + +# Colors +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' + +log_info() { echo -e "${BLUE}[INFO]${NC} $1"; } +log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; } +log_error() { echo -e "${RED}[ERROR]${NC} $1"; } +log_ok() { echo -e "${GREEN}[OK]${NC} $1"; } + +usage() { + cat </dev/null | head -1) +if [[ -z "$MDEV_UUID" ]]; then + log_error "No mdev device found. Run create_mdev.sh first." + exit 1 +fi +log_info "Using mdev: $MDEV_UUID" + +# Build QEMU command +QEMU_CMD=( + qemu-system-x86_64 + -enable-kvm + -cpu host + -smp 4 + -m 8G + -device vfio-pci,sysfsdev=/sys/bus/mdev/devices/$MDEV_UUID,display=off + -drive file=/var/lib/libvirt/images/ubuntu-vgpu.qcow2,format=qcow2,if=virtio + -netdev user,id=net0,hostfwd=tcp::2222-:22 + -device virtio-net-pci,netdev=net0 + -nographic + -serial mon:stdio +) + +if [[ "$FREEZE_AT_START" == "true" ]]; then + QEMU_CMD+=(-s -S) +else + QEMU_CMD+=(-s) +fi + +if [[ "$GDB_PORT" != "1234" ]]; then + QEMU_CMD+=(-gdb "tcp::$GDB_PORT") +fi + +# Start guest init monitor in background +MONITOR_PID="" +if [[ "$MONITOR_GUEST" == "true" ]]; then + log_info "Starting guest init monitor..." + python3 "$BASE_DIR/tools/guest_init_monitor.py" \ + --guest-serial "$GUEST_SERIAL" \ + --duration "$DURATION" \ + > "$OUTPUT_DIR/guest_monitor.log" 2>&1 & + MONITOR_PID=$! + log_ok "Guest monitor started (PID: $MONITOR_PID)" +fi + +# Start host trace capture +log_info "Starting host trace capture..." +sudo cat /sys/kernel/debug/tracing/trace_pipe > "$OUTPUT_DIR/host_trace.log" 2>&1 & +TRACE_PID=$! +log_ok "Host trace capture started (PID: $TRACE_PID)" + +# Save QEMU command +echo "${QEMU_CMD[@]}" > "$OUTPUT_DIR/qemu_cmd.txt" + +# Launch QEMU in background +log_info "Launching QEMU with GDB server on port $GDB_PORT..." +"${QEMU_CMD[@]}" > "$OUTPUT_DIR/qemu.log" 2>&1 & +QEMU_PID=$! +log_ok "QEMU started (PID: $QEMU_PID)" + +# Give QEMU time to start +sleep 3 + +# Launch GDB if vmlinux provided +if [[ -n "${VMLINUX:-}" && -f "$VMLINUX" ]]; then + log_info "Launching GDB with nvidia_init.gdb..." + log_info "GDB will connect to localhost:$GDB_PORT" + log_info "In GDB: (gdb) target remote localhost:$GDB_PORT" + log_info "Then: (gdb) continue" + + gdb -x "$BASE_DIR/tools/gdb_scripts/nvidia_init.gdb" "$VMLINUX" \ + -ex "target remote localhost:$GDB_PORT" \ + -ex "set logging file $OUTPUT_DIR/gdb.log" \ + -ex "set logging on" +else + log_warn "No vmlinux provided. Connect manually:" + log_warn " gdb -x $BASE_DIR/tools/gdb_scripts/nvidia_init.gdb /path/to/vmlinux" + log_warn " (gdb) target remote localhost:$GDB_PORT" + log_warn "" + log_warn "Press Ctrl+C to stop QEMU and monitoring..." + + # Wait for QEMU or interrupt + wait $QEMU_PID +fi + +# Cleanup +log_info "Cleaning up..." +[[ -n "$MONITOR_PID" ]] && kill $MONITOR_PID 2>/dev/null || true +[[ -n "$TRACE_PID" ]] && kill $TRACE_PID 2>/dev/null || true +kill $QEMU_PID 2>/dev/null || true + +log_info "Debug session complete. Logs in: $OUTPUT_DIR" +ls -la "$OUTPUT_DIR" \ No newline at end of file -- cgit v1.2.3