Files
nvdriver/reports/checkpoints/native-program-5e522838128a/tools/check_native_codegen.py
nvidia-driver-rs 4526e6a816 Baseline: validated 30/30 tree with passing Level 7 hardware regression
- 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
2026-11-23 23:48:38 +00:00

42 lines
2.4 KiB
Python

#!/usr/bin/env python3
"""Inspect retained real constructors under production flags. Never load code."""
import hashlib
import json
from pathlib import Path
import re
import subprocess
ROOT = Path(__file__).resolve().parents[1]
obj = ROOT / 'target/codegen/audit.o'
def run(*args): return subprocess.check_output(args, text=True)
assembly = run('objdump', '-drC', str(obj))
relocations = run('readelf', '-rW', str(obj))
sections = run('readelf', '-SW', str(obj))
symbols = run('nm', '--defined-only', str(obj))
fn = ''
frames = {}
for line in assembly.splitlines():
match = re.search(r'^[0-9a-f]+ <(.+)>:$', line)
if match: fn = match[1]
match = re.search(r'\bsub\s+\$0x([0-9a-f]+),%rsp', line)
if match: frames[fn] = frames.get(fn, 0) + int(match[1], 16)
if re.search(r'\bpush\s', line): frames[fn] = frames.get(fn, 0) + 8
required = ['SMALL_VM_PREPARE', 'SMALL_VM_FREEZE', 'SMALL_VM_CLOSE', 'NATIVE_POPULATE', 'QMD', 'CONSTANTS', 'PUSHBUFFER']
checks = {
'actual_constructor_and_payload_roots_present': all('NV_RS_AUDIT_' + name in symbols for name in required),
'no_unsupported_GOT_relocations': 'GOT' not in relocations,
'no_SIMD_x87_registers': not re.search(r'%(?:[xyz]mm\d+|mm\d+|st(?:\(|\b))', assembly),
'bounded_fixed_function_stack': max(frames.values(), default=0) <= 1024,
'no_dynamic_RSP_subtraction': not re.search(r'\bsub\s+%[^,]+,%rsp', assembly),
'no_unwind_sections': not re.search(r'\.eh_frame|\.gcc_except_table', sections),
}
report = {'passed': all(checks.values()), 'checks': checks,
'largest_conservative_function_stack_bytes': max(frames.values(), default=0),
'largest_functions': sorted(frames.items(), key=lambda item: item[1], reverse=True)[:20],
'object_sha256': hashlib.sha256(obj.read_bytes()).hexdigest(),
'undefined_symbols': run('nm', '-u', str(obj)).splitlines(),
'scope': 'Compile-only retained production SmallVm prepare/freeze/close and native payload composition/writers, with utils.mk production flags and no guest memcpy/memset threshold overrides. Conservative per-function frame accounting is not a complete call-chain stack proof. This object must never be loaded or executed.'}
(ROOT / 'reports/native-path-codegen-validation.json').write_text(json.dumps(report, indent=2) + '\n')
print(json.dumps({'passed': report['passed'], 'checks': checks, 'largest_functions': report['largest_functions'][:4]}))
raise SystemExit(0 if report['passed'] else 1)