code wiki / (root) / nx_rvc_gate.nx

nx_rvc_gate.nx source

↩ module page · 62 lines · 3970 B

1// nx_rvc_gate.nx -- THE VERDICT GATE for nishios NO3 (nx_rvc_run_suite, watch symbol rvc_run_suite). 2// 3// SUBJECT: the nx_rvc_run_suite ELF, forked for real (argv[1] overrides; default the serving-root 4// _offc copy). It runs the organ's SELF-CONTAINED `selftest`, which builds a synthetic RV64 program 5// in memory (no third-party corpus, so this gate is non-vacuous on the NAS where there is no gcc): 6// the program stores two known words to a signature region, writes tohost, then loops. The runner's 7// OWN compare core (the same rvc_run_img the real suite uses) is then exercised three ways: 8// good a correct reference -> verdict PASS (T1) 9// corrupt a WRONG reference word -> verdict FAIL (T2, THE KNOWN-FAILING CONTROL: a comparator that 10// always PASSed -- a vacuous suite -- fails HERE, 11// so no pass count can be quoted from a blind ruler) 12// illegal a bad instruction word -> verdict UNSUPPORTED, not a silent PASS/FAIL (T3) 13// empty a nonexistent pin -> zero runs, RED at the caller (T4, neg-control-empty-corpus) 14// T5 requires the runner's own aggregate self-verdict GREEN and exit 0 (partition + all four held). 15// 16// The full per-group compliance numbers (I/M/C/privilege/Zifencei against the pinned repo references) 17// are the LOCAL WITNESS (bench/riscv-arch-test/nishios_NO3_local_witness.txt) -- the third-party 18// gcc assembler and the 12 MB corpus are laptop-only by the estate's no-gcc-on-NAS design; this gate 19// proves the RUNNER MECHANISM everywhere, which is what makes that witness trustworthy. 20// license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0 21import "nx_syscalls.nx" 22import "nx_gate_verdict.nx" 23import "nx_tool_run.nx" 24 25const RVG_SUBJECT_DEFAULT: *u8 = "_offc/nx_rvc_run_suite.elf\x00" 26const RVG_CAP: i64 = 262144 27const RVG_TIMEOUT_MS: i64 = 60000 // the selftest runs a handful of tiny programs; a minute is a hang 28 29func main(argc: i64, argv: *i64) -> i64 { 30 var subject: *u8 = RVG_SUBJECT_DEFAULT 31 if argc >= 2 { subject = argv[1] as *u8 } 32 // CWD anchor: the tools-API exec lane starts organs in the serving root; if _offc holds the subject 33 // there, we are already correct. The selftest needs no corpus files, so no chdir is required. 34 let ctr: *i64 = gv_ctr() 35 gv_head("=== nx_rvc_gate -- NO3 conformance runner mechanism (self-contained synthetic RV64) ===" as *u8) 36 37 let out: *u8 = sys_mmap(RVG_CAP) 38 let olen: *i64 = sys_mmap(8) as *i64 39 let rc: i64 = tr_run1_to(subject, "selftest\x00" as *u8, out, RVG_CAP, olen, RVG_TIMEOUT_MS) 40 let n: i64 = olen[0] 41 42 gv_puts(" subject=" as *u8); gv_puts(subject); gv_puts(" rc=" as *u8); gv_num(rc); gv_puts(" bytes=" as *u8); gv_num(n); gv_puts("\n" as *u8) 43 44 let t1: i64 = tr_contains(out, n, "RVC-SELFTEST good_verdict=0 good_done=1" as *u8) 45 gv_check("good-signature-verdict-PASS-and-completed" as *u8, t1, ctr) 46 47 let t2: i64 = tr_contains(out, n, "RVC-SELFTEST corrupt_verdict=1" as *u8) 48 gv_check("neg-control-corrupt-signature-verdict-FAIL (the ruler is not vacuous; a blind always-PASS fails HERE)" as *u8, t2, ctr) 49 50 let t3: i64 = tr_contains(out, n, "RVC-SELFTEST illegal_verdict=2" as *u8) 51 gv_check("illegal-instruction-verdict-UNSUPPORTED-not-silent-PASS" as *u8, t3, ctr) 52 53 let t4: i64 = tr_contains(out, n, "RVC-SELFTEST empty_suite_runs=0" as *u8) 54 gv_check("neg-control-empty-corpus-yields-zero-runs" as *u8, t4, ctr) 55 56 let t5g: i64 = tr_contains(out, n, "RVC-SELFTEST verdict=GREEN" as *u8) 57 var t5: i64 = 0 58 if t5g == 1 { if rc == 0 { t5 = 1 } } 59 gv_check("runner-aggregate-selfverdict-GREEN-and-exit0" as *u8, t5, ctr) 60 61 return gv_verdict("nx_rvc_gate" as *u8, ctr, "NO3 conformance runner mechanism proven on a self-contained synthetic RV64 test; full per-group compliance is the pinned local witness (bench/riscv-arch-test)" as *u8) 62}