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 / gpu / driver / chan / params.om

332 lines · 10386 bytes Raw Blame History
1note chan/params.om: the RM-alloc and RM-control parameter records the W5 "hello" chain forwards
2note to GSP-RM (GSP_RM_ALLOC 103 / GSP_RM_CONTROL 76 carry them verbatim: rpcRmApiAlloc_GSP and
3note rpcRmApiControl_GSP memcpy the caller's params) plus the two page-directory RPC bodies.
4note Layout source of record: NVIDIA open-gpu-kernel-modules 580.173.02 (MIT), struct offsets and
5note sizes printed by tests/params_ref.c from offsetof/sizeof on the NVIDIA headers and compared
6note byte for byte by tests/params_diff.sh. Library unit, no main. Prefix pa.
7note Every encoder zeroes pabuf, writes one record little-endian, sets palen and returns its size,
8note or a negative error and leaves pabuf untouched: PAEFIT a value does not fit its field,
9note PAERANGE a value outside the field's legal set, PAELEN a reply of the wrong length.
10const PAOK long 0
11const PAEFIT long -1
12const PAERANGE long -2
13const PAELEN long -3
14note 0xFFFFFFFF
15const PAU32 ulong 4294967295
16note channel ids are 12 bits (0xFFF)
17const PACHMAX ulong 4095
18note RPC function numbers (nvidia/inc/kernel/vgpu/rpc_global_enums.h:64,86,89,113)
19const PARSETPD ulong 54
20const PARCTRL ulong 76
21const PARUNSPD ulong 79
22const PARALLOC ulong 103
23note classes: NV01_ROOT 0x0, NV01_DEVICE_0 0x80, NV20_SUBDEVICE_0 0x2080, FERMI_VASPACE_A 0x90f1,
24note KEPLER_CHANNEL_GROUP_A 0xa06c, FERMI_CONTEXT_SHARE_A 0x9067, BLACKWELL_CHANNEL_GPFIFO_A 0xc96f,
25note BLACKWELL_CHANNEL_GPFIFO_B 0xca6f, BLACKWELL_COMPUTE_B 0xcec0, VOLTA_USERMODE_A 0xc361,
26note HOPPER_USERMODE_A 0xc661
27const PACROOT ulong 0
28const PACDEV ulong 128
29const PACSUB ulong 8320
30const PACVAS ulong 37105
31const PACTSG ulong 41068
32const PACCTX ulong 36967
33const PACGPF ulong 51567
34const PACGPFB ulong 51823
35const PACCMP ulong 52928
36const PACUMVA ulong 50017
37const PACUMHA ulong 50785
38note controls: NVA06C_CTRL_CMD_GPFIFO_SCHEDULE 0xa06c0101 (ctrla06c.h:97),
39note NV2080_CTRL_CMD_INTERNAL_STATIC_KGR_GET_INFO 0x20800a2a (ctrl2080internal.h:422),
40note NVC36F_CTRL_CMD_GPFIFO_GET_WORK_SUBMIT_TOKEN 0xc36f0108 (ctrlc36f.h)
41const PACMSCH ulong 2691432705
42const PACMGRI ulong 545262122
43const PACMWST ulong 3278831880
44note NV2080_ENGINE_TYPE_GRAPHICS 0x1, NV_CTXSHARE_ALLOCATION_FLAGS_SUBCONTEXT_ASYNC 0x1
45const PAENGGR ulong 1
46const PACTXAS ulong 1
47note record sizes (sizeof on the 580.173.02 headers)
48const PASZROOT ulong 120
49const PASZDEV ulong 56
50const PASZSUB ulong 4
51const PASZVAS ulong 56
52const PASZTSG ulong 20
53const PASZCTX ulong 12
54const PASZCHAN ulong 368
55const PASZSCH ulong 3
56const PASZWST ulong 4
57const PASZSPD ulong 48
58const PASZUPD ulong 16
59note GR info reply: 8 engines x 0x3a entries x 8 bytes = 3712; one engine is 58 x 8 = 464 bytes;
60note SM_VERSION is index 0xC, its data word at 12 x 8 + 4 = 100
61const PAGRSZ ulong 3712
62const PAGRENG ulong 464
63const PAGRMAX ulong 8
64const PASMOFF ulong 100
65note NVOS04 channel flags: clear USERD_INDEX_VALUE 10:8, USERD_INDEX_FIXED 11, USERD_INDEX_PAGE_VALUE
66note 20:12 and USERD_INDEX_PAGE_FIXED 21 (mask 0xFFC000FF), then set PAGE_FIXED (1 << 21)
67const PAFLMSK ulong 4290773247
68const PAPGFIX ulong 2097152
69text PANAME "aien-ogd"
70global pabuf uchar 4096
71global palen ulong 1
72global pain ulong 48
73global pareply uchar 4096
74fn paclr n ulong to void
75for i ulong 4096
76put pabuf i 0
77end
78put palen 0 n
79end
80fn paput32 o ulong v ulong to void
81for i ulong 4
82put pabuf add o i uchar and shr v mul i 8 255
83end
84end
85fn paput64 o ulong v ulong to void
86for i ulong 8
87put pabuf add o i uchar and shr v mul i 8 255
88end
89end
90fn paget32 o ulong to ulong
91v = ulong 0
92for i ulong 4
93v = or shl v 8 ulong get pareply add o sub 3 i
94end
95ret v
96end
97fn paf4 a ulong b ulong c ulong d ulong to bool
98ret and and le a PAU32 le b PAU32 and le c PAU32 le d PAU32
99end
100note NV0000_ALLOC_PARAMETERS: hClient 0, processID 4, processName[100] 8 ("aien-ogd", NUL padded),
101note pOsPidInfo 112 (0)
102fn paroot hcli ulong pid ulong to long
103if not paf4 hcli pid 0 0
104ret PAEFIT
105end
106paclr PASZROOT
107paput32 0 hcli
108paput32 4 pid
109for i ulong len PANAME
110put pabuf add 8 i get PANAME i
111end
112ret long PASZROOT
113end
114note NV0080_ALLOC_PARAMETERS: deviceId 0, hClientShare 4, hTargetClient 8 (0), hTargetDevice 12 (0),
115note flags 16, vaSpaceSize 24, vaStartInternal 32 (0), vaLimitInternal 40 (0), vaMode 48
116fn padevice devid ulong hshare ulong flags ulong vamode ulong vasize ulong to long
117if not paf4 devid hshare flags vamode
118ret PAEFIT
119end
120paclr PASZDEV
121paput32 0 devid
122paput32 4 hshare
123paput32 16 flags
124paput64 24 vasize
125paput32 48 vamode
126ret long PASZDEV
127end
128note NV2080_ALLOC_PARAMETERS: subDeviceId 0
129fn pasubdev subid ulong to long
130if gt subid PAU32
131ret PAEFIT
132end
133paclr PASZSUB
134paput32 0 subid
135ret long PASZSUB
136end
137note NV_VASPACE_ALLOCATION_PARAMETERS: index 0, flags 4, vaSize 8, vaStartInternal 16 (0),
138note vaLimitInternal 24 (0), bigPageSize 32, vaBase 40, pasid 48 (0)
139fn pavaspace index ulong flags ulong vasize ulong vabase ulong bigpg ulong to long
140if not paf4 index flags bigpg 0
141ret PAEFIT
142end
143paclr PASZVAS
144paput32 0 index
145paput32 4 flags
146paput64 8 vasize
147paput32 32 bigpg
148paput64 40 vabase
149ret long PASZVAS
150end
151note NV_CHANNEL_GROUP_ALLOCATION_PARAMETERS: hObjectError 0, hObjectEccError 4, hVASpace 8,
152note engineType 12, bIsCallingContextVgpuPlugin 16 (NV_FALSE)
153fn patsg herr ulong hecc ulong hvas ulong eng ulong to long
154if not paf4 herr hecc hvas eng
155ret PAEFIT
156end
157paclr PASZTSG
158paput32 0 herr
159paput32 4 hecc
160paput32 8 hvas
161paput32 12 eng
162ret long PASZTSG
163end
164note NV_CTXSHARE_ALLOCATION_PARAMETERS: hVASpace 0, flags 4, subctxId 8
165fn pactxsh hvas ulong flags ulong subctx ulong to long
166if not paf4 hvas flags subctx 0
167ret PAEFIT
168end
169paclr PASZCTX
170paput32 0 hvas
171paput32 4 flags
172paput32 8 subctx
173ret long PASZCTX
174end
175note pain indices that hold NvU64 fields in the channel layout: gpFifoOffset 1, userdOffset[0] 7,
176note base/size of the six NV_MEMORY_DESC_PARAMS (16,17 20,21 24,25 28,29 32,33 38,39)
177fn pawide k ulong to bool
178if or eq k 1 eq k 7
179ret true
180end
181if and ge k 16 le k 35
182ret lt rem sub k 16 4 2
183end
184ret or eq k 38 eq k 39
185end
186note NV_MEMORY_DESC_PARAMS at o from pain[k..k+3]: base 0, size 8, addressSpace 16, cacheAttrib 20
187fn pamd o ulong k ulong to void
188paput64 o get pain k
189paput64 add o 8 get pain add k 1
190paput32 add o 16 get pain add k 2
191paput32 add o 20 get pain add k 3
192end
193note the GSP-client flag rewrite of kernel_channel.c:2814-2821: USERD_INDEX_FIXED false,
194note USERD_INDEX_PAGE_FIXED true, USERD_INDEX_VALUE = chid % 8, USERD_INDEX_PAGE_VALUE = chid / 8
195fn pachfl fl ulong chid ulong to ulong
196v = or and fl PAFLMSK PAPGFIX
197ret or v or shl rem chid 8 8 shl and div chid 8 511 12
198end
199note NV_CHANNEL_ALLOC_PARAMS (368 bytes) from pain:
200note 0 hObjectError, 1 gpFifoOffset, 2 gpFifoEntries, 3 client flags, 4 hContextShare, 5 hVASpace,
201note 6 hUserdMemory[0], 7 userdOffset[0], 8 engineType, 9 subDeviceId, 10 hObjectEccError,
202note 11 hPhysChannelGroup, 12 error notifier type, 13 ECC error notifier type, 14 privilege level,
203note 15 chid, 16-19 instanceMem, 20-23 userdMem, 24-27 ramfcMem, 28-31 mthdbufMem,
204note 32-35 errorNotifierMem, 36 ProcessID, 37 SubProcessID, 38-41 eccErrorNotifierMem.
205note hObjectBuffer, cid, hUserdMemory[1..7], userdOffset[1..7], the IVs, hmacNonce and tpcConfigID
206note are 0. internalFlags = PRIVILEGE 1:0 | ERROR_NOTIFIER_TYPE 3:2 | ECC_ERROR_NOTIFIER_TYPE 5:4.
207fn pachan to long
208for k ulong 42
209if and not pawide k gt get pain k PAU32
210ret PAEFIT
211end
212end
213if or or gt get pain 12 3 gt get pain 13 3 gt get pain 14 3
214ret PAERANGE
215end
216chid = get pain 15
217if gt chid PACHMAX
218ret PAERANGE
219end
220paclr PASZCHAN
221paput32 0 get pain 0
222paput64 8 get pain 1
223paput32 16 get pain 2
224paput32 20 pachfl get pain 3 chid
225paput32 24 get pain 4
226paput32 28 get pain 5
227paput32 32 get pain 6
228paput64 64 get pain 7
229paput32 128 get pain 8
230paput32 136 get pain 9
231paput32 140 get pain 10
232pamd 144 16
233pamd 168 20
234pamd 192 24
235pamd 216 28
236paput32 240 get pain 11
237paput32 244 or or get pain 14 shl get pain 12 2 shl get pain 13 4
238pamd 248 32
239pamd 272 38
240paput32 296 get pain 36
241paput32 300 get pain 37
242ret long PASZCHAN
243end
244note NVA06C_CTRL_GPFIFO_SCHEDULE_PARAMS: bEnable 0, bSkipSubmit 1, bSkipEnable 2 (NvBool each)
245fn pasched en ulong skipsub ulong skipen ulong to long
246if or or gt en 1 gt skipsub 1 gt skipen 1
247ret PAERANGE
248end
249paclr PASZSCH
250put pabuf 0 uchar en
251put pabuf 1 uchar skipsub
252put pabuf 2 uchar skipen
253ret long PASZSCH
254end
255note NV2080_CTRL_INTERNAL_STATIC_GR_GET_INFO_PARAMS request: all zero, GSP-RM fills the reply
256fn pagrinfo to long
257paclr PAGRSZ
258ret long PAGRSZ
259end
260note SM_VERSION of engine eng from a GR_GET_INFO reply of n bytes copied into pareply:
261note engineInfo[eng].infoList[0xC].data
262fn pasmver eng ulong n ulong to long
263if ne n PAGRSZ
264ret PAELEN
265end
266if ge eng PAGRMAX
267ret PAERANGE
268end
269ret long paget32 add mul eng PAGRENG PASMOFF
270end
271note rpc_set_page_directory_v1E_05 (48 bytes) from pain: 0 hClient 0, 1 hDevice 4, 2 pasid 8,
272note params at 16: 3 physAddress 16, 4 numEntries 24, flags 28 = 5 APERTURE 1:0 (0..2) |
273note 6 PRESERVE_PDES 2:2 (0..1), 7 hVASpace 32, 8 chId 36, 9 subDeviceId 40, 10 params.pasid 44
274fn pasetpd to long
275for k ulong 11
276if and ne k 3 gt get pain k PAU32
277ret PAEFIT
278end
279end
280if or gt get pain 5 2 gt get pain 6 1
281ret PAERANGE
282end
283paclr PASZSPD
284paput32 0 get pain 0
285paput32 4 get pain 1
286paput32 8 get pain 2
287paput64 16 get pain 3
288paput32 24 get pain 4
289paput32 28 or get pain 5 shl get pain 6 2
290paput32 32 get pain 7
291paput32 36 get pain 8
292paput32 40 get pain 9
293paput32 44 get pain 10
294ret long PASZSPD
295end
296note rpc_unset_page_directory_v1E_05: hClient 0, hDevice 4, params at 8: hVASpace 8, subDeviceId 12
297fn paunsetpd hcli ulong hdev ulong hvas ulong subdev ulong to long
298if not paf4 hcli hdev hvas subdev
299ret PAEFIT
300end
301paclr PASZUPD
302paput32 0 hcli
303paput32 4 hdev
304paput32 8 hvas
305paput32 12 subdev
306ret long PASZUPD
307end
308note GB20B uses BLACKWELL_CHANNEL_GPFIFO_B (0xca6f) alongside GB10B BLACKWELL_CHANNEL_GPFIFO_A (0xc96f).
309fn pacgpcls gb20b bool to ulong
310if gb20b
311ret PACGPFB
312end
313ret PACGPF
314end
315note Empty (0-byte) alloc params for BLACKWELL_COMPUTE_B (0xcec0) and VOLTA/HOPPER_USERMODE_A.
316fn paempty to long
317paclr 0
318ret PAOK
319end
320note NVC36F_CTRL_CMD_GPFIFO_GET_WORK_SUBMIT_TOKEN request: 4 bytes initialized to 0xFFFFFFFF.
321fn pawstreq to long
322paclr PASZWST
323paput32 0 PAU32
324ret long PASZWST
325end
326note Decode workSubmitToken (u32 at +0) from a 4-byte GET_WORK_SUBMIT_TOKEN reply in pareply.
327fn pawstdec n ulong to long
328if ne n PASZWST
329ret PAELEN
330end
331ret long paget32 0
332end