managarm/hel
Loading...
Searching...
No Matches
hel.h
Go to the documentation of this file.
1
3
4#ifndef HEL_H
5#define HEL_H
6
7#include <stddef.h>
8#include <string.h>
9#include <stdint.h>
10
11#include "hel-types.h"
12
13#ifdef __cplusplus
14#define HEL_C_LINKAGE extern "C"
15#else
16#define HEL_C_LINKAGE
17#endif
18
19enum {
20 // largest system call number plus 1
21 kHelNumCalls = 114,
22
23 kHelCallLog = 1,
24 kHelCallPanic = 10,
25
26 kHelCallNop = 2,
27 kHelCallSubmitAsyncNop = 3,
28
29 kHelCallCreateUniverse = 62,
30 kHelCallTransferDescriptor = 66,
31 kHelCallDescriptorInfo = 32,
32 kHelCallGetCredentials = 84,
33 kHelCallCloseDescriptor = 21,
34 kHelCallObtainHandle = 4,
35
36 kHelCallCreateQueue = 89,
37 kHelCallDriveQueue = 105,
38 kHelCallAlertQueue = 106,
39
40 kHelCallAllocateMemory = 51,
41 kHelCallResizeMemory = 83,
42 kHelCallCreateManagedMemory = 64,
43 kHelCallCreateKcovBuffer = 72,
44 kHelCallEnableCoverage = 90,
45 kHelCallDisableCoverage = 92,
46 kHelCallCopyOnWrite = 39,
47 kHelCallAccessPhysical = 30,
48 kHelCallCreateSliceView = 88,
49 kHelCallForkMemory = 40,
50 kHelCallCreateSpace = 27,
51 kHelCallCreateDmaSpace = 108,
52 kHelCallConfigureIrq = 109,
53 kHelCallCreateIndirectMemory = 45,
54 kHelCallAlterMemoryIndirection = 52,
55 kHelCallMapMemory = 44,
56 kHelCallSubmitProtectMemory = 99,
57 kHelCallSubmitSynchronizeSpace = 53,
58 kHelCallUnmapMemory = 36,
59 kHelCallPointerPhysical = 43,
60 kHelCallSubmitReadMemory = 77,
61 kHelCallSubmitWriteMemory = 78,
62 kHelCallMemoryInfo = 26,
63 kHelCallSubmitManageMemory = 46,
64 kHelCallUpdateMemory = 47,
65 kHelCallSubmitLockMemoryView = 48,
66 kHelCallLoadahead = 49,
67 kHelCallCreateVirtualizedSpace = 50,
68 kHelCallCreateSwapSpace = 110,
69 kHelCallAllocateSwappableMemory = 111,
70
71 kHelCallAccessIommu = 13,
72
73 kHelCallCreateThread = 67,
74 kHelCallQueryThreadStats = 95,
75 kHelCallSetPriority = 85,
76 kHelCallYield = 34,
77 kHelCallSubmitObserve = 74,
78 kHelCallKillThread = 87,
79 kHelCallInterruptThread = 86,
80 kHelCallResume = 61,
81 kHelCallLoadRegisters = 75,
82 kHelCallStoreRegisters = 76,
83 kHelCallQueryRegisterInfo = 102,
84 kHelCallWriteFsBase = 41,
85 kHelCallGetClock = 42,
86 kHelCallSubmitAwaitClock = 80,
87 kHelCallCreateVirtualizedCpu = 37,
88 kHelCallRunVirtualizedCpu = 38,
89 kHelCallAssertVirtualizedIrq = 107,
90 kHelCallKickVirtualizedCpu = 112,
91 kHelCallGetRandomBytes = 101,
92 kHelCallWriteGsBase = 54,
93 kHelCallReadFsBase = 55,
94 kHelCallReadGsBase = 56,
95 kHelCallGetCurrentCpu = 57,
96
97 kHelCallCreateStream = 68,
98 kHelCallSubmitAsync = 79,
99 kHelCallShutdownLane = 91,
100
101 kHelCallFutexWait = 73,
102 kHelCallFutexWake = 71,
103
104 kHelCallCreateOneshotEvent = 96,
105 kHelCallCreateBitsetEvent = 97,
106 kHelCallCreateSequencedEvent = 15,
107 kHelCallRaiseEvent = 98,
108 kHelCallAccessIrq = 14,
109 kHelCallHandleIrq = 5,
110 kHelCallAcknowledgeIrq = 81,
111 kHelCallSubmitAwaitEvent = 82,
112 kHelCallAutomateIrq = 94,
113 kHelCallQueryMsiInfo = 6,
114
115 kHelCallAccessIo = 11,
116 kHelCallEnableIo = 12,
117
118 kHelCallBindKernlet = 93,
119
120 kHelCallGetAffinity = 103,
121 kHelCallSetAffinity = 100,
122
123 kHelCallCreateToken = 104,
124
125 kHelCallExtendHierarchy = 7,
126 kHelCallQueryHierarchy = 8,
127
128 kHelCallSuper = 0x80000000
129};
130
131enum {
132 kHelErrNone = 0,
133 kHelErrBufferTooSmall = 1,
134 kHelErrBadDescriptor = 2,
135 kHelErrTimeout = 3,
136 kHelErrNoDescriptor = 4,
137 kHelErrIllegalSyscall = 5,
138 kHelErrIllegalObject = 6,
139 kHelErrIllegalArgs = 7,
140 kHelErrLaneShutdown = 8,
141 kHelErrEndOfLane = 9,
142 kHelErrFault = 10,
143 kHelErrThreadTerminated = 11,
144 kHelErrCancelled = 12,
145 kHelErrTransmissionMismatch = 13,
146 kHelErrQueueTooSmall = 14,
147 kHelErrIllegalState = 15,
148 kHelErrNoHardwareSupport = 16,
149 kHelErrNoMemory = 17,
150 kHelErrUnsupportedOperation = 18,
151 kHelErrOutOfBounds = 19,
152 kHelErrDismissed = 20,
153 kHelErrRemoteFault = 21,
154 kHelErrAlreadyExists = 22,
155 kHelErrBadPermissions = 23,
156 kHelErrOther = 24,
157 kHelErrFutexRace = 25,
158 kHelErrBadRights = 26,
159};
160
161typedef uint32_t HelRights;
162
163// No right but easier to recognize in code than a zero literal.
164// - General: descriptor properties can be queried without any rights.
165// - Memory view: memory size can be queried without any rights.
166// - Thread: statistics can be queried without any rights.
167static const HelRights kHelRightNull = 0;
168// Right to map into an object.
169// - Universe: required to transfer into the universe.
170// - Universe: required to close descriptors in the universe.
171// - Universe: required to create a thread in the universe.
172// - Address space: required to map into the space.
173// - Address space: required to change memory protection.
174// - Virtualized space: required to map into the space.
175// - DMA space: required to map into the space.
176static const HelRights kHelRightGrant = UINT32_C(1) << 0;
177// Right to map from an object.
178// - Universe: required to transfer out of the universe.
179// - Universe: required to create a thread in the universe.
180static const HelRights kHelRightTake = UINT32_C(1) << 1;
181// Right to read data.
182// - IPC queue: required to map readable.
183// - Memory view: required to read.
184// - Memory view: required to map readable.
185// - Memory view: required to create copy-on-write view.
186// - Memory view: required to map into indirect memory.
187// - Memory slice: required to map readable.
188// - Memory slice: required to map into indirect memory.
189// - Address space: required to read from it.
190// - Address space: required to create thread.
191// - Virtualized space: required to read from it.
192// - I/O objects: required to enable userspace I/O.
193// - Thread: required to read registers.
194// - Thread: required to read memory in its address space.
195// - Thread: required to get the affinity.
196// - Virtualized CPUs: required to read registers.
197static const HelRights kHelRightRead = UINT32_C(1) << 2;
198// Right to write data.
199// - IPC queue: required to map writeable.
200// - Memory view: required to write.
201// - Memory view: required to map writeable.
202// - Memory view: required to map into indirect memory.
203// - Memory slice: required to map writeable.
204// - Memory slice: required to map into indirect memory.
205// - Address space: required to write to it.
206// - Address space: required to create thread.
207// - Virtualized space: required to write to it.
208// - I/O objects: required to enable userspace I/O.
209// - Thread: required to write registers.
210// - Thread: required to write memory in its address space.
211// - Thread: required to set the affinity.
212// - Virtualized CPUs: required to write registers.
213static const HelRights kHelRightWrite = UINT32_C(1) << 3;
214// Right to execute code.
215// - Memory view: required to map executable.
216// - Memory slice: required to map executable.
217static const HelRights kHelRightExecute = UINT32_C(1) << 4;
218// Right to execute operations.
219// - IPC queue: required to submit.
220// - Lane: required to do exchange messages.
221// - Virtualized CPUs: required to run.
222static const HelRights kHelRightInvoke = UINT32_C(1) << 5;
223// Right to build new objects on top of existing ones.
224// - IPC queue: required to map.
225// - Universe: required to create thread.
226// - Address space: required to create thread.
227// - Memory view: required to map.
228// - Memory view: required to create copy-on-write view.
229// - Memory view: required to map into indirect memory.
230// - Memory view: required to create slice.
231// - Memory view: required to bind to kernlet.
232// - IRQ pin: required to install an IRQ handler.
233// - Memory slice: required to map.
234// - Memory slice: required to map into indirect memory.
235// - Swap space: required to allocate memory backed by it.
236// - Virtualized space: required to create virtualized CPU.
237// - I/O objects: required to enable userspace I/O.
238// - Kernlets: required to create a bound kernlet from it.
239// - Bound kernlets: required to attach to an IRQ.
240static const HelRights kHelRightAssign = UINT32_C(1) << 6;
241// Right to derive new objects that affect the original one.
242// - Memory view: required to fork.
243// - Hierarchy: required to extend it by a child hierarchy node.
244static const HelRights kHelRightDerive = UINT32_C(1) << 7;
245// Right to add, remove or manipulate components.
246// - Memory views: required to perform loadahead.
247// - Address space: required to synchronize.
248// - Address space: required to resolve physical addresses.
249// - DMA space: required to populate.
250// - DMA space: required to resolve physical addresses.
251// - Hierarchy: required to charge resources to it.
252static const HelRights kHelRightProvision = UINT32_C(1) << 8;
253// Right to pin memory pages.
254// - Memory view: required to pin pages.
255static const HelRights kHelRightPin = UINT32_C(1) << 9;
256// Right to perform memory fences.
257// - Memory view: required for fences.
258static const HelRights kHelRightFence = UINT32_C(1) << 10;
259// Right to wait on an object.
260// - IPC queue: required to drive.
261// - Thread: required to observe.
262// - Event: required to wait.
263// - IRQ: required to wait.
264// - IRQ: required to attach a kernlet.
265static const HelRights kHelRightWait = UINT32_C(1) << 11;
266// Right to signal an object.
267// - IPC queue: required to alert.
268// - Thread: required to interrupt.
269// - Event: required to raise.
270// - Event: required to bind to kernlet.
271// - IRQ: required to acknowledge.
272// - IRQ: required to attach a kernlet.
273// - Virtualized CPUs: required to raise an interrupt.
274static const HelRights kHelRightSignal = UINT32_C(1) << 12;
275// Right to manage an object (includes potentially destructive operations).
276// - Lane: required to shut down.
277// - Memory view: required to resize.
278// - Memory view: required to manage.
279// - Memory view: required to invalidate.
280// - Swap space: required to attach or detach swap regions.
281// - Thread: required to set priority.
282// - Thread: required to resume.
283// - Thread: required to kill.
284// - IRQ pin: required to configure the IRQ.
285// - IRQ pin: required to obtain MSI address and data words.
286// - Hierarchy: required to query its statistics.
287// - Hierarchy: required to await memory pressure.
288static const HelRights kHelRightManage = UINT32_C(1) << 13;
289// All rights (even unspecified ones). Easier to recognize in code than a literal.
290static const HelRights kHelRightsMax = ~UINT32_C(0);
291
292struct HelX86SegmentRegister {
293 uint64_t base;
294 uint32_t limit;
295 uint16_t selector;
296 uint8_t type, present, dpl, db, s, l, g, avl;
297 // The segment register does not hold a usable segment (e.g., a null selector).
298 uint8_t unusable;
299};
300
301struct HelX86DescriptorTable {
302 uint64_t base;
303 uint16_t limit;
304};
305
306struct HelX86VirtualizationRegs {
307 uint64_t rax;
308 uint64_t rbx;
309 uint64_t rcx;
310 uint64_t rdx;
311 uint64_t rsi;
312 uint64_t rdi;
313 uint64_t rbp;
314 uint64_t r8;
315 uint64_t r9;
316 uint64_t r10;
317 uint64_t r11;
318 uint64_t r12;
319 uint64_t r13;
320 uint64_t r14;
321 uint64_t r15;
322
323 uint64_t rsp;
324 uint64_t rip;
325 uint64_t rflags;
326
327 struct HelX86SegmentRegister cs, ds, es, fs, gs, ss;
328 struct HelX86SegmentRegister tr, ldt;
329 struct HelX86DescriptorTable gdt, idt;
330
331 uint64_t cr0, cr2, cr3, cr4, cr8;
332 uint64_t efer;
333 uint64_t apic_base;
334};
335
336// The registers that VMMs need on most exits,
337struct HelX86VirtualizationBasicRegs {
338 uint64_t rax;
339 uint64_t rbx;
340 uint64_t rcx;
341 uint64_t rdx;
342 uint64_t rsi;
343 uint64_t rdi;
344 uint64_t rbp;
345 uint64_t r8;
346 uint64_t r9;
347 uint64_t r10;
348 uint64_t r11;
349 uint64_t r12;
350 uint64_t r13;
351 uint64_t r14;
352 uint64_t r15;
353
354 uint64_t rsp;
355 uint64_t rip;
356 uint64_t rflags;
357};
358
359struct HelX86VirtualizationMsrs {
360 uint64_t kernelGsBase;
361 uint64_t star;
362 uint64_t lstar;
363 uint64_t cstar;
364 uint64_t sfmask;
365 uint64_t sysenterCs;
366 uint64_t sysenterEsp;
367 uint64_t sysenterEip;
368 uint64_t xcr0;
369};
370
371struct HelRiscv64VirtualizationRegs {
372 union {
373 uint64_t x[32];
374
375 struct {
376 uint64_t zero;
377 uint64_t ra;
378 uint64_t sp;
379 uint64_t gp;
380 uint64_t tp;
381 uint64_t t0;
382 uint64_t t1;
383 uint64_t t2;
384 uint64_t s0;
385 uint64_t s1;
386 uint64_t a0;
387 uint64_t a1;
388 uint64_t a2;
389 uint64_t a3;
390 uint64_t a4;
391 uint64_t a5;
392 uint64_t a6;
393 uint64_t a7;
394 uint64_t s2;
395 uint64_t s3;
396 uint64_t s4;
397 uint64_t s5;
398 uint64_t s6;
399 uint64_t s7;
400 uint64_t s8;
401 uint64_t s9;
402 uint64_t s10;
403 uint64_t s11;
404 uint64_t t3;
405 uint64_t t4;
406 uint64_t t5;
407 uint64_t t6;
408 };
409 };
410
411 uint64_t pc;
412 uint8_t kernelMode;
413
414 // CSRs
415 uint64_t sstatus;
416 uint64_t sie;
417 uint64_t stvec;
418 uint64_t sscratch;
419 uint64_t sepc;
420 uint64_t scause;
421 uint64_t stval;
422 uint64_t sip;
423 uint64_t satp;
424 uint64_t stimecmp;
425};
426
427#if defined(__riscv) && __riscv_xlen == 64
428typedef struct HelRiscv64VirtualizationRegs HelVirtualizationRegs;
429#else
430typedef struct HelX86VirtualizationRegs HelVirtualizationRegs;
431#endif
432
433enum {
434 kHelNullHandle = 0,
435 kHelThisUniverse = -1,
436 kHelThisThread = -2
437};
438
439enum {
440 kHelWaitInfinite = -1
441};
442
443enum {
444 kHelActionNone = 0,
445 kHelActionDismiss = 11,
446 kHelActionOffer = 5,
447 kHelActionAccept = 6,
448 kHelActionImbueCredentials = 8,
449 kHelActionExtractCredentials = 9,
450 kHelActionSendFromBuffer = 1,
451 kHelActionSendFromBufferSg = 10,
452 kHelActionRecvInline = 7,
453 kHelActionRecvToBuffer = 3,
454 kHelActionPushDescriptor = 2,
455 kHelActionPullDescriptor = 4
456};
457
458enum {
459 kHelItemChain = 1,
460 kHelItemAncillary = 2,
461 kHelItemWantLane = (1 << 16),
462};
463
464static const uint32_t kHelTransferDescriptorOut = UINT32_C(1) << 0;
465static const uint32_t kHelTransferDescriptorIn = UINT32_C(1) << 1;
466
467enum {
468 kHelObtainZeroMemory = 1,
469 kHelObtainClockPage = 2
470};
471
473enum {
483 kHelClockTime = 4
485
496 uint64_t seqlock;
498 uint32_t clockType;
500 int32_t tickShift;
502 uint64_t tickFactor;
503};
504
505struct HelSgItem {
506 void *buffer;
507 size_t length;
508};
509
510struct HelAction {
511 int type;
512 uint32_t flags;
513 // TODO: It may be worth to restructure this to a union of structs
514 // (e.g., a HelActionDataBufferSize, HelActionDataDescriptorRights, ...),
515 // but that requires simultaneous mlibc and Managarm changes.
516 union {
517 uintptr_t word0;
518 void *buffer;
519 };
520 union {
521 uintptr_t word1;
522 size_t length;
523 // For kHelPushDescriptor, kHelPullDescriptor.
524 uint32_t rights;
525 };
526 union {
527 uintptr_t word2;
528 // For kHelActionImbueCredentials, kHelPushDescriptor, kHelPullDescriptor.
529 HelHandle handle;
530 };
531};
532
533struct HelDescriptorInfo {
534 int type;
535};
536
537enum HelAllocFlags {
538 kHelAllocContinuous = 4,
539 kHelAllocOnDemand = 1,
540};
541
542struct HelAllocRestrictions {
543 int addressBits;
544};
545
546enum HelManagedFlags {
547 kHelManagedReadahead = 1
548};
549
550enum HelManageRequests {
551 kHelManageInitialize = 1,
552 kHelManageWriteback = 2
553};
554
562
564 // Additional flags that may be set.
565 kHelMapProtRead = UINT32_C(1) << 8,
566 kHelMapProtWrite = UINT32_C(1) << 9,
567 kHelMapProtExecute = UINT32_C(1) << 10,
568 kHelMapDontRequireBacking = UINT32_C(1) << 7,
569 kHelMapFixed = UINT32_C(1) << 11,
570 kHelMapFixedNoReplace = UINT32_C(1) << 12,
571 kHelMapPreferBottom = UINT32_C(1) << 13,
574 kHelMapNoDirtyTracking = UINT32_C(1) << 14
576
577enum HelSliceFlags {
578 kHelSliceCacheWriteCombine = 1,
579};
580
581enum HelCachingMode {
582 kHelCachingDefault = 0,
583 kHelCachingUncached = 1,
584 kHelCachingWriteCombine = 2,
585 kHelCachingWriteThrough = 3,
586 kHelCachingWriteBack = 4,
587 kHelCachingMmio = 5,
588 kHelCachingMmioNonPosted = 6
589};
590
591enum HelThreadFlags {
592 kHelThreadStopped = 1
593};
594
595enum HelObservation {
596 kHelObserveNull = 0,
597 kHelObserveInterrupt = 4,
598 kHelObservePanic = 3,
599 kHelObserveBreakpoint = 1,
600 kHelObservePageFault = 2,
601 kHelObserveGeneralFault = 5,
602 kHelObserveIllegalInstruction = 6,
603 kHelObserveDivByZero = 7,
604 kHelObserveSuperCall = 0x80000000
605};
606
607enum HelRegisterSets {
608 kHelRegsProgram = 1,
609 kHelRegsGeneral = 2,
610 kHelRegsThread = 3,
611 kHelRegsDebug = 4,
612 kHelRegsVirtualization = 5,
613 kHelRegsSimd = 6,
614 kHelRegsSignal = 7,
615 kHelRegsPageFault = 8,
616 kHelRegsVirtualizationBasic = 9,
617 kHelRegsVirtualizationMsrs = 10
618};
619
620enum HelPageFaultFlags {
621 kHelPageFaultMapError = 1,
622 kHelPageFaultAccessError = 2,
623 kHelPageFaultOutOfMemory = 3
624};
625
630};
631
632#if defined(__x86_64__)
633enum HelRegisterIndex {
634 kHelRegRax = 0,
635 kHelRegRbx = 1,
636 kHelRegRcx = 2,
637 kHelRegRdx = 3,
638 kHelRegRdi = 4,
639 kHelRegRsi = 5,
640 kHelRegR8 = 6,
641 kHelRegR9 = 7,
642 kHelRegR10 = 8,
643 kHelRegR11 = 9,
644 kHelRegR12 = 10,
645 kHelRegR13 = 11,
646 kHelRegR14 = 12,
647 kHelRegR15 = 13,
648 kHelRegRbp = 14,
649
650 kHelNumGprs = 15,
651
652 kHelRegIp = 0,
653 kHelRegSp = 1
654};
655
656enum HelSyscallArgs {
657 kHelRegNumber = kHelRegRdi,
658 kHelRegError = kHelRegRdi,
659
660 kHelRegArg0 = kHelRegRsi,
661 kHelRegArg1 = kHelRegRdx,
662 kHelRegArg2 = kHelRegRax,
663 kHelRegArg3 = kHelRegR8,
664 kHelRegArg4 = kHelRegR9,
665 kHelRegArg5 = kHelRegR10,
666 kHelRegArg6 = kHelRegR12,
667 kHelRegArg7 = kHelRegR13,
668 kHelRegArg8 = kHelRegR14,
669
670 kHelRegOut0 = kHelRegRsi,
671 kHelRegOut1 = kHelRegRdx,
672 kHelRegOut2 = kHelRegRax
673};
674
675#elif defined(__aarch64__)
676enum HelRegisterIndex {
677 kHelRegX0 = 0,
678 kHelRegX1,
679 kHelRegX2,
680 kHelRegX3,
681 kHelRegX4,
682 kHelRegX5,
683 kHelRegX6,
684 kHelRegX7,
685 kHelRegX8,
686 kHelRegX9,
687 kHelRegX10,
688 kHelRegX11,
689 kHelRegX12,
690 kHelRegX13,
691 kHelRegX14,
692 kHelRegX15,
693 kHelRegX16,
694 kHelRegX17,
695 kHelRegX18,
696 kHelRegX19,
697 kHelRegX20,
698 kHelRegX21,
699 kHelRegX22,
700 kHelRegX23,
701 kHelRegX24,
702 kHelRegX25,
703 kHelRegX26,
704 kHelRegX27,
705 kHelRegX28,
706 kHelRegX29,
707 kHelRegX30,
708
709 kHelNumGprs = 31,
710
711 kHelRegIp = 0,
712 kHelRegSp = 1
713};
714
715enum HelSyscallArgs {
716 kHelRegNumber = kHelRegX0,
717 kHelRegError = kHelRegX0,
718
719 kHelRegArg0 = kHelRegX1,
720 kHelRegArg1 = kHelRegX2,
721 kHelRegArg2 = kHelRegX3,
722 kHelRegArg3 = kHelRegX4,
723 kHelRegArg4 = kHelRegX5,
724 kHelRegArg5 = kHelRegX6,
725 kHelRegArg6 = kHelRegX7,
726 kHelRegArg7 = kHelRegX8,
727 kHelRegArg8 = kHelRegX9,
728
729 kHelRegOut0 = kHelRegX1,
730 kHelRegOut1 = kHelRegX2,
731 kHelRegOut2 = kHelRegX3
732};
733
734#elif defined(__riscv) && __riscv_xlen == 64
735enum HelRegisterIndex {
736 kHelRegRa = 0,
737 kHelRegGp,
738 kHelRegTp,
739 kHelRegT0,
740 kHelRegT1,
741 kHelRegT2,
742 kHelRegS0,
743 kHelRegS1,
744 kHelRegA0,
745 kHelRegA1,
746 kHelRegA2,
747 kHelRegA3,
748 kHelRegA4,
749 kHelRegA5,
750 kHelRegA6,
751 kHelRegA7,
752 kHelRegS2,
753 kHelRegS3,
754 kHelRegS4,
755 kHelRegS5,
756 kHelRegS6,
757 kHelRegS7,
758 kHelRegS8,
759 kHelRegS9,
760 kHelRegS10,
761 kHelRegS11,
762 kHelRegT3,
763 kHelRegT4,
764 kHelRegT5,
765 kHelRegT6,
766 kHelNumGprs,
767 kHelRegIp = 0,
768 kHelRegSp = 1
769};
770enum HelSyscallArgs {
771 kHelRegNumber = kHelRegA0,
772 kHelRegError = kHelRegA0,
773 kHelRegArg0 = kHelRegA1,
774 kHelRegArg1 = kHelRegA2,
775 kHelRegArg2 = kHelRegA3,
776 kHelRegArg3 = kHelRegA4,
777 kHelRegArg4 = kHelRegA5,
778 kHelRegArg5 = kHelRegA6,
779 kHelRegArg6 = kHelRegA7,
780 kHelRegArg7 = kHelRegS2,
781 kHelRegArg8 = kHelRegS3,
782
783 kHelRegOut0 = kHelRegA1,
784 kHelRegOut1 = kHelRegA2,
785 kHelRegOut2 = kHelRegA3
786};
787
788#endif
789
790struct HelQueueParameters {
791 uint32_t flags;
792 unsigned int numChunks;
793 size_t chunkSize;
794 unsigned int numSqChunks;
795};
796
798static const uint32_t kHelHierarchyMemoryController = UINT32_C(1) << 0;
799
800struct HelHierarchyParameters {
801 // Optional tag to identify the hierarchy in kernel messages.
802 // Null-terminated unless it fills the entire array.
803 char tag[128];
804 // Bitmask of controllers that we want to enable.
805 uint32_t controllers;
806 // Only used with kHelHierarchyMemoryController; must be zero otherwise.
807 // Allocations of the hierarchy and its descendants wait (or fail) unless memoryFloor bytes
808 // of memory stay free on top of the kernel's own reserve.
809 // This keeps memory available to hierarchies with lower floors.
810 // The effective floor is the maximum over this floor and any parent floor.
811 size_t memoryFloor;
812};
813
830
832static const int kHelUserNotifyCqProgress = (1 << 0);
834static const int kHelUserNotifySupplySqChunks = (1 << 1);
836static const int kHelUserNotifyError = (1 << 14);
838static const int kHelUserNotifyAlert = (1 << 15);
839
841static const int kHelKernelNotifySqProgress = (1 << 0);
843static const int kHelKernelNotifySupplyCqChunks = (1 << 1);
844
846static const uint32_t kHelDriveWait = (1 << 0);
847
848enum {
849 kHelAccessIommuIntelVtd = 1,
850 kHelAccessIommuAmdVi = 2,
851};
852
853enum {
854 kHelDmaRegionRead = 1,
855 kHelDmaRegionWrite = 2,
856};
857
860 uint64_t base;
861 uint64_t size;
862 uint32_t flags;
863};
864
867 uint32_t segment;
868 uint8_t bus;
869 uint8_t slot;
870 uint8_t function;
871};
872
874static const uint32_t kHelSubmitCancel = 256;
876static const uint32_t kHelSubmitAsyncNop = 1;
878static const uint32_t kHelSubmitExchangeMsgs = 2;
880static const uint32_t kHelSubmitAwaitClock = 3;
882static const uint32_t kHelSubmitAwaitEvent = 4;
884static const uint32_t kHelSubmitProtectMemory = 5;
886static const uint32_t kHelSubmitSynchronizeSpace = 6;
888static const uint32_t kHelSubmitReadMemory = 7;
890static const uint32_t kHelSubmitWriteMemory = 8;
892static const uint32_t kHelSubmitManageMemory = 9;
894static const uint32_t kHelSubmitLockMemoryView = 10;
896static const uint32_t kHelSubmitObserve = 11;
898static const uint32_t kHelSubmitResizeMemory = 12;
900static const uint32_t kHelSubmitForkMemory = 13;
902static const uint32_t kHelSubmitWritebackFence = 14;
904static const uint32_t kHelSubmitInvalidateMemory = 15;
906static const uint32_t kHelSubmitPopulateSpace = 16;
908static const uint32_t kHelSubmitMapMemory = 17;
910static const uint32_t kHelSubmitUnmapMemory = 18;
912static const uint32_t kHelSubmitBindDmaDevice = 19;
914static const uint32_t kHelSubmitUnbindDmaDevice = 20;
916static const uint32_t kHelSubmitActivateIommu = 21;
918static const uint32_t kHelSubmitSetSwapRegion = 23;
920static const uint32_t kHelSubmitAwaitPressure = 24;
921
923struct HelQueue {
928
933
937
941};
942
944static const int kHelNextPresent = (1 << 24);
945
947static const int kHelProgressMask = 0xFFFFFF;
949static const int kHelProgressDone = (1 << 25);
951static const int kHelProgressFull = (1 << 26);
952
953struct HelChunk {
956 int next;
957
959 int progressFutex;
960
962 char buffer[];
963};
964
968 unsigned int length;
970 unsigned int opcode;
972 void *context;
973};
974
977 uint64_t cancellationTag;
978};
979
984 HelHandle lane;
986 size_t count;
988 uint32_t flags;
989};
990
994 uint64_t counter;
997};
998
1002 HelHandle handle;
1004 uint64_t sequence;
1007};
1008
1020 uint64_t sequence;
1023};
1024
1028 HelHandle spaceHandle;
1030 void *pointer;
1032 size_t size;
1034 uint32_t flags;
1035};
1036
1040 HelHandle spaceHandle;
1042 void *pointer;
1044 size_t size;
1045};
1046
1050 HelHandle handle;
1052 uintptr_t address;
1054 size_t length;
1056 void *buffer;
1057};
1058
1062 HelHandle handle;
1064 uintptr_t address;
1066 size_t length;
1068 const void *buffer;
1069};
1070
1074 HelHandle handle;
1075};
1076
1080 HelHandle handle;
1082 uintptr_t offset;
1084 size_t size;
1085};
1086
1090 HelHandle handle;
1091};
1092
1096 HelHandle handle;
1098 size_t newSize;
1099};
1100
1106 HelHandle handle;
1107};
1108
1113 HelHandle handle;
1115 uintptr_t offset;
1117 size_t size;
1118};
1119
1121static const uint32_t kHelInvalidateNoWriteback = 1;
1122
1126 HelHandle handle;
1128 uintptr_t offset;
1130 size_t size;
1132 uint32_t flags;
1133};
1134
1138 HelHandle handle;
1140 uintptr_t address;
1142 size_t length;
1143};
1144
1148 HelHandle memoryHandle;
1150 HelHandle spaceHandle;
1152 void *pointer;
1154 uintptr_t offset;
1156 size_t size;
1158 uint32_t flags;
1159};
1160
1164 HelHandle spaceHandle;
1166 void *pointer;
1168 size_t size;
1169};
1170
1183
1193
1200 HelHandle iommuHandle;
1201};
1202
1206static const int kHelSwapRegionShift = 44;
1208static const uint32_t kHelNumSwapRegions = 1 << 18;
1209
1217 HelHandle swapHandle;
1221 size_t numPages;
1223 uint32_t region;
1224};
1225
1226struct HelSimpleResult {
1227 HelError error;
1228 int reserved;
1229};
1230
1231struct HelCredentialsResult {
1232 HelError error;
1233 int reserved;
1234 char credentials[16];
1235};
1236
1237struct HelManageResult {
1238 HelError error;
1239 int type;
1240 uintptr_t offset;
1241 size_t length;
1242};
1243
1244struct HelObserveResult {
1245 HelError error;
1246 unsigned int observation;
1247};
1248
1249struct HelInlineResult {
1250 HelError error;
1251 int reserved;
1252 size_t length;
1253 char data[];
1254};
1255
1256struct HelInlineResultNoFlex {
1257 HelError error;
1258 int reserved;
1259 size_t length;
1260};
1261
1262struct HelLengthResult {
1263 HelError error;
1264 int reserved;
1265 size_t length;
1266};
1267
1268struct HelHandleResult {
1269 HelError error;
1270 int reserved;
1271 HelHandle handle;
1272};
1273
1274struct HelPointerResult {
1275 HelError error;
1276 int reserved;
1277 void *pointer;
1278};
1279
1280struct HelEventResult {
1281 HelError error;
1282 uint32_t bitset;
1283 uint64_t sequence;
1284};
1285
1286struct HelPressureResult {
1287 HelError error;
1288 int reserved;
1290 uint64_t sequence;
1291};
1292
1293enum HelAckFlags {
1294 kHelAckAcknowledge = 2,
1295 kHelAckNack = 3,
1296 kHelAckKick = 1,
1297 kHelAckClear = 0x100,
1298};
1299
1300union HelKernletData {
1301 HelHandle handle;
1302};
1303
1304struct HelThreadStats {
1305 uint64_t userTime;
1306};
1307
1308enum {
1309 // The guest executed HLT (x86 with SVM only; with VMX, the kernel handles HLT).
1310 kHelVmexitHlt = 0,
1311 // A guest-physical access to an unmapped address (e.g., MMIO).
1312 // address is the guest-physical address and flags is a combination of kHelVmFault*.
1313 // The instruction is neither decoded nor skipped; the VMM emulates it and advances RIP by itself.
1314 kHelVmexitTranslationFault = 1,
1315 // VMCALL/VMMCALL (x86) or ECALL (RISC-V).
1316 // On x86, it needs a completion; data[0] of the completion is written to RAX.
1317 kHelVmexitHyperCall = 2,
1318 kHelVmexitInstructionTrap = 3,
1319 kHelVmexitKicked = 4,
1320 // x86 port I/O, it needs a completion.
1321 // Address is the port, code is the access size in bytes, flags is a combination of kHelVmexitIo*.
1322 // String I/O is emulated by the VMM (which decodes the instruction); the completion skips it.
1323 // For non-string IN, data[0] of the completion is the value read.
1324 // For non-string OUT, data is the value.
1325 kHelVmexitIo = 5,
1326 // x86 CPUID, it needs a completion.
1327 // address is EAX (the leaf) and data is ECX (the subleaf).
1328 // data[0..3] of the completion are written to EAX, EBX, ECX and EDX.
1329 kHelVmexitCpuid = 6,
1330 // x86 RDMSR, it needs a completion;
1331 // address is the MSR index, data[0] of the completion is written to EDX:EAX.
1332 kHelVmexitRdmsr = 7,
1333 // x86 WRMSR, it needs a completion; address is the MSR index, data is the value.
1334 kHelVmexitWrmsr = 8,
1335 // The guest caused a triple fault.
1336 kHelVmexitShutdown = 9,
1337 // x86 with VMX: the guest EOI'd a level-triggered interrupt (e.g., for the remote IRR of an
1338 // emulated I/O APIC); code is the vector.
1339 kHelVmexitEoi = 10,
1340 // VM entry failed, code is the platform's entry failure reason.
1341 kHelVmexitError = -1,
1342 // Unknown VM exit reason, code is the platform's exit reason.
1343 kHelVmexitUnknownPlatformSpecificExitCode = -2,
1344};
1345
1346enum {
1347 kHelVmexitIoIn = 1 << 0,
1348 kHelVmexitIoString = 1 << 1,
1349};
1350
1351enum {
1352 kHelVmexitCompletionDone = 0,
1353 kHelVmexitCompletionFault = 1,
1354};
1355
1356struct HelVmexitCompletion {
1357 uint32_t status;
1358 uint32_t reserved;
1359 uint64_t data[4];
1360};
1361
1362enum {
1363 kHelVmFaultRead = 1 << 0,
1364 kHelVmFaultWrite = 1 << 1,
1365 kHelVmFaultExecute = 1 << 2,
1366};
1367
1368#if defined(__riscv) && __riscv_xlen == 64
1369
1370struct HelVmexitReason {
1371 uint32_t exitReason;
1372 // If bit 63 is set then stores a compressed unexpanded instruction,
1373 // otherwise stores a normal 32-bit instruction (possibly originally compressed in which case bits 1:0 aren't 0b11).
1374 uint64_t instruction;
1375 size_t address;
1376 size_t flags;
1377};
1378
1379#else
1380
1381struct HelVmexitReason {
1382 uint32_t exitReason;
1383 uint32_t code;
1384 size_t address;
1385 size_t flags;
1386 uint64_t data;
1387};
1388
1389#endif
1390
1391// see RFC 5424
1392enum HelLogSeverity {
1393 kHelLogSeverityEmergency,
1394 kHelLogSeverityAlert,
1395 kHelLogSeverityCritical,
1396 kHelLogSeverityError,
1397 kHelLogSeverityWarning,
1398 kHelLogSeverityNotice,
1399 kHelLogSeverityInfo,
1400 kHelLogSeverityDebug,
1401};
1402
1403enum {
1404 kHelAccessIrqByGsi = 1,
1405 kHelAccessIrqByPhandle = 2,
1406 kHelAccessIrqAllocateMsi = 3,
1407};
1408
1410enum {
1411 kHelIrqNameSize = 32,
1412};
1413
1414enum {
1415 kHelIrqTriggerNull = 0,
1416 kHelIrqTriggerEdge = 1,
1417 kHelIrqTriggerLevel = 2
1418};
1419
1420enum {
1421 kHelIrqPolarityNull = 0,
1422 kHelIrqPolarityHigh = 1,
1423 kHelIrqPolarityLow = 2
1424};
1425
1428 uint64_t address;
1429 uint32_t data;
1430};
1431
1433enum {
1434 kHelPageShift = 12,
1435 kHelPageSize = 1 << kHelPageShift
1436};
1437
1440
1448HEL_C_LINKAGE HelError helLog(const enum HelLogSeverity severity, const char *string, size_t length);
1449
1455HEL_C_LINKAGE void helPanic(const char *string, size_t length)
1456 __attribute__ (( noreturn ));
1457
1461
1463HEL_C_LINKAGE HelError helNop();
1464
1468HEL_C_LINKAGE HelError helSubmitAsyncNop(HelHandle queueHandle, uintptr_t context);
1469
1477HEL_C_LINKAGE HelError helExtendHierarchy(HelHandle hierarchyHandle,
1478 const struct HelHierarchyParameters *params, HelHandle *handle);
1479
1485HEL_C_LINKAGE HelError helQueryHierarchy(HelHandle hierarchyHandle,
1486 struct HelHierarchyStats *stats);
1487
1491
1495HEL_C_LINKAGE HelError helCreateUniverse(HelHandle *handle);
1496
1504HEL_C_LINKAGE HelError
1505helTransferDescriptor(HelHandle handle, HelHandle universeHandle,
1506 uint32_t flags, uint32_t exposedRights, uint32_t requiredRights, HelHandle *outHandle);
1507
1508HEL_C_LINKAGE HelError helDescriptorInfo(HelHandle handle, struct HelDescriptorInfo *info);
1509
1517HEL_C_LINKAGE HelError helGetCredentials(HelHandle handle, uint32_t flags,
1518 char *credentials);
1519
1525HEL_C_LINKAGE HelError helCloseDescriptor(HelHandle universeHandle, HelHandle handle);
1526
1532HEL_C_LINKAGE HelError helObtainHandle(int kind, HelHandle *handle);
1533
1537
1547HEL_C_LINKAGE HelError helCreateQueue(const struct HelQueueParameters *params,
1548 HelHandle *handle);
1549
1561HEL_C_LINKAGE HelError helDriveQueue(HelHandle queueHandle, uint32_t flags, uint32_t notifyMask);
1562
1569HEL_C_LINKAGE HelError helAlertQueue(HelHandle queueHandle);
1570
1574
1588HEL_C_LINKAGE HelError helAllocateMemory(HelHandle hierarchy, size_t size, uint32_t flags,
1589 const struct HelAllocRestrictions *restrictions, HelHandle *handle);
1590
1597HEL_C_LINKAGE HelError helResizeMemory(HelHandle handle, size_t newSize);
1598
1609HEL_C_LINKAGE HelError helCreateKcovBuffer(size_t size, HelHandle *handle);
1610
1612enum {
1616 kHelKcovModeCmp = 2
1618
1630HEL_C_LINKAGE HelError helEnableCoverage(HelHandle thread, HelHandle buffer, uint32_t mode);
1631
1637HEL_C_LINKAGE HelError helDisableCoverage(HelHandle thread);
1638
1653HEL_C_LINKAGE HelError helCreateManagedMemory(HelHandle hierarchy, size_t size, uint32_t flags,
1654 HelHandle *backingHandle, HelHandle *frontalHandle);
1655
1677HEL_C_LINKAGE HelError helCreateSwapSpace(HelHandle hierarchy, uint32_t flags,
1678 HelHandle *backingHandle, HelHandle *swapHandle);
1679
1695HEL_C_LINKAGE HelError helAllocateSwappableMemory(HelHandle hierarchy, HelHandle swapSpace,
1696 size_t size, uint32_t flags, HelHandle *handle);
1697
1717HEL_C_LINKAGE HelError helCopyOnWrite(HelHandle hierarchy, HelHandle swapSpace, HelHandle memory,
1718 uintptr_t offset, size_t size, HelHandle *handle);
1719
1720HEL_C_LINKAGE HelError helAccessPhysical(
1721 HelHandle accessToken, uintptr_t physical, size_t size, uint32_t cachingMode, HelHandle *handle
1722);
1723
1729HEL_C_LINKAGE HelError helCreateIndirectMemory(size_t numSlots, HelHandle *handle);
1730
1747HEL_C_LINKAGE HelError helAlterMemoryIndirection(HelHandle indirectHandle, size_t slotIndex,
1748 HelHandle memoryHandle, uintptr_t offset, size_t size);
1749
1750HEL_C_LINKAGE HelError helCreateSliceView(HelHandle bundle, uintptr_t offset, size_t size,
1751 uint32_t flags, HelHandle *handle);
1752
1760HEL_C_LINKAGE HelError helForkMemory(HelHandle handle, HelHandle *forkedHandle);
1761
1765HEL_C_LINKAGE HelError helCreateSpace(HelHandle *handle);
1766
1776HEL_C_LINKAGE HelError helAccessIommu(HelHandle accessHandle, uint32_t mode, uint64_t base,
1777 HelHandle *handle);
1778
1798HEL_C_LINKAGE HelError helCreateDmaSpace(HelHandle iommuHandle,
1799 const struct HelDmaReservedRegion *regions, size_t numRegions,
1800 uint32_t flags, HelHandle *handle);
1801
1819HEL_C_LINKAGE HelError helMapMemory(HelHandle memoryHandle, HelHandle spaceHandle,
1820 void *pointer, uintptr_t offset, size_t size, uint32_t flags, void **actualPointer);
1821
1822
1833HEL_C_LINKAGE HelError helUnmapMemory(HelHandle spaceHandle, void *pointer, size_t size);
1834
1835HEL_C_LINKAGE HelError helPointerPhysical(HelHandle spaceHandle, const void *pointer, uintptr_t *physical);
1836
1837HEL_C_LINKAGE HelError helMemoryInfo(HelHandle handle,
1838 size_t *size);
1839
1840HEL_C_LINKAGE HelError helUpdateMemory(HelHandle handle, int type, uintptr_t offset, size_t length);
1841
1852HEL_C_LINKAGE HelError helLoadahead(HelHandle handle, uintptr_t offset, size_t length);
1853
1854HEL_C_LINKAGE HelError helCreateVirtualizedSpace(HelHandle *handle);
1855
1859
1874HEL_C_LINKAGE HelError helCreateThread(HelHandle hierarchy, HelHandle universe,
1875 HelHandle spaceHandle, void *ip, void *sp, uint32_t flags, HelHandle *handle);
1876
1882HEL_C_LINKAGE HelError helQueryThreadStats(HelHandle handle, struct HelThreadStats *stats);
1883
1892HEL_C_LINKAGE HelError helSetPriority(HelHandle handle, int priority);
1893
1895HEL_C_LINKAGE HelError helYield();
1896
1900HEL_C_LINKAGE HelError helKillThread(HelHandle handle);
1901
1908HEL_C_LINKAGE HelError helInterruptThread(HelHandle handle);
1909
1916HEL_C_LINKAGE HelError helResume(HelHandle handle);
1917
1925HEL_C_LINKAGE HelError helLoadRegisters(HelHandle handle, int set, void *image);
1926
1934HEL_C_LINKAGE HelError helStoreRegisters(HelHandle handle, int set, const void *image);
1935
1938// Register set to query information for.
1941HEL_C_LINKAGE HelError helQueryRegisterInfo(int set, struct HelRegisterInfo *info);
1942
1943HEL_C_LINKAGE HelError helWriteFsBase(void *pointer);
1944
1945HEL_C_LINKAGE HelError helReadFsBase(void **pointer);
1946
1947HEL_C_LINKAGE HelError helWriteGsBase(void *pointer);
1948
1949HEL_C_LINKAGE HelError helReadGsBase(void **pointer);
1950
1952HEL_C_LINKAGE HelError helGetCurrentCpu(int *cpu);
1953
1958HEL_C_LINKAGE HelError helGetClock(uint64_t *counter);
1959
1960// x86 vCPUs with VMX have an in-kernel x2APIC:
1961// * ID 0,
1962// * starts software-disabled,
1963// * timer at 1 GHz before the divider,
1964// * and the guest's TSC equals the host's.
1965// The kernel handles its MSRs (0x800 - 0x8FF, IA32_APIC_BASE, IA32_TSC_DEADLINE),
1966// CR8 and HLT without exiting.
1967// SVM has no local APIC yet.
1968
1974HEL_C_LINKAGE HelError helCreateVirtualizedCpu(HelHandle handle, HelHandle *out_handle);
1975
1988HEL_C_LINKAGE HelError helRunVirtualizedCpu(HelHandle handle,
1989 const struct HelVmexitCompletion *completion, struct HelVmexitReason *reason);
1990
2003HEL_C_LINKAGE HelError helAssertVirtualizedIrq(HelHandle handle, uint64_t irq, uint8_t level);
2004
2009HEL_C_LINKAGE HelError helKickVirtualizedCpu(HelHandle handle);
2010
2011HEL_C_LINKAGE HelError helGetRandomBytes(void *buffer, size_t wantedSize, size_t *actualSize);
2012
2022HEL_C_LINKAGE HelError helGetAffinity(HelHandle handle, uint8_t *mask, size_t size, size_t *actualSize);
2023
2031HEL_C_LINKAGE HelError helSetAffinity(HelHandle handle, uint8_t *mask, size_t size);
2032
2036
2045HEL_C_LINKAGE HelError helCreateStream(HelHandle *lane1, HelHandle *lane2, uint32_t attach_credentials);
2046
2047HEL_C_LINKAGE HelError helShutdownLane(HelHandle handle);
2048
2056HEL_C_LINKAGE HelError helCreateToken(HelHandle *handle);
2057
2061
2070HEL_C_LINKAGE HelError helFutexWait(int *pointer, int expected, int64_t deadline);
2071
2077HEL_C_LINKAGE HelError helFutexWake(int *pointer, unsigned int count);
2078
2082
2086HEL_C_LINKAGE HelError helCreateOneshotEvent(HelHandle *handle);
2087
2091HEL_C_LINKAGE HelError helCreateBitsetEvent(HelHandle *handle);
2092
2103HEL_C_LINKAGE HelError helCreateSequencedEvent(HelHandle *waitHandle, HelHandle *raiseHandle);
2104
2109HEL_C_LINKAGE HelError helRaiseEvent(HelHandle handle);
2110
2131HEL_C_LINKAGE HelError helAccessIrq(
2132 HelHandle accessHandle, uint32_t mode, uint64_t controller, uint64_t index,
2133 const char *name, HelHandle *handle
2134);
2135
2141HEL_C_LINKAGE HelError helHandleIrq(HelHandle pinHandle, HelHandle *handle);
2142
2154HEL_C_LINKAGE HelError helConfigureIrq(HelHandle pinHandle, uint32_t trigger, uint32_t polarity);
2155
2162HEL_C_LINKAGE HelError helQueryMsiInfo(HelHandle pinHandle, struct HelMsiInfo *info);
2163
2164HEL_C_LINKAGE HelError helAcknowledgeIrq(HelHandle handle, uint32_t flags, uint64_t sequence);
2165
2166HEL_C_LINKAGE HelError helAutomateIrq(HelHandle handle, uint32_t flags, HelHandle kernlet);
2167
2171
2172HEL_C_LINKAGE HelError helAccessIo(
2173 HelHandle accessToken, const uintptr_t *portArray, size_t numPorts, HelHandle *handle
2174);
2175
2179HEL_C_LINKAGE HelError helEnableIo(HelHandle handle);
2180
2184
2194HEL_C_LINKAGE HelError helBindKernlet(HelHandle handle,
2195 const union HelKernletData *data, size_t numData, HelHandle *boundHandle);
2196
2198
2199extern inline __attribute__ (( always_inline )) const char *_helErrorString(HelError code) {
2200 switch(code) {
2201 case kHelErrNone:
2202 return "Success";
2203 case kHelErrIllegalSyscall:
2204 return "Illegal syscall";
2205 case kHelErrIllegalArgs:
2206 return "Illegal arguments";
2207 case kHelErrIllegalState:
2208 return "Illegal state";
2209 case kHelErrUnsupportedOperation:
2210 return "Unsupported operation";
2211 case kHelErrNoDescriptor:
2212 return "No such descriptor";
2213 case kHelErrBadDescriptor:
2214 return "Illegal descriptor for this operation";
2215 case kHelErrThreadTerminated:
2216 return "Thread terminated already";
2217 case kHelErrLaneShutdown:
2218 return "Lane shutdown";
2219 case kHelErrEndOfLane:
2220 return "End of lane";
2221 case kHelErrDismissed:
2222 return "IPC item dismissed by remote";
2223 case kHelErrBufferTooSmall:
2224 return "Buffer too small";
2225 case kHelErrQueueTooSmall:
2226 return "Buffer too small";
2227 case kHelErrFault:
2228 return "Segfault";
2229 case kHelErrNoHardwareSupport:
2230 return "Missing hardware support for this feature";
2231 case kHelErrNoMemory:
2232 return "Out of memory";
2233 case kHelErrTransmissionMismatch:
2234 return "Transmission mismatch";
2235 case kHelErrCancelled:
2236 return "Cancelled";
2237 case kHelErrOutOfBounds:
2238 return "Out of bounds";
2239 case kHelErrAlreadyExists:
2240 return "Already exists";
2241 case kHelErrBadRights:
2242 return "Missing rights for this operation";
2243 default:
2244 return 0;
2245 }
2246}
2247
2248extern inline __attribute__ (( always_inline )) void _helCheckFailed(HelError err_code,
2249 const char *string, int fatal) {
2250 helLog(kHelLogSeverityError, string, strlen(string));
2251
2252 const char *err_string = _helErrorString(err_code);
2253 if(err_string == 0)
2254 err_string = "(Unexpected error code)";
2255 helLog(kHelLogSeverityError, err_string, strlen(err_string));
2256 helLog(kHelLogSeverityError, "\n", 1);
2257
2258 if(fatal)
2259 helPanic(0, 0);
2260}
2261
2262#define HEL_STRINGIFY_AUX(x) #x
2263#define HEL_STRINGIFY(x) HEL_STRINGIFY_AUX(x)
2264
2265#define HEL_CHECK(expr) do { HelError __error = expr; if(__error != kHelErrNone) \
2266 _helCheckFailed(__error, "HEL_CHECK failed: " #expr "\n" \
2267 " In file " __FILE__ " on line " HEL_STRINGIFY(__LINE__) "\n", 1); } while(0)
2268#define HEL_SOFT_CHECK(expr) do { HelError __error = expr; if(__error != kHelErrNone) \
2269 _helCheckFailed(__error, "HEL_SOFT_CHECK failed: " #expr "\n" \
2270 " In file " __FILE__ " on line " HEL_STRINGIFY(__LINE__) "\n", 0); } while(0)
2271
2272#endif // HEL_H
2273
@ kHelClockTsc
x86: TSC.
Definition hel.h:477
@ kHelClockCntvct
ARM: virtual counter (CNTVCT_EL0).
Definition hel.h:481
@ kHelClockCntpct
ARM: physical counter (CNTPCT_EL0).
Definition hel.h:479
@ kHelClockNone
No clock that is accessible to userspace (= helGetClock() has to be used).
Definition hel.h:475
@ kHelClockTime
RISC-V: time CSR.
Definition hel.h:483
HEL_C_LINKAGE HelError helLog(const enum HelLogSeverity severity, const char *string, size_t length)
Writes a text message (e.g., a line of text) to the kernel's log.
HEL_C_LINKAGE HelError helSetPriority(HelHandle handle, int priority)
Set the priority of a thread.
HEL_C_LINKAGE HelError helYield()
Yields the current thread.
HEL_C_LINKAGE HelError helEnableCoverage(HelHandle thread, HelHandle buffer, uint32_t mode)
Attaches a kcov buffer to a thread, which then records coverage to it.
HEL_C_LINKAGE HelError helQueryMsiInfo(HelHandle pinHandle, struct HelMsiInfo *info)
Retrieves the message address and data of an MSI pin.
HEL_C_LINKAGE HelError helAccessIrq(HelHandle accessHandle, uint32_t mode, uint64_t controller, uint64_t index, const char *name, HelHandle *handle)
Access the IRQ pin that an IRQ is attached to.
HEL_C_LINKAGE HelError helConfigureIrq(HelHandle pinHandle, uint32_t trigger, uint32_t polarity)
Configure the trigger mode and polarity of an IRQ pin.
static const int kHelUserNotifyAlert
Set in userNotify when the queue is alerted.
Definition hel.h:838
HEL_C_LINKAGE HelError helTransferDescriptor(HelHandle handle, HelHandle universeHandle, uint32_t flags, uint32_t exposedRights, uint32_t requiredRights, HelHandle *outHandle)
Copies descriptors from the current universe to another universe.
HEL_C_LINKAGE HelError helCloseDescriptor(HelHandle universeHandle, HelHandle handle)
Closes a descriptor.
HEL_C_LINKAGE HelError helQueryRegisterInfo(int set, struct HelRegisterInfo *info)
Query register-related information.
HEL_C_LINKAGE HelError helMapMemory(HelHandle memoryHandle, HelHandle spaceHandle, void *pointer, uintptr_t offset, size_t size, uint32_t flags, void **actualPointer)
Maps memory objects into an address space.
HEL_C_LINKAGE HelError helSetAffinity(HelHandle handle, uint8_t *mask, size_t size)
Set a thread's CPU affinity mask.
static const int kHelSwapRegionShift
Byte offset (((uint64_t)r << kHelSwapRegionShift) + o) in the backing memory of a swap space addresse...
Definition hel.h:1206
static const uint32_t kHelNumSwapRegions
Number of swap regions per swap space.
Definition hel.h:1208
static const int kHelKernelNotifySqProgress
Set in kernelNotify after userspace has added SQ elements.
Definition hel.h:841
static const uint32_t kHelSubmitInvalidateMemory
SQ opcode: invalidate memory.
Definition hel.h:904
HEL_C_LINKAGE HelError helQueryThreadStats(HelHandle handle, struct HelThreadStats *stats)
Query run-time statistics of a thread.
HEL_C_LINKAGE HelError helAlterMemoryIndirection(HelHandle indirectHandle, size_t slotIndex, HelHandle memoryHandle, uintptr_t offset, size_t size)
Modifies indirect memory objects.
HEL_C_LINKAGE HelError helCreateVirtualizedCpu(HelHandle handle, HelHandle *out_handle)
Creates a virtualized CPU in a virtualized space.
HEL_C_LINKAGE HelError helCreateBitsetEvent(HelHandle *handle)
Create an event consisting of multiple bits that can fire independently.
static const uint32_t kHelInvalidateNoWriteback
Flag for kHelSubmitInvalidateMemory: discard dirty pages instead of writing them back.
Definition hel.h:1121
HEL_C_LINKAGE HelError helGetCredentials(HelHandle handle, uint32_t flags, char *credentials)
Returns the credentials associated with a given descriptor.
HEL_C_LINKAGE HelError helKillThread(HelHandle handle)
Kill (i.e., terminate) a thread.
static const uint32_t kHelSubmitWriteMemory
SQ opcode: write memory.
Definition hel.h:890
static const uint32_t kHelSubmitUnmapMemory
SQ opcode: unmap memory.
Definition hel.h:910
HEL_C_LINKAGE HelError helObtainHandle(int kind, HelHandle *handle)
Obtains a descriptor to one of the kernel's global objects.
HEL_C_LINKAGE HelError helCreateDmaSpace(HelHandle iommuHandle, const struct HelDmaReservedRegion *regions, size_t numRegions, uint32_t flags, HelHandle *handle)
Creates a DMA space that memory can be mapped into for device DMA.
HEL_C_LINKAGE HelError helGetAffinity(HelHandle handle, uint8_t *mask, size_t size, size_t *actualSize)
Get a thread's CPU affinity mask.
static const uint32_t kHelSubmitAsyncNop
SQ opcode: asynchronous no-op (for testing/profiling).
Definition hel.h:876
HEL_C_LINKAGE HelError helAccessIommu(HelHandle accessHandle, uint32_t mode, uint64_t base, HelHandle *handle)
Access an IOMMU that the kernel discovered from firmware.
HEL_C_LINKAGE HelError helGetClock(uint64_t *counter)
Read the system-wide monotone clock.
HEL_C_LINKAGE HelError helLoadahead(HelHandle handle, uintptr_t offset, size_t length)
Notifies the kernel that a certain range of memory should be preloaded.
HEL_C_LINKAGE HelError helCopyOnWrite(HelHandle hierarchy, HelHandle swapSpace, HelHandle memory, uintptr_t offset, size_t size, HelHandle *handle)
Creates memory object that obtains its memory by copy-on-write from another memory object.
HEL_C_LINKAGE HelError helLoadRegisters(HelHandle handle, int set, void *image)
Load a register image (e.g., from a thread).
HEL_C_LINKAGE void helPanic(const char *string, size_t length) __attribute__((noreturn))
Kills the current thread and writes an error message to the kernel's log.
HEL_C_LINKAGE HelError helUnmapMemory(HelHandle spaceHandle, void *pointer, size_t size)
Unmaps memory from an address space.
HEL_C_LINKAGE HelError helAllocateSwappableMemory(HelHandle hierarchy, HelHandle swapSpace, size_t size, uint32_t flags, HelHandle *handle)
Allocates memory that behaves like helAllocateMemory() but is backed by a swap space: under memory pr...
HEL_C_LINKAGE HelError helFutexWake(int *pointer, unsigned int count)
Wakes up all waiters of a futex.
HEL_C_LINKAGE HelError helResizeMemory(HelHandle handle, size_t newSize)
Resizes a memory object.
static const int kHelProgressMask
Mask to extract the number of valid bytes in the chunk.
Definition hel.h:947
static const uint32_t kHelSubmitManageMemory
SQ opcode: manage memory.
Definition hel.h:892
static const uint32_t kHelSubmitForkMemory
SQ opcode: fork memory.
Definition hel.h:900
HEL_C_LINKAGE HelError helInterruptThread(HelHandle handle)
Interrupt a thread.
static const int kHelProgressFull
Set by the producer once the chunk is full (i.e., no more bytes will be written).
Definition hel.h:951
static const uint32_t kHelSubmitUnbindDmaDevice
SQ opcode: block the DMA requests of a device.
Definition hel.h:914
static const uint32_t kHelSubmitSynchronizeSpace
SQ opcode: synchronize space.
Definition hel.h:886
HEL_C_LINKAGE HelError helRaiseEvent(HelHandle handle)
Raise an event.
static const uint32_t kHelDriveWait
Flag for helDriveQueue: wait until userNotify has any bits not in notifyMask set.
Definition hel.h:846
HEL_C_LINKAGE HelError helDisableCoverage(HelHandle thread)
Detaches the kcov buffer that is attached to a thread.
static const uint32_t kHelSubmitObserve
SQ opcode: observe thread.
Definition hel.h:896
HEL_C_LINKAGE HelError helForkMemory(HelHandle handle, HelHandle *forkedHandle)
Forks memory objects, i.e., copies them using copy-on-write.
HEL_C_LINKAGE HelError helCreateQueue(const struct HelQueueParameters *params, HelHandle *handle)
Creates an IPC queue.
HEL_C_LINKAGE HelError helCreateToken(HelHandle *handle)
Create a token object.
static const uint32_t kHelSubmitBindDmaDevice
SQ opcode: bind a device to a DMA space.
Definition hel.h:912
HEL_C_LINKAGE HelError helResume(HelHandle handle)
Resume a suspended thread.
static const uint32_t kHelSubmitExchangeMsgs
SQ opcode: exchange messages on a stream.
Definition hel.h:878
static const uint32_t kHelSubmitReadMemory
SQ opcode: read memory.
Definition hel.h:888
static const int kHelNextPresent
Marks the next field as present.
Definition hel.h:944
static const int kHelKernelNotifySupplyCqChunks
Set in kernelNotify after userspace has supplied new chunks.
Definition hel.h:843
HEL_C_LINKAGE HelError helSubmitAsyncNop(HelHandle queueHandle, uintptr_t context)
Does nothing, asynchronously (useful only for profiling).
HEL_C_LINKAGE HelError helHandleIrq(HelHandle pinHandle, HelHandle *handle)
Install an IRQ handler on an IRQ pin.
HEL_C_LINKAGE HelError helStoreRegisters(HelHandle handle, int set, const void *image)
Store a register image (e.g., to a thread).
static const uint32_t kHelSubmitAwaitEvent
SQ opcode: wait for an event.
Definition hel.h:882
static const uint32_t kHelSubmitAwaitClock
SQ opcode: wait for time to pass.
Definition hel.h:880
static const uint32_t kHelSubmitPopulateSpace
SQ opcode: populate a space.
Definition hel.h:906
HEL_C_LINKAGE HelError helAlertQueue(HelHandle queueHandle)
Alerts an IPC queue.
static const uint32_t kHelSubmitActivateIommu
SQ opcode: activate translation on an IOMMU.
Definition hel.h:916
HEL_C_LINKAGE HelError helCreateStream(HelHandle *lane1, HelHandle *lane2, uint32_t attach_credentials)
Create a stream (which always consists of two lanes).
static const uint32_t kHelSubmitProtectMemory
SQ opcode: protect memory.
Definition hel.h:884
HelMapFlags
Definition hel.h:563
@ kHelMapNoDirtyTracking
Discards the mapping's dirty bits instead of scheduling the pages for writeback.
Definition hel.h:574
static const uint32_t kHelSubmitAwaitPressure
SQ opcode: wait until reclaim stalls on an allocation that blocks a hierarchy.
Definition hel.h:920
static const uint32_t kHelSubmitMapMemory
SQ opcode: map memory.
Definition hel.h:908
static const int kHelUserNotifySupplySqChunks
Set in userNotify after kernel has supplied new SQ chunks.
Definition hel.h:834
HEL_C_LINKAGE HelError helCreateIndirectMemory(size_t numSlots, HelHandle *handle)
Creates a memory object that obtains its memory by delegating to other memory objects.
HEL_C_LINKAGE HelError helGetCurrentCpu(int *cpu)
Gets the index of the cpu which the calling thread is running on.
HEL_C_LINKAGE HelError helNop()
Does nothing (useful only for profiling).
HEL_C_LINKAGE HelError helRunVirtualizedCpu(HelHandle handle, const struct HelVmexitCompletion *completion, struct HelVmexitReason *reason)
Runs a virtualized CPU until it exits to the VMM.
HEL_C_LINKAGE HelError helFutexWait(int *pointer, int expected, int64_t deadline)
Waits on a futex.
HEL_C_LINKAGE HelError helBindKernlet(HelHandle handle, const union HelKernletData *data, size_t numData, HelHandle *boundHandle)
Bind parameters to a kernlet.
static const int kHelUserNotifyCqProgress
Set in userNotify after kernel has written progress.
Definition hel.h:832
HEL_C_LINKAGE HelError helCreateSpace(HelHandle *handle)
Creates a virtual address space that threads can run in.
static const uint32_t kHelSubmitWritebackFence
SQ opcode: writeback fence.
Definition hel.h:902
HelUpdateMemoryTypes
Additional type values of helUpdateMemory(); these are never issued as manage requests.
Definition hel.h:556
@ kHelUpdateMarkDirty
Marks a range as dirty, as if it had been written through a dirty-tracked mapping.
Definition hel.h:560
HEL_C_LINKAGE HelError helCreateSequencedEvent(HelHandle *waitHandle, HelHandle *raiseHandle)
Create an event that counts how often it was raised.
static const uint32_t kHelSubmitResizeMemory
SQ opcode: resize memory.
Definition hel.h:898
HEL_C_LINKAGE HelError helCreateOneshotEvent(HelHandle *handle)
Create an event that fires at most once.
HEL_C_LINKAGE HelError helCreateSwapSpace(HelHandle hierarchy, uint32_t flags, HelHandle *backingHandle, HelHandle *swapHandle)
Creates a swap space, the backing store for swappable anonymous memory (see helAllocateSwappableMemor...
HEL_C_LINKAGE HelError helDriveQueue(HelHandle queueHandle, uint32_t flags, uint32_t notifyMask)
Drives an IPC queue.
static const uint32_t kHelSubmitLockMemoryView
SQ opcode: lock memory view.
Definition hel.h:894
HEL_C_LINKAGE HelError helCreateUniverse(HelHandle *handle)
Creates a new universe descriptor.
static const int kHelProgressDone
Set by the producer once it retires the chunk.
Definition hel.h:949
HEL_C_LINKAGE HelError helEnableIo(HelHandle handle)
Enable userspace access to hardware I/O resources.
static const uint32_t kHelHierarchyMemoryController
Gives the new hierarchy its own memory controller with the given memoryFloor.
Definition hel.h:798
HEL_C_LINKAGE HelError helCreateManagedMemory(HelHandle hierarchy, size_t size, uint32_t flags, HelHandle *backingHandle, HelHandle *frontalHandle)
Creates a memory object that is managed by userspace.
HEL_C_LINKAGE HelError helCreateKcovBuffer(size_t size, HelHandle *handle)
Creates a buffer for kernel code coverage (kcov).
static const int kHelUserNotifyError
Set in userNotify if the queue encounters a contract violation.
Definition hel.h:836
HEL_C_LINKAGE HelError helExtendHierarchy(HelHandle hierarchyHandle, const struct HelHierarchyParameters *params, HelHandle *handle)
Creates a child hierarchy capability.
HEL_C_LINKAGE HelError helCreateThread(HelHandle hierarchy, HelHandle universe, HelHandle spaceHandle, void *ip, void *sp, uint32_t flags, HelHandle *handle)
Create a new thread.
static const uint32_t kHelSubmitSetSwapRegion
SQ opcode: set the capacity of a swap region.
Definition hel.h:918
static const uint32_t kHelSubmitCancel
SQ opcode: cancel an asynchronous operation.
Definition hel.h:874
HEL_C_LINKAGE HelError helQueryHierarchy(HelHandle hierarchyHandle, struct HelHierarchyStats *stats)
Retrieves the statistics of a hierarchy node.
HEL_C_LINKAGE HelError helKickVirtualizedCpu(HelHandle handle)
Makes helRunVirtualizedCpu() return with kHelVmexitKicked as soon as possible.
HEL_C_LINKAGE HelError helAllocateMemory(HelHandle hierarchy, size_t size, uint32_t flags, const struct HelAllocRestrictions *restrictions, HelHandle *handle)
Creates a memory object consisting of unmanaged RAM.
@ kHelKcovModeCmp
Record comparisons.
Definition hel.h:1616
@ kHelKcovModePc
Record PCs.
Definition hel.h:1614
HEL_C_LINKAGE HelError helAssertVirtualizedIrq(HelHandle handle, uint64_t irq, uint8_t level)
Raises an interrupt in a virtualized CPU.
Parameters that allow userspace to compute the current time on the monotone clock (i....
Definition hel.h:495
int32_t tickShift
Scaling exponent of the tick -> nanosecond conversion.
Definition hel.h:500
uint64_t tickFactor
Factor of the tick -> nanosecond conversion.
Definition hel.h:502
uint32_t clockType
One of the kHelClock* constants.
Definition hel.h:498
Requester ID that a device issues DMA requests as (see kHelSubmitBindDmaDevice).
Definition hel.h:866
Range of physical memory that a DMA space identity-maps (see helCreateDmaSpace).
Definition hel.h:859
A single element of a HelQueue.
Definition hel.h:966
unsigned int length
Length of the element in bytes.
Definition hel.h:968
void * context
User-defined value.
Definition hel.h:972
unsigned int opcode
Operation code (for SQ elements).
Definition hel.h:970
Statistics of a hierarchy node (see helQueryHierarchy).
Definition hel.h:815
size_t stalledFloor
Memory floor of the stalled allocation, in bytes. Only valid if stalledShortfall is non-zero.
Definition hel.h:825
uint64_t stalledNanos
Time for which the stalled allocation waited without reclaim evicting memory.
Definition hel.h:828
size_t stalledShortfall
Bytes that the first waiting allocation lacks.
Definition hel.h:823
size_t chargedMemory
Physical memory that is charged to the node, in bytes.
Definition hel.h:817
size_t chargedSwap
Swap slots that are held by memory views of the node, in bytes.
Definition hel.h:819
Message address / data pair that raises an MSI (see helQueryMsiInfo).
Definition hel.h:1427
In-memory kernel/user-space queue.
Definition hel.h:923
int kernelNotify
Futex that is used to wake the kernel.
Definition hel.h:932
int userNotify
Futex that is used to wake userspace.
Definition hel.h:927
int cqFirst
Index of the first chunk of the completion queue.
Definition hel.h:936
int sqFirst
Index of the first chunk of the submission queue.
Definition hel.h:940
Register-related information returned by helQueryRegisterInfo.
Definition hel.h:627
int setSize
Size of the selected register set.
Definition hel.h:629
SQ data for kHelSubmitActivateIommu.
Definition hel.h:1198
HelHandle iommuHandle
Handle to the IOMMU (see helAccessIommu).
Definition hel.h:1200
SQ data for kHelSubmitAwaitClock.
Definition hel.h:992
uint64_t cancellationTag
Tag to cancel this operation.
Definition hel.h:996
uint64_t counter
Deadline in nanoseconds since boot.
Definition hel.h:994
SQ data for kHelSubmitAwaitEvent.
Definition hel.h:1000
HelHandle handle
Handle to the event descriptor.
Definition hel.h:1002
uint64_t cancellationTag
Tag to cancel this operation.
Definition hel.h:1006
uint64_t sequence
Previous sequence number.
Definition hel.h:1004
SQ data for kHelSubmitAwaitPressure.
Definition hel.h:1016
HelHandle hierarchyHandle
Handle to the hierarchy. Requires kHelRightManage.
Definition hel.h:1018
uint64_t cancellationTag
Tag to cancel this operation.
Definition hel.h:1022
uint64_t sequence
Previous sequence number (zero before the first report).
Definition hel.h:1020
SQ data for kHelSubmitBindDmaDevice.
Definition hel.h:1174
struct HelDmaDeviceId id
Requester ID of the device.
Definition hel.h:1181
HelHandle iommuHandle
Handle to the IOMMU (see helAccessIommu).
Definition hel.h:1176
HelHandle dmaSpaceHandle
Handle to a DMA space of that IOMMU (see helCreateDmaSpace).
Definition hel.h:1179
SQ data for kHelSubmitCancel.
Definition hel.h:976
SQ data for kHelSubmitExchangeMsgs.
Definition hel.h:982
uint32_t flags
Flags.
Definition hel.h:988
size_t count
Number of actions.
Definition hel.h:986
HelHandle lane
Handle to the lane.
Definition hel.h:984
SQ data for kHelSubmitForkMemory.
Definition hel.h:1102
HelHandle hierarchyHandle
Handle to the hierarchy object that owns the memory object.
Definition hel.h:1104
HelHandle handle
Handle to the memory object.
Definition hel.h:1106
SQ data for kHelSubmitInvalidateMemory.
Definition hel.h:1124
uint32_t flags
Flags (kHelInvalidate*).
Definition hel.h:1132
HelHandle handle
Handle to the memory object.
Definition hel.h:1126
size_t size
Size of the range.
Definition hel.h:1130
uintptr_t offset
Offset within the memory object.
Definition hel.h:1128
SQ data for kHelSubmitLockMemoryView.
Definition hel.h:1078
size_t size
Size to lock.
Definition hel.h:1084
uintptr_t offset
Offset within the memory object.
Definition hel.h:1082
HelHandle handle
Handle to the memory object.
Definition hel.h:1080
SQ data for kHelSubmitManageMemory.
Definition hel.h:1072
HelHandle handle
Handle to the memory object.
Definition hel.h:1074
SQ data for kHelSubmitMapMemory.
Definition hel.h:1146
uint32_t flags
Flags (kHelMap*).
Definition hel.h:1158
HelHandle spaceHandle
Handle to the space that the memory is mapped into.
Definition hel.h:1150
HelHandle memoryHandle
Handle to the memory object.
Definition hel.h:1148
uintptr_t offset
Offset within the memory object.
Definition hel.h:1154
void * pointer
Address to map at (depending on kHelMap*).
Definition hel.h:1152
size_t size
Size of the mapping.
Definition hel.h:1156
SQ data for kHelSubmitObserve.
Definition hel.h:1088
HelHandle handle
Handle to the thread.
Definition hel.h:1090
SQ data for kHelSubmitPopulateSpace.
Definition hel.h:1136
HelHandle handle
Handle to the memory space.
Definition hel.h:1138
uintptr_t address
Address within the memory space.
Definition hel.h:1140
size_t length
Length of the range.
Definition hel.h:1142
SQ data for kHelSubmitProtectMemory.
Definition hel.h:1026
size_t size
Size of the mapping.
Definition hel.h:1032
void * pointer
Pointer to the mapping.
Definition hel.h:1030
uint32_t flags
Protection flags.
Definition hel.h:1034
HelHandle spaceHandle
Handle to the address space.
Definition hel.h:1028
SQ data for kHelSubmitReadMemory.
Definition hel.h:1048
uintptr_t address
Address within the memory object.
Definition hel.h:1052
HelHandle handle
Handle to the memory object.
Definition hel.h:1050
size_t length
Length in bytes.
Definition hel.h:1054
void * buffer
Buffer to read into.
Definition hel.h:1056
SQ data for kHelSubmitResizeMemory.
Definition hel.h:1094
HelHandle handle
Handle to the memory object.
Definition hel.h:1096
size_t newSize
New size in bytes.
Definition hel.h:1098
SQ data for kHelSubmitSetSwapRegion.
Definition hel.h:1214
size_t numPages
New capacity of the region in pages.
Definition hel.h:1221
HelHandle swapHandle
Handle to the swap space (from helCreateSwapSpace).
Definition hel.h:1217
uint32_t region
Index of the region. Must be smaller than kHelNumSwapRegions.
Definition hel.h:1223
SQ data for kHelSubmitSynchronizeSpace.
Definition hel.h:1038
void * pointer
Pointer to the mapping.
Definition hel.h:1042
size_t size
Size of the mapping.
Definition hel.h:1044
HelHandle spaceHandle
Handle to the address space.
Definition hel.h:1040
SQ data for kHelSubmitUnbindDmaDevice.
Definition hel.h:1187
HelHandle iommuHandle
Handle to the IOMMU (see helAccessIommu).
Definition hel.h:1189
struct HelDmaDeviceId id
Requester ID of the device.
Definition hel.h:1191
SQ data for kHelSubmitUnmapMemory.
Definition hel.h:1162
size_t size
Size of the mapping.
Definition hel.h:1168
void * pointer
Pointer to the mapping.
Definition hel.h:1166
HelHandle spaceHandle
Handle to the space that the mapping is removed from.
Definition hel.h:1164
SQ data for kHelSubmitWriteMemory.
Definition hel.h:1060
HelHandle handle
Handle to the memory object.
Definition hel.h:1062
size_t length
Length in bytes.
Definition hel.h:1066
const void * buffer
Buffer to write from.
Definition hel.h:1068
uintptr_t address
Address within the memory object.
Definition hel.h:1064
SQ data for kHelSubmitWritebackFence.
Definition hel.h:1111
HelHandle handle
Handle to the memory object.
Definition hel.h:1113
size_t size
Size of the range.
Definition hel.h:1117
uintptr_t offset
Offset within the memory object.
Definition hel.h:1115