Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/native/kernel/core/osc_task.h # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / native / kernel / core / osc_task.h` 82 lines ยท 4719 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 2 * Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 /* osc_task.h -- launch an admitted OSC unit as an EL0 task (OSC_UNIT_ARTIFACT.md section 9), C3-3a. 18 * Admission (osc_admit.c) never maps anything; this does, for one function call at a time. QEMU only: 19 * nothing here is physical. See docs/osc-launch.md. */ 20 #ifndef AIENOS_CK_OSC_TASK_H 21 #define AIENOS_CK_OSC_TASK_H 22 #include 23 #include 24 #include "osc_launch.h" 25 #include "osc_receipt.h" 26 #include "osc_unit.h" 27 28 #define CK_OSC_PAGE 4096u 29 #define CK_OSC_CODE_MAX_BYTES (16u * CK_OSC_PAGE) /* launcher hard maximum (stricter than the spec's 262144) */ 30 #define CK_OSC_STACK_MAX_BYTES (16u * CK_OSC_PAGE) /* a unit declaring more is refused RESOURCE_UNAVAILABLE */ 31 #define CK_OSC_IN_MAX_BYTES CK_OSC_PAGE 32 33 /* A caller-owned workspace for `cells` arguments: `pages` 4 KiB pages of page-aligned caller memory starting at 34 * `mem`, 0 to OSC_WS_MAX_PAGES (0 = no workspace). It is mapped read-write (never executable) into the task for the 35 * call and is NOT cleared by teardown: state a unit leaves in it is there for the next call that is given the same 36 * workspace. A workspace over the cap, or with unaligned or null memory, is refused 30 before the first instruction. */ 37 /* A workspace is mapped read-write (never executable) into EL0 as it is, so it MUST be memory the caller owns 38 * and nothing else uses: page aligned, not null, not overlapping the launcher's own state or the input buffer 39 * (refused 30, nothing mapped). The kernel has no region it restricts workspaces to, so beyond those checks it 40 * trusts the caller. It is not cleared at teardown. */ 41 struct ck_osc_ws { 42 uint8_t *mem; 43 uint32_t pages; 44 }; 45 46 struct ck_osc_launch_req { 47 const char *name; /* exact function name (osc_unit_lookup) */ 48 size_t name_len; 49 unsigned nargs; 50 uint64_t args[6]; /* a bytes slice is (ck_osc_va_in() + k, len), a cells slice (ck_osc_va_ws() + k, n) */ 51 const uint8_t *in; /* read-only input, copied to the task's input window; at most CK_OSC_IN_MAX_BYTES */ 52 size_t in_len; 53 struct ck_osc_ws *ws; /* caller-owned workspace, or NULL */ 54 uint64_t max_ticks; /* caller cap on the budget, 0 = the unit's declared cpu_ticks only */ 55 }; 56 57 struct ck_osc_launch_info { 58 struct osc_receipt_info rcpt; /* what the receipt check saw (id, class, epochs, which revocation); diagnostic */ 59 uint64_t budget; /* ticks granted */ 60 unsigned pages_mapped; /* user pages that were mapped while the task existed */ 61 int tables_zeroed; /* after teardown every page-table entry of the task is zero and its L0 slot is clear (says nothing about frame contents) */ 62 int slot_free_after; /* the task slot is reusable */ 63 }; 64 65 /* Unit-space addresses of the input window and the workspace window (the same for every launch). 0 if the 66 * kernel has no free address-space slot to build them in. */ 67 uint64_t ck_osc_va_in(void); 68 uint64_t ck_osc_va_ws(void); 69 70 /* Launch the function rq->name of the accepted unit (bytes `unit`, verdict *a from osc_unit_admit on the 71 * same bytes) and wait for it. *res is always filled. A launch needs a realization receipt (`rcpt`, `rcpt_len`; 72 * omega receipt v1, artifact/osc_receipt.h, aienos#383): it is verified FIRST, against *a and the kernel policy 73 * (ck_osc_policy), and a missing or refused receipt is REFUSED with its named reason (64 RECEIPT_MISSING, 65..88 74 * RECEIPT_*) before anything else. The receipt grants nothing: entry, arguments, resources and grants are 75 * checked as before. Refusals (64..88 receipt, 40 unknown name, 41 argument shape or range, 30 resources, 76 * 14 limits, 16 code hash) mean no unit instruction ran and nothing was mapped. */ 77 void ck_osc_launch(const uint8_t *unit, size_t unit_len, const struct osc_accept *a, const uint8_t *rcpt, 78 size_t rcpt_len, const struct ck_osc_launch_req *rq, struct osc_result *res, struct ck_osc_launch_info *info); 79 80 /* "RETURNED value=..", "TRAPPED trap_code=..", "OUTCOME_UNKNOWN reason=..", "REFUSED code=.." */ 81 int ck_osc_result_str(const struct osc_result *r, char *buf, size_t n); 82 #endif