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
441 lines
22 KiB
Python
441 lines
22 KiB
Python
#!/usr/bin/env python3
|
|
"""Run the original GV100 OBJACR Unload after the original Load and write an oracle.
|
|
|
|
The environment is the one tools/check_gpu_acr_load_binary.py builds: that
|
|
file is executed unchanged up to the end of its traced V100 case, so every
|
|
unload case starts from the emulated state the original Load leaves (OBJACR
|
|
InitLocked, OBJLSFM Load, OBJACR Load with the transcript's register values).
|
|
|
|
On a GV100 the unload image does not run on SEC2. OBJACR+38b is clear, so
|
|
OBJACR+130 _nv016972rm passes the image to the PMU function at +2e0
|
|
(_nv052043rm), which resets the PMU Falcon and runs the image there from a
|
|
system-memory allocation through DMA index 4. The status check OBJACR+158
|
|
(_nv016730rm) then reads the mailboxes of the SEC2 Falcon, because OBJACR+37f
|
|
is set.
|
|
|
|
Executed original code (chip HAL 0x23, RM HAL 2):
|
|
|
|
OBJACR Unload _nv016962rm; +130 _nv016972rm with the gate _nv016925rm
|
|
(+150 _nv016745rm), the signature placement _nv016965rm (+370
|
|
_nv016945rm, PMU+3d8 _nv052308rm), the status check +158
|
|
_nv016730rm. The image is prepared as the constructor _nv016731rm
|
|
does it: _nv016905rm(gpu, acr, 6, OBJACR+3c0) with the bundle of
|
|
+2d0 _nv016853rm.
|
|
PMU +2e0 _nv052043rm; +2d0 _nv052261rm; the vtable function at +60 of
|
|
the PMU+b08 object (_nv004583rm, _nv051835rm); of the embedded
|
|
object at +a00 (bound by _nv006032rm, properties _nv005854rm):
|
|
+60 _nv052224rm, the reset +58 _nv052192rm with +68 _nv052223rm,
|
|
+88 _nv052197rm, +70 _nv052194rm, +80 _nv052248rm, +78
|
|
_nv052252rm, +a8 _nv052188rm, +48 _nv052213rm, the start +d8
|
|
_nv052256rm, the wait +d0 _nv052260rm and +c0 _nv052215rm; +278
|
|
_nv051924rm and +280 _nv051927rm; +70 _nv052291rm of the embedded
|
|
object at +c20 (bound by _nv006033rm); the wait wrapper
|
|
_nv052647rm; the boot loader records of the bundle of +370
|
|
(_nv052066rm) as the constructor part _nv051982rm unpacks them.
|
|
Falcon the halt _nv028516rm with +2a8 _nv028520rm, the interface
|
|
functions _nv028817rm and _nv028831rm, +370 _nv028766rm, +378,
|
|
+1a0 _nv028785rm, the DMEM writer _nv028452rm, the IMEM writer
|
|
_nv028523rm, _nv028552rm.
|
|
OBJMC +198 _nv043581rm.
|
|
GPU +7c0 _nv030971rm, +5c8 _nv030977rm and _nv030976rm with the
|
|
clock-gating functions they reach.
|
|
|
|
Fixture-supplied, beyond the load harness: the function at +160 of the
|
|
GPU+1ec8 object (called by _nv041589rm), the interrupt service _nv031481rm
|
|
and _nv031415rm, the PMU class function at vtable +508 (called after a
|
|
timeout), MemorySystem+f10, the GPU+20c8 object's function at +1b8, and the
|
|
system-memory descriptor (creation, allocation with the bus address as a case
|
|
input, mapping backed by emulator memory).
|
|
|
|
Stored by the harness as the creators store them (the creators themselves
|
|
need the object tree and are not executed): the two vtable pointers and self
|
|
pointers of the PMU+a00 object (_nv006737rm), of the PMU+c20 object
|
|
(_nv006738rm; +80 = 0 and +84 = 3 as _nv003401rm and _nv052273rm give for a
|
|
GV100 with GPU+914 clear), and of the PMU+b08 object (_nv006726rm), whose
|
|
state word at +80 is a case input.
|
|
|
|
No hardware is involved. The physical transcript does not contain an unload:
|
|
this harness is instruction-emulation evidence only.
|
|
"""
|
|
import hashlib
|
|
import json
|
|
from pathlib import Path
|
|
import struct
|
|
import sys
|
|
|
|
HERE = Path(__file__).resolve()
|
|
SOURCE = HERE.with_name("check_gpu_acr_load_binary.py")
|
|
MARKER = "# ------------------------------------------------------------------ InitLocked"
|
|
source = SOURCE.read_text()
|
|
assert MARKER in source and "--traced" not in sys.argv
|
|
exec(compile(source[:source.index(MARKER)], str(SOURCE), "exec"), globals()) # noqa: S102
|
|
|
|
LOAD_IMAGE_SHA256 = hashlib.sha256(HS_IMAGE).hexdigest()
|
|
BUNDLE_UNLOAD, BUNDLE_PMU_LOADER = 0x1141350, 0x11432e0
|
|
A00, C20, IMPL, OBJ_1EC8 = PMU + 0xa00, PMU + 0xc20, MEMMGR2 + 0x800, MEMMGR2 + 0xa00
|
|
DMA = 0x1_2345_6000 # bus address of the system-memory allocation in most cases
|
|
|
|
# ------------------------------------------------------------ additional setup
|
|
hooks[text("_nv028817rm")] = ("_nv028817rm", lambda a, low: {
|
|
SEC2 + 0xe8: F_SEC2, PMU + 0xe8: F_PMU}[a[1]])
|
|
|
|
|
|
@service("GPU+1ec8 object +160")
|
|
def object_1ec8_160(a, low):
|
|
emit(f"pg:{state['pg']:x}")
|
|
return state["pg"]
|
|
|
|
|
|
@hook("_nv031481rm")
|
|
def interrupt_service(a, low):
|
|
emit(f"is:{low[2]:x}")
|
|
return 0
|
|
|
|
|
|
@hook("_nv031415rm")
|
|
def gpu_mask(a, low):
|
|
assert a[0] == GPU
|
|
return 1
|
|
|
|
|
|
@service("PMU class vtable +508")
|
|
def pmu_508(a, low):
|
|
assert (a[0], a[1], low[2]) == (GPU, PMU, 1), a
|
|
emit("pd")
|
|
return 0
|
|
|
|
|
|
@service("MemorySystem+f10")
|
|
def memory_f10(a, low):
|
|
assert a[0] == GPU
|
|
emit("mf")
|
|
return 0
|
|
|
|
|
|
@service("GPU+20c8 object +1b8")
|
|
def vbios_1b8(a, low):
|
|
assert (a[0], a[1]) == (GPU, VBIOS)
|
|
emit("vb")
|
|
return 0
|
|
|
|
|
|
# The PMU+a00 object as _nv006737rm leaves it.
|
|
q(A00 + 0x40, A00)
|
|
q(A00 + 0x38, A00 + 8)
|
|
q(A00, rodata(0x5ee72c0))
|
|
q(A00 + 8, rodata(0x5ee72d8))
|
|
call("_nv005854rm", A00, CHIP)
|
|
q(A00 + 0x100, F_PMU)
|
|
assert (byte(A00 + 0xf8), byte(A00 + 0xf9)) == (1, 0)
|
|
# The object _nv006726rm creates for the class _nv003201rm; PMU+b08 is its
|
|
# base at +8 (_nv051986rm casts it to _nv003215rm).
|
|
cpu.mem_write(IMPL, bytes(0x88))
|
|
for index, table in enumerate((0x5ee7500, 0x5ee7518, 0x5ee7530)):
|
|
q(IMPL + 8 * index, rodata(table))
|
|
q(IMPL + 0x68, IMPL + 0x10)
|
|
q(IMPL + 0x70, IMPL + 8)
|
|
q(IMPL + 0x78, IMPL)
|
|
q(IMPL + 8 + 0x50, F_PMU)
|
|
assert pointer(address_of(by_name["_nv003201rm"]) + 0x10) == text("_nv006348rm")
|
|
assert call("_nv005245rm", IMPL, address_of(by_name["_nv003215rm"])) == (IMPL + 8) & 0xffffffff
|
|
q(PMU + 0xb08, IMPL + 8)
|
|
assert slot(pointer(IMPL + 8), 0x60) == "_nv004583rm"
|
|
assert slot(pointer(IMPL), 0xd0) == "_nv051835rm"
|
|
# The PMU+c20 object as _nv006738rm leaves it.
|
|
cpu.mem_write(C20, bytes(0x98))
|
|
q(C20 + 0x40, C20)
|
|
q(C20 + 0x38, C20 + 8)
|
|
q(C20, rodata(0x5ee7360))
|
|
q(C20 + 8, rodata(0x5ee7378))
|
|
call("_nv006033rm", C20, CHIP, RM)
|
|
b(C20 + 0x80, 0)
|
|
d(C20 + 0x84, 3)
|
|
# The PMU class vtable the creator stored: only its function at +508 is
|
|
# replaced, in a copy.
|
|
PMU_VTABLE = MEMMGR2 + 0xc00
|
|
cpu.mem_write(PMU_VTABLE, bytes(cpu.mem_read(pointer(PMU), 0x600)))
|
|
q(PMU_VTABLE + 0x508, pmu_508)
|
|
q(PMU, PMU_VTABLE)
|
|
q(GPU + 0x1ec8, OBJ_1EC8)
|
|
q(OBJ_1EC8 + 0x160, object_1ec8_160)
|
|
q(MEMSYS + 0xf10, memory_f10)
|
|
q(VBIOS + 0x1b8, vbios_1b8)
|
|
# The boot loader records, as the PMU constructor part _nv051982rm unpacks them.
|
|
call(slot(PMU, 0x370), PMU)
|
|
LOADER_BUNDLE = cpu.reg_read(UC_X86_REG_RAX)
|
|
assert analysis(LOADER_BUNDLE) == BUNDLE_PMU_LOADER
|
|
for tag, field in ((0x12, 0x17d0), (0x23, 0x17d8)):
|
|
call("_nv017872rm", LOADER_BUNDLE, tag)
|
|
assert call("_nv017879rm", cpu.reg_read(UC_X86_REG_RAX), PMU + field) == 0
|
|
call(slot(ACR, 0x2d0), ACR)
|
|
assert analysis(cpu.reg_read(UC_X86_REG_RAX)) == BUNDLE_UNLOAD
|
|
BOUND_UNLOAD = {
|
|
"OBJACR": (ACR, {0x130: "_nv016972rm", 0x150: "_nv016745rm", 0x158: "_nv016730rm",
|
|
0x2d0: "_nv016853rm", 0x370: "_nv016945rm", 0x1d0: "_nv016927rm"}),
|
|
"PMU": (PMU, {0x278: "_nv051924rm", 0x280: "_nv051927rm", 0x2d0: "_nv052261rm",
|
|
0x2e0: "_nv052043rm", 0x370: "_nv052066rm", 0x3d8: "_nv052308rm"}),
|
|
"PMU+a00": (A00, {0x48: "_nv052213rm", 0x58: "_nv052192rm", 0x60: "_nv052224rm",
|
|
0x68: "_nv052223rm", 0x70: "_nv052194rm", 0x78: "_nv052252rm",
|
|
0x80: "_nv052248rm", 0x88: "_nv052197rm", 0xa8: "_nv052188rm",
|
|
0xc0: "_nv052215rm", 0xd0: "_nv052260rm", 0xd8: "_nv052256rm"}),
|
|
"PMU+c20": (C20, {0x70: "_nv052291rm"}),
|
|
"PMU Falcon": (F_PMU, {0x1a0: "_nv028785rm", 0x2a8: "_nv028520rm", 0x370: "_nv028766rm"}),
|
|
"GPU": (GPU, {0x5c8: "_nv030977rm", 0x7c0: "_nv030971rm"}),
|
|
}
|
|
bound_unload = {}
|
|
for label, (base, slots) in BOUND_UNLOAD.items():
|
|
for offset, function in slots.items():
|
|
assert slot(base, offset) == function, (label, hex(offset), slot(base, offset))
|
|
bound_unload[f"{label}+{offset:#x}"] = function
|
|
assert slot(pointer(pointer(F_PMU + 0x5d8)), 0xd0) == "_nv028831rm"
|
|
# The image, prepared as the constructor _nv016731rm does for a GV100
|
|
# (OBJACR+38b and +37b clear: type 6 into OBJACR+3c0).
|
|
assert (byte(ACR + 0x38b), byte(ACR + 0x37b), byte(ACR + 0x391), byte(ACR + 0x390)) == (0, 0, 0, 0)
|
|
UNLOADABLE = {}
|
|
for fuse in (0, 0x100000):
|
|
state["reads"] = {0x10ac08: [fuse]}
|
|
saved_acr = bytes(cpu.mem_read(ACR + 0x3c0, 0x70))
|
|
del trace[:]
|
|
assert call("_nv016905rm", GPU, ACR, 6, ACR + 0x3c0) == 0
|
|
PREPARE_EVENTS = list(trace)
|
|
UNLOADABLE[fuse] = loaded_state()
|
|
cpu.mem_write(ACR + 0x3c0, saved_acr)
|
|
|
|
U_SETTINGS = dict(g91d=0, g69e4=0, o1eb=0, a391=0, a37b=0, a37f=1, a390=0, p9a2=0, ps=0, g914=0,
|
|
g252c=0, g915=1, g917=0, g918=0, g926=0, g97c=0, g4de4=0, ge00=0, f3a7=0,
|
|
f3af=0, f3b6=0, f3bb=0, f3be=0, pg=0, k108=0, k1=0, lp234=0, m8ccf=0, mc=1,
|
|
v2d8=0, g6=0, dma=DMA, fuse=0, fail="")
|
|
# Register values of a default run: the regions as the traced Load left them,
|
|
# the PMU halted with the LS image placed (CPUCTL 0x50 at transcript line
|
|
# 147279), everything else as a case input.
|
|
U_READS = {0x100cd4: [0x7fde802, 0x7fdf403, 0x80000c0, 0x80000c1], 0x10ac08: [0],
|
|
0x10a040: [0], 0x80: [0x8f], 0x20c: [0x21ecdedc], 0x10a3c0: [0, 1],
|
|
0x10a0a4: [0x200], 0x10a3c4: [0x10], 0x1221fc: [0], 0x1241fc: [0], 0x1281fc: [0],
|
|
0x10a10c: [1], 0x10ae24: [0x10], 0x10a108: [0x400e0100], 0x10a100: [0x10],
|
|
0x10a130: [0], 0x87040: [0], 0x87044: [0], 0x10a044: [0], 0x10a268: [0x100],
|
|
0x10a04c: [0], 0: [0x140000a1], 0x10a12c: [0xca0e1136], 0x10a048: [0],
|
|
0x10a430: [0], 0x10a1c0: [0]}
|
|
def unload_begin(reads, checks, settings):
|
|
restore_loaded(UNLOADABLE[settings["fuse"]])
|
|
del trace[:]
|
|
diagnostics[0] = 0
|
|
fail = {}
|
|
for item in filter(None, settings["fail"].split(",")):
|
|
kind, number, status = item.split(":")
|
|
fail[kind] = (int(number), int(status, 16))
|
|
state.update(reads={offset: list(values) for offset, values in reads.items()},
|
|
checks=list(checks), addresses=[settings["dma"]], fail=fail, counts={},
|
|
k1=settings["k1"], g6=settings["g6"], pg=settings["pg"], no_buffer=None)
|
|
for offset, name in ((0x391, "a391"), (0x37b, "a37b"), (0x37f, "a37f"), (0x390, "a390")):
|
|
b(ACR + offset, settings[name])
|
|
for offset, name in ((0x91d, "g91d"), (0x914, "g914"), (0x915, "g915"), (0x917, "g917"),
|
|
(0x918, "g918"), (0x926, "g926"), (0x97c, "g97c"), (0x4de4, "g4de4")):
|
|
b(GPU + offset, settings[name])
|
|
d(GPU + 0x69e4, settings["g69e4"])
|
|
d(GPU + 0x252c, settings["g252c"])
|
|
cpu.mem_write(GPU + 0xe00, struct.pack("<H", settings["ge00"]))
|
|
b(OBJ_22C0 + 0x1eb, settings["o1eb"])
|
|
b(PMU + 0x9a2, settings["p9a2"])
|
|
d(IMPL + 0x80, settings["ps"])
|
|
for offset, name in ((0x3a7, "f3a7"), (0x3af, "f3af"), (0x3b6, "f3b6"), (0x3bb, "f3bb"),
|
|
(0x3be, "f3be")):
|
|
b(F_PMU + offset, settings[name])
|
|
b(OBJ_1E70 + 0x108, settings["k108"])
|
|
b(LPWR + 0x234, settings["lp234"])
|
|
b(MEMSYS + 0x8ccf, settings["m8ccf"])
|
|
b(VBIOS + 0x2d8, settings["v2d8"])
|
|
q(GPU + 0x1ea0, MC if settings["mc"] else 0)
|
|
|
|
|
|
UNLOAD_STATE = (("a37d", ACR + 0x37d, 1), ("a37f", ACR + 0x37f, 1), ("pf60", PMU + 0xf60, 4),
|
|
("p42f", PMU + 0x42f, 1), ("pf34", PMU + 0xf34, 1), ("pf38", PMU + 0xf38, 4),
|
|
("pf40", PMU + 0xf40, 1), ("f3a7", F_PMU + 0x3a7, 1), ("f3aa", F_PMU + 0x3aa, 1),
|
|
("f28c4", F_PMU + 0x28c4, 1))
|
|
urows, ucounts = [], {}
|
|
|
|
|
|
def unload_case(reads=None, checks=(), entry="_nv016962rm", **changes):
|
|
"""OBJACR Unload _nv016962rm, or the PreInitLocked body, after the original Load."""
|
|
settings = dict(U_SETTINGS, **changes)
|
|
reads = merged({key: value for key, value in U_READS.items() if key not in (reads or {})},
|
|
reads or {})
|
|
reads[0x10ac08] = [settings["fuse"]]
|
|
unload_begin(reads, checks, settings)
|
|
try:
|
|
status = call(entry, GPU, ACR)
|
|
except Exception:
|
|
print("FAILED", changes, function_at(cpu.reg_read(UC_X86_REG_RIP)),
|
|
hex(cpu.reg_read(UC_X86_REG_RIP)), trace[-12:])
|
|
raise
|
|
consumed = used(reads)
|
|
left = len(state["checks"])
|
|
after = " ".join(f"{name}={int.from_bytes(cpu.mem_read(address, size), 'little'):x}"
|
|
for name, address, size in UNLOAD_STATE)
|
|
image = next((hashlib.sha256(bytes(cpu.mem_read(backing, 0x1800))).hexdigest()
|
|
for backing, size, base in state["ranges"] if base == settings["dma"]), "-")
|
|
kind = "U" if entry == "_nv016962rm" else "P"
|
|
ucounts[kind] = ucounts.get(kind, 0) + 1
|
|
urows.append("|".join((kind, text_of(settings), reads_of(consumed),
|
|
",".join(f"{value:x}" for value in checks[:len(checks) - left]),
|
|
f"{status:x}", f"{after} img={image}", f"{diagnostics[0]:x}",
|
|
" ".join(trace))))
|
|
return status, list(trace)
|
|
|
|
|
|
# --------------------------------------------------------------- the default run
|
|
track(True)
|
|
before = set(executed)
|
|
status, DEFAULT_EVENTS = unload_case()
|
|
assert status == 0, status
|
|
UNLOAD_EXECUTED = sorted(executed - before)
|
|
track(False)
|
|
UNLOAD_IMAGE = next(bytes(cpu.mem_read(backing, 0x1800)) for backing, size, base in state["ranges"]
|
|
if base == DMA)
|
|
out = ROOT / "target/gpu-stage"
|
|
(out / "original-acr-unload-image-gv100.bin").write_bytes(UNLOAD_IMAGE)
|
|
DESCRIPTOR_WORDS = [token.split(":")[2] for token in DEFAULT_EVENTS if token.startswith("w:10a1c4:")]
|
|
LOADER_WORDS = [token for token in DEFAULT_EVENTS if token.startswith("w:10a184:")]
|
|
assert len(DESCRIPTOR_WORDS) == 21 and len(LOADER_WORDS) == 128
|
|
|
|
# ------------------------------------------------------------------ the wrapper
|
|
for changes in (dict(g91d=1), dict(g69e4=1), dict(g69e4=1, o1eb=1), dict(g69e4=2), dict(v2d8=1),
|
|
dict(g91d=1, v2d8=1), dict(p9a2=1), dict(a37b=1), dict(g6=0xf), dict(fuse=0x100000),
|
|
dict(a390=1), dict(g914=1), dict(g914=1, g252c=1), dict(g914=1, g252c=3),
|
|
dict(fail="create:1:51"), dict(fail="allocate:1:1a"), dict(fail="m:1:1"),
|
|
dict(k108=1), dict(k108=1, k1=1), dict(lp234=1), dict(m8ccf=1),
|
|
dict(k108=1, lp234=1, m8ccf=1), dict(dma=0x1000), dict(dma=0xfffffff000),
|
|
dict(dma=0x100000000), dict(dma=0xffffe000)):
|
|
unload_case(**changes)
|
|
# The gate: region 1 as OBJACR+150 reads it.
|
|
for region in ([0x1ffffe02, 3, 0xc0, 0xc1], [2, 3, 0xc0, 0xc1], [0x7fde802, 0x7fde803, 0, 1],
|
|
[0x7fdf402, 0x7fde803, 0xc0, 0xc1], [0x12, 3, 0, 1], [2, 0x13, 0, 1],
|
|
[0xfffffff2, 0xfffffff3, 0xffffffc0, 0xffffffc1]):
|
|
unload_case(reads={0x100cd4: region})
|
|
# ------------------------------------------------------------- the PMU launcher
|
|
for changes in (dict(mc=0), dict(ps=1), dict(ps=2), dict(ps=3), dict(ps=4), dict(g915=0),
|
|
dict(g918=1), dict(g917=1), dict(g926=1), dict(g97c=1), dict(ge00=1),
|
|
dict(pg=0x56), dict(f3bb=1), dict(f3a7=1), dict(f3af=1), dict(g4de4=1),
|
|
dict(a37f=0)):
|
|
unload_case(**changes)
|
|
for device in (0x7f, 0xff, 0x70, 0):
|
|
unload_case(reads={0x80: [device]})
|
|
unload_case(reads={0x80: [device]}, f3a7=1)
|
|
# The reset: already held, the halt request and its timeout, the hold wait.
|
|
unload_case(reads={0x10a3c0: [1]})
|
|
unload_case(reads={0x10a3c0: [1, 0]})
|
|
unload_case(reads={0x10a0a4: [0, 0, 0x200]}, checks=(0, 0))
|
|
unload_case(reads={0x10a0a4: [0]}, checks=(0, 0x65))
|
|
unload_case(reads={0x10a0a4: [0xfffffdff]}, checks=(0x56,))
|
|
unload_case(reads={0x10a3c4: [0]})
|
|
unload_case(reads={0x10a3c4: [0xffffffef]}, f3a7=1)
|
|
unload_case(reads={0x10a3c0: [0] * 14 + [1]}, checks=(0, 0, 0))
|
|
unload_case(reads={0x10a3c0: [0]}, checks=(0, 0x65))
|
|
unload_case(reads={0x10a3c0: [0]}, checks=(0x65,))
|
|
unload_case(reads={0x10a3c0: [0]}, checks=(0, 0x56, 0x65))
|
|
# After the release: the memory scrub wait and the idle wait.
|
|
for dmactl, checks in (([6, 0], (0,)), ([7, 7, 1], (0, 0)), ([6, 6, 1], (0, 0x65)),
|
|
([2, 2, 0], (0x56,)), ([0xfffffff9], ()), ([6], (0x65,)),
|
|
([4], (0, 0, 0x65))):
|
|
unload_case(reads={0x10a10c: dmactl}, checks=checks)
|
|
for idle, checks in (([1, 0], (0,)), ([2, 0x10000, 0], (0, 0)), ([0xfffe], (0, 0x65)),
|
|
([1], (0x65,)), ([0xffff0000], ()), ([1, 1, 0], (0x56, 0))):
|
|
unload_case(reads={0x10a04c: idle}, checks=checks)
|
|
for mailbox in (0xffffffff, 0x12345678):
|
|
unload_case(reads={0x10a040: [mailbox]})
|
|
for value in (0, 0xffffffff, 0x80):
|
|
unload_case(reads={0x10ae24: [value], 0x10a10c: [1, 1, value | 1]})
|
|
for boundary in (0, 1, 0x100, 0xffffff, 0xffffffff):
|
|
unload_case(reads={0x10a268: [boundary]})
|
|
# Above the boundary every word is followed by a fault check of the control word.
|
|
for control in ([0x80000000], [0, 0, 0x20000000], [0, 0x40000000], [0x1fffffff]):
|
|
unload_case(reads={0x10a268: [0], 0x10a1c0: control})
|
|
for hwcfg in (0x400e0100, 0x1ff, 2, 0x202, 0x3fe, 0xffffffff):
|
|
unload_case(reads={0x10a108: [hwcfg]})
|
|
# Start and the halt wait.
|
|
for cpuctl, checks in (([0x10, 0x10], ()), ([0x50, 0x10], ()), ([0, 0, 0x10], (0,)),
|
|
([0xffffffed, 0, 0, 0, 0x10], (0, 0, 0)), ([0x10, 0], (0, 0, 0x65)),
|
|
([0x10, 0], (0x65,)), ([0x10, 0, 0, 0x10], (0x56, 0)),
|
|
([0x10, 0, 0x10], (0x56,))):
|
|
unload_case(reads={0x10a100: cpuctl}, checks=checks)
|
|
unload_case(reads={0x10a100: cpuctl, 0x10a130: [0xfffffffd]}, checks=checks, f3a7=1)
|
|
# The status check: mailboxes of the SEC2 Falcon (OBJACR+37f set) or the PMU's.
|
|
for mailbox in list(range(1, 0x20)) + [0x39, 0x63, 0x64, 0xae, 0xaf, 0xfe, 0xff, 0x100, 0xdeadbeef]:
|
|
unload_case(reads={0x87040: [mailbox], 0x87044: [mailbox ^ 0x55]})
|
|
for second in range(9):
|
|
unload_case(reads={0x87040: [0xb], 0x87044: [second]})
|
|
for mailbox in (1, 0xb, 0xff):
|
|
unload_case(reads={0x10a040: [0, mailbox], 0x10a044: [mailbox ^ 0x55]}, a37f=0)
|
|
|
|
# ------------------------------------------- first open with a region already set
|
|
# OBJACR PreInitLocked (_nv004038rm -> _nv016961rm) calls the same OBJACR+130
|
|
# when +100 (_nv016960rm) leaves OBJACR+37b clear. That needs the PMU feature
|
|
# bytes of PMU+330 (_nv052503rm on a GV100, called by the PMU constructor
|
|
# _nv051986rm), which no unload case reads; they are applied here only.
|
|
assert slot(PMU, 0x330) == "_nv052503rm" and slot(ACR, 0x100) == "_nv016960rm"
|
|
for fuse in list(UNLOADABLE):
|
|
restore_loaded(UNLOADABLE[fuse])
|
|
call("_nv052503rm", GPU, PMU)
|
|
assert byte(PMU + 0x43c) == 1
|
|
UNLOADABLE[fuse] = loaded_state()
|
|
oracle_rows, urows = urows, []
|
|
TRACED_REGION = transcript_reads(37715, 37722)[0x100cd4]
|
|
status, PREINIT_EMPTY = unload_case(reads={0x100cd4: TRACED_REGION}, entry="_nv016961rm")
|
|
assert status == 0 and byte(ACR + 0x37b) == 0
|
|
assert [token for token in PREINIT_EMPTY if token[:2] in ("r:", "w:")] == transcript_tokens(
|
|
37715, 37722), PREINIT_EMPTY
|
|
status, PREINIT_SET = unload_case(entry="_nv016961rm")
|
|
assert status == 0 and PREINIT_SET == DEFAULT_EVENTS
|
|
status, PREINIT_FAILED = unload_case(reads={0x10a100: [0x10, 0]}, checks=(0x65,),
|
|
entry="_nv016961rm")
|
|
assert status == 0x65
|
|
PREINIT = {
|
|
"body": "_nv016961rm (OBJACR PreInitLocked, stage thunk _nv004038rm): OBJACR+108 "
|
|
"_nv016733rm and +118 _nv016735rm (constant zero), +100 _nv016960rm, then "
|
|
"OBJACR+130 _nv016972rm when OBJACR+37b and +391 are clear",
|
|
"region_1_as_traced": {
|
|
"transcript_lines": [37715, 37722], "events": PREINIT_EMPTY,
|
|
"result": "the eight accesses of the transcript lines and nothing else; status 0"},
|
|
"region_1_set": {
|
|
"events": len(PREINIT_SET),
|
|
"result": "the event list equals the default Unload case: the unlock image runs on "
|
|
"the PMU during PreInit; status 0"},
|
|
"region_1_set_and_the_pmu_never_halts": {
|
|
"status": hex(status),
|
|
"result": "the body returns the status of OBJACR+130 (0x65)"},
|
|
}
|
|
urows = oracle_rows
|
|
oracle = "\n".join(urows) + "\n"
|
|
(out / "original-acr-unload.txt").write_text(oracle)
|
|
report = {
|
|
"original_sha256": DIGEST, "chip_hal": "0x23", "rm_hal": 2,
|
|
"environment": "tools/check_gpu_acr_load_binary.py executed unchanged up to the end of its "
|
|
"traced V100 case (OBJACR InitLocked, OBJLSFM Load, OBJACR Load)",
|
|
"load_hs_image_sha256": LOAD_IMAGE_SHA256,
|
|
"executed_on_the_default_case": UNLOAD_EXECUTED,
|
|
"bindings": bound_unload,
|
|
"pmu_b08_object": {"class": "_nv003201rm (creator _nv006348rm -> _nv006726rm)",
|
|
"vtable +0x60": "_nv004583rm -> _nv051835rm (state word +0x80 above 1)"},
|
|
"bundles": {"unload image (OBJACR+2d0)": hex(BUNDLE_UNLOAD),
|
|
"PMU boot loader (PMU+370)": hex(BUNDLE_PMU_LOADER)},
|
|
"image_preparation_events": PREPARE_EVENTS,
|
|
"cases": len(urows), "cases_by_kind": {"Unload _nv016962rm (U)": len(urows)},
|
|
"oracle": "target/gpu-stage/original-acr-unload.txt",
|
|
"oracle_sha256": hashlib.sha256(oracle.encode()).hexdigest(),
|
|
"unload_image": {"file": "target/gpu-stage/original-acr-unload-image-gv100.bin",
|
|
"bytes": len(UNLOAD_IMAGE),
|
|
"sha256": hashlib.sha256(UNLOAD_IMAGE).hexdigest()},
|
|
"default_case": {"boot_descriptor_words": DESCRIPTOR_WORDS,
|
|
"boot_loader_words_sha256": hashlib.sha256(
|
|
" ".join(LOADER_WORDS).encode()).hexdigest(),
|
|
"register_accesses": sum(1 for token in DEFAULT_EVENTS
|
|
if token[:2] in ("r:", "w:"))},
|
|
"physical_transcript": "none: the capture ended before any unload",
|
|
"first_open_with_a_region_already_set": PREINIT,
|
|
"scope": "Original GV100 OBJACR Unload after the original Load in one emulated state. "
|
|
"Register values, time, the system-memory descriptor and the listed cross-object "
|
|
"services are fixture-supplied; no hardware executed."}
|
|
(ROOT / "reports/gpu-acr-unload-original.json").write_text(json.dumps(report, indent=2) + "\n")
|
|
print(f"{len(urows)} original ACR unload cases; PreInit with region 1 set runs the same "
|
|
f"unlock ({len(PREINIT_SET)} events); image sha256 "
|
|
f"{report['unload_image']['sha256']}; oracle sha256 {report['oracle_sha256']}")
|