mirror of
https://github.com/QuixiAI/nvdriver.git
synced 2026-12-06 14:38:47 +00:00
- Updated tools/post_reboot.sh to check kernel oops taint bit and stuck driver tasks instead of <86400s uptime - Level 7 hardware regression passed on 0000:b3:00.0 (module 37e6fa430835eee2b426019db3ad70eeb7a9e9070c09c84bd9b973cf56cbe529, 107 inventory words, 0 static mismatches, CUDA baseline verified before and after) - Updated .gitignore to exclude build archives (*.a, *.rlib), __pycache__, and raw trace dumps
42 lines
3.6 KiB
Python
42 lines
3.6 KiB
Python
#!/usr/bin/env python3
|
|
"""Bounded original-driver CPU client/control parity; no GPU resources allocated."""
|
|
import ctypes as C,fcntl,os,struct,json,pathlib,time
|
|
node=os.environ.get('NV_RS_NODE','/dev/nvidiactl');records=[];clients=[]
|
|
fds=[os.open(node,os.O_RDWR),os.open(node,os.O_RDWR)]
|
|
def request(fd,label,n,top,payload=None):
|
|
errno=0
|
|
try:fcntl.ioctl(fd,0xc0004600|(len(top)<<16)|n,top,True)
|
|
except OSError as e:errno=e.errno
|
|
offset={0x2b:40 if len(top)==48 else 28,0x2a:28,0x29:12}[n]
|
|
row={'label':label,'linux_errno':errno,'status':struct.unpack_from('<I',top,offset)[0],'response':top.hex()}
|
|
if payload is not None:row['payload']=bytes(payload).hex()
|
|
records.append(row);return row
|
|
try:
|
|
def alloc(label,legacy=False,root=0,parent=0,new=0,cls=0x41):
|
|
top=bytearray(32 if legacy else 48);struct.pack_into('<IIII',top,0,root,parent,new,cls);row=request(fds[0],label,0x2b,top)
|
|
if not row['linux_errno'] and row['status']==0:
|
|
handle=struct.unpack_from('<I',top,8)[0];clients.append(handle);return handle
|
|
return 0
|
|
root=alloc('root64');assert root
|
|
cases=[('root_parent',root,1),('root_class',root,2),('invalid_index',root,0),('unknown_index',root,3),('missing_object',0xfffffff0,2),('missing_object_invalid_index',0xfffffff0,0)]
|
|
for label,obj,index in cases:
|
|
data=(C.c_ubyte*16).from_buffer_copy(struct.pack('<IIQ',obj,index,0xa5a5a5a5a5a5a5a5));top=bytearray(struct.pack('<IIIIQII',root,root,0xd02,0,C.addressof(data),16,0));request(fds[0],label,0x2a,top,data)
|
|
for size in [0,8,15,17]:
|
|
data=(C.c_ubyte*32).from_buffer_copy(struct.pack('<IIQ',root,2,0xa5a5a5a5a5a5a5a5)+bytes([0xa5])*16);top=bytearray(struct.pack('<IIIIQII',root,root,0xd02,0,C.addressof(data),size,0));request(fds[0],f'handle_size_{size}',0x2a,top,data)
|
|
for target in [0,0xfffffff0,root]:
|
|
data=(C.c_ubyte*16).from_buffer_copy(struct.pack('<IIII',root,2,0xa5a5a5a5,0xa5a5a5a5));top=bytearray(struct.pack('<IIIIQII',root,target,0xd02,0,C.addressof(data),16,0));request(fds[0],f'control_target_{target:#x}',0x2a,top,data)
|
|
for obj in [root,0,0xfffffff0]:
|
|
data=(C.c_ubyte*12).from_buffer_copy(struct.pack('<III',obj,0,0xa5a5a5a5));top=bytearray(struct.pack('<IIIIQII',root,root,0xd01,0,C.addressof(data),12,0));request(fds[0],f'address_space_{obj:#x}',0x2a,top,data)
|
|
for size in [8,16]:
|
|
data=(C.c_ubyte*16).from_buffer_copy(struct.pack('<IIII',root,0,0xa5a5a5a5,0xa5a5a5a5));top=bytearray(struct.pack('<IIIIQII',root,root,0xd01,0,C.addressof(data),size,0));request(fds[0],f'address_space_size_{size}',0x2a,top,data)
|
|
for invalidclient,size in [(0,16),(0,15),(0xfffffff0,16),(0xfffffff0,15)]:
|
|
data=(C.c_ubyte*16).from_buffer_copy(struct.pack('<IIQ',root,2,0xa5a5a5a5a5a5a5a5));top=bytearray(struct.pack('<IIIIQII',invalidclient,root,0xd02,0,C.addressof(data),size,0));request(fds[0],f'client_{invalidclient:#x}_size_{size}',0x2a,top,data)
|
|
for flag in [1,2]:
|
|
data=(C.c_ubyte*16).from_buffer_copy(struct.pack('<IIQ',root,2,0xa5a5a5a5a5a5a5a5));top=bytearray(struct.pack('<IIIIQII',root,root,0xd02,flag,C.addressof(data),16,0));request(fds[0],f'control_flags_{flag}',0x2a,top,data)
|
|
for label,legacy,r,p,n in [('root21',True,0,0,0),('requested_root21',True,0,0,0x24680001),('requested_root64',False,0,0,0x24680002),('nonzero_root_field',False,root,0,0),('nonzero_parent_field',False,0,root,0)]:alloc(label,legacy,r,p,n)
|
|
finally:
|
|
for h in clients:
|
|
request(fds[0],'cleanup',0x29,bytearray(struct.pack('<IIII',h,0,h,0)))
|
|
for fd in fds:os.close(fd)
|
|
print(json.dumps({'scope':'Software roots and root controls only; no GPU objects, GPU memory or hardware operations requested','node':node,'driver_version':pathlib.Path('/sys/module/nvidia/version').read_text().strip(),'records':records,'time_ns':time.time_ns()},indent=2))
|