14#define HEL_C_LINKAGE extern "C"
27 kHelCallSubmitAsyncNop = 3,
29 kHelCallCreateUniverse = 62,
30 kHelCallTransferDescriptor = 66,
31 kHelCallDescriptorInfo = 32,
32 kHelCallGetCredentials = 84,
33 kHelCallCloseDescriptor = 21,
34 kHelCallObtainHandle = 4,
36 kHelCallCreateQueue = 89,
37 kHelCallDriveQueue = 105,
38 kHelCallAlertQueue = 106,
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,
71 kHelCallAccessIommu = 13,
73 kHelCallCreateThread = 67,
74 kHelCallQueryThreadStats = 95,
75 kHelCallSetPriority = 85,
77 kHelCallSubmitObserve = 74,
78 kHelCallKillThread = 87,
79 kHelCallInterruptThread = 86,
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,
97 kHelCallCreateStream = 68,
98 kHelCallSubmitAsync = 79,
99 kHelCallShutdownLane = 91,
101 kHelCallFutexWait = 73,
102 kHelCallFutexWake = 71,
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,
115 kHelCallAccessIo = 11,
116 kHelCallEnableIo = 12,
118 kHelCallBindKernlet = 93,
120 kHelCallGetAffinity = 103,
121 kHelCallSetAffinity = 100,
123 kHelCallCreateToken = 104,
125 kHelCallExtendHierarchy = 7,
126 kHelCallQueryHierarchy = 8,
128 kHelCallSuper = 0x80000000
133 kHelErrBufferTooSmall = 1,
134 kHelErrBadDescriptor = 2,
136 kHelErrNoDescriptor = 4,
137 kHelErrIllegalSyscall = 5,
138 kHelErrIllegalObject = 6,
139 kHelErrIllegalArgs = 7,
140 kHelErrLaneShutdown = 8,
141 kHelErrEndOfLane = 9,
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,
157 kHelErrFutexRace = 25,
158 kHelErrBadRights = 26,
161typedef uint32_t HelRights;
167static const HelRights kHelRightNull = 0;
176static const HelRights kHelRightGrant = UINT32_C(1) << 0;
180static const HelRights kHelRightTake = UINT32_C(1) << 1;
197static const HelRights kHelRightRead = UINT32_C(1) << 2;
213static const HelRights kHelRightWrite = UINT32_C(1) << 3;
217static const HelRights kHelRightExecute = UINT32_C(1) << 4;
222static const HelRights kHelRightInvoke = UINT32_C(1) << 5;
240static const HelRights kHelRightAssign = UINT32_C(1) << 6;
244static const HelRights kHelRightDerive = UINT32_C(1) << 7;
252static const HelRights kHelRightProvision = UINT32_C(1) << 8;
255static const HelRights kHelRightPin = UINT32_C(1) << 9;
258static const HelRights kHelRightFence = UINT32_C(1) << 10;
265static const HelRights kHelRightWait = UINT32_C(1) << 11;
274static const HelRights kHelRightSignal = UINT32_C(1) << 12;
288static const HelRights kHelRightManage = UINT32_C(1) << 13;
290static const HelRights kHelRightsMax = ~UINT32_C(0);
292struct HelX86SegmentRegister {
296 uint8_t type, present, dpl, db, s, l, g, avl;
301struct HelX86DescriptorTable {
306struct HelX86VirtualizationRegs {
327 struct HelX86SegmentRegister cs, ds, es, fs, gs, ss;
328 struct HelX86SegmentRegister tr, ldt;
329 struct HelX86DescriptorTable gdt, idt;
331 uint64_t cr0, cr2, cr3, cr4, cr8;
337struct HelX86VirtualizationBasicRegs {
359struct HelX86VirtualizationMsrs {
360 uint64_t kernelGsBase;
366 uint64_t sysenterEsp;
367 uint64_t sysenterEip;
371struct HelRiscv64VirtualizationRegs {
427#if defined(__riscv) && __riscv_xlen == 64
428typedef struct HelRiscv64VirtualizationRegs HelVirtualizationRegs;
430typedef struct HelX86VirtualizationRegs HelVirtualizationRegs;
435 kHelThisUniverse = -1,
440 kHelWaitInfinite = -1
445 kHelActionDismiss = 11,
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
460 kHelItemAncillary = 2,
461 kHelItemWantLane = (1 << 16),
464static const uint32_t kHelTransferDescriptorOut = UINT32_C(1) << 0;
465static const uint32_t kHelTransferDescriptorIn = UINT32_C(1) << 1;
468 kHelObtainZeroMemory = 1,
469 kHelObtainClockPage = 2
533struct HelDescriptorInfo {
538 kHelAllocContinuous = 4,
539 kHelAllocOnDemand = 1,
542struct HelAllocRestrictions {
546enum HelManagedFlags {
547 kHelManagedReadahead = 1
550enum HelManageRequests {
551 kHelManageInitialize = 1,
552 kHelManageWriteback = 2
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,
578 kHelSliceCacheWriteCombine = 1,
582 kHelCachingDefault = 0,
583 kHelCachingUncached = 1,
584 kHelCachingWriteCombine = 2,
585 kHelCachingWriteThrough = 3,
586 kHelCachingWriteBack = 4,
588 kHelCachingMmioNonPosted = 6
592 kHelThreadStopped = 1
597 kHelObserveInterrupt = 4,
598 kHelObservePanic = 3,
599 kHelObserveBreakpoint = 1,
600 kHelObservePageFault = 2,
601 kHelObserveGeneralFault = 5,
602 kHelObserveIllegalInstruction = 6,
603 kHelObserveDivByZero = 7,
604 kHelObserveSuperCall = 0x80000000
607enum HelRegisterSets {
612 kHelRegsVirtualization = 5,
615 kHelRegsPageFault = 8,
616 kHelRegsVirtualizationBasic = 9,
617 kHelRegsVirtualizationMsrs = 10
620enum HelPageFaultFlags {
621 kHelPageFaultMapError = 1,
622 kHelPageFaultAccessError = 2,
623 kHelPageFaultOutOfMemory = 3
632#if defined(__x86_64__)
633enum HelRegisterIndex {
657 kHelRegNumber = kHelRegRdi,
658 kHelRegError = kHelRegRdi,
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,
670 kHelRegOut0 = kHelRegRsi,
671 kHelRegOut1 = kHelRegRdx,
672 kHelRegOut2 = kHelRegRax
675#elif defined(__aarch64__)
676enum HelRegisterIndex {
716 kHelRegNumber = kHelRegX0,
717 kHelRegError = kHelRegX0,
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,
729 kHelRegOut0 = kHelRegX1,
730 kHelRegOut1 = kHelRegX2,
731 kHelRegOut2 = kHelRegX3
734#elif defined(__riscv) && __riscv_xlen == 64
735enum HelRegisterIndex {
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,
783 kHelRegOut0 = kHelRegA1,
784 kHelRegOut1 = kHelRegA2,
785 kHelRegOut2 = kHelRegA3
790struct HelQueueParameters {
792 unsigned int numChunks;
794 unsigned int numSqChunks;
800struct HelHierarchyParameters {
805 uint32_t controllers;
849 kHelAccessIommuIntelVtd = 1,
850 kHelAccessIommuAmdVi = 2,
854 kHelDmaRegionRead = 1,
855 kHelDmaRegionWrite = 2,
977 uint64_t cancellationTag;
1226struct HelSimpleResult {
1231struct HelCredentialsResult {
1234 char credentials[16];
1237struct HelManageResult {
1244struct HelObserveResult {
1246 unsigned int observation;
1249struct HelInlineResult {
1256struct HelInlineResultNoFlex {
1262struct HelLengthResult {
1268struct HelHandleResult {
1274struct HelPointerResult {
1280struct HelEventResult {
1286struct HelPressureResult {
1294 kHelAckAcknowledge = 2,
1297 kHelAckClear = 0x100,
1300union HelKernletData {
1304struct HelThreadStats {
1314 kHelVmexitTranslationFault = 1,
1317 kHelVmexitHyperCall = 2,
1318 kHelVmexitInstructionTrap = 3,
1319 kHelVmexitKicked = 4,
1329 kHelVmexitCpuid = 6,
1332 kHelVmexitRdmsr = 7,
1334 kHelVmexitWrmsr = 8,
1336 kHelVmexitShutdown = 9,
1341 kHelVmexitError = -1,
1343 kHelVmexitUnknownPlatformSpecificExitCode = -2,
1347 kHelVmexitIoIn = 1 << 0,
1348 kHelVmexitIoString = 1 << 1,
1352 kHelVmexitCompletionDone = 0,
1353 kHelVmexitCompletionFault = 1,
1356struct HelVmexitCompletion {
1363 kHelVmFaultRead = 1 << 0,
1364 kHelVmFaultWrite = 1 << 1,
1365 kHelVmFaultExecute = 1 << 2,
1368#if defined(__riscv) && __riscv_xlen == 64
1370struct HelVmexitReason {
1371 uint32_t exitReason;
1374 uint64_t instruction;
1381struct HelVmexitReason {
1382 uint32_t exitReason;
1392enum HelLogSeverity {
1393 kHelLogSeverityEmergency,
1394 kHelLogSeverityAlert,
1395 kHelLogSeverityCritical,
1396 kHelLogSeverityError,
1397 kHelLogSeverityWarning,
1398 kHelLogSeverityNotice,
1399 kHelLogSeverityInfo,
1400 kHelLogSeverityDebug,
1404 kHelAccessIrqByGsi = 1,
1405 kHelAccessIrqByPhandle = 2,
1406 kHelAccessIrqAllocateMsi = 3,
1411 kHelIrqNameSize = 32,
1415 kHelIrqTriggerNull = 0,
1416 kHelIrqTriggerEdge = 1,
1417 kHelIrqTriggerLevel = 2
1421 kHelIrqPolarityNull = 0,
1422 kHelIrqPolarityHigh = 1,
1423 kHelIrqPolarityLow = 2
1435 kHelPageSize = 1 << kHelPageShift
1448HEL_C_LINKAGE HelError
helLog(
const enum HelLogSeverity severity,
const char *
string,
size_t length);
1455HEL_C_LINKAGE
void helPanic(
const char *
string,
size_t length)
1456 __attribute__ (( noreturn ));
1478 const struct HelHierarchyParameters *params, HelHandle *handle);
1504HEL_C_LINKAGE HelError
1506 uint32_t flags, uint32_t exposedRights, uint32_t requiredRights, HelHandle *outHandle);
1508HEL_C_LINKAGE HelError helDescriptorInfo(HelHandle handle,
struct HelDescriptorInfo *info);
1561HEL_C_LINKAGE HelError
helDriveQueue(HelHandle queueHandle, uint32_t flags, uint32_t notifyMask);
1589 const struct HelAllocRestrictions *restrictions, HelHandle *handle);
1654 HelHandle *backingHandle, HelHandle *frontalHandle);
1678 HelHandle *backingHandle, HelHandle *swapHandle);
1696 size_t size, uint32_t flags, HelHandle *handle);
1717HEL_C_LINKAGE HelError
helCopyOnWrite(HelHandle hierarchy, HelHandle swapSpace, HelHandle memory,
1718 uintptr_t offset,
size_t size, HelHandle *handle);
1720HEL_C_LINKAGE HelError helAccessPhysical(
1721 HelHandle accessToken, uintptr_t physical,
size_t size, uint32_t cachingMode, HelHandle *handle
1748 HelHandle memoryHandle, uintptr_t offset,
size_t size);
1750HEL_C_LINKAGE HelError helCreateSliceView(HelHandle bundle, uintptr_t offset,
size_t size,
1751 uint32_t flags, HelHandle *handle);
1776HEL_C_LINKAGE HelError
helAccessIommu(HelHandle accessHandle, uint32_t mode, uint64_t base,
1800 uint32_t flags, HelHandle *handle);
1819HEL_C_LINKAGE HelError
helMapMemory(HelHandle memoryHandle, HelHandle spaceHandle,
1820 void *pointer, uintptr_t offset,
size_t size, uint32_t flags,
void **actualPointer);
1833HEL_C_LINKAGE HelError
helUnmapMemory(HelHandle spaceHandle,
void *pointer,
size_t size);
1835HEL_C_LINKAGE HelError helPointerPhysical(HelHandle spaceHandle,
const void *pointer, uintptr_t *physical);
1837HEL_C_LINKAGE HelError helMemoryInfo(HelHandle handle,
1840HEL_C_LINKAGE HelError helUpdateMemory(HelHandle handle,
int type, uintptr_t offset,
size_t length);
1852HEL_C_LINKAGE HelError
helLoadahead(HelHandle handle, uintptr_t offset,
size_t length);
1854HEL_C_LINKAGE HelError helCreateVirtualizedSpace(HelHandle *handle);
1875 HelHandle spaceHandle,
void *ip,
void *sp, uint32_t flags, HelHandle *handle);
1943HEL_C_LINKAGE HelError helWriteFsBase(
void *pointer);
1945HEL_C_LINKAGE HelError helReadFsBase(
void **pointer);
1947HEL_C_LINKAGE HelError helWriteGsBase(
void *pointer);
1949HEL_C_LINKAGE HelError helReadGsBase(
void **pointer);
1989 const struct HelVmexitCompletion *completion,
struct HelVmexitReason *reason);
2011HEL_C_LINKAGE HelError helGetRandomBytes(
void *buffer,
size_t wantedSize,
size_t *actualSize);
2022HEL_C_LINKAGE HelError
helGetAffinity(HelHandle handle, uint8_t *mask,
size_t size,
size_t *actualSize);
2045HEL_C_LINKAGE HelError
helCreateStream(HelHandle *lane1, HelHandle *lane2, uint32_t attach_credentials);
2047HEL_C_LINKAGE HelError helShutdownLane(HelHandle handle);
2070HEL_C_LINKAGE HelError
helFutexWait(
int *pointer,
int expected, int64_t deadline);
2132 HelHandle accessHandle, uint32_t mode, uint64_t controller, uint64_t index,
2133 const char *name, HelHandle *handle
2141HEL_C_LINKAGE HelError
helHandleIrq(HelHandle pinHandle, HelHandle *handle);
2154HEL_C_LINKAGE HelError
helConfigureIrq(HelHandle pinHandle, uint32_t trigger, uint32_t polarity);
2164HEL_C_LINKAGE HelError helAcknowledgeIrq(HelHandle handle, uint32_t flags, uint64_t sequence);
2166HEL_C_LINKAGE HelError helAutomateIrq(HelHandle handle, uint32_t flags, HelHandle kernlet);
2172HEL_C_LINKAGE HelError helAccessIo(
2173 HelHandle accessToken,
const uintptr_t *portArray,
size_t numPorts, HelHandle *handle
2195 const union HelKernletData *data,
size_t numData, HelHandle *boundHandle);
2199extern inline __attribute__ (( always_inline ))
const char *_helErrorString(HelError code) {
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";
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:
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";
2248extern inline __attribute__ (( always_inline ))
void _helCheckFailed(HelError err_code,
2249 const char *
string,
int fatal) {
2250 helLog(kHelLogSeverityError,
string, strlen(
string));
2252 const char *err_string = _helErrorString(err_code);
2254 err_string =
"(Unexpected error code)";
2255 helLog(kHelLogSeverityError, err_string, strlen(err_string));
2256 helLog(kHelLogSeverityError,
"\n", 1);
2262#define HEL_STRINGIFY_AUX(x) #x
2263#define HEL_STRINGIFY(x) HEL_STRINGIFY_AUX(x)
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)
@ 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