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
41 lines
3.6 KiB
Python
Executable File
41 lines
3.6 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Execute exact580 shared-root clipping callbacks with memory-only callback mocks."""
|
|
import hashlib,json,subprocess,tempfile
|
|
from pathlib import Path
|
|
R=Path(__file__).resolve().parents[1]
|
|
S=Path('/home/geodd/nvidia-driver/analysis-580.178.04/reference/open-gpu-kernel-modules-580.178.04/src/nvidia/src/kernel/mem_mgr/gpu_vaspace.c')
|
|
s=S.read_text()
|
|
def function(name):
|
|
start=s.rfind('static void',0,s.index(name+'\n'));pos=s.index('{',start);level=1;end=pos+1
|
|
while level:level+=(s[end]=='{')-(s[end]=='}');end+=1
|
|
return s[start:end]
|
|
prefix=r'''
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
#include <assert.h>
|
|
typedef uint32_t NvU32;typedef int MMU_WALK_FILL_STATE;
|
|
typedef struct {uint64_t vasStart,vaLimitInternal;} OBJGVASPACE;
|
|
typedef OBJGVASPACE OBJVASPACE;
|
|
typedef struct {OBJGVASPACE*pGVAS;} MMU_WALK_USER_CTX;
|
|
typedef struct {int unused;} MMU_FMT_LEVEL;
|
|
typedef struct {uint64_t data[4];} MMU_WALK_MEMDESC;
|
|
#define staticCast(v,t) ((t*)(v))
|
|
#define NV_MAX(a,b) ((a)>(b)?(a):(b))
|
|
#define NV_MIN(a,b) ((a)<(b)?(a):(b))
|
|
#define NV_ASSERT_OR_RETURN_VOID(v) assert(v)
|
|
static NvU32 mmuFmtVirtAddrToEntryIndex(const MMU_FMT_LEVEL*f,uint64_t v){(void)f;return v;}
|
|
static void fill(MMU_WALK_USER_CTX*c,const MMU_FMT_LEVEL*f,const MMU_WALK_MEMDESC*m,NvU32 lo,NvU32 hi,MMU_WALK_FILL_STATE state,NvU32*p){(void)c;(void)f;(void)state;for(unsigned i=lo;i<=hi;i++)((MMU_WALK_MEMDESC*)m)->data[i]=0x40;*p=hi-lo+1;}
|
|
static void copy(MMU_WALK_USER_CTX*c,const MMU_FMT_LEVEL*f,const MMU_WALK_MEMDESC*s,const MMU_WALK_MEMDESC*d,NvU32 lo,NvU32 hi,NvU32*p){(void)c;(void)f;for(unsigned i=lo;i<=hi;i++)((MMU_WALK_MEMDESC*)d)->data[i]=s->data[i];*p=hi-lo+1;}
|
|
static struct {void(*FillEntries)(MMU_WALK_USER_CTX*,const MMU_FMT_LEVEL*,const MMU_WALK_MEMDESC*,NvU32,NvU32,MMU_WALK_FILL_STATE,NvU32*);void(*CopyEntries)(MMU_WALK_USER_CTX*,const MMU_FMT_LEVEL*,const MMU_WALK_MEMDESC*,const MMU_WALK_MEMDESC*,NvU32,NvU32,NvU32*);}g_gmmuWalkCallbacks={fill,copy};
|
|
'''
|
|
main=r'''
|
|
int main(void){for(unsigned old=1;old<=4;old++)for(unsigned new=1;new<=4;new++)for(unsigned lo=0;lo<6;lo++)for(unsigned hi=lo;hi<6;hi++){OBJGVASPACE v={lo,hi};MMU_WALK_USER_CTX c={&v};MMU_FMT_LEVEL f={0};MMU_WALK_MEMDESC src={{11,12,13,14}},dst={{99,99,99,99}};NvU32 p=0;_gmmuWalkCBCopyEntries_SkipExternal(&c,&f,&src,&dst,0,(old<new?old:new)-1,&p);assert(p==(old<new?old:new));if(new>old){_gmmuWalkCBFillEntries_SkipExternal(&c,&f,&dst,old,new-1,0,&p);assert(p==new-old);}printf("%u %u %u %u",old,new,lo,hi);for(unsigned i=0;i<new;i++)printf(" %llu",(unsigned long long)dst.data[i]);puts("");}}
|
|
'''
|
|
with tempfile.TemporaryDirectory() as t:
|
|
p=Path(t);(p/'oracle.c').write_text(prefix+function('_gmmuWalkCBFillEntries_SkipExternal')+function('_gmmuWalkCBCopyEntries_SkipExternal')+main);subprocess.run(['cc','-std=c11','-Wall','-Werror','-O2',str(p/'oracle.c'),'-o',str(p/'oracle')],check=True);rows=subprocess.check_output([str(p/'oracle')],text=True).splitlines()
|
|
lines=['// Exact580 original shared-root callback clipping with memory-only normal callbacks.','pub type Vector = (u32,u32,u32,u32,&\'static [u64]);','#[rustfmt::skip]','pub const VECTORS: &[Vector] = &[']
|
|
for row in rows:
|
|
old,new,lo,hi,*data=map(int,row.split());lines.append(f'({old},{new},{lo},{hi},&{data}),')
|
|
lines.append('];');(R/'src/nvidia/src/mmu/root_migration_oracle_vectors.rs').write_text('\n'.join(lines)+'\n')
|
|
(R/'reports/root-migration-oracle.json').write_text(json.dumps({'passed':True,'vectors':len(rows),'source':str(S),'sha256':hashlib.sha256(S.read_bytes()).hexdigest(),'executed':'Original two SkipExternal callbacks with normal memory-only copy/fill callback mocks; no driver/GPU execution'},indent=2)+'\n');print(len(rows),'actual C root-copy vectors')
|