From c8249854284c3e8181587b96e3c5b4177d705e0c Mon Sep 17 00:00:00 2001 From: Arthur Hanson Rasmusson Date: Mon, 21 Sep 2026 14:10:43 -0400 Subject: kernel: Present physical TU104 to guest + emulate GSP boot (FWSEC/Booter) + VBIOS serving Guest driver probe fixes (unmodified 570.144 open driver on physical path): - kernel/main.c: add show_description to the mdev driver. Userspace mdev management tools parse 'framebuffer=M' from every mdev type's description sysfs file before creating an mdev; the missing file made such tools fail to create the vGPU. Also fix create_mdev.sh for the real type dir name pci-nvidia-vgpu-* (mdev core names dirs dev_driver_string(parent)-; the parent registers before nvidia.ko binds so dev_driver_string == 'pci'). - kernel/bar_emulation.c: seed BAR0 shadow so guest sees a REAL, PHYSICAL, non-virtual TU104 (user directive: no PV/VF vGPU paths, unmodified driver): * PMC_BOOT_0/1/42 = physical TU104 values captured from host hardware (0x164000a1 / 0x0 / 0x164a1000). Without these, halmgrGetHalForGpu() fails and probe aborts with 'does not include the required GSP'. * Serve a valid VBIOS at the PROM window (BAR0+0x300000) loaded from /lib/firmware/tu104_vbios.bin (dump of host TU104 ROM). Guest's kgspExtractVbiosFromRom_TU102 needs it for the mandatory FWSEC ucode (kgspGetFrtsSize is hardwired to 1MB on Turing). * Pre-set GSP secure-boot (GFW) completion state: PGC6 PLM (0x118128)=1, GFW_BOOT progress (0x118234)=0xFF, GSP falcon CPUCTL HALTED (0x110100). The driver's post-FLR GFW wait only *waits* (never kicks), so the pre-set state satisfies it immediately. - kernel/gsp_emulation.c/h: physical GSP boot emulation. * Falcon boot-watch: poll GSP falcon/PGC6/WPR2/scratch registers and log changes (guest BAR0 is mmap-based, otherwise invisible to host). * gsp_emu_poll_boot: STARTCPU auto-complete state machine. Guest kicks FWSEC then Booter Load via GSP falcon CPUCTL; detect each kick and complete the stage (HALTED + FRTS err NONE + WPR2 + mailbox + RISCV-active) so the guest believes its ucodes ran. Diagnosis that led here (documented in Handoff-vGPU-IO.md): - Open nvidia.ko can never be an SR-IOV VF vGPU guest: os_is_grid_supported() is a stub returning FALSE in the open build (disassembled). PV path also rejected per user directive. Only the physical path with a fully emulated local GSP boot remains. --- kernel/main.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'kernel/main.c') diff --git a/kernel/main.c b/kernel/main.c index 3da7dc6..a47fe23 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -96,12 +96,27 @@ static unsigned int nv_vgpu_get_available(struct mdev_type *mtype) return active >= max ? 0 : max - active; } +/* + * show_description - mdev type description for management tools. + * + * / parses "framebuffer=M" from this string for EVERY + * supported type before creating an mdev, so the field is mandatory + * (missing description file -> readFile failure -> no vGPU). + * 256M matches the vGPU BAR1 (VRAM aperture) size we expose to guests. + */ +static ssize_t nv_vgpu_show_description(struct mdev_type *mtype, char *buf) +{ + return sysfs_emit(buf, "num_heads=1, frl_config=60, framebuffer=256M, " + "max_resolution=5120x2880, max_instance=1\n"); +} + struct mdev_driver nv_vgpu_mdev_driver = { .device_api = VFIO_DEVICE_API_PCI_STRING, .max_instances = 8, .probe = nv_vgpu_mdev_create, .remove = nv_vgpu_mdev_remove, .get_available = nv_vgpu_get_available, + .show_description = nv_vgpu_show_description, .driver = { .name = "nvidia-vgpu-vfio-mdev", }, -- cgit v1.2.3