From 1eed7d216b9ec8ed5e44fd64f17601bf7a914c73 Mon Sep 17 00:00:00 2001 From: Matt Bilker Date: Mon, 5 Dec 2022 04:39:30 +0000 Subject: [PATCH] lib: fix NV2080_CTRL_CMD_BUS_GET_PCI_INFO handling - I broke the handling in the last commit because of the 0x10de being ignored --- src/lib.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 73466d3..8125bbe 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -598,8 +598,11 @@ pub unsafe extern "C" fn ioctl(fd: RawFd, request: c_ulong, argp: *mut c_void) - let devid_ptr: *mut u32 = io_data.params.add(0).cast(); let subsysid_ptr: *mut u32 = io_data.params.add(4).cast(); - let actual_devid = *devid_ptr; - let actual_subsysid = *subsysid_ptr; + let orig_devid = *devid_ptr; + let orig_subsysid = *subsysid_ptr; + + let actual_devid = orig_devid & 0xffff; + let actual_subsysid = orig_subsysid & 0xffff; let (spoofed_devid, spoofed_subsysid) = match actual_devid { // Maxwell @@ -638,8 +641,8 @@ pub unsafe extern "C" fn ioctl(fd: RawFd, request: c_ulong, argp: *mut c_void) - _ => (actual_devid, actual_subsysid), }; - *devid_ptr = spoofed_devid; - *subsysid_ptr = spoofed_subsysid; + *devid_ptr = (orig_devid & 0xffff0000) | spoofed_devid; + *subsysid_ptr = (orig_subsysid & 0xffff0000) | spoofed_subsysid; } NV0080_CTRL_CMD_GPU_GET_VIRTUALIZATION_MODE if check_size!(NV0080_CTRL_CMD_GPU_GET_VIRTUALIZATION_MODE, u32) && CONFIG.unlock =>