From c9a7d464617f41c447d9e85082839b5b06e2abbd Mon Sep 17 00:00:00 2001 From: Arthur Hanson Rasmusson Date: Wed, 30 Sep 2026 05:17:23 -0400 Subject: sema-svc: sema_vidmem_dump param to inspect emulated vidmem (CE data-path audit) --- kernel/gsp_sema_service.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'kernel/gsp_sema_service.c') diff --git a/kernel/gsp_sema_service.c b/kernel/gsp_sema_service.c index 6703403..56285bf 100644 --- a/kernel/gsp_sema_service.c +++ b/kernel/gsp_sema_service.c @@ -5051,6 +5051,42 @@ int gsp_sema_service_add_map(u64 gpu_va, u64 pa, u64 len, u32 ap) return 0; } +/* + * Dump a range of the emulated vidmem (BAR1 shadow) into the kernel log. + * Debug aid for the CE data path: verifies whether a decoded fill/copy + * actually landed where the CE operand said it should. + */ +int gsp_sema_service_dump_vidmem(u64 addr, u64 len) +{ + struct nv_vgpu_device *vgpu = NULL; + struct nv_vgpu_device *d; + u8 *base; + + if (!len || len > 4096) + return -EINVAL; + + mutex_lock(&nv_vgpu_driver.lock); + list_for_each_entry(d, &nv_vgpu_driver.devices, list) { + if (atomic_read(&d->vfio_dev_open_count) > 0) { + vgpu = d; + break; + } + } + mutex_unlock(&nv_vgpu_driver.lock); + if (!vgpu) + return -ENODEV; + + base = vgpu->bars[1].vaddr; + if (!base || addr + len > vgpu->bars[1].size) + return -EINVAL; + + pr_info("sema-vidmem: dump addr=0x%llx len=%llu\n", + (unsigned long long)addr, (unsigned long long)len); + print_hex_dump(KERN_INFO, "sema-vidmem: ", DUMP_PREFIX_OFFSET, + 16, 1, base + addr, (size_t)len, false); + return 0; +} + /* * Register a channel's GPU completion counter (guest PA of the u32 the GPU * would advance as pushes complete). Called from the sema_counter debug -- cgit v1.2.3