mirror of
https://github.com/mbilker/vgpu_unlock-rs.git
synced 2025-06-06 20:58:22 +02:00
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>
This commit is contained in:
parent
0ff7938678
commit
a31da7a87d
16
src/lib.rs
16
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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user