#!/usr/bin/env python3 """Run the original GV100 light-secure start of SEC2, FECS and GPCCS, and their unload. The environment is the one tools/check_gpu_acr_load_binary.py builds, up to and including its traced OBJACR Load: OBJSEC2, the PMU class, FECS and GPCCS objects from their creators, five Falcons bound, attached and configured, OBJLSFM InitLocked and Load, OBJACR InitLocked and Load, all executed from the original object. That file's text up to its traced case is executed here with one change to the image harness it loads: the Falcon property initializer _nv005778rm runs after the binder _nv005876rm, as the Falcon creator _nv006487rm calls it. (Both older harnesses leave it out; Falcon+3a6 is then 0 instead of 1, and with it the interface word at base+48 keeps bit 0.) Executed original code (chip HAL 0x23, RM HAL 2): S OBJSEC2 Load (class slot +3f0) _nv055933rm with _nv055814rm, the Falcon load _nv028572rm (class list query _nv030463rm, Falcon+60 _nv028555rm, the reset Falcon+128 _nv028679rm with _nv028467rm twice, _nv028539rm, _nv028746rm), the OS bootstrap _nv028391rm (_nv037825rm, the interrupt words, _nv028398rm with the boot descriptor _nv028530rm -> interface +70 _nv028829rm -> _nv028607rm, interface +28 and +40, Falcon+198 _nv028454rm, the DMEM writer Falcon+1e0, Falcon+208 _nv028529rm, Falcon+218 _nv028531rm, Falcon+1c8 _nv028764rm, the OS word, Falcon+120 _nv028554rm), _nv028500rm and GPU+5c8 _nv030977rm with the gating tables, _nv030868rm, _nv030878rm. F the FECS start, FECS object slot +80 _nv027343rm (_nv043190rm, Falcon+128, FECS object +70 _nv027634rm with Graphics+1368 _nv031679rm, the 0x409a20 write, then _nv028391rm with Falcon+1c8). G the GPCCS start, GPCCS object slot +98 _nv029620rm (_nv043190rm, _nv028391rm with Falcon+368 _nv028744rm and Falcon+1c8). U the unload of each: _nv027643rm (FECS) and GPCCS+88 _nv029887rm -> Falcon+90 _nv028773rm -> _nv028772rm -> _nv028467rm; OBJSEC2 Unload (class slot +3f8) _nv055940rm -> _nv055939rm (_nv030927rm, _nv030214rm, the command, SEC2+258 _nv055947rm, Falcon+90 with the OBJMC branch of _nv028467rm, the SEC2 interface function +c8 and Falcon+1a0). T the three starts with the register values of the traced V100. Before the F and G rows the Falcon functions of Graphics StateLoad (_nv027641rm and GPCCS+80) run once, as StateLoad calls them: they store the register bases. Fixture-supplied: everything the ACR harness supplies, and: the light-secure manager's request _nv043191rm (recorded with its arguments; its body is the subject of the PMU queue oracles), the feature state _nv031034rm, the SEC2 command _nv055600rm (recorded with the first eight bytes of the command; the SEC2 queue transport is not executed), the registry string lookups _nv049788rm and _nv049789rm (no value), the object lookups _nv049086rm (the GPU), the GPU cast of _nv005245rm, _nv000333rm (the Graphics object), the attach link _nv049088rm and the class id _nv006816rm of a Falcon's owner (0x28c408, 0x5ee8dc, 0x4781e8: the descriptor at Falcon+5ec without its instance byte), the Graphics register object (a write through it is recorded as a register write; on a GV100 its offsets are BAR0 offsets), Graphics+1858 = 0x400000, the dword +38 of the SEC2 base object that _nv028391rm casts the interface to (-1, what its constructor _nv037808rm stores), and the GPU+23c0 object (absent on a GV100). No hardware is involved. """ import hashlib import json from pathlib import Path import sys HERE = Path(__file__).resolve() ACR_HARNESS = HERE.with_name("check_gpu_acr_load_binary.py") WPR_HARNESS = HERE.with_name("check_gpu_wpr_blob_binary.py") CUT = "# The image the original uploaded for the traced values" BINDER = ' call("_nv005876rm", falcon, CHIP, RM)\n' LOADER = "source = SOURCE.read_text()\n" _acr, _wpr = ACR_HARNESS.read_text(), WPR_HARNESS.read_text() assert CUT in _acr and _acr.count(LOADER) == 1 and _wpr.count(BINDER) == 1 PATCHED_IMAGE_HARNESS = _wpr.replace(BINDER, BINDER + ' call("_nv005778rm", falcon, CHIP, RM)\n') _acr = _acr[:_acr.index(CUT)].replace(LOADER, "source = PATCHED_IMAGE_HARNESS\n") __file__ = str(ACR_HARNESS) _arguments, sys.argv = sys.argv[1:], sys.argv[:1] exec(compile(_acr, str(ACR_HARNESS), "exec"), globals()) # noqa: S102 __file__ = str(HERE) FALCON = {"SEC2": F_SEC2, "FECS": F_FECS, "GPCCS": F_GPCCS} OBJECT = {"SEC2": SEC2, "FECS": FECS, "GPCCS": GPCCS, "GPU": GPU, "ACR": ACR} CLASS_ID = {"SEC2": 0x28c408, "FECS": 0x5ee8dc, "GPCCS": 0x4781e8} REGISTER_OBJECT = MEMMGR2 + 0x800 GPU_CLASS = address_of(by_name["_nv003109rm"]) SERVICE_CLASS = address_of(by_name["_nv003131rm"]) STATE_BYTES = (0x3a2, 0x3a3, 0x3a5, 0x3a7, 0x582, 0x583, 0x584) out_rows, out_counts = [], {} @hook("_nv043191rm") def lsfm_request(a, low): emit(f"lsfm:{low[2]:x}:{low[3]:x}:{low[4]:x}:{state['lsfm']:x}") return state["lsfm"] @hook("_nv031034rm") def feature_state_value(a, low): emit(f"fs:{low[1]:x}:{low[2]:x}:{state['fs']:x}") return state["fs"] @hook("_nv055600rm") def sec2_command(a, low): emit("cmd:" + bytes(cpu.mem_read(a[2], 8)).hex() + f":{state['cmd']:x}") return state["cmd"] @hook("_nv049788rm", "_nv049789rm") def registry_string(a, low): return 0x56 @hook("_nv049086rm") def ancestor(a, low): assert low[1] == 0x7ef3cb, a return GPU @hook("_nv000333rm") def graphics_of(a, low): assert a[0] == GPU return GRAPHICS @hook("_nv049088rm") def attach_link(a, low): return a[0] @hook("_nv006816rm") def class_of_owner(a, low): return CLASS_ID[state["falcon"]] @hook("_nv028817rm") def falcon_on_this_gpu(a, low): assert a[0] == GPU return pointer(a[1] + 0x18) @hook("_nv049819rm") def yield_now(a, low): emit("y") return 0 def gpu_cast(emu, address, size, unused): if emu.reg_read(UC_X86_REG_RSI) == GPU_CLASS: leave(emu, GPU) cpu.hook_add(UC_HOOK_CODE, gpu_cast, begin=text("_nv005245rm"), end=text("_nv005245rm")) @service("Graphics register object, vtable +40") def graphics_write(a, low): assert a[0] == REGISTER_OBJECT emit(f"w:{low[1]:x}:{low[2]:x}") return 0 def call64(name, *arguments): call(name, *arguments) return cpu.reg_read(UC_X86_REG_RAX) def function_of(address): return entries.get(address - TEXT, hex(address)) # ------------------------------------------------------------------ the state restore_loaded(loaded_state()) ACR_LOADED_SEC2 = {f"+{offset:#x}": byte(F_SEC2 + offset) for offset in ( 0x3a2, 0x3a3, 0x3a4, 0x3a5, 0x3a7, 0x3aa, 0x3b4, 0x3b7, 0x544, 0x580, 0x582, 0x583, 0x584)} q(GRAPHICS + 0x1368, text("_nv031679rm")) q(GRAPHICS + 0x17a8, REGISTER_OBJECT) q(REGISTER_OBJECT, REGISTER_OBJECT + 0x100) q(REGISTER_OBJECT + 0x140, graphics_write) d(GRAPHICS + 0x1858, 0x400000) assert pointer(GPU + 0x23c0) == 0 # The base object of class _nv003131rm inside OBJSEC2; FECS and GPCCS have none. SERVICE = {name: call64("_nv005245rm", pointer(falcon + 0x5d8), SERVICE_CLASS) for name, falcon in FALCON.items()} assert SERVICE["SEC2"] and not SERVICE["FECS"] and not SERVICE["GPCCS"], SERVICE q(SERVICE["SEC2"] + 0x38, 0xffffffffffffffff) b(F_SEC2 + 0x3a6, 1) # A GPU that is initialised and attached: GPU+915 set, bits 23:8 of GPU+908 clear. b(GPU + 0x915, 1) assert word(GPU + 0x908) & 0xffff00 == 0 # Graphics StateLoad's Falcon calls: register bases, status 0xffff, no access. state.update(reads={}, lsfm=0, fs=0, cmd=0, falcon="FECS") del trace[:] LOAD_CALLS = (call("_nv027641rm", GPU, FECS), call(function_of(pointer(GPCCS + 0x80)), GPU, GPCCS)) assert LOAD_CALLS == (0xffff, 0xffff) and not trace, (LOAD_CALLS, trace) SLOTS = { "OBJSEC2+0x3f0": function_of(pointer(SEC2 + 0x3f0)), "OBJSEC2+0x3f8": function_of(pointer(SEC2 + 0x3f8)), "OBJSEC2+0x258": function_of(pointer(SEC2 + 0x258)), "OBJSEC2+0x1e8": function_of(pointer(SEC2 + 0x1e8)), "FECS+0x70": function_of(pointer(FECS + 0x70)), "FECS+0x80": function_of(pointer(FECS + 0x80)), "FECS+0x88": function_of(pointer(FECS + 0x88)), "GPCCS+0x88": function_of(pointer(GPCCS + 0x88)), "GPCCS+0x98": function_of(pointer(GPCCS + 0x98)), "GPU+0x5c8": function_of(pointer(GPU + 0x5c8)), } assert SLOTS == {"OBJSEC2+0x3f0": "_nv055933rm", "OBJSEC2+0x3f8": "_nv055940rm", "OBJSEC2+0x258": "_nv055947rm", "OBJSEC2+0x1e8": "_nv055604rm", "FECS+0x70": "_nv027634rm", "FECS+0x80": "_nv027343rm", "FECS+0x88": "_nv027611rm", "GPCCS+0x88": "_nv029887rm", "GPCCS+0x98": "_nv029620rm", "GPU+0x5c8": "_nv030977rm"}, SLOTS FALCON_SLOTS = {name: {f"+{offset:#x}": function_of(pointer(falcon + offset)) for offset in ( 0x60, 0x90, 0xb8, 0xd0, 0x108, 0x110, 0x120, 0x128, 0x1a0, 0x1c8, 0x1d0, 0x1e0, 0x198, 0x208, 0x218, 0x368, 0x370)} for name, falcon in FALCON.items()} assert FALCON_SLOTS["SEC2"] == FALCON_SLOTS["FECS"] == FALCON_SLOTS["GPCCS"] INTERFACE_SLOTS = {name: {f"+{offset:#x}": function_of(pointer(pointer(pointer( falcon + 0x5d8)) + offset)) for offset in (0x20, 0x28, 0x40, 0x58, 0x68, 0x70, 0xc8)} for name, falcon in FALCON.items()} def falcon_fields(falcon): fields = {f"+{offset:#x}": byte(falcon + offset) for offset in ( 0x3a2, 0x3a3, 0x3a4, 0x3a5, 0x3a6, 0x3a7, 0x3aa, 0x3af, 0x3b4, 0x3b7, 0x544, 0x580, 0x581, 0x582, 0x583, 0x584)} fields.update({f"+{offset:#x}": f"{word(falcon + offset):#x}" for offset in ( 0x548, 0x560, 0x564, 0x568, 0x578, 0x5ec, 0x5f8, 0x608, 0x650)}) fields["+0x3d8"] = f"{pointer(falcon + 0x3d8):#x}" return fields BEFORE = {name: falcon_fields(falcon) for name, falcon in FALCON.items()} SEC2_BYTES = {f"+{offset:#x}": byte(SEC2 + offset) for offset in ( 0x50, 0x508, 0x509, 0x50a, 0x50c, 0x50e, 0x513, 0x514, 0x516, 0x520)} assert SEC2_BYTES == {"+0x50": 0, "+0x508": 0, "+0x509": 1, "+0x50a": 1, "+0x50c": 0, "+0x50e": 1, "+0x513": 0, "+0x514": 0, "+0x516": 0, "+0x520": 1}, SEC2_BYTES for name, (base, identifier, mask) in {"SEC2": (0x87000, 7, 0xfff2), "FECS": (0x409000, 2, 0xffd2), "GPCCS": (0x41a000, 3, 0xffd2)}.items(): expected = {"+0x3a2": 1, "+0x3a3": 0, "+0x3a4": 0, "+0x3a5": 0, "+0x3a6": 1, "+0x3a7": 1, "+0x3aa": 1, "+0x3af": 0, "+0x3b4": 0, "+0x3b7": 0, "+0x580": 1, "+0x581": 1, "+0x582": 0, "+0x583": 0, "+0x584": 0, "+0x548": hex(base), "+0x564": hex(mask), "+0x568": "0xfff2", "+0x578": "0x0", "+0x5f8": "0x0", "+0x608": hex(identifier), "+0x650": "0x1", "+0x3d8": "0x0"} found = {key: BEFORE[name][key] for key in expected} assert found == expected, (name, found) # The OS word _nv028398rm writes: dword +c of the record at Falcon+3e8, which is the # decoded loader descriptor of the SEC2 image (packed record at .rodata 0x1153b50). q(SCRATCH, 0) assert call("_nv017879rm", rodata(0x1153b50), SCRATCH) == 0 SEC2_LOADER_BYTES = call("_nv017874rm", rodata(0x1153b50)) # (_nv028614rm inserts a zero dword at +50 of a record whose version word is below 4, so # only the first 0x50 bytes are the record's own.) assert SEC2_LOADER_BYTES >= 0x50 and bytes(cpu.mem_read(pointer(SCRATCH), 0x50)) == bytes( cpu.mem_read(pointer(F_SEC2 + 0x3e8), 0x50)) SEC2_OS_WORD = word(pointer(F_SEC2 + 0x3e8) + 0xc) READY = loaded_state() DEFAULT_READS = { "SEC2": {0x87048: [5, 4], 0x87108: [0x20420100], 0x87268: [0x100], 0x87100: [0x50], 0x87294: [0xff], 0x871c0: [0]}, "FECS": {0x409048: [4, 4], 0x409100: [0x50], 0x409294: [0xff]}, "GPCCS": {0x41a048: [2], 0x41a100: [0x50], 0x41a294: [0xff]}, } UNLOAD_READS = { "SEC2": {0x87048: [7], 0x200: [0x1fecdff1, 0x1fec9ff1], 0x873c0: [0, 1], 0x87040: [0], 0x8710c: [1], 0x87100: [0x10]}, "FECS": {0x409048: [7]}, "GPCCS": {0x41a048: [3]}, } PATCHABLE = {"f": None, "s": SEC2, "g": GPU, "a": ACR} def prepare_case(name, reads, patches, inputs, checks=()): """`patches`: 'f.3a6=0' (the Falcon under test), 's.50e=0' (OBJSEC2), 'g.934=1' (GPU), 'a.391=1' (OBJACR), 'v.38=5' (the dword +38 of the SEC2 base object), 'w.564=..' (a dword of the Falcon), 'x.908=..' (a dword of the GPU).""" # The ACR harness's begin() stores its own settings in four SEC2 Falcon bytes; the # started byte +582 is kept as the start left it. started = byte(F_SEC2 + 0x582) begin(reads, [], checks, dict(SETTINGS, k108=1, f3a6=1)) b(F_SEC2 + 0x582, started) state.update(lsfm=inputs.get("lsfm", 0), fs=inputs.get("fs", 0), cmd=inputs.get("cmd", 0), falcon=name) for item in filter(None, patches.split(",")): target, value = item.split("=") kind, offset = target.split(".") if kind == "v": d(SERVICE["SEC2"] + int(offset, 16), int(value, 16)) elif kind == "w": d(FALCON[name] + int(offset, 16), int(value, 16)) elif kind == "x": d(GPU + int(offset, 16), int(value, 16)) else: b((PATCHABLE[kind] or FALCON[name]) + int(offset, 16), int(value, 16)) del trace[:] diagnostics[0] = 0 def record(kind, name, patches, inputs, status, extra=""): falcon = FALCON[name] after = " ".join(f"{offset:x}={byte(falcon + offset):x}" for offset in STATE_BYTES) out_counts[kind] = out_counts.get(kind, 0) + 1 out_rows.append("|".join(( kind, name, patches, ",".join(f"{key}={value:x}" for key, value in sorted(inputs.items())), f"{status:x}", after + extra, f"{diagnostics[0]:x}", " ".join(trace)))) return list(trace) def record_left(kind, name, patches, inputs, reason): out_counts[kind + " left"] = out_counts.get(kind + " left", 0) + 1 LEFT.append({"kind": kind, "falcon": name, "patches": patches, "reason": reason}) out_rows.append("|".join(( kind, name, patches, ",".join(f"{key}={value:x}" for key, value in sorted(inputs.items())), "left", "", "", " ".join(trace)))) return None LEFT = [] def outside(error): """Why a case left the fixtures, or None for a defect of the harness.""" message = str(error) if isinstance(error, AssertionError) and "unexpected read" in message: return message if "UC_ERR_FETCH_UNMAPPED" in message and cpu.reg_read(UC_X86_REG_RIP) < 0x1000: return "call through a null function pointer" if isinstance(error, RuntimeError) and "does not terminate" in message: return message return None def start(name, flags=0): if name == "SEC2": return call("_nv055933rm", GPU, SEC2, flags) if name == "FECS": return call("_nv027343rm", FECS) return call("_nv029620rm", GPCCS) def unload(name, flags): if name == "SEC2": return call("_nv055940rm", GPU, SEC2, flags) if name == "FECS": return call("_nv027643rm", GPU, FECS, flags) return call(function_of(pointer(GPCCS + 0x88)), GPU, GPCCS, flags) def start_case(name, reads=None, patches="", flags=0, **inputs): restore_loaded(READY) prepare_case(name, {**DEFAULT_READS[name], **(reads or {})}, patches, inputs) if flags: inputs = dict(inputs, flags=flags) kind = {"SEC2": "S", "FECS": "F", "GPCCS": "G"}[name] try: status = start(name, flags) except Exception as error: # A branch outside this harness's fixtures (a start that is not light-secure, # a wait for the SEC2 INIT message, a call through an object that is not built # here): recorded as left, with the accesses so far. if not outside(error): print("FAILED", name, patches, inputs, trace, function_at(cpu.reg_read(UC_X86_REG_RIP))) raise return None, record_left(kind, name, patches, inputs, outside(error)) return status, record(kind, name, patches, inputs, status) def unload_case(name, started, reads=None, patches="", flags=0, checks=(), **inputs): restore_loaded(READY) if started: prepare_case(name, DEFAULT_READS[name], "", {}) assert start(name) == 0 prepare_case(name, {**UNLOAD_READS[name], **(reads or {})}, patches, inputs, checks) try: status = unload(name, flags) except Exception as error: if not outside(error): print("FAILED unload", name, started, patches, inputs, trace, function_at(cpu.reg_read(UC_X86_REG_RIP))) raise return None, record_left("U", name, patches, dict(inputs, started=int(started), flags=flags), outside(error)) extra = f" 511={byte(FALCON[name] + 0x511):x} 3c8={int(pointer(FALCON[name] + 0x3c8) != 0)}" return status, record("U", name, patches, dict(inputs, started=int(started), flags=flags), status, extra) # ------------------------------------------------------------ the traced V100 def transcript_falcon(first, last, base): reads, tokens = {}, [] for line in TRANSCRIPT_LINES[first - 1:last]: kind, offset, value, unused = line.split() offset, value = int(offset, 16), int(value, 16) if base <= offset < base + 0x1000: tokens.append(f"{kind.lower()}:{offset:x}:{value:x}") if kind == "R": reads.setdefault(offset, []).append(value) return reads, tokens TRACED = {} restore_loaded(READY) for name, (first, last, base) in {"SEC2": (164966, 165083, 0x87000), "FECS": (166382, 166428, 0x409000), "GPCCS": (167022, 167028, 0x41a000)}.items(): reads, expected = transcript_falcon(first, last, base) track(True) executed.clear() prepare_case(name, reads, "", {}) status = start(name) events = record("T", name, "", {}, status) track(False) assert status == 0 registers = [token for token in events if token[:2] in ("r:", "w:")] assert registers == expected, (name, registers, expected) assert not any(values[1:] for values in state["reads"].values()), state["reads"] TRACED[name] = {"lines": [first, last], "register_accesses": len(registers), "executed": sorted(executed), "state_after": falcon_fields(FALCON[name])} AFTER_ALL = {name: {key: fields[key] for key in ("+0x3a2", "+0x3a3", "+0x3a5", "+0x3a7", "+0x582", "+0x583", "+0x584")} for name, fields in ((name, falcon_fields(falcon)) for name, falcon in FALCON.items())} if "--traced" in _arguments: print(json.dumps(TRACED, indent=1)) sys.exit(0) # ------------------------------------------------------------------ the cases rng = __import__("random").Random(0x55933) WORDS = (0, 1, 2, 3, 4, 5, 6, 7, 0xffffffff, 0xfffffffc, 0x12345678) CPUCTL = (0x50, 0x10, 0x40, 0, 0xffffffff, 0x12) READY_294 = (0xff, 0x11, 0x10, 1, 0, 0xffffffee, 0x31) for name in ("SEC2", "FECS", "GPCCS"): base = int(BEFORE[name]["+0x548"], 16) start_case(name) for first in WORDS: for second in (first, 4, 7, 0): start_case(name, {base + 0x48: [first, second]}) for value in CPUCTL: start_case(name, {base + 0x100: [value]}) for value in READY_294: start_case(name, {base + 0x294: [value]}) for status in (0, 1, 0x65, 0xffff, 0x56): start_case(name, lsfm=status) for patch in ("f.3a6=0", "f.3b4=1", "f.580=0", "f.583=1", "f.3aa=0", "f.3a2=0", "f.3a2=0,f.3a3=0", "f.3a3=1", "f.3a2=0,f.3a3=1", "f.3a6=0,f.3b4=1", "w.564=12345678,w.568=9abcdef0", "g.934=1", "g.934=1,a.391=1", "a.391=1", "a.37b=1", "g.4de5=1", "f.582=1", "f.584=1", "f.3a5=1"): for word_48 in (5, 4, 0xffffffff): start_case(name, {base + 0x48: [word_48, word_48 & ~3]}, patch) for number in range(40): start_case(name, {base + 0x48: [rng.choice(WORDS), rng.choice(WORDS)], base + 0x100: [rng.choice(CPUCTL)], base + 0x294: [rng.choice(READY_294)]}, rng.choice(("", "f.3a6=0", "f.3b4=1", "f.3aa=0", "f.3a3=1")), lsfm=rng.choice((0, 0, 0xffff))) # SEC2 only: the descriptor write, the argument offset, the gating tables, the object bytes. for hwcfg in (0x20420100, 0, 0xffffffff, 0x200, 0x3fe00, 0x1e0): start_case("SEC2", {0x87108: [hwcfg]}) for boundary, control in ((0, [0]), (0, [0x80000000]), (0, [0, 0, 0x20000000]), (0, [0, 0x40000000]), (1, [0]), (0xffffff, [0])): start_case("SEC2", {0x87268: [boundary], 0x871c0: control}) for feature in (0, 1, 2): start_case("SEC2", fs=feature) for patch in ("s.50e=0", "s.50=1", "s.508=1", "s.509=0,s.50a=0", "s.50a=0", "s.516=1", "s.513=1", "s.513=1,s.514=1", "s.514=1", "v.38=5", "v.38=0", "s.50e=0,f.3a6=0"): start_case("SEC2", None, patch) for flags in (1, 0x20, 0xffffffff): start_case("SEC2", None, "", flags) for name in ("SEC2", "FECS", "GPCCS"): base = int(BEFORE[name]["+0x548"], 16) for started in (True, False): for flags in (0, 1, 0x20, 0x21): unload_case(name, started, flags=flags) for value in WORDS: unload_case(name, started, {base + 0x48: [value]}) for patch in ("f.3a6=0", "f.3b4=1", "f.3a7=0", "f.3a7=0,f.3a5=0", "g.934=1,a.391=1"): unload_case(name, started, None, patch) for started in (True, False): for status in (1, 0x65, 0xffff): unload_case("SEC2", started, cmd=status) for patch in ("s.509=0", "s.50=1", "s.508=1", "g.915=0", "g.917=1", "g.918=1", "g.919=1", "g.91d=1", "g.926=1", "x.908=100", "x.908=800000", "x.908=ff0000ff"): unload_case("SEC2", started, None, patch) for pmc in ([0x1fecdff1, 0x1fec9ff1], [0x1fec9ff1], [0xffffffff, 0xffffbfff], [0]): unload_case("SEC2", started, {0x200: pmc}) for reset in ([0, 1], [0xfffffffe, 0xffffffff], [1, 1]): unload_case("SEC2", started, {0x873c0: reset}) unload_case("SEC2", started, {0x8710c: [7, 6, 1]}, checks=(0, 0)) unload_case("SEC2", started, {0x8710c: [6, 6, 0]}, checks=(0x65,)) unload_case("SEC2", started, {0x8710c: [6, 6, 6]}, checks=(0x65,)) unload_case("SEC2", started, {0x8710c: [6]}, checks=(0x1b,)) # SEC2+520 clear: the wait for the halt bit of SEC2+258. unload_case("SEC2", started, {0x87100: [0x10]}, "s.520=0") unload_case("SEC2", started, {0x87100: [0, 0, 0x10]}, "s.520=0", checks=(0, 0)) unload_case("SEC2", started, {0x87100: [0, 0, 0]}, "s.520=0", checks=(0, 0x65)) unload_case("SEC2", started, {0x87100: [0x10]}, "s.520=0", cmd=0x65) out = ROOT / "target/gpu-stage" oracle = "\n".join(out_rows) + "\n" (out / "original-falcon-ls-start.txt").write_text(oracle) report = { "original_sha256": DIGEST, "chip_hal": "0x23", "rm_hal": 2, "environment": "tools/check_gpu_acr_load_binary.py up to and including its traced OBJACR " "Load, with _nv005778rm added to the Falcon creation of the image harness", "kinds": {"S": "OBJSEC2 Load _nv055933rm(gpu, sec2, flags)", "F": "FECS object slot +80 _nv027343rm", "G": "GPCCS object slot +98 _nv029620rm", "U": "_nv027643rm, GPCCS+88 _nv029887rm, OBJSEC2 Unload _nv055940rm", "T": "the three starts with the traced register values, in order, in one state"}, "row": "kind|falcon|patches|inputs|status|falcon bytes after|diagnostics|events", "slots": SLOTS, "falcon_slots": FALCON_SLOTS["SEC2"], "interface_slots": INTERFACE_SLOTS, "falcon_objects_before_the_start": BEFORE, "sec2_falcon_after_acr_load": ACR_LOADED_SEC2, "objsec2_bytes": SEC2_BYTES, "sec2_os_word": f"{SEC2_OS_WORD:#x}", "sec2_loader_record": "0x1153b50", "traced": TRACED, "falcon_bytes_after_all_starts": AFTER_ALL, "cases": len(out_rows), "cases_by_kind": out_counts, "left": LEFT, "oracle": "target/gpu-stage/original-falcon-ls-start.txt", "oracle_sha256": hashlib.sha256(oracle.encode()).hexdigest(), "scope": "Original instructions of the light-secure start and unload of SEC2, FECS and " "GPCCS on a GV100. No hardware executed.", } (ROOT / "reports/gpu-falcon-ls-start-original.json").write_text(json.dumps(report, indent=1) + "\n") print(f"{len(out_rows)} original rows {out_counts}") print(report["oracle_sha256"])