#!/usr/bin/env python3 """Run the original GV100 OBJACR ConstructEngine (_nv016731rm) for the bytes OBJACR Load and Unload read, and write an oracle. The environment and the case construction are those of tools/check_gpu_lsfm_mask_binary.py, whose source is executed unchanged up to its OBJACR ConstructEngine section. That harness compares the stores to +37b, +37c, +381 and +391; this one records, for the same kind of case, the bytes +37b, +37c, +37f, +385, +386, +38b, +38e, +38f, +390, +391 and +529 as the constructor leaves them after the GV100 property initializer _nv005809rm. Registry values, the fuse register and the GPU bytes are case inputs. No hardware is involved. """ from pathlib import Path HERE = Path(__file__).resolve() SOURCE = HERE.with_name("check_gpu_lsfm_mask_binary.py") MARKER = "# ------------------------------------------------- A: OBJACR ConstructEngine" source = SOURCE.read_text() assert MARKER in source exec(compile(source[:source.index(MARKER)], str(SOURCE), "exec"), globals()) # noqa: S102 BYTES = (0x37b, 0x37c, 0x37f, 0x385, 0x386, 0x38b, 0x38e, 0x38f, 0x390, 0x391, 0x529) out_rows = [] def construct(registry_values=None, fuse=1, pmu=1, d8c=0, g90e=0, g4de2=0, g4de4=0, g4de5=0, g914=0, g92b=0): begin("A") case["registry"].update(registry_values or {}) d(GPU + 0xd00, 0x140) d(GPU + 0xd04, 0) d(GPU + 0x9e8, 0x23) case["registers"][FUSE_REGISTER] = fuse if not pmu: q(GPU + 0x2120, 0) d(PMU + 0xd8c, d8c) for offset, value in ((0x90e, g90e), (0x4de2, g4de2), (0x4de4, g4de4), (0x4de5, g4de5), (0x914, g914), (0x92b, g92b)): b(GPU + offset, value) before = hexes(byte(ACR + offset) for offset in BYTES) status = call("_nv016731rm", GPU, ACR) out_rows.append(f"{answers(ACR_KEYS)} {fuse:x} {pmu:x} {d8c:x} {g90e:x} {g4de2:x} {g4de4:x} " f"{g4de5:x} {g914:x} {g92b:x};{status:x};{before};" + hexes(byte(ACR + offset) for offset in BYTES)) construct() for key in ACR_KEYS: for value in (0, 1, 2, 3, 4, 5, 7, 0xc, 0xd, 0xf, 0x10, 0x15, 0x30, 0x3f, 0xffffffff): for fuse in (0, 1): construct({key: value}, fuse=fuse) for first, second in itertools.combinations(ACR_KEYS, 2): for values in ((1, 1), (0, 1), (1, 0), (3, 0x3f)): construct({first: values[0], second: values[1]}) for fuse, pmu, d8c, g90e, g4de2, g4de4, g4de5, g914, g92b in itertools.product((0, 1), repeat=9): if pmu or not d8c: construct(fuse=fuse, pmu=pmu, d8c=d8c, g90e=g90e, g4de2=g4de2, g4de4=g4de4, g4de5=g4de5, g914=g914, g92b=g92b) for mode, fuse, g4de4, g90e in itertools.product((0, 1, 0x15, 0x3f, 0x2a), (0, 1), (0, 1), (0, 1)): construct({"RmBootFromHs": mode}, fuse=fuse, g4de4=g4de4, g90e=g90e) oracle = "\n".join(out_rows) + "\n" target = ROOT / "target/gpu-stage/original-acr-construct.txt" target.write_text(oracle) print(f"{len(out_rows)} original OBJACR ConstructEngine cases; oracle sha256 " f"{hashlib.sha256(oracle.encode()).hexdigest()}")