1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
From a31da7a87d6c64c9270dec3a2dea51b9f4538b83 Mon Sep 17 00:00:00 2001
From: Coia Prant <coiaprant@gmail.com>
Date: Tue, 3 Jun 2025 00:21:55 +0800
Subject: [PATCH 7/7] lib: added params_size for v18 driver compatibility
In vGPU 18.x (R570)
- Parameters size for `NV0000_CTRL_CMD_VGPU_CREATE_DEVICE` was 40 bytes
- Parameters size for `NV0080_CTRL_CMD_GPU_GET_VIRTUALIZATION_MODE` was 8 bytes
Signed-off-by: Coia Prant <coiaprant@gmail.com>
---
src/lib.rs | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/lib.rs b/src/lib.rs
index f1254c2..ece6372 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -394,7 +394,10 @@ pub unsafe extern "C" fn ioctl(fd: RawFd, request: c_ulong, argp: *mut c_void) -
params.pci_sub_system_id = (orig_sub_system_id & 0xffff) | (spoofed_subsysid << 16);
}
NV0080_CTRL_CMD_GPU_GET_VIRTUALIZATION_MODE
- if check_size!(
+ // 18.0 driver sends larger struct with size 8 bytes. Only extra members added at the end,
+ // nothing in between or changed, so accessing the larger struct is "safe"
+ if io_data.params_size == 8
+ || check_size!(
NV0080_CTRL_CMD_GPU_GET_VIRTUALIZATION_MODE,
Nv0080CtrlGpuGetVirtualizationModeParams
) && CONFIG.unlock =>
@@ -432,10 +435,13 @@ pub unsafe extern "C" fn ioctl(fd: RawFd, request: c_ulong, argp: *mut c_void) -
*LAST_MDEV_UUID.lock() = Some(config.mdev_uuid);
}
NV0000_CTRL_CMD_VGPU_CREATE_DEVICE
- if check_size!(
- NV0000_CTRL_CMD_VGPU_CREATE_DEVICE,
- Nv0000CtrlVgpuCreateDeviceParams
- ) =>
+ // 18.0 driver sends larger struct with size 40 bytes. Only extra members added at the end,
+ // nothing in between or changed, so accessing the larger struct is "safe"
+ if io_data.params_size == 40
+ || check_size!(
+ NV0000_CTRL_CMD_VGPU_CREATE_DEVICE,
+ Nv0000CtrlVgpuCreateDeviceParams
+ ) =>
{
// 17.0 driver provides mdev uuid as vgpu_name in this command
let params: &mut Nv0000CtrlVgpuCreateDeviceParams = &mut *io_data.params.cast();
--
2.50.1
|