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 / uvm / service.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Requires DriverOmega gsp/irqqueue.om iqcommand model adapter, not a physical RPC. |
| 3 | note Event rows: VA,access,decision,PA,PTE,mapping-mask; up to16 per caller batch. |
| 4 | note Queue records use DriverOmega five-u64 LE ABI, op2 invalidate before op1 replay. |
| 5 | note UVREPLAY means records emitted, NEVER completed invalidation/replay. Cancel/fatal are local decisions. |
| 6 | global sev ulong 96 |
| 7 | global sen ulong 1 |
| 8 | global sqbad ulong 1 |
| 9 | fn sevent act ulong pa ulong pte ulong mask ulong to ulong |
| 10 | if ge get sen 0 16 |
| 11 | ret UVENOM |
| 12 | end |
| 13 | o = mul get sen 0 6 |
| 14 | put sev o get uvfva 0 |
| 15 | put sev add o 1 get uvfacc 0 |
| 16 | put sev add o 2 act |
| 17 | put sev add o 3 pa |
| 18 | put sev add o 4 pte |
| 19 | put sev add o 5 mask |
| 20 | put sen 0 add get sen 0 1 |
| 21 | ret act |
| 22 | end |
| 23 | fn sdecision to ulong |
| 24 | if eq get uvfval 0 0 |
| 25 | ret UVIGN |
| 26 | end |
| 27 | if or eq get slive 0 0 ne get sqbad 0 0 |
| 28 | ret UVFATAL |
| 29 | end |
| 30 | if or eq get uvfen 0 0 or eq get uvfrep 0 0 ge get uvftyp 0 3 |
| 31 | ret UVFATAL |
| 32 | end |
| 33 | if gt get uvfacc 0 3 |
| 34 | ret UVFATAL |
| 35 | end |
| 36 | i = sfind get uvfva 0 |
| 37 | if eq i 64 |
| 38 | ret UVCANCEL |
| 39 | end |
| 40 | if eq sget i 7 1 |
| 41 | ret UVCANCEL |
| 42 | end |
| 43 | if eq sget i 2 0 |
| 44 | ret UVCANCEL |
| 45 | end |
| 46 | if and eq sget i 6 1 or eq get uvfacc 0 1 eq get uvfacc 0 2 |
| 47 | ret UVFATAL |
| 48 | end |
| 49 | ret UVREPLAY |
| 50 | end |
| 51 | fn sqready to bool |
| 52 | if or ne get iqcmode 0 1 ne get iqcstate 0 1 |
| 53 | ret false |
| 54 | end |
| 55 | if gt sub get iqcprod 0 get iqccons 0 6 |
| 56 | ret false |
| 57 | end |
| 58 | if gt get iqcseq 0 18446744073709551613 |
| 59 | ret false |
| 60 | end |
| 61 | if gt get iqcprod 0 18446744073709551613 |
| 62 | ret false |
| 63 | end |
| 64 | ret true |
| 65 | end |
| 66 | fn sqemit va ulong pa ulong mask ulong to ulong |
| 67 | r = iqcommand 2 add get iqcseq 0 1 va pa mask |
| 68 | if ne r 0 |
| 69 | put sqbad 0 1 |
| 70 | ret UVFATAL |
| 71 | end |
| 72 | r = iqcommand 1 add get iqcseq 0 1 va pa mask |
| 73 | if ne r 0 |
| 74 | put sqbad 0 1 |
| 75 | ret UVFATAL |
| 76 | end |
| 77 | ret UVREPLAY |
| 78 | end |
| 79 | fn squiescent to bool |
| 80 | ret and eq get iqcprod 0 get iqccons 0 eq get fbget 0 get fbput 0 |
| 81 | end |
| 82 | fn spermission i ulong acc ulong to ulong |
| 83 | if eq sget i 6 1 |
| 84 | ret 4 |
| 85 | end |
| 86 | if or eq acc 1 eq acc 2 |
| 87 | ret 0 |
| 88 | end |
| 89 | if eq sget i 5 1 |
| 90 | ret 4 |
| 91 | end |
| 92 | ret 0 |
| 93 | end |
| 94 | fn ssetpte va ulong pa ulong pcf ulong to ulong |
| 95 | r = uvread va UV4K |
| 96 | if eq r UVMAPPED |
| 97 | if ne get uvdpa 0 pa |
| 98 | ret UVEPERM |
| 99 | end |
| 100 | if eq get uvdpcf 0 pcf |
| 101 | ret UVOK |
| 102 | end |
| 103 | note Change permissions on the same physical page, not a copy or a new physical residency. |
| 104 | r = uvunmap va UV4K UV4K |
| 105 | if ne r UVOK |
| 106 | ret r |
| 107 | end |
| 108 | end |
| 109 | ret uvmap va pa UV4K UV4K UVAPSYS pcf |
| 110 | end |
| 111 | fn smapfault i ulong j ulong to ulong |
| 112 | va = get uvfva 0 |
| 113 | pa = add sget i 2 sub va sget i 0 |
| 114 | mask = smask i get uvfacc 0 |
| 115 | pcf = spermission i get uvfacc 0 |
| 116 | r = ssetpte va pa pcf |
| 117 | if ne r UVOK |
| 118 | ret sevent UVFATAL 0 0 0 |
| 119 | end |
| 120 | put spage mul j 3 va |
| 121 | put spage add mul j 3 1 mask |
| 122 | r = sqemit va pa mask |
| 123 | ret sevent r pa uvld64 get uvleaf 0 mask |
| 124 | end |
| 125 | fn sservice to ulong |
| 126 | act = sdecision |
| 127 | if ne act UVREPLAY |
| 128 | ret sevent act 0 0 0 |
| 129 | end |
| 130 | if ge get sen 0 16 |
| 131 | ret UVENOM |
| 132 | end |
| 133 | note Serialized caller owns queue, no concurrent producer. Reserve TWO slots before PTE change. |
| 134 | if not sqready |
| 135 | ret UVENOM |
| 136 | end |
| 137 | i = sfind get uvfva 0 |
| 138 | j = spfind get uvfva 0 |
| 139 | if eq j 128 |
| 140 | j = spfree |
| 141 | end |
| 142 | if eq j 128 |
| 143 | ret UVENOM |
| 144 | end |
| 145 | ret smapfault i j |
| 146 | end |