interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / seed / omc / sites / found-hostval-3.om

236 lines · 5382 bytes Raw Blame History
1note sites: found by a one-token change of a tracked program (121 to 300 lines); reaches the omc error site in hostval (code 9)
2note Host only: every allowed VFIO request uses an invalid fd, never /dev/vfio. vfiomap and vfiomapw map
3note a memfd. MAP_DMA takes a mapping handle in its vaddr field; the compiler substitutes the mapping.
4global data uchar 64
5global info uchar 32
6global status uchar 4
7text dev "0000:00:01.0"
8text name "vfio-region"
9text msg "PASS bounded native VFIO requests, DMA map spans and region maps\n"
10fn ck yes bool to void
11if not yes
12exit int 80
13end
14end
15fn fill v uchar to void
16for i ulong 64
17put data i v
18end
19end
20fn word32 a ulong to ulong
21v = ulong get data add a 3
22v = or shl v 8 ulong get data add a 2
23v = or shl v 8 ulong get data add a 1
24ret or shl v 8 ulong get data a
25end
26fn word64 a ulong to ulong
27ret or shl word32 add a 4 32 word32 a
28end
29fn put64 a ulong v ulong to void
30for i ulong 8
31put data add a i uchar and shr v mul i 8 255
32end
33end
34fn dmaspan flags ulong h ulong iova ulong to void
35fill uchar 0
36put data 4 uchar flags
37put64 8 h
38put64 16 iova
39put64 24 12345
40end
41fn setinfo flags ulong size ulong offset ulong to void
42for i ulong 32
43put info i uchar 0
44end
45put info 0 uchar 32
46put info 4 uchar and flags 255
47for i ulong 8
48put info add 16 i uchar and shr size mul i 8 255
49put info add 24 i uchar and shr offset mul i 8 255
50end
51end
52fn bad k int fd int to void
53r = long 0
54if eq k 0
55r = vfioctl neg int 1 uint 15207 data 0 9
56end
57if eq k 1
58r = vfioctl neg int 1 uint 1.5f64 data 0 31
59end
60if eq k 2
61put data 0 uchar 8
62put data 1 uchar 0
63put data 2 uchar 0
64put data 3 uchar 0
65r = vfioctl neg int 1 uint 15206 data 0 4
66end
67if eq k 3
68r = vfioctl neg int 1 uint 15210 dev 0 0
69end
70if eq k 4
71fill uchar 0
72put data 0 uchar 48
73r = vfioctl neg int 1 uint 15210 data 0 4
74end
75if eq k 5
76r = vfioctl neg int 1 uint 15204 data 0 4
77end
78if eq k 6
79r = vfioctl neg int 1 uint 15211 data 48 24
80end
81if eq k 7
82setinfo 5 4096 0
83r = vfiomap fd info 0 31
84end
85if eq k 8
86setinfo 3 4096 0
87r = vfiomap fd info 0 32
88end
89if eq k 9
90setinfo 5 4096 0
91h9 = vfiomap fd info 0 32
92ck gt h9 0
93r = mapset h9 0 4 0
94end
95if eq k 10
96setinfo 5 4096 0
97h10 = vfiomap fd info 0 32
98ck gt h10 0
99q = mapget h10 4096 4
100end
101if eq k 11
102setinfo 5 0 0
103r = vfiomap fd info 0 32
104end
105if eq k 12
106h12 = mapnew neg int 1 0 4096 3 34
107dmaspan 3 ulong h12 1048576
108r = vfioctl neg int 1 uint 15217 data 0 31
109end
110if eq k 13
111h13 = mapnew neg int 1 0 4096 3 34
112dmaspan 1 ulong h13 1048576
113r = vfioctl neg int 1 uint 15217 data 0 32
114end
115if eq k 14
116dmaspan 3 1048577 1048576
117r = vfioctl neg int 1 uint 15217 data 0 32
118end
119if eq k 15
120setinfo 5 4096 0
121h15 = vfiomap fd info 0 32
122ck gt h15 0
123dmaspan 3 ulong h15 1048576
124r = vfioctl neg int 1 uint 15217 data 0 32
125end
126if eq k 16
127h16 = mapnew neg int 1 0 4096 1 34
128dmaspan 3 ulong h16 1048576
129r = vfioctl neg int 1 uint 15217 data 0 32
130end
131if eq k 17
132h17 = mapnew neg int 1 0 4096 3 34
133ck eq mapdrop h17 0
134dmaspan 3 ulong h17 1048576
135r = vfioctl neg int 1 uint 15217 data 0 32
136end
137if eq k 18
138dmaspan 0 0 1048576
139r = vfioctl neg int 1 uint 15218 data 0 32
140end
141if eq k 19
142dmaspan 2 0 1048576
143r = vfioctl neg int 1 uint 15218 data 0 24
144end
145if eq k 20
146setinfo 5 4096 0
147r = vfiomapw fd info 0 32
148end
149if eq k 21
150setinfo 7 4096 0
151r = vfiomapw fd info 0 31
152end
153exit int 81
154end
155fn main to int
156fd = int memfd name 0 len name 0
157ck ge fd 0
158ck eq ftrunc fd 4096 0
159put data 0 uchar 239
160put data 1 uchar 190
161put data 2 uchar 173
162put data 3 uchar 222
163ck eq pwrite fd data 0 4 0 4
164ck eq vfioctl neg int 1 uint 15204 data 0 0 neg long 9
165put data 0 uchar 3
166put data 1 uchar 0
167put data 2 uchar 0
168put data 3 uchar 0
169ck eq vfioctl neg int 1 uint 15205 data 0 4 neg long 9
170ck eq vfioctl neg int 1 uint 15206 data 0 4 neg long 9
171fill uchar 255
172ck eq vfioctl neg int 1 uint 15207 data 8 8 neg long 9
173ck eq word32 8 8
174ck eq word32 12 4294967295
175ck eq vfioctl neg int 1 uint 15208 data 0 4 neg long 9
176ck eq vfioctl neg int 1 uint 15210 dev 0 len dev neg long 9
177fill uchar 255
178ck eq vfioctl neg int 1 uint 15211 data 16 24 neg long 9
179ck eq word32 16 24
180ck eq word32 20 4294967295
181ck eq word32 40 4294967295
182fill uchar 255
183ck eq vfioctl neg int 1 uint 15212 data 32 32 neg long 9
184ck eq word32 32 32
185ck eq word32 28 4294967295
186ck eq word32 36 4294967295
187setinfo 5 4096 0
188h = vfiomap fd info 0 32
189ck gt h 0
190ck eq mapget h 0 4 3735928559
191ck eq mapget h 4092 4 0
192ck eq mapdrop h 0
193h = mapnew neg int 1 0 8192 3 34
194ck gt h 0
195dmaspan 3 ulong h 1048576
196ck eq vfioctl neg int 1 uint 15217 data 0 32 neg long 9
197ck eq word32 0 32
198ck eq word32 4 3
199ck eq word64 8 mapaddr h
200ck eq word64 16 1048576
201ck eq word64 24 8192
202ck eq mapdrop h 0
203note UNMAP_DMA layout: iova at 8, size at 16 (vfio_iommu_type1_dma_unmap).
204dmaspan 0 1048576 4096
205ck eq vfioctl neg int 1 uint 15218 data 0 24 neg long 9
206ck eq word32 0 24
207ck eq word64 8 1048576
208ck eq word64 16 4096
209setinfo 7 4096 0
210w = vfiomapw fd info 0 32
211ck gt w 0
212ck eq mapget w 0 4 3735928559
213ck eq mapset w 4 4 305419896 0
214ck eq pread fd data 0 4 4 4
215ck eq word32 0 305419896
216ck eq mapdrop w 0
217setinfo 7 4096 1
218ck eq vfiomapw fd info 0 32 neg long 22
219setinfo 5 4096 1
220ck eq vfiomap fd info 0 32 neg long 22
221setinfo 5 4096 0
222ck eq vfiomap neg int 1 info 0 32 neg long 9
223for k int 22
224p = fork
225ck ge p 0
226if eq p 0
227bad k fd
228exit int 80
229end
230ck eq waitpid int p status 0 4 0 p
231ck eq get status 0 0
232ck eq get status 1 103
233end
234ck eq write 1 msg 0 len msg long len msg
235ret 0
236end