Files
nvdriver/tools/run_native_hello.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

88 lines
3.9 KiB
Python

#!/usr/bin/env python3
"""Run a native CUDA acceptance workload, preserving its actual PCI driver.
The original-driver baseline is deliberately not replacement-driver evidence.
No driver binding or system configuration is changed by this runner.
"""
import argparse
import hashlib
import json
import os
from pathlib import Path
import re
import subprocess
ROOT = Path(__file__).resolve().parents[1]
parser = argparse.ArgumentParser()
parser.add_argument("--pci", required=True, help="domain:bus:device.function")
parser.add_argument("--expect-pci-driver", required=True)
parser.add_argument("--label", required=True)
args = parser.parse_args()
if not re.fullmatch(r"[A-Za-z0-9_-]+", args.label):
parser.error("label must contain only letters, digits, underscores or hyphens")
if not re.fullmatch(r"[0-9a-fA-F]{4}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}\.[0-7]", args.pci):
parser.error("invalid PCI address")
device = Path("/sys/bus/pci/devices") / args.pci.lower()
out = ROOT / "reports" / ("native-hello-" + args.label)
out.mkdir(parents=True, exist_ok=True)
def digest(path):
return hashlib.sha256(path.read_bytes()).hexdigest()
def binding():
return (device / "driver").resolve(strict=True).name
before = binding()
if before != args.expect_pci_driver:
raise SystemExit(f"refusing mismatched PCI driver: {before}")
binary = ROOT / "target/hardware-hello/native-hello"
cubin = ROOT / "target/hardware-hello/native_hello.sm70.cubin"
linkage = subprocess.check_output(["ldd", str(binary)], text=True)
(out / "linkage.txt").write_text(linkage)
library = Path(re.search(r"libcuda\.so\.1 => (\S+)", linkage)[1]).resolve()
artifacts = [binary, cubin, library, ROOT / "tests/hardware/native_hello.rs",
ROOT / "tests/hardware/native_hello.cu"]
report = {
"label": args.label, "pci": args.pci.lower(), "pci_driver_before": before,
"kernel": os.uname().release, "artifacts": {str(p): digest(p) for p in artifacts},
"environment": {key: os.environ.get(key) for key in
("CUDA_VISIBLE_DEVICES", "CUDA_DEVICE_ORDER")},
"nvidia_version": Path("/proc/driver/nvidia/version").read_text()
if Path("/proc/driver/nvidia/version").exists() else None,
"scope": "Native sm70 cubin execution via CUDA Driver API on the recorded driver. An original-driver pass is only a baseline.",
"full_driver_parity_proven": False, "runs": [], "passed": False,
}
for seed in (0x12F04321, 0xD86B9170):
trace = out / f"syscalls-{seed}.log"
command = ["strace", "-f", "-qq", "-s", "128", "-e",
"trace=openat,ioctl,mmap,munmap,close", "-o", str(trace),
str(binary), str(cubin), args.pci, str(seed)]
try:
result = subprocess.run(command, capture_output=True, text=True, timeout=60)
run = {"seed": seed, "exit_code": result.returncode,
"stdout": result.stdout, "stderr": result.stderr,
"command": command, "trace_sha256": digest(trace)}
if result.returncode == 0:
observed = json.loads(result.stdout)
run["observed"] = observed
run["passed"] = (observed.get("passed") is True
and observed.get("seed") == seed
and observed.get("verified_words") == 64
and observed.get("context_destroyed") is True)
else:
run["passed"] = False
except subprocess.TimeoutExpired as error:
run = {"seed": seed, "passed": False, "timeout": True, "error": str(error)}
report["runs"].append(run)
if not run["passed"]:
break
report["pci_driver_after"] = binding()
report["passed"] = (len(report["runs"]) == 2 and all(run["passed"] for run in report["runs"])
and report["pci_driver_after"] == before)
(out / "validation.json").write_text(json.dumps(report, indent=2) + "\n")
print(json.dumps(report, indent=2))
raise SystemExit(0 if report["passed"] else 1)