Peios Learn
Documentation

Peios

Peios Peios Kernel Universal Directory Project

Developer Tools

Trail Acta Provium clackatoo CAF GCSL Pekit

Applications

Framewright

Standards and Conventions

Standards and Conventions Peios Specifications
Peios Kernel

KMES

Single-page view · as markdown

KMES

Peios Kernel / Userspace interfaces / Native interfaces / KMES

Use these articles to understand kmes in the Peios kernel.

  • Emission and attachment syscalls
  • Generated ABI tables
  • ABI semantics and limits

Emission and attachment syscalls

Peios Kernel / Userspace interfaces / Native interfaces / KMES

KMES exposes three syscalls in the PKM syscall range (1090–1099): kmes_emit (1090) emits a single event from userspace, kmes_attach (1091) attaches the caller as a consumer of one per-CPU ring buffer, and kmes_emit_batch (1092) emits multiple events in one operation. All three follow the standard Linux convention — they return −1 and set errno on failure — and their numbers, entry struct layout, error tables, and privilege masks are collected in KMES ABI Reference.

Before KMES initialisation completes, all three syscalls fail with ENOMEM. Before KACS initialisation, the emit syscalls fail closed with EPERM, since privilege checks cannot be performed.

kmes_emit #

Emits one event. The origin class is set to 0 (userspace) unconditionally — the caller cannot choose it — and the event is written to the ring buffer of the CPU the calling thread is executing on at write time.

Privilege gate #

The caller's effective token has to hold SeAuditPrivilege, enabled; otherwise the syscall fails with EPERM. A successful gate records SeAuditPrivilege as used on the token, as a KACS standalone privilege gate; a failed gate records nothing. If recording the used state itself fails, the syscall also fails with EPERM.

Rate limiting #

Callers without enabled SeTcbPrivilege are rate limited per process by a token bucket: the refill rate and the burst capacity both equal the configured MaxEmitRatePerProcess (Self-Configuration). The bucket is allocated together with the process's KACS security state at fork, initialised to full capacity, and freed when the process's security state is released at exit. Refill is computed against the monotonic clock, so wall-clock jumps do not affect it. When MaxEmitRatePerProcess changes at runtime, the new rate and capacity take effect immediately — rates are read live on every operation — and each bucket's current token count is clamped down to the new capacity.

A token is reserved up front and refunded if the syscall subsequently fails, so validation failures cost nothing; the refund is clamped to capacity, which means a refund landing just after a rate decrease can forfeit the token. An empty bucket fails the reserve with EAGAIN, consuming nothing. Callers holding enabled SeTcbPrivilege bypass the bucket entirely, and the exemption records SeTcbPrivilege as used.

Rate state is per-process rather than per-SID: per-SID limiting would penalise unrelated services sharing a SID (LocalService, for instance). A process that forks to reset its limit is bounded by RLIMIT_NPROC.

Validation #

Validation runs in order and stops at the first failure; the errno reflects the first failing check.

  1. The privilege gate and rate reservation, above.
  2. event_type_len is nonzero — EINVAL otherwise.
  3. The declared total event size (77 + type_len + payload_len) is computed from the length fields alone, without dereferencing either userspace pointer, with overflow-checked arithmetic — overflow is EINVAL.
  4. The declared size is within MaxEventSize — ENOSPC otherwise.
  5. The declared size is within 50% of the ring capacity — ENOSPC otherwise. At this stage the check runs against the first live ring's capacity; it is repeated against the actual target CPU's ring inside the write phase, so a capacity swap racing the syscall can surface ENOSPC after all other validation has passed.
  6. The event type and payload are copied into a kernel staging buffer (EFAULT if a pointer is inaccessible, ENOMEM if allocation fails). Everything after this point — validation and the ring write — operates on the kernel copy, closing the TOCTOU window in which userspace could rewrite the payload after validation.
  7. The event type is validated as UTF-8 — EINVAL otherwise.
  8. The payload is validated as msgpack within MaxNestingDepth (Event Model) — EINVAL otherwise.

Preemption #

Validation runs with preemption enabled — the userspace copies can fault, and msgpack validation of a large payload takes microseconds. Preemption is disabled only around the ring buffer write: determining the CPU, stamping, writing, publishing write_pos, and checking need_wake. The cpu_id and identity GUIDs therefore reflect the thread's state at write time, not at syscall entry. On success the syscall returns 0 and the event is immediately visible to consumers.

kmes_emit_batch #

Emits up to 256 events in one call, sharing the privilege check, the timestamp, the identity capture, and the single write_pos publication across the batch. The 256-entry cap bounds the preemption-disabled write window to roughly 50–100 microseconds for typical event sizes.

The caller passes an array of 32-byte entry descriptors (layout in KMES ABI Reference; the descriptor padding bytes are documented as reserved-must-be-zero in the ABI header but are not validated), a count, and an emitted_out pointer.

Processing order:

  1. The SeAuditPrivilege gate, as for kmes_emit.
  2. count is within 1–256 — EINVAL otherwise.
  3. count tokens are reserved from the rate bucket in one critical section, so concurrent threads cannot both pass the check — EAGAIN if unavailable, and nothing is emitted. SeTcbPrivilege exempts as before.
  4. Zero is stored to *emitted_out before any per-entry work — EFAULT if unwritable, with nothing emitted.
  5. The descriptor array is copied from userspace (EFAULT/ENOMEM).
  6. Each entry, in order, goes through the same staging pipeline as kmes_emit — declared-size arithmetic, MaxEventSize, 50% capacity, userspace copy, UTF-8, msgpack. Staging stops at the first failing entry.
  7. The validated prefix is emitted in one preemption-disabled write phase: one timestamp, one identity capture, a sequence number per event, origin class 0 throughout, and a single deferred publication that makes the whole prefix visible atomically.
  8. Unused tokens (count minus events emitted) are refunded — only events actually emitted are charged.

On full success the syscall returns 0 and writes count to *emitted_out. If entry N fails, entries 0 through N−1 are emitted, N is written to *emitted_out, and the syscall returns −1 with the errno of the failing entry. Failed entries never consume sequence numbers, so batch validation failures leave no consumer-visible gap. The final emitted_out store is a second write to userspace; if it faults, the syscall reports EFAULT even though the prefix was already emitted.

Every staged entry is held in kernel memory simultaneously until the write phase completes, so a batch's transient allocation is bounded by count × MaxEventSize — up to 1 GB at the maximum settings — rather than by a single event.

kmes_attach #

Attaches the caller as a consumer of one per-CPU ring buffer, returning a file descriptor. The consumer contract built on this fd — the mapped region layout, the drain and notification protocols, and the re-attach protocol across buffer swaps — is specified in the PSPK event stream chapter; the TRM side of the mechanics is Ring Buffers.

The caller's effective token has to hold SeSecurityPrivilege, enabled — EPERM otherwise — and a successful gate records SeSecurityPrivilege as used. cpu_id is a logical CPU index using the same numbering as the ring metadata and event headers.

The slot array is allocated at KMES initialisation and sized by nr_cpu_ids, then filled by walking for_each_possible_cpu. Those two quantities are not the same thing: the array size bounds a valid cpu_id, while the ring count is however many of those slots got a ring. They agree only when the possible-CPU mask is dense. An index at or beyond the array size fails with EINVAL; so does an index inside it whose slot holds no live ring.

A consumer learns the array size by calling kmes_attach with cpu_id set to KMES_ATTACH_QUERY_SLOTS (0xFFFFFFFF). The call takes the same privilege gate, writes the slot count through capacity, returns 0, and opens no descriptor. Enumeration then walks 0 to slots-1 and skips the indexes that answer EINVAL.

Counting up until the first EINVAL — which is what this interface used to ask for — is wrong on a sparse mask: it stops at the first hole, and every ring above it becomes permanently unreachable, filling and overwriting with no consumer able to attach.

CPUs that were possible but offline at initialisation have rings and are attachable; hotplug beyond the initial set is not handled (Failure Modes).

On success the current ring capacity is written to *capacity — the consumer computes its mmap size as 8192 + 2 × capacity — and the fd is returned. The fd is opened O_RDWR | O_CLOEXEC and supports exactly two operations: mmap() and close(). The fd is installed before the capacity write-back; if that write faults, the fd is closed again and the syscall returns EFAULT, but another thread of the process can have observed the fd in the interim.

Repeated attaches to the same CPU are permitted and return a new fd each time; all fds for one CPU share the same ring — producer metadata, consumer metadata, and data region — so multiple direct consumers can drain one buffer concurrently, each keeping its own read position in its own memory. KMES stores no per-consumer state: the fd's private data is a reference to the ring, nothing more. When events arrive and need_wake is set, KMES increments that buffer's futex counter and wakes all waiting threads.

Generated ABI tables

Peios Kernel / Userspace interfaces / Native interfaces / KMES

Every name, value, offset and size in this appendix is generated from include/uapi/pkm/kmes.h by tools/docs/peios-reference/generators/gen-kmes-abi.py, with struct layouts measured by compiling a probe against the real header. Regenerate it whenever the ABI changes; do not edit it by hand. The names here are the ones a program actually compiles against.

What a compiler cannot measure -- the error vocabulary of each syscall, the privilege each requires by name, what the configuration keys do, and the implementation bounds that are not in the header -- is in the notes appendix, KMES ABI Notes, which this generator does not touch.

Syscall numbers #

Signatures are read from the SYSCALL_DEFINE sites in security/pkm/kmes/. The PKM UAPI exports the uppercase constants in <pkm/syscall.h>. Peios glibc 2.44-5 and later exports the standard lowercase SYS_kmes_* aliases in <sys/syscall.h>; each alias has the same number as its PKM constant.

NumberPKM constantglibc aliasSignature
1090SYS_KMES_EMITSYS_kmes_emitkmes_emit(const char __user *event_type, u16 event_type_len, const void __user *payload, u32 payload_len)
1091SYS_KMES_ATTACHSYS_kmes_attachkmes_attach(unsigned int cpu_id, u64 __user *capacity)
1092SYS_KMES_EMIT_BATCHSYS_kmes_emit_batchkmes_emit_batch(const struct kmes_emit_entry __user *entries, u32 count, u32 __user *emitted_out)

Structure layouts #

Offsets and sizes are measured, not declared.

struct kmes_emit_entry #

Total size 32 bytes.

OffsetSizeTypeField
08__u64event_type
82__u16event_type_len
106__u8[6]_pad0
168__u64payload
244__u32payload_len
284__u8[4]_pad1

Constants #

Grouped as the header groups them.

Event origin class — kmes_event_header.origin_class.

ConstantValueNotes
KMES_ORIGIN_USERSPACE0
KMES_ORIGIN_KMES1
KMES_ORIGIN_KACS2
KMES_ORIGIN_LCS3
KMES_ORIGIN_NTFE4net/ntfe: ntfe.verdict.reported, ntfe.policy.published, ntfe.policy.rejected

Ring-slot discovery.

Ring slots are indexed by logical CPU id and the array is sized by the kernel's nr_cpu_ids, so a slot inside the array holds no ring when that CPU is not possible. Counting up from 0 until SYS_KMES_ATTACH returns -EINVAL therefore stops at the first hole and misses every ring above it, leaving those CPUs' events permanently unreachable.

Call SYS_KMES_ATTACH with cpu_id KMES_ATTACH_QUERY_SLOTS to learn the slot count instead. It writes the count through the capacity argument, returns 0, and opens no descriptor. Enumerate 0 .. count-1 and treat -EINVAL as "this slot holds no ring", not as the end of the array.

The sentinel is outside the index space for good: nr_cpu_ids is bounded by CONFIG_NR_CPUS, which cannot reach 2^32-1.

ConstantValue
KMES_ATTACH_QUERY_SLOTS0xFFFFFFFF

Largest entry count a single SYS_KMES_EMIT_BATCH call accepts.

ConstantValue
KMES_BATCH_MAX_ENTRIES256

Runtime configuration registry location and keys.

Type values match the LCS REG_* constants: REG_DWORD is 4 and REG_QWORD is 11. They are repeated here so <pkm/kmes.h> remains standalone.

ConstantValue
KMES_CONFIG_ROOT_HIVE"Machine"
KMES_CONFIG_ROOT_SYSTEM_KEY"System"
KMES_CONFIG_ROOT_KMES_KEY"KMES"
KMES_CONFIG_KEY_BUFFER_CAPACITY"BufferCapacity"
KMES_CONFIG_KEY_MAX_EVENT_SIZE"MaxEventSize"
KMES_CONFIG_KEY_MAX_NESTING_DEPTH"MaxNestingDepth"
KMES_CONFIG_KEY_MAX_EMIT_RATE_PER_PROCESS"MaxEmitRatePerProcess"
KMES_CONFIG_TYPE_REG_DWORD4
KMES_CONFIG_TYPE_REG_QWORD11
KMES_CONFIG_BUFFER_CAPACITY_TYPE11
KMES_CONFIG_BUFFER_CAPACITY_DEFAULT4194304
KMES_CONFIG_BUFFER_CAPACITY_MIN65536
KMES_CONFIG_BUFFER_CAPACITY_MAX268435456
KMES_CONFIG_MAX_EVENT_SIZE_TYPE4
KMES_CONFIG_MAX_EVENT_SIZE_DEFAULT65536
KMES_CONFIG_MAX_EVENT_SIZE_MIN1024
KMES_CONFIG_MAX_EVENT_SIZE_MAX4194304
KMES_CONFIG_MAX_NESTING_DEPTH_TYPE4
KMES_CONFIG_MAX_NESTING_DEPTH_DEFAULT32
KMES_CONFIG_MAX_NESTING_DEPTH_MIN4
KMES_CONFIG_MAX_NESTING_DEPTH_MAX256
KMES_CONFIG_MAX_EMIT_RATE_PER_PROCESS_TYPE4
KMES_CONFIG_MAX_EMIT_RATE_PER_PROCESS_DEFAULT10000
KMES_CONFIG_MAX_EMIT_RATE_PER_PROCESS_MIN100
KMES_CONFIG_MAX_EMIT_RATE_PER_PROCESS_MAX1000000

Privilege requirements.

Values mirror the corresponding KACS privilege bits while keeping this header standalone.

ConstantValue
KMES_EMIT_REQUIRED_PRIVILEGE0x0000000000200000 (1ULL << 21)
KMES_ATTACH_REQUIRED_PRIVILEGE0x0000000000000100 (1ULL << 8)

On-wire event header.

Every event in a ring begins with a fixed 77-byte header, followed by event_type_len bytes of type string and then the msgpack payload. Events abut at event_size stride, so a header is not generally aligned; it crosses the ABI as raw bytes, not a C struct. Its fields, in order:

__u32  event_size            total event byte length (header + type + payload)
__u32  header_size           byte offset from the event start to the payload
__u64  timestamp_ns
__u64  sequence
__u16  cpu_id
__u8   origin_class          one of KMES_ORIGIN_* above
__u8   effective_token_guid[16]
__u8   true_token_guid[16]
__u8   process_guid[16]
__u16  event_type_len        length of the type string following the header

The three GUIDs are 16-byte Microsoft GUID binary values (Data1/Data2/Data3 little-endian, Data4 raw), captured from KACS at emission time; the null GUID (16 zero bytes) means identity was unavailable (KACS not initialised, or no process context). KMES copies them opaquely.

Read each field at its KMES_EVENT_*_OFFSET below. header_size locates the payload: it is KMES_EVENT_HEADER_BASE_SIZE + event_type_len. A future revision may grow the header, so consumers must use header_size, not the end of the type string, to find the payload.

ConstantValue
KMES_EVENT_SIZE_OFFSET0
KMES_EVENT_HEADER_SIZE_OFFSET4
KMES_EVENT_TIMESTAMP_NS_OFFSET8
KMES_EVENT_SEQUENCE_OFFSET16
KMES_EVENT_CPU_ID_OFFSET24
KMES_EVENT_ORIGIN_CLASS_OFFSET26
KMES_EVENT_EFFECTIVE_TOKEN_GUID_OFFSET27
KMES_EVENT_TRUE_TOKEN_GUID_OFFSET43
KMES_EVENT_PROCESS_GUID_OFFSET59
KMES_EVENT_TYPE_LEN_OFFSET75

Byte width of each identity GUID in the event header.

ConstantValue
KMES_EVENT_GUID_SIZE16

Byte size of the fixed event header — the offset at which the type string begins.

ConstantValue
KMES_EVENT_HEADER_BASE_SIZE77

Ring-buffer metadata layout.

An attached ring is mmap'd as:

page 0          producer metadata (read-only to the consumer)
page 1          consumer metadata (read-write)
ring data       the event bytes, mapped twice back-to-back so an event
                that wraps the buffer end is still contiguous.

The producer metadata page begins with KMES_RING_MAGIC.

ConstantValue
KMES_RING_MAGIC"KMESRING"
KMES_RING_VERSION1
KMES_METADATA_PAGE_SIZE4096
KMES_METADATA_TOTAL_SIZE8192
KMES_MAPPING_PRODUCER_OFFSET0
KMES_MAPPING_CONSUMER_OFFSET4096
KMES_MAPPING_DATA_OFFSET8192

Field offsets within the producer metadata page.

ConstantValue
KMES_PRODUCER_MAGIC_OFFSET0
KMES_PRODUCER_VERSION_OFFSET8
KMES_PRODUCER_CPU_ID_OFFSET12
KMES_PRODUCER_CAPACITY_OFFSET16
KMES_PRODUCER_DATA_OFFSET_OFFSET24
KMES_PRODUCER_GENERATION_OFFSET32
KMES_PRODUCER_WRITE_POS_OFFSET64
KMES_PRODUCER_TAIL_POS_OFFSET72
KMES_PRODUCER_FUTEX_COUNTER_OFFSET128

Field offset within the consumer metadata page.

ConstantValue
KMES_CONSUMER_NEED_WAKE_OFFSET0

Tracepoint diagnostic codes #

From uapi/pkm/trace.h. These are a diagnostic contract for ftrace, perf and eBPF consumers, letting a tool decode a kmes: event's reason, op or state field without recompiling against a specific kernel. No KMES syscall accepts or returns them, and values are append-only.

kmes_drop reason — why the KMES ring machinery lost an event.

RING_FULL is a normal overwrite; TAIL_RESYNC is the silent corruption- recovery path that discards ALL pending events; VALIDATE is a kernel- emit size/type reject at the ring boundary; BATCH_STRUCT_INVALID is a per-entry structural reject in the kernel batch path. Emitted by kmes:kmes_drop. No event payload bytes.

ConstantValueNotes
KMES_DROP_RING_FULL0capacity overwrite; oldest event dropped
KMES_DROP_TAIL_RESYNC1corrupt ring header; pending events silently discarded
KMES_DROP_VALIDATE2single kernel-emit size/type reject
KMES_DROP_BATCH_STRUCT_INVALID3kernel-batch entry structurally invalid

kmes_swap reason — a bounded ring capacity swap lifecycle marker.

BEGIN and COMPLETE/FAILED are whole-topology (cpu field is U16_MAX); MIGRATE_SKIP is per-CPU and carries the skipped byte count in ret. Emitted by kmes:kmes_swap.

ConstantValueNotes
KMES_SWAP_BEGIN0capacity change accepted, rings allocating
KMES_SWAP_COMPLETE1swap committed across all CPUs
KMES_SWAP_MIGRATE_SKIP2shrink: old event too large, skipped (ret=bytes)
KMES_SWAP_FAILED3swap aborted; ret is the errno

kmes_rate reason — the per-process token-bucket backpressure signal.

THROTTLE is an -EAGAIN emit rejection; RECONFIGURE marks an admin rate change clamping all buckets. Emitted by kmes:kmes_rate.

ConstantValueNotes
KMES_RATE_THROTTLE0emit denied -EAGAIN; tokens < requested
KMES_RATE_RECONFIGURE1max emit rate reconfigured for all buckets

kmes_wake reason — consumer wakeup machinery.

NOTE arms a pending wake; FUTEX is the actual futex wake of blocked consumers. Emitted by kmes:kmes_wake.

ConstantValueNotes
KMES_WAKE_NOTE0wake armed; futex counter incremented
KMES_WAKE_FUTEX1blocked consumers woken

kmes_ring_lifecycle reason — a generation-stable ring object transition.

ret is the outcome. Emitted by kmes:kmes_ring_lifecycle.

ConstantValueNotes
KMES_RING_ALLOC0ring backing allocated (or -ENOMEM)
KMES_RING_FREE1ring backing released
KMES_RING_PRODUCER_PAGE2producer shmem/meta page attached
KMES_RING_CONSUMER_FD3consumer anon-inode fd created

kmes_ingress_reject reason — why an emit request was rejected before the ring.

OVER_MAX/OVER_CAP_HALF/SIZE_OVERFLOW are declared-size rejects; EMIT_OVERSIZE is a staged event too large at ring-write time; BATCH_PARTIAL marks a batch that validated fewer entries than requested. Emitted by kmes:kmes_ingress_reject.

ConstantValueNotes
KMES_INGRESS_OVER_MAX0event_size exceeds configured max_event_size
KMES_INGRESS_OVER_CAP_HALF1event_size exceeds ring_capacity/2
KMES_INGRESS_SIZE_OVERFLOW2declared header/event size overflow
KMES_INGRESS_EMIT_OVERSIZE3staged event exceeds live capacity/2 at emit
KMES_INGRESS_BATCH_PARTIAL4batch staged fewer entries than requested

kmes_validate reason — the C-boundary result of the Rust staged-event validator.

The Rust side collapses its structural checks into one nonzero return; only visible type/payload lengths and ret are recorded here. Emitted by kmes:kmes_validate.

ConstantValueNotes
KMES_VAL_EINVAL0Rust msgpack/structural validation rejected

ABI semantics and limits

Peios Kernel / Userspace interfaces / Native interfaces / KMES

KMES ABI Reference is generated from include/uapi/pkm/kmes.h and holds only what a compiler can measure. This appendix holds the rest.

The split is structural rather than editorial. gen-kmes-abi.py overwrites KMES ABI Reference wholesale on every run, so anything written there is lost the next time the ABI changes.

Layouts that form part of the consumer contract — the event header, the producer and consumer metadata pages, and the mapped region — are specified normatively in the PSPK event stream specification. KMES ABI Reference gives their offsets as the header defines them; the specification governs.

Syscall parameters #

SyscallParameterTypeMeaning
kmes_emitevent_typeconst char *Event type string.
event_type_lenu16Its length in bytes.
payloadconst void *MessagePack payload.
payload_lenu32Its length in bytes.
kmes_emit_batchentriesstruct kmes_emit_entry *Array of event descriptors.
countu32Number of entries, 1 to KMES_BATCH_MAX_ENTRIES.
emitted_outu32 *Receives the number of events emitted.
kmes_attachcpu_idunsigned intRing slot index, or KMES_ATTACH_QUERY_SLOTS to query the slot count.
capacityu64 *Receives the ring buffer capacity in bytes.

kmes_emit and kmes_emit_batch return 0 on success; kmes_attach returns a file descriptor. All three return -1 and set errno on failure.

The PKM syscall range is 1090–1099; KMES uses the first three.

Privilege requirements #

kmes.h gives these as bit masks so it can stand alone. The names belong to the KACS privilege catalogue, and the bit index is what the two agree on.

OperationRequired privilegeBit
kmes_emit, kmes_emit_batchSeAuditPrivilege21
Rate-limit exemption on bothSeTcbPrivilege7
kmes_attachSeSecurityPrivilege8

Holding a privilege is not enough: it must be enabled, and KMES marks it used before proceeding. A failure to record the used state is itself an EPERM, because an unrecorded privilege use is an audit gap.

SeTcbPrivilege is checked but not required — an emitter that holds it enabled is exempt from the per-process rate limit, and one that does not is throttled.

Implementation bounds #

These are properties of the implementation rather than of the ABI, so they are not in kmes.h and a program must not compile against them. They bound what the interface will accept.

QuantityValueWhere
Maximum event size, structural50% of ring capacitysecurity/pkm/kmes/kmes.c
MessagePack validator nesting stack256security/pkm/kmes/kmes_validate.rs
Self-configuration payload buffer768 bytessecurity/pkm/kmes/kmes.c
Self-configuration audit intents per read4security/pkm/kmes/kmes.h
Self-configuration parameter name64 bytessecurity/pkm/kmes/kmes.h

The structural 50% bound is independent of MaxEventSize and applies to kernel emitters too. An event may satisfy the configured maximum and still be refused because the ring is small.

The validator's 256-frame stack is why MaxNestingDepth has a maximum of 256. The two bounds are enforced independently: the configuration range check refuses a larger value at apply time, and the validator refuses every event outright if it is somehow handed one, rather than silently accepting nesting it cannot track.

Error codes #

kmes_emit #

ErrnoCondition
EPERMSeAuditPrivilege not held or not enabled, or recording its used state failed.
EAGAINPer-process rate limit exceeded.
EINVALZero event type length, event type not valid UTF-8, declared size arithmetic overflowed, payload not valid msgpack, or nesting depth over MaxNestingDepth.
EFAULTEvent type or payload pointer inaccessible.
ENOSPCEvent exceeds MaxEventSize or 50% of ring capacity.
ENOMEMStaging buffer allocation failed, or KMES not initialised.

kmes_emit_batch #

ErrnoCondition
EPERMAs kmes_emit.
EAGAINFewer than count tokens available.
EINVALcount is 0 or over KMES_BATCH_MAX_ENTRIES, or the failing entry hit one of kmes_emit's EINVAL conditions.
EFAULTemitted_out, the entry array, or the failing entry's type or payload pointer inaccessible.
ENOSPCThe failing entry exceeds MaxEventSize or 50% of ring capacity.
ENOMEMKernel allocation failed, or KMES not initialised.

kmes_attach #

ErrnoCondition
EPERMSeSecurityPrivilege not held or not enabled, or recording its used state failed.
EINVALcpu_id at or beyond the ring array size, or its slot holds no live ring.
EFAULTcapacity pointer inaccessible.
ENOMEMKernel allocation failed, or KMES not initialised.

A KMES_ATTACH_QUERY_SLOTS call takes the same EPERM, EFAULT and ENOMEM conditions and cannot return EINVAL.

The ring array is sized by nr_cpu_ids, not by the number of rings allocated. On a machine with a sparse possible-CPU mask the two differ, and a slot inside the array with no live ring returns EINVAL exactly as an index beyond the array does. A consumer therefore enumerates against the slot count from KMES_ATTACH_QUERY_SLOTS and skips the EINVAL slots rather than stopping at the first one; see Syscall Interface.

Peios Learn — documentation for Peios software.

Built with Trail.