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
445 lines
23 KiB
Python
445 lines
23 KiB
Python
#!/usr/bin/env python3
|
|
"""Run the original GV100 FECS start and context size discovery (_nv033633rm) and the
|
|
Graphics unload stages around a running FECS, and write an oracle for core
|
|
gpu::gr_fecs_start.
|
|
|
|
Executed original code on the emulator of check_gpu_graphics_load_binary.py, with the
|
|
HAL-owner casts of check_gpu_graphics_level_binary.py (the Falcon objects are bound for chip
|
|
HAL 0x23), on the Graphics state the original constructors, PreInitLocked and InitLocked
|
|
leave, plus the LTC register objects of _nv044445rm:
|
|
|
|
S _nv033633rm(gpu, graphics) from entry to return: KernelGraphics+198 _nv041053rm (+180
|
|
_nv041021rm), the FECS ready wait _nv027644rm (_nv031757rm -> _nv055403rm ->
|
|
_nv031747rm, FECS+90 _nv027352rm), Graphics+10f8 _nv033346rm -> _nv033345rm -> +1100
|
|
_nv033527rm with the submit _nv033685rm, +bf0 _nv032221rm, +1290 _nv032877rm, +c78,
|
|
MemorySystem+1130 _nv045007rm (+b28 _nv044978rm, +b10 _nv044754rm), +1458, +1460, the
|
|
ten calls of _nv031818rm (_nv041186rm, +1098 _nv031821rm, _nv031820rm, +d80
|
|
_nv033724rm, +c90 _nv033010rm, +1158 _nv031649rm), +1418, the Lpwr tests and +ab0.
|
|
U _nv033671rm(gpu, graphics, flags) twice per case, with FECS+1f8 and GRinfo+154 clear and
|
|
set: the accesses are the same (asserted here).
|
|
P PreUnload _nv033668rm(gpu, graphics, 0) and PostUnload _nv033666rm(gpu, graphics) with
|
|
OBJMC bound by its binder _nv006001rm.
|
|
K KernelFifo+170 _nv040326rm(gpu, KernelFifo, 0), the subcontext count of the patch
|
|
buffer size, with its first-call producer +178 _nv040324rm -> Graphics+14f0
|
|
_nv032981rm.
|
|
C the GRinfo words the computed sizes read, as the constructor _nv031721rm leaves them
|
|
without registry keys, the six GPU+420 constants and KernelFifo+170.
|
|
|
|
Fixture-supplied: register values; Graphics+10e0 _nv031609rm (the start of FECS and GPCCS:
|
|
one call with a status; core gpu::falcon_ls_start has its own oracle); the timeout record
|
|
_nv059509rm / _nv059505rm and the yield; the failure report _nv027616rm and the dump
|
|
function Graphics+530; the Falcon unload functions and the idle wait's engine status query
|
|
in U rows; everything the load harness supplies. No hardware.
|
|
|
|
A FECS+90 read of 0x16, 0x17 or 0x18 at 0x409818 ends in `jmp .` in the original
|
|
(_nv027352rm+0x60); such a case runs with an instruction limit and is recorded as status
|
|
`loop`.
|
|
"""
|
|
import hashlib
|
|
import json
|
|
from pathlib import Path
|
|
import sys
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
ARGUMENTS = sys.argv[1:]
|
|
sys.argv = sys.argv[:1]
|
|
import check_gpu_graphics_level_binary as lv # noqa: E402
|
|
from unicorn import UcError # noqa: E402
|
|
|
|
h = lv.h
|
|
ROOT = h.ROOT
|
|
GPU, GR, KGR, MEMSYS, LPWR, PGCTRL = h.GPU, h.GR, h.KGR, h.MEMSYS, h.LPWR, h.PGCTRL
|
|
TRANSCRIPT_RANGES = ((166380, 166381), (167029, 167097))
|
|
rows = []
|
|
|
|
# Installed before any original code runs (translated blocks are cached).
|
|
h.hook("_nv031609rm", lambda a: h.emit("start") or h.state["case"].get("start", 0))
|
|
# The load harness already answers _nv059509rm (event "ts"); this second hook only records
|
|
# the interval and the flags and leaves the answer to the first.
|
|
h.install(h.by_name["_nv059509rm"],
|
|
lambda a: h.emit(f"ts:{a[2] & 0xffffffff:x}:{a[3] & 0xffffffff:x}"))
|
|
h.hook("_nv027616rm", lambda a: h.emit(f"rep:{a[2] & 0xffffffff:x}:{a[3] & 0xffffffff:x}") or 0)
|
|
h.hook("_nv042925rm", lambda a: h.emit(f"pg925:{a[2] & 0xffffffff:x}:{a[3] & 0xff:x}") or 0)
|
|
h.hook("_nv042840rm", lambda a: h.emit(f"pg840:{a[2] & 0xffffffff:x}") or 0)
|
|
h.hook("_nv042848rm", lambda a: h.emit(f"pg848:{a[2] & 0xffffffff:x}") or 0)
|
|
h.hook("_nv042861rm", lambda a: h.emit(f"pg861:{a[2] & 0xffffffff:x}") or 0)
|
|
# Graphics+530 on a GV100: the register dump after a failed wait (several hundred reads).
|
|
h.hook("_nv032302rm", lambda a: h.emit("dump") or 0)
|
|
# The allocation inside the Lpwr control object's creation (C row), as in the level harness.
|
|
h.hook("_nv006583rm", lambda a: h.wq(a[0], lv.PG) or 0)
|
|
# os_delay_us is recorded by the level harness (event du).
|
|
|
|
GPU_BYTES = (0x90e, 0x4de2, 0x4de4, 0xe00, 0x52fc, 0x92d)
|
|
GR_BYTES = (0x15b1, 0x15b2, 0x15b3, 0x15c0, 0x160c, 0x45f4, 0x159e)
|
|
GRINFO_WORDS = (0, 4, 0xc, 0x14, 0x18, 0x1c, 0x20, 0x28, 0x2c, 0x40, 0x154, 0x530, 0x550)
|
|
CONSTANTS = (0x14, 0x17, 0x1c, 0x1e, 0x25, 0x2f)
|
|
CLAMPED = (0xc, 0x14, 0x18, 0x1c, 0x20, 0x28)
|
|
V100_LTC = 0x401c0062 # transcript lines 167042-167059
|
|
LIMIT = 4000000
|
|
|
|
|
|
def ltc_default(offset):
|
|
return V100_LTC if 0x140000 <= offset < 0x180000 and offset & 0x1fff == 0x480 else 0
|
|
|
|
|
|
def kept(events):
|
|
return [event for event in events if not event.startswith("e:") and event != "ts"]
|
|
|
|
|
|
def prepare(case):
|
|
block = h.prepare(case)
|
|
assert h.call("_nv044445rm", GPU, MEMSYS) & 0xffffffff == 0
|
|
for offset, value in case.get("dwords", {}).items():
|
|
h.wd(GPU + offset, value)
|
|
h.cpu.mem_write(PGCTRL, bytes(0x2000))
|
|
for offset, value in case.get("pg", {}).items():
|
|
h.wd(PGCTRL + offset, value)
|
|
for offset, value in case.get("lpwr_bytes", {}).items():
|
|
h.wb(LPWR + offset, value)
|
|
h.state["events"].clear()
|
|
return block
|
|
|
|
|
|
def bounded(name, *arguments):
|
|
"""call() with an instruction limit; None when the limit ends the run."""
|
|
from unicorn.x86_const import UC_X86_REG_RAX, UC_X86_REG_RBP, UC_X86_REG_RIP, UC_X86_REG_RSP
|
|
for register, argument in zip(h.ARGS, arguments):
|
|
h.cpu.reg_write(register, argument & (1 << 64) - 1)
|
|
rsp = ((h.STACK + 0xf0000) & ~0xf) - 8
|
|
h.cpu.reg_write(UC_X86_REG_RSP, rsp)
|
|
h.cpu.reg_write(UC_X86_REG_RBP, h.STACK + 0x80000)
|
|
h.wq(rsp, h.STOP)
|
|
try:
|
|
h.cpu.emu_start(h.by_name[name], h.STOP, count=LIMIT)
|
|
except UcError as error:
|
|
pc = h.cpu.reg_read(UC_X86_REG_RIP)
|
|
raise RuntimeError(f"{error} at {pc:#x} {h.function_at(pc)}\ncalls {h.calls[-16:]}\n"
|
|
f"events {h.state['events'][-12:]}\n{h.listing(pc)}") from error
|
|
if h.cpu.reg_read(UC_X86_REG_RIP) != h.STOP:
|
|
return None
|
|
return h.cpu.reg_read(UC_X86_REG_RAX)
|
|
|
|
|
|
def discover(label, **changes):
|
|
case = h.default_load()
|
|
# KernelFifo+3c0: the count _nv040326rm caches at its first call (K rows; register
|
|
# 0x404030 read 0x40 at transcript line 140981).
|
|
case.update(start=0, dwords={0x1e18: 4}, pg={}, lpwr_bytes={}, subcontexts=0x40)
|
|
case.update(changes)
|
|
# The read lists are consumed by a run: every case gets its own copies.
|
|
case["reads"] = {offset: list(values) for offset, values in {
|
|
**h.default_load()["reads"], 0x12006c: [0x10], **changes.get("reads", {})}.items()}
|
|
case["check"] = list(changes.get("check", []))
|
|
if "default_read" not in changes:
|
|
case["default_read"] = ltc_default
|
|
case["gpu"] = {**h.default_load()["gpu"], **changes.get("gpu", {})}
|
|
block = prepare(case)
|
|
h.wd(h.q(GPU + 0x22d0) + 0x3c0, case["subcontexts"])
|
|
fecs = h.q(GR + 0x15e8)
|
|
gpc_count = h.call(h.q(GR + 0xc78), GPU, GR) & 0xffffffff
|
|
constants = [h.call(h.q(GPU + 0x420), GPU, index) & 0xffffffff for index in CONSTANTS]
|
|
fifo = h.q(GPU + 0x22d0)
|
|
subcontexts = h.call(h.q(fifo + 0x170), GPU, fifo, 0) & 0xffffffff
|
|
lpwr = h.q(GPU + 0x22c8)
|
|
fields = [" ".join(f"{h.b(GPU + offset):x}" for offset in GPU_BYTES),
|
|
f"{h.d(GPU + 0x1e18):x}",
|
|
" ".join(f"{h.b(GR + offset):x}" for offset in GR_BYTES),
|
|
" ".join(f"{h.d(block + offset):x}" for offset in GRINFO_WORDS),
|
|
f"{gpc_count:x}", " ".join(f"{value:x}" for value in constants),
|
|
f"{subcontexts:x}", f"{case['start']:x}",
|
|
"%x %x %x %x" % (int(lpwr != 0), h.d(PGCTRL + 0xe0), h.d(PGCTRL + 0x1820),
|
|
h.b(LPWR + 0x27c))]
|
|
h.state["events"].clear()
|
|
status = bounded("_nv033633rm", GPU, GR)
|
|
events = kept(h.state["events"])
|
|
h.state["continuations"].clear()
|
|
outputs = [" ".join(f"{h.d(block + 0x154 + 4 * index):x}" for index in range(10)),
|
|
" ".join(f"{h.d(block + offset):x}" for offset in CLAMPED),
|
|
"%x %x %x" % (h.d(block + 0x4f0), h.b(fecs + 0x1f8), h.b(KGR + 0x1a9))]
|
|
shown = "loop" if status is None else f"{status & 0xffffffff:x}"
|
|
rows.append(f"S|{label}|" + "|".join(fields) + f"|{shown}|" + "|".join(outputs) + "|"
|
|
+ " ".join(events))
|
|
return shown, events
|
|
|
|
|
|
def transcript_tokens():
|
|
lines = h.TRANSCRIPT.read_text().split("\n")
|
|
tokens = []
|
|
for first, last in TRANSCRIPT_RANGES:
|
|
for line in lines[first - 1:last]:
|
|
kind, offset, value = line.split()[:3]
|
|
tokens.append(f"{kind.lower()}:{int(offset, 16):x}:{int(value, 16):x}")
|
|
return tokens
|
|
|
|
|
|
def discovery_cases(random):
|
|
ready = {0x409800: [0] * 7 + [1] + [0] * 9 + [0x111800] + [0] * 3 + [0xf0c00]
|
|
+ [0] * 3 + [0xb300] + [0] * 7 + [0x140e00]}
|
|
status, events = discover("traced", reads=ready)
|
|
assert status == "0", status
|
|
registers = [event for event in events if event[0] in "rw" and event[1] == ":"]
|
|
traced = transcript_tokens()
|
|
for position, (mine, theirs) in enumerate(zip(registers, traced)):
|
|
assert mine == theirs, (position, mine, theirs)
|
|
assert len(registers) == len(traced), (len(registers), len(traced))
|
|
quick = {0x409800: [1, 0x111800, 0xf0c00, 0xb300, 0x140e00]}
|
|
discover("quick", reads=quick)
|
|
discover("discovered", reads=quick, grinfo={0x154: 0x111800})
|
|
for start in (0x65, 0xffff, 0x56):
|
|
discover(f"start={start:x}", reads=quick, start=start)
|
|
# The ready wait.
|
|
discover("ready-timeout", reads={0x409800: [0]}, check=[0, 0, 0x65])
|
|
discover("ready-timeout-late", reads={0x409800: [0, 0, 0, 0, 1, 0x10, 0x16, 0x25, 0x1a]},
|
|
check=[0, 0, 0x65])
|
|
discover("ready-check-status", reads={0x409800: [0, 0, 0, 1, 0x10, 0x16, 0x25, 0x1a]},
|
|
check=[0x40, 0])
|
|
discover("ready-other-value", reads={0x409800: [2, 0xffffffff, 1, 0x10, 0x16, 0x25, 0x1a]})
|
|
for word in (0x15, 0x16, 0x17, 0x18, 0x19, 0xffffffff):
|
|
discover(f"m6={word:x}", reads={**quick, 0x409818: [word]})
|
|
discover("m6-after-timeout", reads={0x409800: [0], 0x409818: [5]}, check=[0x65])
|
|
# Timing of the waits.
|
|
for gpu_90e, gpu_4de2, interval in ((1, 0, 4), (0, 1, 4), (1, 1, 4), (0, 0, 0), (0, 0, 7),
|
|
(1, 0, 0x400)):
|
|
discover(f"timing={gpu_90e}{gpu_4de2}:{interval:x}", reads=quick,
|
|
gpu={0x90e: gpu_90e, 0x4de2: gpu_4de2}, dwords={0x1e18: interval})
|
|
# The optional methods of Graphics+10f8.
|
|
for mask in range(1, 8):
|
|
bytes_set = {0x15b1 + bit: 1 for bit in range(3) if mask >> bit & 1}
|
|
count = bin(mask).count("1")
|
|
discover(f"methods={mask:x}", gr=bytes_set,
|
|
reads={0x409800: [1] + [1] * count + [0x10, 0x16, 0x25, 0x1a]})
|
|
discover(f"methods={mask:x}-wait", gr=bytes_set,
|
|
reads={0x409800: [1] + [0, 1] * count + [0x10, 0x16, 0x25, 0x1a]})
|
|
discover(f"methods={mask:x}-timeout", gr=bytes_set,
|
|
reads={0x409800: [1, 0]}, check=[0, 0x65])
|
|
discover("method-d-then-f-timeout", gr={0x15b1: 1, 0x15b2: 1},
|
|
reads={0x409800: [1, 1, 0]}, check=[0x65])
|
|
# The MemorySystem query.
|
|
discover("ltc-broadcast-0", reads={**quick, 0x17e480: [0x01c0062]})
|
|
discover("ltc-count-0", reads={**quick, 0x12006c: [0x20]})
|
|
discover("ltc-count-11", reads={**quick, 0x12006c: [0x11]})
|
|
discover("ltc-count-1f", reads={**quick, 0x12006c: [0x1f]})
|
|
for count in (1, 2, 5, 0xf):
|
|
discover(f"ltc-count-{count:x}", reads={**quick, 0x12006c: [count]})
|
|
discover("ltc-3-empty", reads={**quick, 0x146480: [0x01c0062]})
|
|
for slices in (1, 2, 8, 0xf):
|
|
word = slices << 28 | 0x1c0062
|
|
discover(f"ltc-slices-{slices:x}", reads=quick,
|
|
default_read=lambda offset, word=word: word if ltc_default(offset) else 0)
|
|
discover("ltc-mixed", reads={**quick, 0x17e480: [0xf0000000], 0x140480: [0x10000000],
|
|
0x15e480: [0xf0000000]})
|
|
# The size queries.
|
|
for index, name in enumerate(("main", "zcull", "pm", "preempt")):
|
|
reads = [1, 0x111800, 0xf0c00, 0xb300, 0x140e00][:index + 1] + [0]
|
|
discover(f"{name}-timeout", reads={0x409800: reads}, check=[0, 0, 0x65])
|
|
late = [1, 0x111800, 0xf0c00, 0xb300, 0x140e00][:index + 1] + [0, 0, 0x5000]
|
|
discover(f"{name}-at-expiry", reads={0x409800: late + [0x16, 0x25, 0x1a]},
|
|
check=[0, 0x65])
|
|
discover("sizes-high", reads={0x409800: [1, 0xffffffff, 0x80000000, 1, 0xdeadbeef]})
|
|
# The computed sizes.
|
|
for number in range(40):
|
|
grinfo = {offset: random.pick((0, 1, 0x480, 0x6c0, 0xc00, 0x155555, 0x155556, 0x3fff,
|
|
0x5555, 0x5556, 0xffffffff, random.word() & 0xfffff,
|
|
random.word()))
|
|
for offset in (0xc, 0x14, 0x18, 0x1c, 0x20, 0x28, 0x2c, 0x40)}
|
|
if number % 5 == 4:
|
|
grinfo[0x530] = 0
|
|
if number % 7 == 6:
|
|
grinfo[0x550] = random.pick((0, 1, 0x29, 0x100))
|
|
discover(f"computed-{number}", reads=quick, grinfo=grinfo,
|
|
gr={0x15c0: number % 3 != 2},
|
|
subcontexts=random.pick((0x40, 0x40, 1, 2, 0x5f, 0x10)))
|
|
# Lpwr.
|
|
discover("no-lpwr", reads=quick, lpwr=False)
|
|
discover("pg-1820", reads=quick, pg={0x1820: 5})
|
|
discover("pg-1820-27c", reads=quick, pg={0x1820: 0x80000001}, lpwr_bytes={0x27c: 1})
|
|
for index, name in enumerate(("main", "pm")):
|
|
discover(f"no-3d-{name}-timeout", gr={0x160c: 0},
|
|
reads={0x409800: [1, 0x111800][:index + 1] + [0]}, check=[0x65])
|
|
discover("no-3d", reads={0x409800: [1, 0x111800, 0xb300]}, gr={0x160c: 0})
|
|
discover("gr-45f4", reads=quick, gr={0x45f4: 1})
|
|
discover("gpu-e00", reads=quick, gpu={0xe00: 1})
|
|
for number in range(48):
|
|
values = [1] + [random.pick((0, 0, 0, 1, random.word())) for unused in range(24)] + [1]
|
|
discover(f"random-{number}", reads={0x409800: values},
|
|
check=[random.pick((0, 0, 0, 0, 0, 0x65)) for unused in range(24)] + [0x65])
|
|
|
|
|
|
def unload_pairs(random):
|
|
"""StateUnload with FECS stopped and with FECS running: the same accesses."""
|
|
gpccs_88 = h.function_at(h.q(h.q(GR + 0x15f0) + 0x88))
|
|
states = {"f643": [], "g88": []}
|
|
|
|
def falcon(name):
|
|
def handler(a):
|
|
h.emit(f"{name}:{a[2] & 0xffffffff:x}")
|
|
return 0
|
|
return handler
|
|
h.hook("_nv027643rm", falcon("f643"))
|
|
h.hook(gpccs_88, falcon("g88"))
|
|
h.hook("_nv033702rm", lambda a: h.emit("cu") or 0)
|
|
del states
|
|
for number in range(24):
|
|
flags = (0, 0, 0, 1, 2, 0x20)[number % 6]
|
|
word = random.pick((0, 0, 0x80000000, random.word()))
|
|
seen = []
|
|
for running, discovered in ((0, 0), (1, 0x111800)):
|
|
case = h.default_load()
|
|
case["reads"] = {**case["reads"], 0x12006c: [0x10], 0x409b00: [word, 0]}
|
|
case["default_read"] = h.hashed(number)
|
|
block = prepare(case)
|
|
h.wd(GR + 0x1620, 1)
|
|
h.wb(h.q(GR + 0x15e8) + 0x1f8, running)
|
|
h.wd(block + 0x154, discovered)
|
|
h.state["events"].clear()
|
|
status = h.call("_nv033671rm", GPU, GR, flags) & 0xffffffff
|
|
events = kept(h.state["events"])
|
|
seen.append((status, events))
|
|
rows.append(f"U|{number}|{flags:x}|{running:x}|{discovered:x}|{status:x}|"
|
|
f"{h.b(h.q(GR + 0x15e8) + 0x1f8):x} {h.d(block + 0x154):x}|"
|
|
+ " ".join(events))
|
|
assert seen[0] == seen[1], number
|
|
|
|
|
|
def stages():
|
|
"""PreUnload and PostUnload on the state the level leaves."""
|
|
case = h.default_load()
|
|
block = prepare(case)
|
|
before = bytes(h.cpu.mem_read(block + 0x12c, 0x24))
|
|
status = h.call("_nv033668rm", GPU, GR, 0) & 0xffffffff
|
|
rows.append(f"P|pre|0|{status:x}|{before.hex()}|"
|
|
f"{bytes(h.cpu.mem_read(block + 0x12c, 0x24)).hex()}|"
|
|
+ " ".join(kept(h.state["events"])))
|
|
for gr_15ab, pmc in ((0, 0x1fecdff1), (0, 0x1fecc0f1), (1, 0x1fecdff1), (0, 0xffffffff)):
|
|
case = h.default_load()
|
|
case["reads"] = {**case["reads"], 0x200: [pmc]}
|
|
prepare(case)
|
|
h.cpu.mem_write(h.MC, bytes(0x1000))
|
|
h.call("_nv006001rm", h.MC, h.CHIP, h.RM)
|
|
h.wb(GR + 0x15ab, gr_15ab)
|
|
slots = [h.function_at(h.q(h.MC + offset)) for offset in (0x150, 0x158, 0x190)]
|
|
h.state["events"].clear()
|
|
try:
|
|
status = "%x" % (h.call("_nv033666rm", GPU, GR) & 0xffffffff)
|
|
except (RuntimeError, AssertionError) as error:
|
|
status = "unexecuted:" + str(error).split("\n")[0][:60].replace("|", "/")
|
|
rows.append(f"P|post|{gr_15ab:x}|{pmc:x}|{status}|" + "/".join(str(s) for s in slots)
|
|
+ "|" + " ".join(kept(h.state["events"])))
|
|
|
|
|
|
def subcontext_counts(random):
|
|
"""KernelFifo+170 _nv040326rm(gpu, KernelFifo, 0): +178 _nv040324rm -> Graphics+14f0
|
|
_nv032981rm, which reads 0x404030 after Graphics+d10 _nv033245rm (PMC bit 12)."""
|
|
fifo = h.q(GPU + 0x22d0)
|
|
cases = [(1, 0, 0x1fecdff1, 0x40, 0), (1, 0x40, 0x1fecdff1, 0x12, 0),
|
|
(0, 0, 0x1fecdff1, 0x40, 0), (1, 0, 0x1fecc0f1, 0x40, 0),
|
|
(1, 0, 0x1fecdff1, 0x40, 1), (1, 0, 0x1fecdff1, 0x5f, 0),
|
|
(1, 0, 0x1fecdff1, 0x60, 0), (1, 0, 0x1fecdff1, 0xfffff040, 0),
|
|
(1, 0, 0x1fecdff1, 0, 0)]
|
|
cases += [(1, 0, random.word(), random.word(), 0) for unused in range(16)]
|
|
for byte_44d, cached, pmc, word, argument in cases:
|
|
case = h.default_load()
|
|
case["reads"] = {**case["reads"], 0x200: [pmc], 0x404030: [word]}
|
|
prepare(case)
|
|
h.wb(fifo + 0x44d, byte_44d)
|
|
h.wd(fifo + 0x3c0, cached)
|
|
h.state["events"].clear()
|
|
value = h.call(h.q(fifo + 0x170), GPU, fifo, argument) & 0xffffffff
|
|
rows.append(f"K|{byte_44d:x}|{cached:x}|{argument:x}|{value:x}|{h.d(fifo + 0x3c0):x}|"
|
|
f"{h.b(GR + 0x15ce):x}|" + " ".join(kept(h.state["events"])))
|
|
|
|
|
|
def control_object():
|
|
"""The Lpwr control object as _nv021616rm builds it on a GV100 (Pmu present, its byte
|
|
+5de clear): the dwords the routine tests."""
|
|
h.prepare(h.default_load())
|
|
lv.build_pmu(0x330)
|
|
h.cpu.mem_write(lv.PG, bytes(0x10000))
|
|
h.call("_nv005931rm", lv.PG, h.CHIP, h.RM)
|
|
h.call("_nv005804rm", lv.PG, h.CHIP, h.RM)
|
|
h.wq(GPU + 0x22c8, LPWR)
|
|
h.wq(GPU + 0x2120, lv.PMU)
|
|
for offset in (0x11b8, 0x11c0, 0x11c8, 0x11d0, 0x11d8, 0x11e0):
|
|
h.wq(LPWR + offset, 0)
|
|
assert h.call("_nv021616rm", GPU, LPWR) & 0xffffffff == 0 and h.q(LPWR + 0x11c0) == lv.PG
|
|
words = [h.d(lv.PG + offset) for offset in (0xe0, 0x1820, 0x1824, 0x1828, 0x182c)]
|
|
assert not any(words), words
|
|
return "%s %x %x" % (" ".join(f"{word:x}" for word in words), h.b(LPWR + 0x27c),
|
|
h.b(LPWR + 0x248))
|
|
|
|
|
|
def constants():
|
|
control = control_object()
|
|
case = h.default_load()
|
|
block = prepare(case)
|
|
assert h.function_at(h.q(GR + 0x530)) == "_nv032302rm"
|
|
fifo = h.q(GPU + 0x22d0)
|
|
words = " ".join(f"{offset:x}={h.d(block + offset):x}"
|
|
for offset in (0, 4, 0xc, 0x10, 0x14, 0x18, 0x1c, 0x20, 0x24, 0x28, 0x2c,
|
|
0x30, 0x40, 0x48, 0x4c, 0x50, 0x530, 0x550))
|
|
chip = " ".join(f"{index:x}={h.call(h.q(GPU + 0x420), GPU, index) & 0xffffffff:x}"
|
|
for index in CONSTANTS)
|
|
rows.append(f"C|{words}|{chip}|{h.call(h.q(fifo + 0x170), GPU, fifo, 0) & 0xffffffff:x}|"
|
|
f"{h.b(GR + 0x15c0):x}|" + "/".join(
|
|
h.function_at(h.q(GR + offset)) for offset in
|
|
(0x10e0, 0x10f8, 0x1100, 0xbf0, 0x1290, 0xc78, 0x1098, 0x1158, 0xd80, 0xc90,
|
|
0x1418, 0xab0, 0x1458, 0x1460))
|
|
+ "|" + "/".join((h.function_at(h.q(h.q(GR + 0x15e8) + 0x90)),
|
|
h.function_at(h.q(KGR + 0x198)), h.function_at(h.q(KGR + 0x180)),
|
|
h.function_at(h.q(MEMSYS + 0x1130)),
|
|
h.function_at(h.q(MEMSYS + 0xb28)),
|
|
h.function_at(h.q(MEMSYS + 0xb10)),
|
|
h.function_at(h.q(fifo + 0x170)))) + f"|{control}")
|
|
|
|
|
|
def main():
|
|
random = h.Random(0x33633)
|
|
constants()
|
|
subcontext_counts(random)
|
|
discovery_cases(random)
|
|
stages()
|
|
unload_pairs(random)
|
|
oracle = "\n".join(rows) + "\n"
|
|
path = ROOT / "target/gpu-stage/original-graphics-fecs-start.txt"
|
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
path.write_text(oracle)
|
|
kinds = {}
|
|
for row in rows:
|
|
kinds[row.split("|")[0]] = kinds.get(row.split("|")[0], 0) + 1
|
|
report = {
|
|
"original": str(h.ORIGINAL), "original_sha256": h.DIGEST,
|
|
"entry": "_nv033633rm(gpu, graphics); _nv033671rm(gpu, graphics, flags); "
|
|
"_nv033668rm(gpu, graphics, 0); _nv033666rm(gpu, graphics)",
|
|
"row_format": {
|
|
"S": "label | GPU bytes 90e 4de2 4de4 e00 52fc 92d | GPU+1e18 | Graphics bytes "
|
|
"15b1 15b2 15b3 15c0 160c 45f4 159e | GRinfo words 0 4 c 14 18 1c 20 28 2c 40 "
|
|
"154 530 550 | Graphics+c78 | GPU+420 of 14 17 1c 1e 25 2f | KernelFifo+170 | "
|
|
"status of Graphics+10e0 | Lpwr present, control +e0, +1820, Lpwr+27c | status "
|
|
"| GRinfo+154.. (ten sizes) | GRinfo c 14 18 1c 20 28 afterwards | GRinfo+4f0, "
|
|
"FECS+1f8, KernelGraphics+1a9 | events",
|
|
"U": "case | flags | FECS+1f8 | GRinfo+154 | status | both afterwards | events",
|
|
"P": "pre: flags, status, GRinfo+12c..+150 before and after, events; post: "
|
|
"Graphics+15ab, PMC enable word, status, OBJMC slots +150/+158/+190, events",
|
|
"K": "KernelFifo+44d | +3c0 before | argument | result | +3c0 after | Graphics+15ce "
|
|
"| events",
|
|
"C": "GRinfo words | GPU+420 constants | KernelFifo+170 | Graphics+15c0 | Graphics "
|
|
"slot bodies | other slot bodies | the Lpwr control object's dwords +e0, "
|
|
"+1820..+182c and Lpwr bytes +27c, +248"},
|
|
"events": "r/w register access; start = Graphics+10e0; ts:interval:flags = "
|
|
"_nv059509rm; tc:line:status = _nv059505rm; y = yield; wt = _nv033180rm; "
|
|
"rep:kind:tag = _nv027616rm; dump = Graphics+530; A:line, S:status:line = "
|
|
"the assertion and status reports; pg*: Lpwr control functions",
|
|
"cases": len(rows), "cases_by_kind": kinds,
|
|
"oracle": "target/gpu-stage/original-graphics-fecs-start.txt",
|
|
"oracle_sha256": hashlib.sha256(oracle.encode()).hexdigest(),
|
|
"transcript_lines": [list(pair) for pair in TRANSCRIPT_RANGES],
|
|
"scope": "Original instructions in emulator memory. No hardware executed."}
|
|
(ROOT / "reports/gpu-graphics-fecs-start-original.json").write_text(
|
|
json.dumps(report, indent=1) + "\n")
|
|
print(f"{len(rows)} original rows {kinds}")
|
|
print(report["oracle_sha256"])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|