aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / native / argus / argus_detect.h
| 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 | /* |
| 18 | * argus_detect.h -- internals of the ARGUS-0 hard-invariant detectors (lane E). |
| 19 | * |
| 20 | * The public entry points (argus_hard_detectors, argus_hard_detector_count, |
| 21 | * argus_detect_run) are declared in argus_abi.h. This header only mirrors the |
| 22 | * few authority constants the detectors compare against, so that |
| 23 | * argus_detect.c stays freestanding and does not include or link the |
| 24 | * authority. tests/test_argus_detect.c includes the real |
| 25 | * ../capability/aienos_capability.h and asserts each mirror is equal. |
| 26 | * |
| 27 | * ARGUS never re-validates a capability. These values are only used to read |
| 28 | * the result code the producer copied from the authority into ev->code, and |
| 29 | * the rights mask the producer copied into a GRANTED event. |
| 30 | */ |
| 31 | #ifndef ARGUS_DETECT_H |
| 32 | #define ARGUS_DETECT_H |
| 33 | #include "argus_abi.h" |
| 34 | |
| 35 | /* Mirrors of native/capability/aienos_capability.h (checked by the tests). */ |
| 36 | #define ARGUS_AUTH_OK 0 |
| 37 | #define ARGUS_AUTH_ERR_BOUNDS (-1) |
| 38 | #define ARGUS_AUTH_ERR_STALE_GEN (-2) |
| 39 | #define ARGUS_AUTH_ERR_REVOKED (-3) |
| 40 | #define ARGUS_AUTH_ERR_CHAIN (-9) |
| 41 | #define ARGUS_AUTH_RIGHT_WRITE 0x2u |
| 42 | #define ARGUS_AUTH_RIGHT_EFFECT 0x4u |
| 43 | |
| 44 | /* Number of detectors in argus_hard_detectors: ids 1..10, 14, 15, in id order. |
| 45 | * Codes 11, 12, 13 and 16 are raised by the core, never by a detector. */ |
| 46 | #define ARGUS_HARD_DETECTOR_COUNT 12u |
| 47 | |
| 48 | /* Upper bound on findings argus_detect_run can emit for one event: one per |
| 49 | * detector, except QUARANTINED_USE, which can emit two (provider + machine). |
| 50 | * A caller that passes cap >= ARGUS_DETECT_MAX_FINDINGS never sees |
| 51 | * ARGUS_ERR_OVERFLOW. */ |
| 52 | #define ARGUS_DETECT_MAX_FINDINGS 13u |
| 53 | |
| 54 | /* Machine trust rank (argus_abi.h machine lifecycle): lower is more trusted. |
| 55 | * TRUSTED 0 < OBSERVED 1 < REATTESTATION_REQUIRED 2 < RESTRICTED 3 < |
| 56 | * QUARANTINED 4 < UNTRUSTED 5. Returns -1 for values outside 1..6 |
| 57 | * (UNKNOWN or garbage), which callers treat as "no claim". */ |
| 58 | static inline int argus_trust_rank(uint32_t trust) |
| 59 | { |
| 60 | switch (trust) { |
| 61 | case ARGUS_TRUST_TRUSTED: return 0; |
| 62 | case ARGUS_TRUST_OBSERVED: return 1; |
| 63 | case ARGUS_TRUST_REATTESTATION_REQUIRED: return 2; |
| 64 | case ARGUS_TRUST_RESTRICTED: return 3; |
| 65 | case ARGUS_TRUST_QUARANTINED: return 4; |
| 66 | case ARGUS_TRUST_UNTRUSTED: return 5; |
| 67 | default: return -1; |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | #endif /* ARGUS_DETECT_H */ |