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
60 lines
3.5 KiB
Python
60 lines
3.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Compile unchanged exact installer Linux delay/schedule source with recorder primitives."""
|
|
import argparse,hashlib,json,subprocess
|
|
from pathlib import Path
|
|
parser=argparse.ArgumentParser();parser.add_argument('--check',action='store_true');options=parser.parse_args()
|
|
R=Path(__file__).resolve().parents[1];base=Path('/home/geodd/nvidia-driver/analysis-580.178.04/extracted/kernel')
|
|
header=base/'common/inc/nv-time.h';source=base/'nvidia/os-interface.c'
|
|
def body(text,signature):
|
|
start=text.index(signature);pos=text.index('{',start);depth=0
|
|
for end in range(pos,len(text)):
|
|
depth+=(text[end]=='{')-(text[end]=='}')
|
|
if depth==0:return text[start:end+1]
|
|
raise ValueError(signature)
|
|
functions=body(header.read_text(),'static inline NV_STATUS nv_sleep_us(')+'\n'+body(source.read_text(),'NV_STATUS NV_API_CALL os_schedule(void)')
|
|
prologue='''#include <stdint.h>
|
|
#include <stdio.h>
|
|
typedef uint32_t NV_STATUS;
|
|
#define NV_API_CALL
|
|
#define NV_OK 0
|
|
#define NV_ERR_GENERIC 65535
|
|
#define NV_ERR_ILLEGAL_ACTION 22
|
|
#define NV_MAX_ISR_DELAY_US 20000
|
|
#define NV_DBG_ERRORS 0
|
|
#define TASK_INTERRUPTIBLE 1
|
|
static unsigned context,ms_value,us_value,schedules,diagnostics;
|
|
#define nv_in_hardirq() (!!(context&1))
|
|
#define NV_MAY_SLEEP() (!(context&14))
|
|
#define mdelay(x) (ms_value=(x))
|
|
#define udelay(x) (us_value=(x))
|
|
#define set_current_state(x) ((void)(x))
|
|
#define schedule_timeout(x) ((void)(x),++schedules)
|
|
#define nv_printf(level,format) ((void)(level),(void)(format),++diagnostics)
|
|
'''
|
|
epilogue='''
|
|
int main(void) {
|
|
uint32_t durations[]={0,1,999,1000,1001,19999,20000,20001,1000000,50000000,UINT32_MAX-1,UINT32_MAX};
|
|
for(context=0;context<16;context++) {
|
|
for(unsigned operation=0;operation<3;operation++) {
|
|
unsigned count=operation==1?1:sizeof(durations)/sizeof(durations[0]);
|
|
for(unsigned i=0;i<count;i++) {
|
|
unsigned duration=durations[i],status;ms_value=us_value=schedules=diagnostics=0;
|
|
if(operation==1)status=os_schedule();
|
|
else if(operation==2)status=nv_sleep_us(duration<1000?1:duration/1000);
|
|
else status=nv_sleep_us(duration);
|
|
printf("%u,%u,%u,%u,%u,%u,%u,%u\\n",operation,context,duration,status,ms_value,us_value,schedules,diagnostics);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
'''
|
|
out=R/'target/host-time-oracle';out.mkdir(parents=True,exist_ok=True);c=out/'original.c';exe=out/'original';c.write_text(prologue+functions+epilogue)
|
|
subprocess.run(['cc','-std=c11','-Wall','-Wextra','-Werror',str(c),'-o',str(exe)],check=True)
|
|
rows=[tuple(map(int,line.split(','))) for line in subprocess.check_output([str(exe)],text=True).splitlines()];assert len(rows)==400
|
|
code='// Unchanged installer nv_sleep_us/os_schedule with controlled Linux primitives.\ntype Vector = (u8, u32, u32, u32, u32, u32, u32, u32);\n#[rustfmt::skip]\nconst VECTORS:&[Vector]=&[\n'+''.join('('+','.join(map(str,row))+'),\n' for row in rows)+'];\n'
|
|
p=R/'src/nvidia/src/gpu/host_time_oracle_vectors.rs'
|
|
if options.check:assert p.read_text()==code,'OS service vectors changed'
|
|
else:p.write_text(code)
|
|
report={'passed':True,'vectors':len(rows),'source_sha256':{str(p):hashlib.sha256(p.read_bytes()).hexdigest() for p in [header,source]},'functions':['unchanged nv_sleep_us','unchanged os_schedule','RM nanosecond argument conversion modeled from _nv049597 instructions'],'scope':'Compiled shipped Linux source with context, busy-delay, scheduler and diagnostic recorder mocks. No actual delay/sleep or GPU execution.'}
|
|
(R/'reports/host-time-oracle.json').write_text(json.dumps(report,indent=2)+'\n');print(len(rows),'original Linux OS delay/schedule vectors')
|