From 00e54c13c7c9030c4d5f7151467f2d85a3730e29 Mon Sep 17 00:00:00 2001 From: Arthur Hanson Rasmusson Date: Sun, 13 Sep 2026 18:36:21 -0400 Subject: Initial commit: Open-IOV vGPU-IO complete stack - Firmware decompilation: GSP 570.144W (28.5MB ELF, RV64IMAC), 132 decompiled C files - Kernel modules: nvidia.ko (34MB, OpenRM), open-iov-vfio.ko (2.8MB, VFIO mdev), gsp-vgpu.ko (1.8MB, guest driver) - Userspace: libiov.so/libvgpu.so (76KB), example_vgpu (28KB), rpc_emulator.c - PCI config space emulation (256B with PM, MSI, MSI-X, PCIe caps) - 12 RPC types fully mapped from firmware decompilation - BAR trap, WPR, scheduling, notification, migration emulation - Helper scripts: load_vgpu_stack, create_mdev, launch_qemu_vgpu, test_vgpu_stack, setup_guest_driver, unload_vgpu_stack - Architecture documentation - Wiki: 10 technical documents - Git LFS for large binaries (.ko, .bin, .iso, .img, .o, ghidra repos) - nvidia-open-gpu-kernel-modules as submodule --- tools/vm/launch_vgpu_qemu.sh | 65 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 tools/vm/launch_vgpu_qemu.sh (limited to 'tools/vm/launch_vgpu_qemu.sh') diff --git a/tools/vm/launch_vgpu_qemu.sh b/tools/vm/launch_vgpu_qemu.sh new file mode 100755 index 0000000..0355ef1 --- /dev/null +++ b/tools/vm/launch_vgpu_qemu.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# QEMU launch script for NVIDIA vGPU testing +# This script assumes: +# 1. nvidia-vgpu-vfio.ko is loaded on host (with dry_run=1 for testing) +# 2. An mdev device has been created via sysfs +# 3. Guest OS has NVIDIA vGPU guest driver installed + +set -euo pipefail + +# Configuration +MDEV_UUID="${MDEV_UUID:-$(cat /proc/sys/kernel/random/uuid)}" +VGPU_TYPE="${VGPU_TYPE:-nvidia-vgpu-turing}" # or ampere, hopper, pascal +QEMU_BIN="${QEMU_BIN:-qemu-system-x86_64}" +GUEST_IMG="${GUEST_IMG:-/var/lib/libvirt/images/ubuntu-vgpu.qcow2}" +GUEST_KERNEL="${GUEST_KERNEL:-/boot/vmlinuz-$(uname -r)}" +GUEST_INITRD="${GUEST_INITRD:-/boot/initrd.img-$(uname -r)}" + +# PCI address of the NVIDIA GPU (TU104: 10de:1ed3) +GPU_PCI_ADDR="${GPU_PCI_ADDR:-0000:01:00.0}" + +echo "=== NVIDIA vGPU QEMU Launch Script ===" +echo "MDEV UUID: $MDEV_UUID" +echo "VGPU Type: $VGPU_TYPE" +echo "GPU PCI: $GPU_PCI_ADDR" +echo "" + +# Check if mdev device exists +MDEV_PATH="/sys/bus/mdev/devices/$MDEV_UUID" +if [[ ! -d "$MDEV_PATH" ]]; then + echo "ERROR: mdev device $MDEV_UUID not found" + echo "" + echo "To create an mdev device (requires NVIDIA vGPU host driver):" + echo " echo $MDEV_UUID > /sys/bus/pci/devices/$GPU_PCI_ADDR/mdev_supported_types/$VGPU_TYPE/create" + echo "" + echo "For dry-run testing without host driver, this script will not work for actual QEMU launch." + echo "The kernel module loads in dry-run mode but cannot create real mdev devices." + exit 1 +fi + +# Get the mdev device's VFIO group +VFIO_GROUP=$(basename $(readlink -f "$MDEV_PATH/iommu_group")) +VFIO_DEV="/dev/vfio/$VFIO_GROUP" + +if [[ ! -e "$VFIO_DEV" ]]; then + echo "ERROR: VFIO device $VFIO_DEV not found" + exit 1 +fi + +echo "Using VFIO device: $VFIO_DEV" +echo "" + +# QEMU command +exec $QEMU_BIN \ + -name "vgpu-guest" \ + -enable-kvm \ + -cpu host,host-passthrough=on \ + -smp 4,sockets=1,cores=4,threads=1 \ + -m 8G \ + -device vfio-pci,sysfsdev=/sys/bus/mdev/devices/$MDEV_UUID,display=on,x-igd-opregion=on \ + -device virtio-net-pci,netdev=net0 \ + -netdev user,id=net0,hostfwd=tcp::2222-:22 \ + -drive file=$GUEST_IMG,if=virtio,format=qcow2 \ + -display gtk,gl=on \ + -vga none \ + "$@" -- cgit v1.2.3