code wiki / _hdl_build / _gpu_dxg_gate.nx

_gpu_dxg_gate.nx source

↩ module page · 98 lines · 7258 B

1// _gpu_dxg_gate.nx -- GATE for the SOVEREIGN-GPU foundation rung (R0): proves Nishi reaches the 2// REAL RTX 5080 through /dev/dxg (the WSL dxgkrnl last-mile) with RAW syscalls only -- the emitted 3// elf links NOTHING (no libvulkan / libcuda / libdxcore / libd3d12 / libc). The verdict comes from 4// a REAL ioctl to the REAL device returning REAL adapter data (count + non-zero LUID), NOT from $?. 5// 6// AUTHOR=ORGAN / NO-FALSE-GREEN -- the gate runs the real nx_gpu_dxg_probe mechanism three ways 7// against the SAME binary and asserts ALL must hold: 8// (A) REAL CALL on /dev/dxg: LX_DXENUMADAPTERS2 ret==0 AND num_adapters>=1 AND a non-zero 9// adapter[0] LUID/handle came back from the 5080. 10// (B) TAMPER (magic-0x99 ioctl on the SAME real /dev/dxg fd): the device rejects it with a real 11// errno (< 0, observed -25 ENOTTY) that DIFFERS from the real ret==0. A 0 here = the fd is a 12// no-op => RED. This proves ret==0 is a real device ACCEPT, not "any ioctl returns 0". 13// (C) NON-DXG FD control (/dev/null): the EXACT SAME LX_DXENUMADAPTERS2 ioctl returns a real 14// errno (< 0, ENOTTY) -- NOT 0 and NOT adapter data. This proves the green depends on the 15// REAL dxgkrnl device behind /dev/dxg, not on merely having an open fd. 16// GREEN iff (A) AND (B) AND (C). Any failure -> RED with the real returned values, NEVER a fake green. 17// 18// SCOPE (NO-WAVE): GREEN here means ONLY "Nishi reaches the real RTX 5080 sovereignly via the 19// /dev/dxg paravirt last-mile". It claims NO throughput / speedup / exceed (that is R7, a real 20// cuBLAS head-to-head many rungs up). This is the FOUNDATION rung the GPU ladder rests on. 21// 22// SELF-CONTAINED: imports nx_gpu_dxg_probe and calls dxg_enumadapters() in-process -- it does NOT 23// fork a prebuilt _offc/*.elf, so the /tmp->_offc install landmine does not apply to this gate. 24// Evidence -> knowledge/status/gpu_dxg.log. license_tier: ORIGINAL 25import "nx_syscalls.nx" 26import "nx_gpu_dxg_probe.nx" 27 28func g_p(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 29func g_x(v: i64) -> i64 { g_p("0x" as *u8); let bb:*u8=sys_mmap(20); var k:i64=0; var m:i64=v; if m==0{bb[0]=48;k=1}; while m>0{ let d:i64=m&15; if d<10{bb[k]=(48+d) as u8}else{bb[k]=(87+d) as u8}; m=(m>>4); k=k+1 } var i:i64=0; let o:*u8=sys_mmap(20); while i<k{o[i]=bb[k-1-i];i=i+1} sys_write(1,o,k); return 0 } 30func g_fp(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 } 31func g_fn(fd: i64, v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(fd,"-" as *u8,1)}; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48;k=1}; while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1}; var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1}; sys_write(fd,bb,k); return 0 } 32func g_fx(fd: i64, v: i64) -> i64 { g_fp(fd,"0x" as *u8); let bb:*u8=sys_mmap(20); var k:i64=0; var m:i64=v; if m==0{bb[0]=48;k=1}; while m>0{ let d:i64=m&15; if d<10{bb[k]=(48+d) as u8}else{bb[k]=(87+d) as u8}; m=(m>>4); k=k+1 } var i:i64=0; let o:*u8=sys_mmap(20); while i<k{o[i]=bb[k-1-i];i=i+1} sys_write(fd,o,k); return 0 } 33 34func main() -> i64 { 35 g_p("=== SOVEREIGN-GPU foundation gate (raw /dev/dxg ioctl -> REAL RTX 5080 adapter data) ===\n" as *u8) 36 let lfd: i64 = sys_openat_append("knowledge/status/gpu_dxg.log" as *u8, 0x1a4) 37 38 // (A) REAL CALL on the real device. 39 let rr: *u8 = sys_mmap(64) 40 let ret: i64 = dxg_enumadapters("/dev/dxg" as *u8, rr) 41 let fd: i64 = dxr_get(rr, DXR_FD) 42 let nc: i64 = dxr_get(rr, DXR_NUM_ADAPTERS) 43 let h0: i64 = dxr_get(rr, DXR_HANDLE0) 44 let la: i64 = dxr_get(rr, DXR_LUID_A) 45 let lb: i64 = dxr_get(rr, DXR_LUID_B) 46 let tamper: i64 = dxr_get(rr, DXR_TAMPER_RET) // (B) tamper on the SAME real fd 47 48 g_p(" open(/dev/dxg) fd=" as *u8); g_fn(1, fd); g_p("\n" as *u8) 49 g_p(" LX_DXENUMADAPTERS2 code="as *u8); g_x(DXG_LX_DXENUMADAPTERS2); g_p(" ret=" as *u8); g_fn(1, ret) 50 g_p(" num_adapters=" as *u8); g_fn(1, nc); g_p("\n" as *u8) 51 g_p(" adapter[0] handle=" as *u8); g_x(h0); g_p(" luid.a=" as *u8); g_x(la); g_p(" luid.b=" as *u8); g_x(lb); g_p("\n" as *u8) 52 g_p(" [tamper] magic-0x99 ioctl(SAME fd) ret=" as *u8); g_fn(1, tamper); g_p("\n" as *u8) 53 54 // (C) NON-DXG FD control: same ioctl on /dev/null must NOT return real adapter data. 55 let cc: *u8 = sys_mmap(64) 56 let cret: i64 = dxg_enumadapters("/dev/null" as *u8, cc) 57 let cfd: i64 = dxr_get(cc, DXR_FD) 58 g_p(" [non-dxg control] /dev/null fd=" as *u8); g_fn(1, cfd); g_p(" LX_DXENUMADAPTERS2 ret=" as *u8); g_fn(1, cret); g_p("\n" as *u8) 59 60 // -- assertions (judge by REAL returned values, never $?) -- 61 var luid_real: i64 = 0; if la != 0 { luid_real = 1 }; if lb != 0 { luid_real = 1 }; if h0 != 0 { luid_real = 1 } 62 var a_ok: i64 = 0 63 if ret == 0 { if nc >= 1 { if luid_real == 1 { a_ok = 1 } } } // real call green 64 var b_ok: i64 = 0 65 if tamper < 0 { if tamper != ret { b_ok = 1 } } // tamper -> real errno != real ret 66 var c_ok: i64 = 0 67 if cfd >= 0 { if cret != 0 { c_ok = 1 } } // non-dxg fd -> ioctl is NOT 0 68 69 g_p(" checks: real-call(A)=" as *u8); g_fn(1, a_ok) 70 g_p(" tamper-distinct(B)=" as *u8); g_fn(1, b_ok) 71 g_p(" non-dxg-fd-fails(C)=" as *u8); g_fn(1, c_ok); g_p("\n" as *u8) 72 73 var pass: i64 = 0 74 if a_ok == 1 { if b_ok == 1 { if c_ok == 1 { pass = 1 } } } 75 if pass == 1 { 76 g_p("DXGGATE verdict=GREEN reason=raw-ioctl-reached-real-RTX5080-via-/dev/dxg (ret=0, num_adapters>=1, non-zero LUID; tamper + non-dxg-fd both fail = no-false-green; wrapper-free)\n" as *u8) 77 if lfd >= 0 { 78 g_fp(lfd, "DXGGATE verdict=GREEN rung=R0-sovereign-gpu-foundation device=/dev/dxg ioctl=LX_DXENUMADAPTERS2(" as *u8); g_fx(lfd, DXG_LX_DXENUMADAPTERS2) 79 g_fp(lfd, ") ret=" as *u8); g_fn(lfd, ret); g_fp(lfd, " num_adapters=" as *u8); g_fn(lfd, nc) 80 g_fp(lfd, " adapter0_handle=" as *u8); g_fx(lfd, h0); g_fp(lfd, " luid_a=" as *u8); g_fx(lfd, la); g_fp(lfd, " luid_b=" as *u8); g_fx(lfd, lb) 81 g_fp(lfd, " tamper_magic0x99_ret=" as *u8); g_fn(lfd, tamper); g_fp(lfd, " nondxg_fd_ret=" as *u8); g_fn(lfd, cret) 82 g_fp(lfd, " wrapper_free=raw-syscalls-no-libc scope=reach-only-NO-throughput-exceed epoch=" as *u8); g_fn(lfd, sys_now_realtime_sec()); g_fp(lfd, "\n" as *u8) 83 sys_close(lfd) 84 } 85 sys_exit(0); return 0 86 } 87 g_p("DXGGATE verdict=RED reason=one-or-more-real-checks-failed (see A/B/C above; NOT faking green)\n" as *u8) 88 if lfd >= 0 { 89 g_fp(lfd, "DXGGATE verdict=RED rung=R0-sovereign-gpu-foundation ret=" as *u8); g_fn(lfd, ret) 90 g_fp(lfd, " num_adapters=" as *u8); g_fn(lfd, nc); g_fp(lfd, " luid_a=" as *u8); g_fx(lfd, la) 91 g_fp(lfd, " tamper_ret=" as *u8); g_fn(lfd, tamper); g_fp(lfd, " nondxg_ret=" as *u8); g_fn(lfd, cret) 92 g_fp(lfd, " a_ok=" as *u8); g_fn(lfd, a_ok); g_fp(lfd, " b_ok=" as *u8); g_fn(lfd, b_ok); g_fp(lfd, " c_ok=" as *u8); g_fn(lfd, c_ok) 93 g_fp(lfd, " epoch=" as *u8); g_fn(lfd, sys_now_realtime_sec()); g_fp(lfd, "\n" as *u8) 94 sys_close(lfd) 95 } 96 sys_exit(1) 97 return 1 98}