Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/tests/arboris/probe-common.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / tests / arboris / probe-common.om` 291 lines ยท 6425 bytes Raw Blame History 1 note SPDX-License-Identifier: AGPL-3.0-only 2 fn probe_log label view uchar * v ulong to void 3 digits = new uchar 21 0 4 p = ulong 20 5 put digits p 10 6 while true bound 20 7 p = sub p 1 8 put digits p uchar add 48 rem v 10 9 v = div v 10 10 if eq v 0 11 break 12 end 13 end 14 ignored = write 1 label 0 len label 15 ignored = write 1 digits p sub 21 p 16 end 17 text ps_stage "nvrm_stage=" 18 text ps_errno "linux_errno=" 19 text ps_status "rm_status=" 20 text ps_index "import_index=" 21 text ps_probe "probe_status=" 22 text ps_cpu "cpu_validated_hop_ns=" 23 text ps_gpu "gpu_validated_hop_ns=" 24 text ps_words "matching_fp32_words=" 25 text ps_rc "hop_status=" 26 text ps_input "arena_sha256=" 27 text ps_code "kernel_sha256=" 28 text ps_output "output_sha256=" 29 text ps_hex "`0123456789abcdef`" 30 fn probe_digest label view uchar * hash view uchar * to void 31 line = new uchar 65 10 32 for i ulong 32 33 v = ulong get hash i 34 put line mul i 2 get ps_hex shr v 4 35 put line add mul i 2 1 get ps_hex and v 15 36 end 37 ignored = write 1 label 0 len label 38 ignored = write 1 line 0 65 39 end 40 41 global ps_signed ulong 1 42 text ps_benchmark "benchmark" 43 text ps_reference "reference" 44 text ps_signed_hash "signed_step_sha256=" 45 text ps_epoch "committed_world_epoch=" 46 text ps_message "step_message=" 47 48 note Optional live signer probe. The supervisor installs the raw public key 49 note on FD9, the private request pipe on FD10 and the reply pipe on FD11. 50 fn probe_arm_signer table long m view ulong 16 h view ulong 2 controls ulong to bool 51 if ne get ps_signed 0 2 52 ret true 53 end 54 policy = new uchar 136 0 55 if not ar_signing_policy table 42 h m controls policy 56 ret false 57 end 58 ret eq write 12 policy 0 136 136 59 end 60 61 fn probe_seal table long m view ulong 16 h view ulong 2 to bool 62 pk = new uchar 32 0 63 if ne read 9 pk 0 32 32 64 ret false 65 end 66 grant = new ulong 3 0 67 put grant 0 42 68 put grant 1 get h 0 69 put grant 2 get h 1 70 channel = new int 2 10 71 put channel 1 11 72 receipt = new uchar 248 0 73 if not ar_seal_step table grant m channel pk receipt 74 ret false 75 end 76 epoch = mapget get ar_maps 5 32 8 77 if ne epoch add get m 7 1 78 ret false 79 end 80 ctx = new ulong 40 0 81 digest = new uchar 32 0 82 sha256_init ctx 83 sha256_update ctx receipt 84 sha256_final ctx digest 85 probe_digest ps_signed_hash digest 86 probe_log ps_epoch epoch 87 ret true 88 end 89 90 fn probe_witness table long m view ulong 16 handle view ulong 2 to bool 91 body = new uchar 65536 0 92 metrics = new ulong 3 0 93 if not ar_step_message m 42 handle body metrics 94 ret false 95 end 96 line = new uchar 369 10 97 for i ulong 184 98 v = ulong get body i 99 put line mul i 2 get ps_hex shr v 4 100 put line add mul i 2 1 get ps_hex and v 15 101 end 102 if ne write 1 ps_message 0 len ps_message long len ps_message 103 ret false 104 end 105 if ne write 1 line 0 369 369 106 ret false 107 end 108 if eq get ps_signed 0 2 109 ret probe_seal table m handle 110 end 111 ret true 112 end 113 114 fn probe_le bytes view uchar * i ulong width ulong to ulong 115 v = ulong 0 116 for j ulong width bound 8 117 v = or v shl ulong get bytes add i j mul j 8 118 end 119 ret v 120 end 121 122 fn probe_produce m view ulong 16 offsets view ulong 6 sendfd int ackfd int to int 123 if not nvfull 124 ret 10 125 end 126 rec = new uchar 144 0 127 for i ulong 6 128 tok = nvallocgranule ar_region_bytes m offsets i true true 129 if le tok 0 130 ret 11 131 end 132 if not probe_fill m i tok 133 ret 12 134 end 135 if not nvexport tok 136 ret 13 137 end 138 for j ulong 24 139 put rec add mul i 24 j get nvshrec j 140 end 141 end 142 cpufence 143 if ne write sendfd rec 0 144 144 144 ret 14 145 end 146 if ne read ackfd rec 0 1 1 147 ret 15 148 end 149 ret 0 150 end 151 152 fn probe_import m view ulong 16 offsets view ulong 6 to int 153 fds = new uchar 16 0 154 if ne pipefds fds 0 8 0 0 155 ret 16 156 end 157 if ne pipefds fds 8 8 0 0 158 ret 16 159 end 160 pid = fork 161 if lt pid 0 162 ret 17 163 end 164 if eq pid 0 165 ignored = fclose int probe_le fds 0 4 166 ignored = fclose int probe_le fds 12 4 167 rc = probe_produce m offsets int probe_le fds 4 4 int probe_le fds 8 4 168 if ne rc 0 169 probe_log ps_probe ulong rc 170 probe_log ps_stage ulong get nvstage 0 171 err = get nverr 0 172 if lt err 0 173 probe_log ps_errno ulong neg err 174 else 175 probe_log ps_status ulong err 176 end 177 end 178 if not nvstop 179 rc = int 18 180 end 181 exit rc 182 end 183 ignored = fclose int probe_le fds 4 4 184 ignored = fclose int probe_le fds 8 4 185 records = new uchar 144 0 186 ok = eq read int probe_le fds 0 4 records 0 144 144 187 if ok 188 ok = nvfull 189 end 190 if ok 191 ok = nvchan 192 end 193 if ok 194 ok = ar_map_arena records m get m 12 195 end 196 if ok 197 ok = eq write int probe_le fds 12 4 records 0 1 1 198 end 199 ignored = fclose int probe_le fds 12 4 200 ignored = fclose int probe_le fds 0 4 201 if ne waitpid int pid fds 0 8 0 pid 202 ret 19 203 end 204 if ne probe_le fds 0 4 0 205 ret 20 206 end 207 if not ok 208 ret 21 209 end 210 ret 0 211 end 212 213 fn probe_host_mode to int 214 modebuf = new uchar 16 0 215 count = argread 1 modebuf 0 16 216 if eq count 9 217 benchmark = true 218 reference = true 219 for i ulong 9 220 if ne get modebuf i get ps_benchmark i 221 benchmark = false 222 end 223 if ne get modebuf i get ps_reference i 224 reference = false 225 end 226 end 227 if benchmark 228 put ps_signed 0 4 229 ret probe_reference 230 end 231 if reference 232 ret probe_reference 233 end 234 end 235 ret 49 236 end 237 238 fn main to int 239 if eq argcnt 2 240 ret probe_host_mode 241 end 242 bytes = new uchar 48 0 243 if ne read 0 bytes 0 48 48 244 ret 3 245 end 246 if ne probe_le bytes 0 8 42 247 ret 4 248 end 249 h = new ulong 2 0 250 put h 0 probe_le bytes 8 8 251 put h 1 probe_le bytes 16 8 252 m = new ulong 16 0 253 probe_model_meta m 254 put m 7 probe_le bytes 24 8 255 put m 8 probe_le bytes 32 8 256 table = mapnew int 3 0 22560 1 1 257 if le table 0 258 ret 5 259 end 260 put ps_signed 0 probe_le bytes 40 8 261 rc = probe_run table h m 262 if ne rc 0 263 probe_log ps_stage ulong get nvstage 0 264 note RM statuses are positive and Linux errors negative. 265 probe_log ps_probe ulong rc 266 probe_log ps_index get ar_import_index 0 267 err = get nverr 0 268 if lt err 0 269 probe_log ps_errno ulong neg err 270 else 271 probe_log ps_status ulong err 272 end 273 end 274 if not ar_step_close 275 if eq rc 0 276 rc = int 34 277 end 278 end 279 if not ar_unmap 280 if eq rc 0 281 rc = int 32 282 end 283 end 284 if not nvstop 285 if eq rc 0 286 rc = int 33 287 end 288 end 289 ignored = mapdrop table 290 ret rc 291 end