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
omega-mv / gpu / driver / tests / irqcc_trace.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note gpu/driver/tests/irqcc_trace.om: Host-only self-test for irq.om + irqcc.om + logdec.om (OM-1). |
| 3 | note Build: cat gpu/driver/gsp/logdec.om gpu/driver/gsp/irqsim.om gpu/driver/gsp/irq.om gpu/driver/gsp/irqcc.om gpu/driver/tests/irqcc_trace.om | seed/out/omc > irqcc_trace |
| 4 | note Never opens devices, maps MMIO, or performs DMA. Uses synthetic IRQ + CrashCat fixtures only. |
| 5 | |
| 6 | const CTRPTHDR ulong 14587176806713922100 |
| 7 | const CTCSRHDR ulong 14587183390898804344 |
| 8 | const CTBADHDR ulong 13758233000301035520 |
| 9 | |
| 10 | text CTPASS "IRQCC TEST PASS 6/6\n" |
| 11 | |
| 12 | fn ctput64w o ulong v ulong to void |
| 13 | for i ulong 8 |
| 14 | put lgwpr add o i uchar and shr v mul i 8 255 |
| 15 | end |
| 16 | end |
| 17 | |
| 18 | fn ctput64c o ulong v ulong to void |
| 19 | for i ulong 8 |
| 20 | put ccbuf add o i uchar and shr v mul i 8 255 |
| 21 | end |
| 22 | end |
| 23 | |
| 24 | fn ctput64b o ulong v ulong to void |
| 25 | for i ulong 8 |
| 26 | put lgbuf add o i uchar and shr v mul i 8 255 |
| 27 | end |
| 28 | end |
| 29 | |
| 30 | note Reset host-model irq.om and irqsim.om globals between synthetic test cases. |
| 31 | fn ctreset to void |
| 32 | put iqmode 0 0 |
| 33 | put iqstate 0 0 |
| 34 | put iqgen 0 0 |
| 35 | put iqdone 0 0 |
| 36 | put iqpend 0 0 |
| 37 | put iqhalt 0 0 |
| 38 | put iqccbound 0 0 |
| 39 | put iqccpa 0 0 |
| 40 | put iqccsz 0 0 |
| 41 | put iqccpkts 0 0 |
| 42 | put iqccerr 0 0 |
| 43 | put israw 0 0 |
| 44 | put ismask 0 255 |
| 45 | put isdest 0 255 |
| 46 | put iscnt 0 0 |
| 47 | put isdone 0 0 |
| 48 | put isedge 0 0 |
| 49 | put isfail 0 0 |
| 50 | put islock 0 0 |
| 51 | put istail 0 0 |
| 52 | put ispm 0 0 |
| 53 | put isacks 0 0 |
| 54 | put isreads 0 0 |
| 55 | put ismasks 0 0 |
| 56 | put isviol 0 0 |
| 57 | put islocked 0 0 |
| 58 | end |
| 59 | |
| 60 | note ---- Test 1: HALT IRQ with NO CrashCat buffer bound preserves quarantine ---- |
| 61 | fn cttest1 to bool |
| 62 | ctreset |
| 63 | if ne iqinit 7 0 |
| 64 | ret false |
| 65 | end |
| 66 | put israw 0 16 |
| 67 | r = iqservicecc 7 4 -1 16 |
| 68 | if ne r -13 |
| 69 | ret false |
| 70 | end |
| 71 | if ne get iqstate 0 2 |
| 72 | ret false |
| 73 | end |
| 74 | if ne get iqhalt 0 1 |
| 75 | ret false |
| 76 | end |
| 77 | if ne get ismasks 0 1 |
| 78 | ret false |
| 79 | end |
| 80 | if ne get isacks 0 0 |
| 81 | ret false |
| 82 | end |
| 83 | if ne get israw 0 16 |
| 84 | ret false |
| 85 | end |
| 86 | if ne get iqccpkts 0 0 |
| 87 | ret false |
| 88 | end |
| 89 | if ne get iqccerr 0 0 |
| 90 | ret false |
| 91 | end |
| 92 | ret true |
| 93 | end |
| 94 | |
| 95 | note ---- Test 2: HALT|SWGEN0 with bound linear CrashCat buffer (REPORT + RISCV64_CSR + lgfmtcc) ---- |
| 96 | fn cttest2 to bool |
| 97 | ctreset |
| 98 | if ne iqinit 7 0 |
| 99 | ret false |
| 100 | end |
| 101 | note Packet 0 (48 B): REPORT (sig=0xCA70, ver=1, type=0, plen=5, hdata=0x1234) |
| 102 | ctput64c 0 CTRPTHDR |
| 103 | ctput64c 8 111 |
| 104 | ctput64c 16 222 |
| 105 | ctput64c 24 333 |
| 106 | ctput64c 32 444 |
| 107 | ctput64c 40 555 |
| 108 | note Packet 1 (24 B): RISCV64_CSR (sig=0xCA70, ver=1, type=6, plen=2, hdata=0x5678) |
| 109 | ctput64c 48 CTCSRHDR |
| 110 | ctput64c 56 768 |
| 111 | ctput64c 64 4096 |
| 112 | if ne iqccbind 1 1048576 72 0 |
| 113 | ret false |
| 114 | end |
| 115 | put israw 0 80 |
| 116 | r = iqservicecc 7 4 1 16 |
| 117 | if ne r -13 |
| 118 | ret false |
| 119 | end |
| 120 | if ne get iqstate 0 2 |
| 121 | ret false |
| 122 | end |
| 123 | if ne get iqhalt 0 1 |
| 124 | ret false |
| 125 | end |
| 126 | if ne get ismasks 0 1 |
| 127 | ret false |
| 128 | end |
| 129 | if ne get isacks 0 0 |
| 130 | ret false |
| 131 | end |
| 132 | if ne get iqccpkts 0 2 |
| 133 | ret false |
| 134 | end |
| 135 | if ne get iqccerr 0 0 |
| 136 | ret false |
| 137 | end |
| 138 | if ne get cctype 0 CCTCSR |
| 139 | ret false |
| 140 | end |
| 141 | if ne get ccplen 0 2 |
| 142 | ret false |
| 143 | end |
| 144 | if ne get ccpay 0 768 |
| 145 | ret false |
| 146 | end |
| 147 | if ne get ccpay 1 4096 |
| 148 | ret false |
| 149 | end |
| 150 | if ne get lgoerr 0 0 |
| 151 | ret false |
| 152 | end |
| 153 | ret true |
| 154 | end |
| 155 | |
| 156 | note ---- Test 3: HALT IRQ with GspFwWprMeta-bound paged LibosLog ring CrashCat buffer ---- |
| 157 | fn cttest3 to bool |
| 158 | ctreset |
| 159 | if ne iqinit 7 0 |
| 160 | ret false |
| 161 | end |
| 162 | for i ulong LGWPRSZ |
| 163 | put lgwpr i 0 |
| 164 | end |
| 165 | ctput64w 0 LGWPRMAG |
| 166 | ctput64w 8 1 |
| 167 | ctput64w LGCCQPA 2097152 |
| 168 | ctput64w LGCCQSZ 8192 |
| 169 | if ne iqccbindwpr 2 1 |
| 170 | ret false |
| 171 | end |
| 172 | for i ulong 8192 |
| 173 | put lgbuf i 0 |
| 174 | end |
| 175 | note Ring put = 48 B; 1 REPORT packet at lgbuf[4096..4144) |
| 176 | ctput64b 0 48 |
| 177 | ctput64b 4096 CTRPTHDR |
| 178 | ctput64b 4104 1001 |
| 179 | ctput64b 4112 2002 |
| 180 | ctput64b 4120 3003 |
| 181 | ctput64b 4128 4004 |
| 182 | ctput64b 4136 5005 |
| 183 | put israw 0 16 |
| 184 | r = iqservicecc 7 4 -1 16 |
| 185 | if ne r -13 |
| 186 | ret false |
| 187 | end |
| 188 | if ne get iqstate 0 2 |
| 189 | ret false |
| 190 | end |
| 191 | if ne get iqhalt 0 1 |
| 192 | ret false |
| 193 | end |
| 194 | if ne get iqccpkts 0 1 |
| 195 | ret false |
| 196 | end |
| 197 | if ne get iqccerr 0 0 |
| 198 | ret false |
| 199 | end |
| 200 | if ne get cctype 0 CCTRPT |
| 201 | ret false |
| 202 | end |
| 203 | if ne get ccrsrc 0 1001 |
| 204 | ret false |
| 205 | end |
| 206 | if ne get ccrcse 0 2002 |
| 207 | ret false |
| 208 | end |
| 209 | if ne get ccrext 0 3003 |
| 210 | ret false |
| 211 | end |
| 212 | if ne get ccrts 0 4004 |
| 213 | ret false |
| 214 | end |
| 215 | if ne get ccrver 0 5005 |
| 216 | ret false |
| 217 | end |
| 218 | ret true |
| 219 | end |
| 220 | |
| 221 | note ---- Test 4: Negative control - HALT IRQ with bad CrashCat signature still quarantines ---- |
| 222 | fn cttest4 to bool |
| 223 | ctreset |
| 224 | if ne iqinit 7 0 |
| 225 | ret false |
| 226 | end |
| 227 | ctput64c 0 CTBADHDR |
| 228 | if ne iqccbind 1 1048576 48 0 |
| 229 | ret false |
| 230 | end |
| 231 | put israw 0 16 |
| 232 | r = iqservicecc 7 4 -1 16 |
| 233 | if ne r -13 |
| 234 | ret false |
| 235 | end |
| 236 | if ne get iqstate 0 2 |
| 237 | ret false |
| 238 | end |
| 239 | if ne get iqhalt 0 1 |
| 240 | ret false |
| 241 | end |
| 242 | if ne get ismasks 0 1 |
| 243 | ret false |
| 244 | end |
| 245 | if ne get iqccpkts 0 0 |
| 246 | ret false |
| 247 | end |
| 248 | if ne get iqccerr 0 -10 |
| 249 | ret false |
| 250 | end |
| 251 | ret true |
| 252 | end |
| 253 | |
| 254 | note ---- Test 5: Normal SWGEN0 IRQ with CrashCat bound drains RPC without CrashCat decode ---- |
| 255 | fn cttest5 to bool |
| 256 | ctreset |
| 257 | if ne iqinit 7 0 |
| 258 | ret false |
| 259 | end |
| 260 | if ne iqccbind 1 1048576 48 0 |
| 261 | ret false |
| 262 | end |
| 263 | put israw 0 64 |
| 264 | put iscnt 0 2 |
| 265 | r = iqservicecc 7 4 -1 16 |
| 266 | if ne r 2 |
| 267 | ret false |
| 268 | end |
| 269 | if ne get iqstate 0 1 |
| 270 | ret false |
| 271 | end |
| 272 | if ne get iqhalt 0 0 |
| 273 | ret false |
| 274 | end |
| 275 | if ne get isacks 0 1 |
| 276 | ret false |
| 277 | end |
| 278 | if ne get iqccpkts 0 0 |
| 279 | ret false |
| 280 | end |
| 281 | if ne get iqccerr 0 0 |
| 282 | ret false |
| 283 | end |
| 284 | ret true |
| 285 | end |
| 286 | |
| 287 | note ---- Test 6: Unknown non-HALT IRQ (bit 5 = 32) quarantines without CrashCat decode ---- |
| 288 | fn cttest6 to bool |
| 289 | ctreset |
| 290 | if ne iqinit 7 0 |
| 291 | ret false |
| 292 | end |
| 293 | if ne iqccbind 1 1048576 48 0 |
| 294 | ret false |
| 295 | end |
| 296 | put israw 0 32 |
| 297 | r = iqservicecc 7 4 -1 16 |
| 298 | if ne r -13 |
| 299 | ret false |
| 300 | end |
| 301 | if ne get iqstate 0 2 |
| 302 | ret false |
| 303 | end |
| 304 | if ne get iqhalt 0 0 |
| 305 | ret false |
| 306 | end |
| 307 | if ne get ismasks 0 1 |
| 308 | ret false |
| 309 | end |
| 310 | if ne get iqccpkts 0 0 |
| 311 | ret false |
| 312 | end |
| 313 | if ne get iqccerr 0 0 |
| 314 | ret false |
| 315 | end |
| 316 | ret true |
| 317 | end |
| 318 | |
| 319 | fn main to int |
| 320 | if not cttest1 |
| 321 | ret 1 |
| 322 | end |
| 323 | if not cttest2 |
| 324 | ret 2 |
| 325 | end |
| 326 | if not cttest3 |
| 327 | ret 3 |
| 328 | end |
| 329 | if not cttest4 |
| 330 | ret 4 |
| 331 | end |
| 332 | if not cttest5 |
| 333 | ret 5 |
| 334 | end |
| 335 | if not cttest6 |
| 336 | ret 6 |
| 337 | end |
| 338 | w = write 1 CTPASS 0 len CTPASS |
| 339 | if ne w long len CTPASS |
| 340 | ret 20 |
| 341 | end |
| 342 | ret 0 |
| 343 | end |