mirror of
https://github.com/QuixiAI/nvdriver.git
synced 2026-12-06 06:28:39 +00:00
* tools/docs: NixOS portability for first-open runner, bind_dev_nodes, pahole, and live-swap udev freeze * docs: note udev queue restart on failed or aborted live swaps * docs: drain in-flight udev workers with udevadm settle before freezing queue
1138 lines
68 KiB
Python
1138 lines
68 KiB
Python
#!/usr/bin/env python3
|
|
"""Bind one idle GPU to nvidia_rs, run first open once, and restore the GPU.
|
|
|
|
This is replacement-driver hardware execution. It releases the GPU from the
|
|
original driver, loads nvidia_rs for that one function with the read-only
|
|
register inventory enabled, opens its device node once, unloads the module and
|
|
rebinds the GPU to the original driver. The restore step always runs.
|
|
|
|
Requires sudo and an explicit --confirm naming the same PCI function.
|
|
"""
|
|
import argparse
|
|
import errno
|
|
import hashlib
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
import re
|
|
import subprocess
|
|
import sys
|
|
import time
|
|
|
|
import arch_gate
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
MODULE = ROOT / "kernel-open/nvidia_rs.ko"
|
|
BINDING = ROOT / "tools/gpu_binding.py"
|
|
|
|
|
|
def integer(text):
|
|
"""An int in decimal or 0x hex form."""
|
|
return int(text, 0)
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("--pci", required=True)
|
|
parser.add_argument("--confirm", required=True, help="repeat the PCI function to proceed")
|
|
parser.add_argument("--label", required=True)
|
|
parser.add_argument("--expect-arch", type=integer, metavar="N",
|
|
help="fail the run unless the inventory's 000a00 decodes to this "
|
|
"6-bit PMC_BOOT_42 architecture (0x1b for GB207)")
|
|
parser.add_argument("--forbid-impl", type=integer, metavar="N",
|
|
help="fail the run if 000a00 decodes to this implementation "
|
|
"(0xb is the GB20y/Tegra variant)")
|
|
parser.add_argument("--bringup-bar1", action="store_true",
|
|
help="module parameter bringup_bar1=1: with --bringup 4 or more, the BAR1 "
|
|
"bring-up, a one-page mapping compared through BAR1, BAR2 and PRAMIN, "
|
|
"and the unbind, after the level's own steps (notes 4231xxxx)")
|
|
parser.add_argument("--bringup", type=int, default=0,
|
|
help="direct bring-up level passed to the module (0 none, 1 MC engine enable, 2 adds "
|
|
"timer init, 3 runs the first-open engine reset before them, 4 adds the BAR2 "
|
|
"setup, 5 adds the NVDEC HS Falcon run and an NVDEC reset; level 5 refuses "
|
|
"and only logs while an input of the run has no provider; 6 adds the host "
|
|
"(PFIFO) load of OBJFIFO StateLoad, a read-back of its registers and the "
|
|
"original's unload, and runs only after levels 4 and 5 completed; 7 runs "
|
|
"Graphics InitLocked, StateLoad and StateUnload between that host load "
|
|
"and its unload, with BAR2 kept bound; it starts no Falcon and calls no "
|
|
"ACR routine; 8 is the ACR level (number 7 before 2026-11-19): levels 1 "
|
|
"to 6 without the Graphics level, then the ACR load on SEC2 followed at "
|
|
"once by the ACR unload on the PMU; it needs the user's explicit "
|
|
"approval for that experiment; 9 runs the ACR load inside the host "
|
|
"load and, while the regions are set, the Graphics load, the LS PMU "
|
|
"start, INIT, the bootstrap of SEC2, FECS and GPCCS and their starts "
|
|
"to FECS ready and the size queries, then SEC2 unload, Graphics "
|
|
"unload, PMU unload and the ACR unload; it needs the user's explicit "
|
|
"approval as well)")
|
|
parser.add_argument("--module-param", action="append", default=[], metavar="KEY=VALUE",
|
|
help="extra module parameter passed to insmod, repeatable and validated "
|
|
"against `modinfo -p`; the four parameters this tool sets itself "
|
|
"(pci_target, hardware_inventory, bringup, bringup_bar1) are refused. "
|
|
"Use it for the V100-only knobs a GB207 run must override, e.g. "
|
|
"--module-param v100_hbm_ndiv=0 --module-param nvlink=0")
|
|
arguments = parser.parse_args()
|
|
# Validate the extra parameters before the root check: a wrong key or a duplicate
|
|
# must fail whether or not the caller can load a module.
|
|
TOOL_PARAMETERS = {"pci_target", "hardware_inventory", "bringup", "bringup_bar1"}
|
|
|
|
def module_parameters():
|
|
"""The parameter names this module image accepts."""
|
|
result = subprocess.run(["modinfo", "-p", str(MODULE)], capture_output=True, text=True)
|
|
if result.returncode != 0:
|
|
raise SystemExit(f"modinfo -p {MODULE} failed: {result.stderr.strip()}")
|
|
return {line.split(":", 1)[0] for line in result.stdout.splitlines() if ":" in line}
|
|
|
|
extra = {}
|
|
for item in arguments.module_param:
|
|
key, separator, value = item.partition("=")
|
|
if not separator or not re.fullmatch(r"[A-Za-z_][A-Za-z0-9_]*", key):
|
|
parser.error(f"--module-param must be key=value with a C identifier key: {item!r}")
|
|
if key in TOOL_PARAMETERS:
|
|
parser.error(f"--module-param {key}: this tool sets that parameter itself")
|
|
if key in extra:
|
|
parser.error(f"--module-param {key} given more than once")
|
|
if not re.fullmatch(r"[^\s\x00-\x1f]*", value):
|
|
parser.error(f"--module-param {key}: the value must be printable without whitespace")
|
|
extra[key] = value
|
|
if extra:
|
|
unknown = sorted(set(extra) - module_parameters())
|
|
if unknown:
|
|
parser.error(f"--module-param: unknown module parameter(s) {', '.join(unknown)}; "
|
|
f"see `modinfo -p {MODULE}`")
|
|
if os.geteuid() != 0:
|
|
raise SystemExit("run with sudo")
|
|
if not re.fullmatch(r"[0-9a-f]{4}:[0-9a-f]{2}:[0-9a-f]{2}\.[0-7]", arguments.pci):
|
|
parser.error("a lowercase domain:bus:device.function is required")
|
|
if arguments.confirm != arguments.pci:
|
|
parser.error("--confirm must repeat --pci")
|
|
if not re.fullmatch(r"[A-Za-z0-9_-]+", arguments.label):
|
|
parser.error("label must contain only letters, digits, underscores or hyphens")
|
|
bdf = arguments.pci
|
|
device = Path("/sys/bus/pci/devices") / bdf
|
|
node = Path("/dev") / f"nvidia-rs-{bdf}"
|
|
|
|
|
|
def run(*command, timeout=300):
|
|
result = subprocess.run(command, capture_output=True, text=True, timeout=timeout)
|
|
return {"command": list(command), "exit_code": result.returncode,
|
|
"stdout": result.stdout[-4000:], "stderr": result.stderr[-4000:]}
|
|
|
|
|
|
def binding(action):
|
|
step = run(sys.executable, str(BINDING), action, bdf)
|
|
try:
|
|
step["report"] = json.loads(step.pop("stdout"))
|
|
except ValueError:
|
|
pass
|
|
return step
|
|
|
|
|
|
def driver():
|
|
link = device / "driver"
|
|
return link.resolve().name if link.exists() else None
|
|
|
|
|
|
def kernel_log():
|
|
result = subprocess.run(["dmesg"], capture_output=True, text=True)
|
|
return result.returncode, result.stderr.strip(), result.stdout.splitlines()
|
|
|
|
|
|
def proc_text(path):
|
|
"""Read a /proc file, returning None where the stock driver is not installed.
|
|
|
|
A clean testbench (and any VM built for this gate) has no
|
|
/proc/driver/nvidia/version, so an unguarded read here aborts the script at
|
|
import time, before it can even say what is missing.
|
|
"""
|
|
try:
|
|
return Path(path).read_text()
|
|
except OSError:
|
|
return None
|
|
|
|
|
|
report = {
|
|
"label": arguments.label, "pci": bdf, "kernel": os.uname().release,
|
|
"evidence_category": "replacement hardware execution",
|
|
"scope": "First open of nvidia_rs on one physical GPU with the read-only inventory and "
|
|
"the selected direct bring-up level. No CUDA work runs.",
|
|
"module_sha256": hashlib.sha256(MODULE.read_bytes()).hexdigest(),
|
|
"original_version": proc_text("/proc/driver/nvidia/version"),
|
|
"steps": [], "passed": False,
|
|
}
|
|
report["module_parameters"] = extra
|
|
# The firmware container is data copied from the user's own driver. Install it
|
|
# where the kernel firmware loader looks so the inventory can report it.
|
|
FIRMWARE = ROOT / "target/firmware/nvidia-rs/580.178.04/gv100.fw"
|
|
INSTALLED = Path("/lib/firmware/nvidia-rs/580.178.04/gv100.fw")
|
|
if FIRMWARE.exists():
|
|
if not INSTALLED.exists() or INSTALLED.read_bytes() != FIRMWARE.read_bytes():
|
|
INSTALLED.parent.mkdir(parents=True, exist_ok=True)
|
|
INSTALLED.write_bytes(FIRMWARE.read_bytes())
|
|
report["firmware_container_sha256"] = hashlib.sha256(INSTALLED.read_bytes()).hexdigest()
|
|
# The kernel log is a fixed-size ring. Once it has wrapped, a line count taken here stays
|
|
# about the same as old lines drop off, so slicing by it returns few or none of the lines
|
|
# this run adds. A unique marker written to /dev/kmsg finds where this run starts instead.
|
|
log_marker = f"nvdriver run_hardware_first_open {arguments.label} {os.getpid()} {time.time_ns()}"
|
|
log_before = None
|
|
try:
|
|
Path("/dev/kmsg").write_text(log_marker + "\n")
|
|
except OSError as error:
|
|
# Without a writable /dev/kmsg, fall back to the line count and say so in the report.
|
|
log_marker = None
|
|
log_before = len(kernel_log()[2])
|
|
report["kernel_log_anchor"] = f"line count: /dev/kmsg not writable ({error})"
|
|
failure = None
|
|
loaded = False
|
|
try:
|
|
step = binding("release")
|
|
report["steps"].append(step)
|
|
if step["exit_code"] != 0:
|
|
raise RuntimeError("release failed")
|
|
step = run("insmod", str(MODULE), f"pci_target={bdf}", "hardware_inventory=1",
|
|
f"bringup={arguments.bringup}",
|
|
*(["runtime_engines=0"] if "runtime_engines" not in extra else []),
|
|
*(["bringup_bar1=1"] if arguments.bringup_bar1 else []),
|
|
*[f"{key}={value}" for key, value in extra.items()])
|
|
report["steps"].append(step)
|
|
if step["exit_code"] != 0:
|
|
raise RuntimeError("insmod failed")
|
|
loaded = True
|
|
report["driver_after_load"] = driver()
|
|
if report["driver_after_load"] != "nvidia_rs":
|
|
raise RuntimeError(f"GPU is bound to {report['driver_after_load']}")
|
|
# Read the loaded module's parameters rather than guessing from a spelling such as
|
|
# runtime_engines=Y/on/1. Any positive bringup=N overrides runtime_engines in
|
|
# resolve_bringup_mode(), so diagnostic mode expects EOPNOTSUPP while effective
|
|
# runtime mode (runtime_engines=Y and bringup=0) must open successfully (#57).
|
|
runtime = Path("/sys/module/nvidia_rs/parameters/runtime_engines").read_text().strip()
|
|
if runtime not in ("Y", "N"):
|
|
raise RuntimeError(f"unexpected runtime_engines value {runtime!r}")
|
|
bringup_raw = Path("/sys/module/nvidia_rs/parameters/bringup").read_text().strip()
|
|
try:
|
|
bringup_param = int(bringup_raw, 0)
|
|
except ValueError as error:
|
|
raise RuntimeError(f"unexpected bringup value {bringup_raw!r}") from error
|
|
if bringup_param < 0:
|
|
raise RuntimeError(f"unexpected negative bringup value {bringup_param!r}")
|
|
report["runtime_engines"] = runtime == "Y"
|
|
report["effective_runtime_engines"] = (runtime == "Y") and (bringup_param == 0)
|
|
for _ in range(50):
|
|
if node.exists():
|
|
break
|
|
time.sleep(0.1)
|
|
try:
|
|
os.close(os.open(node, os.O_RDWR))
|
|
report["first_open"] = "succeeded"
|
|
except OSError as error:
|
|
report["first_open"] = errno.errorcode.get(error.errno, str(error.errno))
|
|
report["first_open_errno"] = error.errno
|
|
# Linux gives EOPNOTSUPP and ENOTSUP the same number; errorcode names it ENOTSUP.
|
|
expected_open = (report.get("first_open") == "succeeded"
|
|
if report["effective_runtime_engines"]
|
|
else report.get("first_open_errno") == errno.EOPNOTSUPP)
|
|
if not expected_open:
|
|
raise RuntimeError(f"unexpected first open result {report['first_open']}")
|
|
except Exception as error: # the restore below must still run
|
|
failure = str(error)
|
|
finally:
|
|
if loaded:
|
|
report["steps"].append(run("rmmod", "nvidia_rs"))
|
|
step = binding("restore")
|
|
report["steps"].append(step)
|
|
if step["exit_code"] != 0 and failure is None:
|
|
failure = "restore failed"
|
|
dmesg_status, dmesg_error, lines = kernel_log()
|
|
if dmesg_status != 0:
|
|
lines = []
|
|
if failure is None:
|
|
failure = f"dmesg failed (exit {dmesg_status}): {dmesg_error}"
|
|
elif log_marker is None:
|
|
lines = lines[log_before:]
|
|
else:
|
|
starts = [index for index, line in enumerate(lines) if log_marker in line]
|
|
if starts:
|
|
lines = lines[starts[-1] + 1:]
|
|
else:
|
|
lines = []
|
|
if failure is None:
|
|
failure = "kernel log marker not found: the log wrapped past the start of this run"
|
|
report["kernel_log"] = [line for line in lines if "nvidia_rs" in line or bdf in line
|
|
or "inventory" in line]
|
|
# One pass is logged at entry; a second follows when a bring-up level ran.
|
|
passes = []
|
|
for line in lines:
|
|
match = re.search(r"inventory ([0-9a-f]{6}) ([0-9a-f]{8})", line)
|
|
if match:
|
|
if not passes or match[1] in passes[-1]:
|
|
passes.append({})
|
|
passes[-1][match[1]] = match[2]
|
|
inventory = passes[0] if passes else {}
|
|
report["bringup_level"] = arguments.bringup
|
|
report["inventory"] = inventory
|
|
report["inventory_after_bringup"] = passes[1] if len(passes) > 1 else None
|
|
# Identity of the card that actually answered, from its own PMC_BOOT_42, so a
|
|
# run can assert GB207 (arch 0x1b, not the GB20y implementation 0xb) rather than
|
|
# have the report read by hand. tools/arch_gate.py holds the decode.
|
|
arch_failure = None
|
|
if inventory:
|
|
report["architecture"] = arch_gate.from_inventory(
|
|
inventory, arguments.expect_arch, arguments.forbid_impl)
|
|
if not report["architecture"]["passed"]:
|
|
arch_failure = "ARCHITECTURE GATE FAILED: " + report["architecture"].get(
|
|
"reason", "unknown")
|
|
# Registers that do not depend on driver state must read the same through
|
|
# nvidia_rs as they did under the original driver.
|
|
baseline_path = ROOT / "reports" / f"hardware-inventory-original-{bdf.split(':')[1]}.json"
|
|
if baseline_path.exists() and inventory:
|
|
baseline = json.loads(baseline_path.read_text())["inventory"]
|
|
# 0x88004 mirrors the PCI command word and depends on the bound driver, so it is not compared.
|
|
static = ["000000", "000a00", "002004", "100ce0", "088000", "088008"]
|
|
static += [f"{0x22700 + 4 * index:06x}" for index in range(64)]
|
|
report["static_register_mismatches"] = {
|
|
offset: {"original": baseline.get(offset), "replacement": inventory.get(offset)}
|
|
for offset in static if baseline.get(offset) != inventory.get(offset)}
|
|
report["static_registers_compared"] = len(static)
|
|
report["original_baseline"] = str(baseline_path.relative_to(ROOT))
|
|
if report["inventory_after_bringup"]:
|
|
# 0x1fecdff1 is the first active PMC enable word sampled under the original
|
|
# driver; it is a prediction for this build, not a pass criterion.
|
|
report["pmc_enable"] = {"before": inventory.get("000200"),
|
|
"after_mc_load": report["inventory_after_bringup"].get("000200"),
|
|
"original_first_active_value": "1fecdff1"}
|
|
# At level 3 the reset's read-back (note 4d430004) is the value to compare
|
|
# with the original trace: 1fecdff1 right after the 0xbfffffff write.
|
|
report["bus_interrupt_mask_after"] = report["inventory_after_bringup"].get("001140")
|
|
report["ptimer_after"] = {key: report["inventory_after_bringup"].get(key)
|
|
for key in ("009400", "009410")}
|
|
report["bringup_notes"] = [line.split("bringup note", 1)[1].strip() for line in lines
|
|
if "bringup note" in line]
|
|
# Level 5 (src/nvidia/kernel/nvdec_bringup.rs): its notes by name. Expected
|
|
# values are those of reports/gpu-nvdec-hs-run-validation.json for this board
|
|
# and are predictions, not pass criteria.
|
|
NVDEC_NOTES = {
|
|
0x4e440001: "stage", 0x4e440002: "missing_input", 0x4e440003: "fifo_engine_index",
|
|
0x4e440004: "fifo_reset_bit", 0x4e440005: "predicate", 0x4e440006: "bundle",
|
|
0x4e440007: "tags_signature_image_layout", 0x4e440008: "status",
|
|
0x4e440009: "cpuctl_before_start", 0x4e44000a: "cpuctl_after_halt",
|
|
0x4e44000b: "halt_polls", 0x4e44000c: "halt_microseconds",
|
|
0x4e44000d: "falcon_3a0_5d5_5d4", 0x4e44000e: "gpu_de0", 0x4e44000f: "pmc_enable_at_entry",
|
|
0x4e440010: "vpr_before_0", 0x4e440011: "vpr_before_1", 0x4e440012: "vpr_before_2",
|
|
0x4e440014: "vpr_after_0", 0x4e440015: "vpr_after_1", 0x4e440016: "vpr_after_2",
|
|
0x4e440020: "cleanup_status", 0x4e440021: "cleanup_8410c", 0x4e440022: "cleanup_pmc_enable",
|
|
0x4e440030: "firmware_errno", 0x4e4400d0: "diagnostic",
|
|
0x4e440040: "lsfm_mask", 0x4e440041: "lsfm_nvdec_id_and_bit", 0x4e440042: "lsfm_acr_flags",
|
|
0x4e440043: "lsfm_fuse_021434", 0x4e440044: "lsfm_clients_of_nvdec_and_pmu",
|
|
0x4e440045: "lsfm_refusal_reason_and_detail",
|
|
0x4e440180: "8410c_last", 0x4e440181: "8410c_reads"}
|
|
NVDEC_REGISTERS = ("1180fc", "1180f4", "021644", "10ac08", "084048", "08412c", "08410c",
|
|
"084624", "000200")
|
|
NVDEC_SNAPSHOT = NVDEC_REGISTERS[:8] + ("084100", "100cd0")
|
|
NVDEC_NOTES.update({0x4e440100 + index: f"first_read_{name}"
|
|
for index, name in enumerate(NVDEC_REGISTERS)})
|
|
NVDEC_NOTES.update({0x4e440200 + index: f"snapshot_{name}"
|
|
for index, name in enumerate(NVDEC_SNAPSHOT)})
|
|
NVDEC_MISSING = {
|
|
1: "firmware container",
|
|
2: "OBJLSFM+198 bit (Io::lsfm_manages_falcon; see lsfm_refusal_reason_and_detail)",
|
|
4: "fuse object function +168",
|
|
5: "GPU function +3b8", 6: "registry", 7: "engine table", 8: "NVDEC engine record",
|
|
9: "unreached clock-gating service", 10: "manager device table (Io::gpu_section)",
|
|
11: "kernel storage", 12: "KernelFifo function +170", 13: "Falcon configuration"}
|
|
NVDEC_STAGES = {0xffff0001: "PMC enable bit 15 clear", 0xffff0002: "refused", 0xffff0003:
|
|
"predicate false, not run", 0xffff0004: "failed", 0x00050000: "completed"}
|
|
NVDEC_EXPECTED = {
|
|
"fifo_engine_index": "00000041", "fifo_reset_bit": "0000000f", "predicate": "00000001",
|
|
"bundle": "01146eb0", "tags_signature_image_layout": "000e2318", "status": "00000000",
|
|
"cpuctl_before_start": "00000010", "cpuctl_after_halt": "00000010",
|
|
"falcon_3a0_5d5_5d4": "00010360", "gpu_de0": "140000a1", "pmc_enable_at_entry": "1fecdff1",
|
|
"vpr_before_0": "1ffff000", "vpr_before_1": "00000001", "vpr_before_2": "0000002a",
|
|
"vpr_after_0": "1ffff000", "vpr_after_1": "00000001", "vpr_after_2": "0000002a",
|
|
"first_read_1180fc": "247fffff", "first_read_1180f4": "00000000",
|
|
"first_read_021644": "00000001", "first_read_10ac08": "00000000",
|
|
"first_read_084048": "00000004", "first_read_08412c": "996b1136",
|
|
"first_read_08410c": "00000003", "first_read_084624": "00000110",
|
|
"first_read_000200": "1fecdff1", "cleanup_status": "00000000",
|
|
# reports/gpu-lsfm-mask-validation.json: no Falcon excluded, NVDEC id 4,
|
|
# OBJACR enabled, fuse word 1 (transcript line 37714), both clients.
|
|
"lsfm_mask": "00000000", "lsfm_nvdec_id_and_bit": "00000400",
|
|
"lsfm_acr_flags": "00000000", "lsfm_fuse_021434": "00000001",
|
|
"lsfm_clients_of_nvdec_and_pmu": "00000002"}
|
|
nvdec = {}
|
|
for note in report["bringup_notes"]:
|
|
code, value = note.split()
|
|
name = NVDEC_NOTES.get(int(code, 16))
|
|
if name == "missing_input":
|
|
nvdec.setdefault(name, []).append(NVDEC_MISSING.get(int(value, 16), value))
|
|
elif name == "stage":
|
|
nvdec[name] = NVDEC_STAGES.get(int(value, 16), value)
|
|
elif name == "diagnostic":
|
|
nvdec.setdefault(name, []).append(value)
|
|
elif name:
|
|
nvdec[name] = value
|
|
if nvdec:
|
|
nvdec["differs_from_original_trace"] = {
|
|
name: {"expected": expected, "observed": nvdec[name]}
|
|
for name, expected in NVDEC_EXPECTED.items() if name in nvdec and nvdec[name] != expected}
|
|
report["nvdec_hs_run"] = nvdec
|
|
# Level 4 (src/nvidia/kernel/adapter_start.rs compute_placement): the register
|
|
# words the placement is computed from and the computed placement, by name.
|
|
# Expected values are the original's on this board: the register words of
|
|
# target/trace/b3-bar0.txt (lines 37530, 37590, 37591, 37594, 37597, 37598,
|
|
# 37583, 37529; class word line 138922) and the placement the original
|
|
# instructions give for them (reports/gpu-memory-placement-validation.json),
|
|
# which the trace shows in 0x1700, 0x1704, 0x1714 and 0x100cc8/0x100ccc.
|
|
# Addresses are in 4 KiB pages. Predictions, not pass criteria.
|
|
PLACEMENT_NOTES = {0x42320010 + index: f"register_{name}" for index, name in enumerate(
|
|
("100ce0", "100a0c", "100e34", "100e48", "002008", "104028", "17e3f4", "12006c"))}
|
|
PLACEMENT_NOTES.update({
|
|
0x42320018: "pci_class_word_088008", 0x42320020: "hidden_limit",
|
|
0x42320021: "reserved_base_page", 0x42320022: "reserved_size",
|
|
0x42320023: "comptag_store_page", 0x42320024: "mmu_read_page",
|
|
0x42320025: "mmu_write_page", 0x42320026: "flush_page", 0x42320027: "test_page",
|
|
0x42320028: "later_wpr_sized_request_page",
|
|
0x42320029: "internal_heap_base_page_upper_bound", 0x4232002f: "refusal"})
|
|
PLACEMENT_REFUSALS = {1: "not a PCI 3D controller (display or console inputs not computed)",
|
|
2: "a placement register read returned the PRI error signature",
|
|
3: "the original asserts or fails for these inputs, or the model's "
|
|
"bounds were exceeded"}
|
|
PLACEMENT_EXPECTED = {
|
|
"register_100ce0": "0000020a", "register_100a0c": "00001000",
|
|
"register_100e34": "60002061", "register_100e48": "40001800",
|
|
"register_002008": "00001000", "register_104028": "000001ff",
|
|
"register_17e3f4": "401c0002", "register_12006c": "00000010",
|
|
"pci_class_word_088008": "030200a1", "hidden_limit": "0a090fff",
|
|
"reserved_base_page": "007fffa0", "reserved_size": "00060000",
|
|
"comptag_store_page": "007fdfa0", "mmu_read_page": "007fdf90",
|
|
"mmu_write_page": "007fdf80", "flush_page": "007fdf7f", "test_page": "007fdf7e",
|
|
"later_wpr_sized_request_page": "007fde80",
|
|
# With the cross-object heap sizes taken as zero; the original's base is at or below it.
|
|
"internal_heap_base_page_upper_bound": "007f99a0"}
|
|
computed = {}
|
|
for note in report["bringup_notes"]:
|
|
code, value = note.split()
|
|
name = PLACEMENT_NOTES.get(int(code, 16))
|
|
if name == "refusal":
|
|
# Two notes: the reason, then its detail (class word, register or error code).
|
|
computed.setdefault(name, []).append(
|
|
PLACEMENT_REFUSALS.get(int(value, 16), value) if not computed.get(name) else value)
|
|
elif name:
|
|
computed[name] = value
|
|
if computed:
|
|
computed["differs_from_original_trace"] = {
|
|
name: {"expected": expected, "observed": computed[name]}
|
|
for name, expected in PLACEMENT_EXPECTED.items()
|
|
if name in computed and computed[name] != expected}
|
|
report["memory_placement"] = computed
|
|
# Level 6 (src/nvidia/kernel/fifo_bringup.rs): its notes by name, with the values of the
|
|
# original on the same board from target/trace/b3-bar0.txt. "written" values are what the
|
|
# original wrote there (lines 140621-140934) and are compared with a read-back the
|
|
# transcript does not contain; "read" values are transcript reads (lines 140621-141012).
|
|
FIFO_NOTES = {
|
|
0x46490001: "stage", 0x46490002: "missing_input", 0x46490003: "pmc_enable_at_entry",
|
|
0x46490004: "gpu_image_bytes_911_93b_917_926_52f2_52f3_and_word_918",
|
|
0x46490005: "engines_runlists_pbdmas", 0x46490006: "channels_register_002008",
|
|
0x46490007: "context_switch_timeout_with_enable", 0x46490008: "wait_timeout_us",
|
|
0x46490009: "pbdma_timeout_key", 0x4649000a: "load_status",
|
|
0x4649000b: "interrupt_enable_mask", 0x4649000c: "preempt_reads_and_pending",
|
|
0x4649000d: "userd_base_write_status", 0x4649000e: "unload_status",
|
|
0x4649000f: "load_microseconds", 0x46490010: "interrupt_pending_at_unload",
|
|
0x46490011: "stopped_by", 0x464900d0: "diagnostic"}
|
|
FIFO_WATCHED = ("088004", "000200", "001100", "009080", "088714", "088014", "088018", "04013c",
|
|
"002630", "002a04")
|
|
FIFO_READBACK = ("002140", "002528", "002100", "002630", "002638", "002a00", "002a04", "002a0c",
|
|
"002254", "0012d0", "0026e0", "0026ec", "04010c", "04012c", "04013c", "04014c",
|
|
"05a12c", "002270", "002274", "000200")
|
|
FIFO_AFTER_UNLOAD = ("002100", "002140", "002528", "002a00", "0026ec", "002254")
|
|
FIFO_NOTES.update({0x46490100 + runlist: f"runlist_{runlist}_first_buffer_page"
|
|
for runlist in range(16)})
|
|
FIFO_NOTES.update({0x46490200 + index: f"first_read_{name}"
|
|
for index, name in enumerate(FIFO_WATCHED)})
|
|
FIFO_NOTES.update({0x46490300 + index: f"after_load_{name}"
|
|
for index, name in enumerate(FIFO_READBACK)})
|
|
FIFO_NOTES.update({0x46490400 + index: f"after_unload_{name}"
|
|
for index, name in enumerate(FIFO_AFTER_UNLOAD)})
|
|
FIFO_STAGES = {0xffff0001: "refused: PMC enable bit 8 (host) is clear",
|
|
0xffff0002: "refused: an input has no provider or a path is not implemented",
|
|
0xffff0003: "not run: level 4 or level 5 did not complete",
|
|
0xffff0004: "failed", 0x00060000: "completed"}
|
|
FIFO_MISSING = {1: "registry", 2: "engine table", 3: "kernel storage",
|
|
4: "register 0x2008 (channel count)", 5: "heap model after the BAR2 test page",
|
|
6: "register override table of the GPU object", 7: "more than 16 runlists"}
|
|
FIFO_STOPS = {1: "timer delay", 2: "clock-gating service", 3: "LPWR mutex",
|
|
4: "runlist restriction tree",
|
|
5: "a preempt was still pending and the interrupt service has no provider",
|
|
6: "copy-engine reset bit"}
|
|
# Runlists in the order their owners are created (engine table order of the first engine).
|
|
OWNER_ORDER = (0, 6, 1, 3, 2, 4, 7, 8, 9, 5, 10, 11, 12)
|
|
FIFO_EXPECTED = {
|
|
"stage": "00060000", "pmc_enable_at_entry": "1fecdff1",
|
|
"engines_runlists_pbdmas": "000f0d0e", "channels_register_002008": "00001000",
|
|
"context_switch_timeout_with_enable": "803fffff", "pbdma_timeout_key": "00000000",
|
|
"load_status": "00000000", "interrupt_enable_mask": "7fffffff",
|
|
"preempt_reads_and_pending": "0000000f", "userd_base_write_status": "00000000",
|
|
"unload_status": "00000000",
|
|
# Reads of the transcript.
|
|
"first_read_088004": "00100506", "first_read_000200": "1fecdff1",
|
|
"first_read_001100": "00000000", "first_read_009080": "80002000",
|
|
"first_read_088714": "000048cf", "first_read_088014": "0000000c",
|
|
"first_read_088018": "000039a0", "first_read_04013c": "effffeff",
|
|
"first_read_002630": "00000000", "first_read_002a04": "800f4240",
|
|
"after_load_002140": "61810101", "after_load_002100": "40000000",
|
|
"after_load_002a00": "00001fff", "after_load_002a04": "800f4240",
|
|
"interrupt_pending_at_unload": "40000000", "after_unload_002100": "00000000",
|
|
# Values the original wrote; the transcript has no read-back of them.
|
|
"after_load_002528": "80000000", "after_load_002630": "00000000",
|
|
"after_load_002638": "00000000", "after_load_002a0c": "803fffff",
|
|
"after_load_002254": "10000000", "after_load_0012d0": "00002800",
|
|
"after_load_0026e0": "0000c242", "after_load_0026ec": "00000000",
|
|
"after_load_04010c": "fffff7ff", "after_load_04012c": "000f4240",
|
|
"after_load_04013c": "effff6ff", "after_load_04014c": "ffffffff",
|
|
"after_load_05a12c": "000f4240", "after_load_002274": "00c00000",
|
|
"after_load_000200": "1fecdff1", "after_unload_002140": "00000000",
|
|
"after_unload_002528": "00000000", "after_unload_0026ec": "0001fffe",
|
|
"after_unload_002254": "00000000"}
|
|
# The runlist buffers: this path makes no WPR or PMU request before them, so the verified
|
|
# heap model places them from 0x7fdf50000 down; the original's are from 0x7fdb70000 down.
|
|
FIFO_BUFFERS_THIS_PATH = {f"runlist_{runlist}_first_buffer_page": f"{0x7fdf50 - 0x40 * index:08x}"
|
|
for index, runlist in enumerate(OWNER_ORDER)}
|
|
FIFO_BUFFERS_ORIGINAL = {f"runlist_{runlist}_first_buffer_page": f"{0x7fdb70 - 0x40 * index:08x}"
|
|
for index, runlist in enumerate(OWNER_ORDER)}
|
|
FIFO_EXPECTED.update(FIFO_BUFFERS_THIS_PATH)
|
|
FIFO_EXPECTED["after_load_002270"] = FIFO_BUFFERS_THIS_PATH["runlist_12_first_buffer_page"]
|
|
fifo = {}
|
|
for note in report["bringup_notes"]:
|
|
code, value = note.split()
|
|
name = FIFO_NOTES.get(int(code, 16))
|
|
if name in ("missing_input", "diagnostic", "stopped_by"):
|
|
table = {"missing_input": FIFO_MISSING, "stopped_by": FIFO_STOPS}.get(name, {})
|
|
fifo.setdefault(name, []).append(table.get(int(value, 16), value))
|
|
elif name:
|
|
fifo[name] = value
|
|
if fifo:
|
|
if "stage" in fifo:
|
|
fifo["stage_meaning"] = FIFO_STAGES.get(int(fifo["stage"], 16), "unknown")
|
|
fifo["differs_from_expected"] = {
|
|
name: {"expected": expected, "observed": fifo[name]}
|
|
for name, expected in FIFO_EXPECTED.items() if name in fifo and fifo[name] != expected}
|
|
fifo["runlist_buffers_of_the_original_trace"] = FIFO_BUFFERS_ORIGINAL
|
|
fifo["expectation_basis"] = (
|
|
"target/trace/b3-bar0.txt lines 140621-141012; runlist buffer pages and the last "
|
|
"0x2270 value are those of the verified heap model for this path, which makes no WPR "
|
|
"or PMU request first (the original's are listed separately); after_load_002a00 and "
|
|
"the pending interrupt in the trace follow one more submit of runlist 6")
|
|
report["fifo_load"] = fifo
|
|
# Level 7 (src/nvidia/kernel/gr_bringup.rs): Graphics InitLocked, StateLoad and StateUnload
|
|
# between the host load and the host unload. Expected values of the load part are those of
|
|
# the original on the same board (target/trace/b3-bar0.txt lines 156720-158348, marked
|
|
# "transcript"); the VBIOS values are what the original's parser gives on the image captured
|
|
# from this board ("captured image"); the transcript holds no unload and has lost events
|
|
# over InitLocked, so those values are what the emulated original leaves ("emulation",
|
|
# reports/gpu-graphics-level-validation.json). Predictions, not pass criteria; what fails the
|
|
# run is listed at the end of this section.
|
|
GR_NOTES = {
|
|
0x47520001: "stage", 0x47520002: "refusal", 0x47520003: "core_reason",
|
|
0x47520004: "pmc_enable_at_entry",
|
|
0x47520005: "gpu_image_bytes_911_52fc_915_917_918_919_926_90e_e00_90c_91d_and_word_4de4",
|
|
0x47520006: "bus_gpcs_fuse_gpcs_tpcs_per_gpc_bus_664", 0x47520007: "fuse_gpc_mask_021c1c",
|
|
0x47520008: "vbios_table_pointer_438", 0x47520009: "vbios_table_version_and_entries",
|
|
0x4752000a: "init_status", 0x4752000b: "tpc_counts_per_gpc",
|
|
0x4752000c: "fuse_tpc_masks_gpc_0_to_3", 0x4752000d: "fuse_tpc_masks_gpc_4_and_5",
|
|
0x4752000e: "tile_row_offset_tpcs_ppcs", 0x4752000f: "non_ctx_load_bytes",
|
|
0x47520010: "mmu_write_page_objgmmu_410", 0x47520011: "mmu_read_page_objgmmu_408",
|
|
0x47520012: "load_status", 0x47520013: "zbc_status",
|
|
0x47520014: "features_wanted_done_allowed", 0x47520015: "grinfo_608",
|
|
0x47520016: "load_reads", 0x47520017: "load_writes", 0x47520018: "load_microseconds",
|
|
0x47520019: "engine_status_queries_and_busy_answers", 0x4752001a: "unload_status",
|
|
0x4752001b: "unload_reads", 0x4752001c: "unload_writes", 0x4752001d: "stopped_by",
|
|
0x4752001e: "init_reads_and_writes", 0x4752001f: "register_with_pri_error_signature",
|
|
0x47520020: "vbios_base_1250",
|
|
0x47520021: "vbios_expansion_124c", 0x47520022: "vbios_bit_offset",
|
|
0x47520023: "load_waits",
|
|
0x47520030: "firmware_errno", 0x475200d0: "diagnostic",
|
|
0x475200ff: "unload_incomplete_after_this_many_load_writes"}
|
|
GR_WATCHED = ("400500", "100c80", "100cc8", "100ccc", "100cc4", "4188b0", "400700", "003080",
|
|
"002640", "409b00", "409044", "503018", "100800", "100804", "12006c", "500c50",
|
|
"409660", "17e338", "419b30", "4188a4")
|
|
GR_READBACK = ("400500", "400100", "40013c", "400138", "400130", "400118", "400108", "400124",
|
|
"409c24", "100cc4", "100cc8", "100ccc", "418880", "4188b0", "4188b4", "4188b8",
|
|
"500914", "500910", "500918", "41bfd4", "4181d0", "4188a4", "17e338", "409b00",
|
|
"400700", "000200")
|
|
GR_AFTER_UNLOAD = ("400500", "400100", "40013c", "400138", "400130", "400118", "40011c",
|
|
"400134", "400124", "409c24", "409048", "41a048", "504508", "502c90",
|
|
"410204", "000200")
|
|
GR_NOTES.update({0x47520100 + index: f"first_read_{name}"
|
|
for index, name in enumerate(GR_WATCHED)})
|
|
GR_NOTES.update({0x47520200 + index: f"after_load_{name}"
|
|
for index, name in enumerate(GR_READBACK)})
|
|
GR_NOTES.update({0x47520300 + index: f"after_unload_{name}"
|
|
for index, name in enumerate(GR_AFTER_UNLOAD)})
|
|
GR_STAGES = {0xffff0001: "refused: PMC enable bit 12 (Graphics) is clear",
|
|
0xffff0002: "refused before the first register write",
|
|
0xffff0003: "not run: the host load of level 6 did not complete",
|
|
0xffff0004: "failed",
|
|
0xffff0005: "stopped after writes; the unload ran and returned 0",
|
|
0x00070000: "completed: InitLocked, load, then unload"}
|
|
GR_REFUSALS = {
|
|
1: "registry", 2: "firmware container", 3: "kernel storage",
|
|
4: "netlist record or its region 6", 5: "VBIOS image through the PROM window (image list "
|
|
"or BIT header)", 6: "a BIT 'P' token the parser does not reproduce",
|
|
7: "VBIOS override table with entries, with more than 0x20 entries, or outside the image "
|
|
"list", 8: "GPU state (GPU+4de4, +90c, GPU+cac other than 0x20, or the platform words "
|
|
"GPU+d2c and +d30)",
|
|
9: "an original branch a core routine does not reproduce (see core_reason)",
|
|
10: "InitLocked would end with a non-zero status (see init_status)",
|
|
11: "a register read failed or a provider stopped before the first write",
|
|
12: "registry key RMZcullEqualScreenDistOnFS",
|
|
13: "a register read before the first write returned the PRI error signature (see "
|
|
"register_with_pri_error_signature)"}
|
|
GR_STOPS = {1: "a clock-gating service no GV100 input reaches", 2: "FECS context unload "
|
|
"(_nv033702rm)", 3: "the ZBC service method of the provider", 4: "a register access"}
|
|
|
|
|
|
def fnv(text):
|
|
value = 0x811c9dc5
|
|
for byte in text.encode():
|
|
value = ((value ^ byte) * 0x01000193) & 0xffffffff
|
|
return value
|
|
|
|
|
|
# The reasons of the core routines by the code the level logs: every string literal of the
|
|
# core sources, hashed as kernel/gr_bringup.rs text_code does.
|
|
GR_REASONS = {}
|
|
for name in ("gr_init", "gr_load_sequence", "gr_load", "gr_zbc", "memsys_zbc", "gr_unload"):
|
|
source = ROOT / "src/nvidia/src/gpu" / f"{name}.rs"
|
|
if source.exists():
|
|
for literal in re.findall(r'"([^"\\\n]+)"', source.read_text()):
|
|
GR_REASONS[fnv(literal)] = literal
|
|
GR_EXPECTED_TRANSCRIPT = {
|
|
"stage": "00070000", "pmc_enable_at_entry": "1fecdff1",
|
|
# Lines 37600-37603: 0x120078 = 6, 0x22430 = 6, 0x22434 = 7, 0x22438 = 8.
|
|
"bus_gpcs_fuse_gpcs_tpcs_per_gpc_bus_664": "08070606",
|
|
# Line 166287.
|
|
"fuse_gpc_mask_021c1c": "00000000",
|
|
# Lines 157093-157110 (+914 words) and the fuse words of lines 166291-166335.
|
|
"tpc_counts_per_gpc": "00676777", "fuse_tpc_masks_gpc_0_to_3": "7e7f7f7f",
|
|
"fuse_tpc_masks_gpc_4_and_5": "00007e7f", "tile_row_offset_tpcs_ppcs": "00032812",
|
|
"mmu_write_page_objgmmu_410": "007fdf80", "mmu_read_page_objgmmu_408": "007fdf90",
|
|
"load_status": "00000000", "zbc_status": "00000000",
|
|
"features_wanted_done_allowed": "00000fff", "grinfo_608": "00000040",
|
|
# 349 reads are the traced count, in which every poll was answered at its first read.
|
|
# The original repeats a poll that is not yet answered (_nv031833rm, _nv031876rm,
|
|
# _nv031879rm: read, timeout check, yield, read again), so on hardware the count is 349
|
|
# plus the repeats; "load_reads_without_waits" below removes them when the level logs
|
|
# them (note 47520023).
|
|
"load_reads_without_waits": "0000015d", "load_writes": "00000500",
|
|
"engine_status_queries_and_busy_answers": "00000007",
|
|
# First values read in lines 156720-158348. The two status words (003080, 002640) and
|
|
# 100c80 depend on what ran before; the original had channels then.
|
|
"first_read_400500": "00000000", "first_read_100c80": "00208001",
|
|
"first_read_100cc8": "07fdf800", "first_read_100ccc": "07fdf900",
|
|
"first_read_100cc4": "00020000", "first_read_4188b0": "00000000",
|
|
"first_read_400700": "00000000", "first_read_003080": "10021002",
|
|
"first_read_002640": "10021002", "first_read_409b00": "00000000",
|
|
"first_read_409044": "00000000", "first_read_503018": "00000000",
|
|
"first_read_100800": "000f0010", "first_read_100804": "00000000",
|
|
"first_read_12006c": "00000010", "first_read_500c50": "00000007",
|
|
"first_read_409660": "0003f100", "first_read_17e338": "0000000f",
|
|
"first_read_419b30": "70070080", "first_read_4188a4": "00000000",
|
|
# Values the original wrote; the transcript has no read-back of them. Status registers
|
|
# (400100, 400108, 400118: read and cleared bit by bit in the original's exception
|
|
# service _nv032471rm) do not read back what is written and have no expectation.
|
|
# 40013c and 400138 keep only their implemented enable bits: 003901f3 is the value the
|
|
# original's own netlist list writes to 40013c (transcript line 156748), and 030001bf
|
|
# is what this board read back in both level 7 runs of 2026-11-19 (hardware
|
|
# observation, not transcript; _nv032471rm tests bits 0-5, 7, 8 and 24 of 400108).
|
|
"after_load_400500": "00010001", "after_load_40013c": "003901f3",
|
|
"after_load_400138": "030001bf", "after_load_400130": "ffffffff",
|
|
"after_load_400124": "00000002",
|
|
"after_load_409c24": "000e0002", "after_load_100cc4": "00020000",
|
|
"after_load_100cc8": "07fdf800", "after_load_100ccc": "07fdf900",
|
|
"after_load_418880": "00000001", "after_load_4188b0": "00020000",
|
|
"after_load_4188b4": "07fdf800", "after_load_4188b8": "07fdf900",
|
|
# 500910: the original writes 00040028 (line 157094) and never reads the register.
|
|
# Both level 7 runs read 40040028; bit 30 is not explained (see
|
|
# reports/hardware-first-open-b3-level7-analysis.json), so the written value stays the
|
|
# expectation and the difference stays reported.
|
|
"after_load_500914": "00000307", "after_load_500910": "00040028",
|
|
"after_load_500918": "00033334", "after_load_41bfd4": "00033334",
|
|
"after_load_4181d0": "00777777", "after_load_4188a4": "03000000",
|
|
"after_load_17e338": "0000000f", "after_load_409b00": "00000000",
|
|
"after_load_400700": "00000000", "after_load_000200": "1fecdff1"}
|
|
# What the original's parser (_nv037435rm, _nv059989rm, _nv000194rm) gives on the image
|
|
# captured from this board (target/physical/prom-b3.bin; oracle rows WP, D and VP).
|
|
GR_EXPECTED_CAPTURED_IMAGE = {
|
|
"vbios_bit_offset": "000001b0", "vbios_base_1250": "0000e400",
|
|
"vbios_expansion_124c": "00011800", "vbios_table_pointer_438": "00021a33",
|
|
"vbios_table_version_and_entries": "00200000", "non_ctx_load_bytes": "00000a90"}
|
|
# What the emulated original does (no transcript evidence): InitLocked makes 28 register
|
|
# reads, 12 fuse queries and 6 fuse reads (two registers each) and one write; the unload
|
|
# makes 8 reads and 135 writes when both Falcon interface words read with bits 1:0 clear.
|
|
GR_EXPECTED_EMULATION = {
|
|
"init_status": "00000000", "init_reads_and_writes": "00010040",
|
|
"unload_status": "00000000", "unload_reads": "00000008", "unload_writes": "00000087",
|
|
"after_unload_400500": "00000000", "after_unload_40013c": "00000000",
|
|
"after_unload_400138": "00000000", "after_unload_400130": "00000000",
|
|
"after_unload_400118": "00000000", "after_unload_40011c": "00000000",
|
|
"after_unload_400134": "00000000", "after_unload_400124": "00000000",
|
|
"after_unload_409c24": "00000000", "after_unload_504508": "00000000",
|
|
"after_unload_502c90": "00000000", "after_unload_410204": "00000000",
|
|
"after_unload_000200": "1fecdff1"}
|
|
graphics = {}
|
|
for note in report["bringup_notes"]:
|
|
code, value = note.split()
|
|
name = GR_NOTES.get(int(code, 16))
|
|
if name == "refusal":
|
|
graphics.setdefault(name, []).append(GR_REFUSALS.get(int(value, 16), value))
|
|
elif name == "core_reason":
|
|
graphics.setdefault(name, []).append(GR_REASONS.get(int(value, 16), value))
|
|
elif name == "stopped_by":
|
|
graphics.setdefault(name, []).append(GR_STOPS.get(int(value, 16), value))
|
|
elif name == "diagnostic":
|
|
graphics.setdefault(name, []).append(value)
|
|
elif name:
|
|
graphics[name] = value
|
|
graphics_failure = None
|
|
if graphics:
|
|
stage = int(graphics.get("stage", "0"), 16)
|
|
graphics["stage_meaning"] = GR_STAGES.get(stage, "no stage note: the level did not end")
|
|
if "load_reads" in graphics and "load_waits" in graphics:
|
|
waits = int(graphics["load_waits"], 16)
|
|
polls, line, pending = waits & 0xffff, waits >> 16 & 0xfff, waits >> 28
|
|
graphics["load_waits_meaning"] = {
|
|
"repeated_polls": polls, "source_line_of_the_first": f"{line:x}" if polls else None,
|
|
"reads_of_40060c": pending}
|
|
# A repeat of the idle wait (line b3f) costs four or five reads, not one. Only the
|
|
# first line is logged: when it is b3f nothing is derived, and an idle repeat after
|
|
# a TPC poll shows up as a difference from 349.
|
|
if line != 0xb3f:
|
|
graphics["load_reads_without_waits"] = (
|
|
f"{int(graphics['load_reads'], 16) - polls - pending:08x}")
|
|
for label, expected in (("transcript", GR_EXPECTED_TRANSCRIPT),
|
|
("captured_image", GR_EXPECTED_CAPTURED_IMAGE),
|
|
("emulation", GR_EXPECTED_EMULATION)):
|
|
graphics[f"differs_from_{label}"] = {
|
|
name: {"expected": value, "observed": graphics[name]}
|
|
for name, value in expected.items() if name in graphics and graphics[name] != value}
|
|
graphics["expectation_basis"] = (
|
|
"transcript: target/trace/b3-bar0.txt lines 156720-158348 (and the lines named in "
|
|
"the tool); captured_image: the original's parser on target/physical/prom-b3.bin; "
|
|
"emulation: the emulated original (InitLocked falls in a lost-event gap of the "
|
|
"transcript, which holds no unload)")
|
|
# The level fails the run when it reports a failure, or when a write was made and the
|
|
# unload is not confirmed: no unload status, a non-zero one, or the alarm note.
|
|
wrote = any(name in graphics for name in ("load_status", "load_writes")) or any(
|
|
name.startswith("after_load_") for name in graphics)
|
|
if stage in (0xffff0004, 0xffff0005) or "stage" not in graphics:
|
|
graphics_failure = f"GRAPHICS LEVEL: {graphics['stage_meaning']}"
|
|
elif "unload_incomplete_after_this_many_load_writes" in graphics:
|
|
graphics_failure = "GRAPHICS LEVEL: THE UNLOAD DID NOT COMPLETE"
|
|
elif wrote and graphics.get("unload_status") != "00000000":
|
|
graphics_failure = "GRAPHICS LEVEL: A LOAD WAS NOT FOLLOWED BY A SUCCESSFUL UNLOAD"
|
|
report["graphics_init_load_unload"] = graphics
|
|
# Level 8 (src/nvidia/kernel/acr_bringup.rs; level 7 until 2026-11-19, when the Graphics
|
|
# level took that number and the stage values 0007xxxx became 0008xxxx): ACR load on SEC2,
|
|
# then the ACR unload on the PMU. The level refuses before its first register write while an
|
|
# input has no provider.
|
|
# Expected values of the load part are those of target/trace/b3-bar0.txt lines 147254-147279
|
|
# (analysis/closed-driver-580/acr-load-implementation-notes.md, section 5); the transcript
|
|
# holds no unload, so the values after it have no trace counterpart.
|
|
ACR_NOTES = {
|
|
0x41430001: "stage", 0x41430002: "unresolved_input", 0x41430003: "container_records",
|
|
0x41430004: "firmware_errno", 0x41430005: "acr_bytes", 0x41430006: "fuse_021434",
|
|
0x41430007: "wpr_primary_page", 0x41430008: "wpr_shadow_page",
|
|
0x41430009: "pmu_surface_page", 0x4143000a: "unload_image_bus_address_256",
|
|
0x4143000b: "pci_command_at_entry", 0x4143000c: "pci_command_with_bus_mastering",
|
|
0x4143000d: "pci_command_at_end", 0x4143000f: "region_set_at_entry",
|
|
0x41430020: "sec2_mailbox0_after_load", 0x41430021: "sec2_mailbox1_after_load",
|
|
0x41430022: "pmu_cpuctl_after_load", 0x41430023: "sec2_cpuctl_after_load",
|
|
0x41430024: "hs_image_page", 0x41430025: "sec2_instance_block_page",
|
|
0x41430026: "pmu_instance_block_page",
|
|
# What the first step of the load (PMU+2f8 _nv052412rm, core acr_load::pmu_slot_2f8)
|
|
# tests, read just before it, and the scratch registers afterwards.
|
|
0x41430027: "pmu_cpuctl_before_load", 0x41430028: "pmu_sctl_10a240_before_load",
|
|
0x41430029: "scratch1_001584_before_load", 0x4143002a: "scratch5_001594_before_load",
|
|
0x4143002b: "scratch6_001598_before_load", 0x4143002c: "pmu_stop_wait_status",
|
|
0x4143002d: "scratch1_001584_after_load", 0x4143002e: "scratch6_001598_after_load",
|
|
0x41430031: "load_unsupported_branch", 0x41430044: "unload_unsupported_branch",
|
|
0x41430030: "load_status", 0x41430032: "region_set_after_load",
|
|
0x41430033: "sec2_stop", 0x41430034: "pmc_enable_after_sec2_stop",
|
|
0x41430073: "region_set_at_end", 0x41430074: "system_memory_leaked",
|
|
0x41430075: "dma_context_closed_by_force_allocations_freed",
|
|
0x41430076: "region_set_after_restore",
|
|
0x41430040: "unload_status", 0x41430041: "pmu_mailbox0_after_unload",
|
|
0x41430042: "pmu_cpuctl_after_unload", 0x41430043: "pmu_wait_timed_out_cpuctl",
|
|
0x41430070: "flush_register_100c10_as_found", 0x41430071: "flush_page_address_256",
|
|
0x41430072: "cleanup_bits", 0x41430080: "service_not_provided",
|
|
0x414300ff: "unload_failed_or_regions_still_set"}
|
|
ACR_NOTES.update({0x41430010 + index: f"after_load_100cd4_index_{index}" for index in range(6)})
|
|
ACR_NOTES.update({0x41430050 + index: f"after_unload_100cd4_index_{index}"
|
|
for index in range(6)})
|
|
ACR_STAGES = {0xffff0002: "refused: an input has no provider",
|
|
0xffff0003: "not run: a lower level did not complete",
|
|
0xffff0004: "failed", 0x00080000: "completed: load, then unload",
|
|
0x00080001: "region 1 was set at entry: unload only, regions cleared"}
|
|
ACR_UNRESOLVED = {
|
|
1: "load: the Falcon address-space entries of gpu::acr_load_bar2 are not covered by an "
|
|
"original-instruction oracle",
|
|
9: "unload: system memory for the image or the flush page could not be prepared, or bus "
|
|
"mastering could not be enabled",
|
|
13: "placement: the heap model could not place the requests before the runlist buffers",
|
|
14: "the registry or the retained GPU image could not be read",
|
|
15: "OBJACR ConstructEngine or PreInitLocked disables ACR on this device, or the PMU "
|
|
"constructor fails",
|
|
16: "an OBJACR configuration the level does not implement (+391, +38b, +390, +529 set, "
|
|
"+37f or +386 clear)",
|
|
17: "a registry override of the instance locations is present",
|
|
18: "storage or container records missing", 19: "the engine table could not be built",
|
|
20: "a GPU state the level does not accept (GPU+69e4, +914, +91d, +97c, +4de4, +e00, "
|
|
"+cac, or the GPU check _nv031156rm)",
|
|
21: "the region image could not be composed from the container",
|
|
22: "SEC2 is not enabled in PMC"}
|
|
# acr_load::Unsupported, as kernel/acr_bringup.rs unsupported_code numbers it (6, the PMU
|
|
# not halted, is reproduced since 2026-11-20 and no longer a refusal).
|
|
ACR_UNSUPPORTED = {
|
|
1: "CopyEngine: OBJACR+385 set (shadow copy through a copy-engine channel)",
|
|
2: "Requests: more than one registered request, or one without a mapping",
|
|
3: "SystemPrimary: primary region in system memory or OBJACR+529",
|
|
4: "ImageType: an image type other than 1 (load) or OBJACR+391 (unload)",
|
|
5: "SecondImage: OBJACR+38e/+38f/+390/+38b",
|
|
7: "GuestDevice", 8: "Preamble: PMU Falcon +3b6/+3be/+28c4 or OBJACR+38a/+380"}
|
|
ACR_SERVICES = {1: "clock gating", 2: "device table (multi-GPU section)", 3: "KernelFifo+170",
|
|
4: "a Falcon service", 5: "a memory service", 6: "GPU check PCI lookup",
|
|
7: "flush page second request", 8: "interrupt service with a built table",
|
|
9: "level-2 cache"}
|
|
# Bits 0 to 10: OBJACR +37b, +37c, +37f, +385, +386, +38b, +38e, +38f, +390, +391, +529.
|
|
ACR_EXPECTED = {
|
|
"stage": "00080000", "container_records": "00000003", "acr_bytes": "0000001c",
|
|
"fuse_021434": "00000001", "wpr_primary_page": "007fde80", "wpr_shadow_page": "007fdda0",
|
|
"pmu_surface_page": "007fdb98", "pmu_instance_block_page": "007fdf7e",
|
|
"hs_image_page": "007fdf79", "sec2_instance_block_page": "007fdf78",
|
|
"pci_command_at_entry": "00100502",
|
|
"pci_command_with_bus_mastering": "00100506", "pci_command_at_end": "00100502",
|
|
"region_set_at_entry": "00000000", "load_status": "00000000",
|
|
"sec2_cpuctl_after_load": "00000010", "sec2_mailbox0_after_load": "00000000",
|
|
"sec2_mailbox1_after_load": "00000000", "pmu_cpuctl_after_load": "00000050",
|
|
"after_load_100cd4_index_0": "080000c0", "after_load_100cd4_index_1": "080000c1",
|
|
"after_load_100cd4_index_2": "07fde802", "after_load_100cd4_index_3": "07fdf403",
|
|
"after_load_100cd4_index_4": "1ffffe04", "after_load_100cd4_index_5": "00000005",
|
|
"region_set_after_load": "00000001", "unload_status": "00000000",
|
|
"cleanup_bits": "00000007", "region_set_at_end": "00000000",
|
|
"region_set_after_restore": "00000000"}
|
|
acr = {}
|
|
for note in report["bringup_notes"]:
|
|
code, value = note.split()
|
|
name = ACR_NOTES.get(int(code, 16))
|
|
if name == "unresolved_input":
|
|
acr.setdefault(name, []).append(ACR_UNRESOLVED.get(int(value, 16), value))
|
|
elif name:
|
|
acr[name] = value
|
|
|
|
|
|
def region_cleared(start, end):
|
|
"""A region the gate _nv016925rm (through OBJACR+150) reads as empty: the end data is
|
|
zero and below the start data, as region 1 reads before the first load in the transcript
|
|
(lines 37715-37718: 0xfffe02, 0x3)."""
|
|
start, end = int(start, 16) >> 4, int(end, 16) >> 4
|
|
return end == 0 and start > 0
|
|
|
|
|
|
# True only when an unload ran and both regions then read as empty; None when no unload ran.
|
|
report["regions_cleared_after_unload"] = None
|
|
if acr:
|
|
if "stage" in acr:
|
|
acr["stage_meaning"] = ACR_STAGES.get(int(acr["stage"], 16), "unknown")
|
|
if "service_not_provided" in acr:
|
|
acr["service_meaning"] = ACR_SERVICES.get(int(acr["service_not_provided"], 16), "?")
|
|
for name in ("load_unsupported_branch", "unload_unsupported_branch"):
|
|
if name in acr:
|
|
acr[name + "_meaning"] = ACR_UNSUPPORTED.get(int(acr[name], 16), "?")
|
|
if "pmu_cpuctl_before_load" in acr and "scratch6_001598_before_load" in acr:
|
|
# PMU+2f8: not halted (CPUCTL bit 4 clear) with field 15:12 of scratch 6 equal to 1
|
|
# sets bit 9 of scratch 1 and waits up to 10 ms for the halt (PMU+2f0 _nv052403rm).
|
|
running = int(acr["pmu_cpuctl_before_load"], 16) & 0x10 == 0
|
|
field = int(acr["scratch6_001598_before_load"], 16) >> 12 & 0xf
|
|
acr["pmu_stop_request"] = {
|
|
"pmu_halted_before_load": not running, "scratch6_field_15_12": field,
|
|
"requested": running and field == 1,
|
|
"wait_status": acr.get("pmu_stop_wait_status", "00000000"),
|
|
"basis": "original instructions _nv052412rm/_nv052403rm/_nv052260rm executed in "
|
|
"tools/check_gpu_acr_load_binary.py (rows P); the traced first open "
|
|
"never took this branch"}
|
|
after = [acr.get(f"after_unload_100cd4_index_{index}") for index in range(2, 6)]
|
|
if "unload_status" in acr and all(after):
|
|
report["regions_cleared_after_unload"] = (
|
|
"unload_failed_or_regions_still_set" not in acr
|
|
and int(acr["unload_status"], 16) == 0
|
|
and region_cleared(after[0], after[1]) and region_cleared(after[2], after[3]))
|
|
acr["differs_from_expected"] = {
|
|
name: {"expected": expected, "observed": acr[name]}
|
|
for name, expected in ACR_EXPECTED.items() if name in acr and acr[name] != expected}
|
|
acr["expectation_basis"] = (
|
|
"load part: target/trace/b3-bar0.txt lines 147254-147279; the transcript holds no "
|
|
"unload, so unload_status 0 and empty regions afterwards are what the emulated "
|
|
"original leaves (reports/gpu-acr-unload-validation.json), not an observation")
|
|
report["acr_load_unload"] = acr
|
|
# Level 9 (src/nvidia/kernel/pmu_bringup.rs): with the regions set by the ACR load, the
|
|
# Graphics load, the light-secure PMU start, INIT, the region and bootstrap requests, the
|
|
# SEC2, FECS and GPCCS starts as far as FECS ready and the size queries, then the teardown
|
|
# (SEC2 unload, Graphics unload, PMU unload) before the ACR unload of level 8. The ACR and
|
|
# Graphics notes above are those of the same run.
|
|
PMU_READBACK = ("10a100", "10a008", "10a018", "10a01c", "10a040", "10a094", "10a4c8", "10a4cc",
|
|
"10a800", "10a804", "10a480", "087100", "087008", "087018", "087040", "087044",
|
|
"087048", "087294", "409100", "409008", "409048", "409294", "409800", "409818",
|
|
"409c24", "41a100", "41a048", "41a294", "000100", "000200")
|
|
PMU_AFTER_UNLOAD = ("10a100", "10a008", "10a018", "10a040", "10a4c8", "10a4cc", "10a800",
|
|
"10a480", "10a0a4", "087100", "087040", "087044", "409100", "41a100",
|
|
"000100", "000200")
|
|
PMU_SIZES = ("main", "zcull", "pm", "preempt", "spill", "beta_cb", "pagepool", "rtv_cb", "patch",
|
|
"setup")
|
|
PMU_NOTES = {
|
|
0x504d0001: "stage", 0x504d0002: "refusal", 0x504d0003: "core_reason",
|
|
0x504d0004: "steps_completed", 0x504d0005: "service_not_provided",
|
|
0x504d0006: "gpu_bytes_90c_916_6d59_998_92b_934_90e_4de2_c98_d78_and_word_1e18",
|
|
0x504d0007: "lsfm_mask", 0x504d0008: "pmu_boot_vector", 0x504d0009: "pmu_os_word",
|
|
0x504d000a: "sec2_os_word", 0x504d0010: "subcontexts_404030",
|
|
0x504d0011: "instance_block_fill_status", 0x504d0012: "surface_fill_status",
|
|
0x504d0013: "buffer_bus_page", 0x504d0014: "second_surface_bus_page",
|
|
0x504d0015: "surface_va_page", 0x504d0016: "buffer_va_page",
|
|
0x504d0017: "second_surface_va_page", 0x504d0018: "pmu_root_directory_page",
|
|
0x504d0019: "surface_bar2_offset", 0x504d001a: "mapping_status",
|
|
0x504d001b: "clock_domain_13_khz", 0x504d001c: "fuse_150_status_and_byte",
|
|
0x504d0020: "pmu_load_status", 0x504d0021: "pmu_state_word",
|
|
0x504d0022: "argument_frequency_hz", 0x504d0023: "argument_flags",
|
|
0x504d0024: "init_wait_passes_and_pending", 0x504d0025: "init_status",
|
|
0x504d0026: "falcon_value_irregular_rejected", 0x504d0040: "sec2_load_status",
|
|
0x504d0041: "fecs_discovery_status", 0x504d0042: "fecs_ready_value",
|
|
0x504d0043: "fecs_mailbox6_409818", 0x504d0044: "fecs_sizes_answered",
|
|
0x504d0045: "ltc_slices_and_count", 0x504d0046: "fecs_start_status",
|
|
0x504d0047: "gpccs_start_status", 0x504d0048: "fecs_wait_failure",
|
|
0x504d0049: "fecs_wait_failure_value", 0x504d0062: "events_consumed",
|
|
0x504d0070: "sec2_unload_status", 0x504d0071: "graphics_level_result",
|
|
0x504d0072: "pmu_unload_flags", 0x504d0073: "memory_quiesce_status",
|
|
0x504d0074: "pmu_reset_sequence_status", 0x504d0075: "cleanup_bits",
|
|
0x504d0076: "pmu_unbind_status", 0x504d0077: "graphics_post_unload_status",
|
|
0x504d0078: "system_memory_kept", 0x504d0079: "start_budget_spent_before_step"}
|
|
PMU_NOTES.update({0x504d0030 + falcon: f"request_falcon_{falcon}_status" for falcon in (2, 3, 7)})
|
|
PMU_NOTES.update({0x504d0050 + index: f"size_{name}" for index, name in enumerate(PMU_SIZES)})
|
|
PMU_NOTES.update({0x504d0100 + index: f"init_message_word_{index}" for index in range(15)})
|
|
PMU_NOTES.update({0x504d0200 + index: f"after_start_{name}"
|
|
for index, name in enumerate(PMU_READBACK)})
|
|
PMU_NOTES.update({0x504d0300 + index: f"after_pmu_unload_{name}"
|
|
for index, name in enumerate(PMU_AFTER_UNLOAD)})
|
|
PMU_LISTS = {0x504d0060: "events", 0x504d0061: "event_lengths_and_numbers",
|
|
0x504d0063: "dumps_asked_for", 0x504d00d0: "diagnostics"}
|
|
PMU_STAGES = {0x00090000: "completed", 0xffff0002: "refused before the ACR load",
|
|
0xffff0003: "not run: a lower level did not complete or the ACR load failed",
|
|
0xffff0004: "failed after the ACR load; the teardown and the ACR unload ran"}
|
|
PMU_REFUSALS = {
|
|
1: "registry or retained GPU image unreadable",
|
|
2: "GPU state (resume, GPU+998, GPU+92b, GPU+d78 without +c98, or not attached and running)",
|
|
3: "a registry key changes the computed context buffer sizes",
|
|
4: "PMU or SEC2 loader record of the container",
|
|
5: "storage", 6: "OBJLSFM+198 not computed or it disables SEC2, FECS or GPCCS",
|
|
7: "no SEC2 boot descriptor in the composed region image",
|
|
8: "GPU+1e18 is zero", 9: "PMU surface does not fit the BAR2 mapping"}
|
|
PMU_SERVICES = {1: "device table (multi-GPU section)", 2: "clock gating of Graphics",
|
|
3: "KernelFifo+170", 4: "Falcon configuration", 5: "level-2 cache",
|
|
6: "system memory", 7: "request word", 8: "page levels", 9: "PMU halted"}
|
|
PMU_STEPS = ("init_locked_fills", "pmu_load", "init_message", "sec2_start",
|
|
"fecs_ready_and_sizes", "sec2_unload", "graphics_level", "pmu_unload_detached",
|
|
"cleanup")
|
|
# Values of target/trace/b3-bar0.txt (the line or interval after each group). The traced
|
|
# driver had sent 241 client commands before the first bootstrap request; this level sends
|
|
# none, so what the firmware answers to the requests is the question the run settles.
|
|
PMU_EXPECTED_TRANSCRIPT = {
|
|
"pmu_boot_vector": "00005e00", "pmu_os_word": "02498436", # 147447, 147452
|
|
"sec2_os_word": "018e6cc3", # 165077
|
|
"subcontexts_404030": "00000040", # 140981
|
|
"surface_va_page": "00004000", "buffer_va_page": "00004208", # BAR2 extract, 147335-147416
|
|
"second_surface_va_page": "0000420a", "pmu_root_directory_page": "007fdf7d",
|
|
"surface_bar2_offset": "00008000",
|
|
"clock_domain_13_khz": "00083d60", # 147426-147429
|
|
"fuse_150_status_and_byte": "00000000", # 147430-147431
|
|
"pmu_load_status": "00000000", "pmu_state_word": "00000002", # 147279-147456
|
|
"argument_frequency_hz": "202fbf00", "argument_flags": "00000000",
|
|
"init_status": "00000000", # 147603-147608
|
|
"request_falcon_7_status": "00000000", # 164970-165047
|
|
"request_falcon_2_status": "00000000", # 166388-166421
|
|
"request_falcon_3_status": "00000000", # 166431-167021
|
|
"sec2_load_status": "00000000", # 164966-165083
|
|
"fecs_start_status": "00000000", "gpccs_start_status": "00000000",
|
|
"fecs_discovery_status": "00000000", "fecs_ready_value": "00000001", # 167029-167036
|
|
"fecs_mailbox6_409818": "00000000", "fecs_sizes_answered": "0000000f",
|
|
"ltc_slices_and_count": "00000410", # 167042-167043
|
|
"size_main": "00111800", "size_zcull": "000f0c00", "size_pm": "0000b300",
|
|
"size_preempt": "00140e00", # 167060-167097
|
|
"after_start_10a018": "0000387d", "after_start_10a01c": "00010072", # 147604-147605
|
|
"after_start_409c24": "000e0002"} # 167041
|
|
# What the emulated original leaves (the transcript holds no unload) and the level's own
|
|
# bookkeeping on a complete run.
|
|
PMU_EXPECTED_EMULATION = {
|
|
"stage": "00090000", "steps_completed": "000001ff", "lsfm_mask": "00000000",
|
|
"instance_block_fill_status": "00000000", "surface_fill_status": "00000000",
|
|
"sec2_unload_status": "00000000", "graphics_level_result": "00000000",
|
|
"pmu_unload_flags": "00000003", "memory_quiesce_status": "00000000",
|
|
"pmu_unbind_status": "00000000", "cleanup_bits": "0000003f",
|
|
"graphics_post_unload_status": "00000000"}
|
|
pmu = {}
|
|
for note in report["bringup_notes"]:
|
|
code, value = note.split()
|
|
code = int(code, 16)
|
|
if code in PMU_LISTS:
|
|
pmu.setdefault(PMU_LISTS[code], []).append(value)
|
|
elif PMU_NOTES.get(code) == "refusal":
|
|
pmu.setdefault("refusal", []).append(PMU_REFUSALS.get(int(value, 16), value))
|
|
elif code in PMU_NOTES:
|
|
pmu[PMU_NOTES[code]] = value
|
|
pmu_failure = None
|
|
if pmu:
|
|
stage = int(pmu.get("stage", "0"), 16)
|
|
pmu["stage_meaning"] = PMU_STAGES.get(stage, "no stage note: the level did not end")
|
|
if "steps_completed" in pmu:
|
|
steps = int(pmu["steps_completed"], 16)
|
|
pmu["steps_not_completed"] = [name for bit, name in enumerate(PMU_STEPS)
|
|
if not steps >> bit & 1]
|
|
if "service_not_provided" in pmu:
|
|
pmu["service_meaning"] = PMU_SERVICES.get(int(pmu["service_not_provided"], 16), "?")
|
|
if "events" in pmu:
|
|
# unit, type, size byte, whether the original has a function for the pair.
|
|
pmu["events_decoded"] = [
|
|
{"unit": f"{int(word, 16) >> 24:02x}", "type": f"{int(word, 16) >> 16 & 0xff:02x}",
|
|
"size": int(word, 16) >> 8 & 0xff, "original_has_function": bool(int(word, 16) & 1),
|
|
"detach_event": bool(int(word, 16) & 2)} for word in pmu["events"]]
|
|
for label, expected in (("transcript", PMU_EXPECTED_TRANSCRIPT),
|
|
("emulation", PMU_EXPECTED_EMULATION)):
|
|
pmu[f"differs_from_{label}"] = {
|
|
name: {"expected": value, "observed": pmu[name]}
|
|
for name, value in expected.items() if name in pmu and pmu[name] != value}
|
|
pmu["expectation_basis"] = (
|
|
"transcript: target/trace/b3-bar0.txt at the lines named in the tool, of a run that "
|
|
"sent 241 client commands this level omits; emulation: the emulated original "
|
|
"(reports/gpu-pmu-level9-validation.json). The INIT message words, the events and the "
|
|
"computed sizes have no expected value")
|
|
started = any(name in pmu for name in ("pmu_load_status", "pmu_state_word"))
|
|
if stage not in (0x00090000, 0xffff0002, 0xffff0003):
|
|
pmu_failure = f"LEVEL 9: {pmu['stage_meaning']}"
|
|
# A PMU start must be followed by a complete teardown, whatever the stage says.
|
|
if started and (pmu.get("cleanup_bits") != "0000003f" or "pmu_unload_flags" not in pmu):
|
|
pmu_failure = ("LEVEL 9: THE PMU WAS STARTED AND ITS TEARDOWN IS NOT CONFIRMED COMPLETE "
|
|
f"(cleanup_bits {pmu.get('cleanup_bits')}, "
|
|
f"pmu_unload_flags {pmu.get('pmu_unload_flags')})")
|
|
report["pmu_start_bootstrap_unload"] = pmu
|
|
report["driver_final"] = driver()
|
|
report["module_loaded_final"] = Path("/sys/module/nvidia_rs").exists()
|
|
report["error"] = failure
|
|
report["passed"] = (failure is None and report["driver_final"] == "nvidia"
|
|
and not report["module_loaded_final"] and len(inventory) > 0
|
|
and arch_failure is None)
|
|
if arch_failure:
|
|
report["error"] = (f"{report['error']}; " if report["error"] else "") + arch_failure
|
|
# Level 8 must never end with a protected region left set, or with a load that was not
|
|
# followed by a decodable unload result: either one fails the run whatever else passed.
|
|
loaded = bool(acr) and ("load_status" in acr or any(
|
|
name.startswith("after_load_") for name in acr))
|
|
if (report["regions_cleared_after_unload"] is False
|
|
or "unload_failed_or_regions_still_set" in acr
|
|
or (loaded and report["regions_cleared_after_unload"] is not True)):
|
|
report["passed"] = False
|
|
report["error"] = (f"{report['error']}; " if report["error"] else "") + (
|
|
"LEVEL 8: PROTECTED REGIONS NOT CONFIRMED CLEARED AFTER THE UNLOAD "
|
|
"(regions_cleared_after_unload is not true). Do not start another level; see "
|
|
"acr-load-implementation-notes.md sections 8.2 and 8.6.")
|
|
print("=" * 78 + "\n" + report["error"] + "\n" + "=" * 78, file=sys.stderr)
|
|
if pmu_failure:
|
|
report["passed"] = False
|
|
report["error"] = (f"{report['error']}; " if report["error"] else "") + (
|
|
pmu_failure + ". The ACR unload followed; regions_cleared_after_unload says whether "
|
|
"the protected regions read as cleared. Run the baseline before anything else.")
|
|
print("=" * 78 + "\n" + report["error"] + "\n" + "=" * 78, file=sys.stderr)
|
|
# The regions as the six words read after the unload, whatever the unload's status check
|
|
# said: at level 9 that check reads a SEC2 mailbox the SEC2 start and unload have changed.
|
|
if acr:
|
|
after = [acr.get(f"after_unload_100cd4_index_{index}") for index in range(2, 6)]
|
|
report["regions_read_empty_after_unload"] = (
|
|
region_cleared(after[0], after[1]) and region_cleared(after[2], after[3])
|
|
if all(after) else None)
|
|
# Levels 8 and 9: the requested level must have completed, with a complete cleanup and the
|
|
# regions confirmed clear at each sample (tools/bringup_verdict.py; review findings F4, F5).
|
|
report["requested_level_outcome"] = None
|
|
if arguments.bringup >= 8:
|
|
import bringup_verdict
|
|
report["requested_level_outcome"] = {
|
|
"level_8": bringup_verdict.outcome(acr, bringup_verdict.ACR_COMPLETED)}
|
|
if arguments.bringup >= 9:
|
|
report["requested_level_outcome"]["level_9"] = bringup_verdict.outcome(
|
|
pmu, bringup_verdict.PMU_COMPLETED)
|
|
for message in bringup_verdict.failures(
|
|
arguments.bringup, acr, pmu, report["regions_cleared_after_unload"]):
|
|
report["passed"] = False
|
|
report["error"] = (f"{report['error']}; " if report["error"] else "") + message
|
|
print("=" * 78 + "\n" + message + "\n" + "=" * 78, file=sys.stderr)
|
|
# The BAR1 option (src/nvidia/kernel/bar1_bringup.rs, notes 4231xxxx).
|
|
BAR1_NOTES = {
|
|
0x42310001: "stage", 0x42310002: "pci_bar1_megabytes", 0x42310003: "root_directory_page",
|
|
0x42310004: "init_status", 0x42310005: "block_1704_after_bind",
|
|
0x42310006: "bind_status_1710", 0x42310007: "mapping_address_page",
|
|
0x42310008: "written_through_bar1_read_through_bar2",
|
|
0x42310009: "written_through_bar2_read_through_bar1",
|
|
0x4231000a: "written_through_bar1_read_through_pramin",
|
|
0x4231000b: "written_through_pramin_read_through_bar1",
|
|
0x4231000c: "unmap_status", 0x4231000d: "destroy_status",
|
|
0x4231000e: "block_1704_after_unbind", 0x4231000f: "result",
|
|
0x42310010: "block_1704_at_entry", 0x42310011: "data_page"}
|
|
BAR1_STAGES = {0xffff0000: "not run (needs bringup >= 4 and a completed BAR2 setup)",
|
|
0x00010001: "inputs refused", 0x00020000: "instance block zeroed",
|
|
0x00030000: "bring-up and bind", 0x00040000: "page mapped",
|
|
0x00050000: "comparisons equal", 0x00060000: "mapping removed",
|
|
0x00070000: "space destroyed", 0x00080000: "unbound"}
|
|
# The traced V100 (analysis/closed-driver-580/memory.md, BAR1 section): what a passing run
|
|
# is expected to log on 0000:b3:00.0.
|
|
BAR1_EXPECTED = {
|
|
"pci_bar1_megabytes": "00008000", "root_directory_page": "007fdf77",
|
|
"init_status": "00000000", "block_1704_after_bind": "807fffa0",
|
|
"bind_status_1710": "00000000", "mapping_address_page": "00000080",
|
|
"data_page": "007fdf70", "written_through_bar1_read_through_bar2": "b1a50001",
|
|
"written_through_bar2_read_through_bar1": "b2a50002", "unmap_status": "00000000",
|
|
"destroy_status": "00000000", "block_1704_after_unbind": "007fffa0",
|
|
"result": "00000000"}
|
|
bar1 = {}
|
|
for note in report["bringup_notes"]:
|
|
code, value = note.split()
|
|
name = BAR1_NOTES.get(int(code, 16))
|
|
if name == "stage":
|
|
bar1.setdefault("stages", []).append(value)
|
|
bar1.setdefault("stage_meanings", []).append(BAR1_STAGES.get(
|
|
int(value, 16), "failed at stage " + value[:4] if int(value, 16) & 1
|
|
else "unknown"))
|
|
elif name:
|
|
bar1[name] = value
|
|
if bar1 or arguments.bringup_bar1:
|
|
import bringup_verdict
|
|
bar1["pramin_comparisons_equal"] = bringup_verdict.bar1_pramin_agrees(bar1)
|
|
bar1["differences_from_the_traced_v100"] = {
|
|
name: {"expected": expected, "observed": bar1.get(name)}
|
|
for name, expected in BAR1_EXPECTED.items() if bar1.get(name) != expected}
|
|
report["bar1_option"] = bar1
|
|
for message in bringup_verdict.bar1_failures(arguments.bringup_bar1, bar1):
|
|
report["passed"] = False
|
|
report["error"] = (f"{report['error']}; " if report["error"] else "") + message
|
|
print("=" * 78 + "\n" + message + "\n" + "=" * 78, file=sys.stderr)
|
|
# The PMC enable word or the bus interrupt mask was not written back (note 4d4300fe).
|
|
if any(note.split()[0] == "4d4300fe" for note in report["bringup_notes"]):
|
|
report["passed"] = False
|
|
report["error"] = (f"{report['error']}; " if report["error"] else "") + (
|
|
"PMC ENABLE OR THE BUS INTERRUPT MASK WAS NOT RESTORED (note 4d4300fe)")
|
|
print("=" * 78 + "\n" + report["error"] + "\n" + "=" * 78, file=sys.stderr)
|
|
if graphics_failure:
|
|
report["passed"] = False
|
|
report["error"] = (f"{report['error']}; " if report["error"] else "") + (
|
|
graphics_failure + ". Interrupt and exception enables of PGRAPH may still be set; "
|
|
"the caller restored PMC enable. Run the baseline before anything else.")
|
|
print("=" * 78 + "\n" + report["error"] + "\n" + "=" * 78, file=sys.stderr)
|
|
out = ROOT / "reports" / f"hardware-first-open-{arguments.label}.json"
|
|
out.write_text(json.dumps(report, indent=2) + "\n")
|
|
print(json.dumps({key: report[key] for key in (
|
|
"passed", "error", "first_open", "driver_after_load", "driver_final",
|
|
"module_loaded_final") if key in report}, indent=2))
|
|
print(f"{len(inventory)} inventory words; static mismatches "
|
|
f"{len(report.get('static_register_mismatches', {}))}; notes {report['bringup_notes']}; "
|
|
f"report {out}")
|
|
raise SystemExit(0 if report["passed"] else 1)
|