interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / native / kernel / svc / store_crash.h

60 lines · 2952 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/* store_crash.h -- TEST-ONLY Store crash hook for the C kernel QEMU gate
18 * M4_STORE_CRASH (scripts/qemu_ck_store_crash_test.sh).
19 *
20 * Compiled only into the TEST image "make full CK_TEST_STORE_CRASH=1"
21 * ($(OUT)/full-test-store-crash/). The Makefile and store_crash.c refuse it
22 * together with CK_HARDWARE_STAGING or CK_QEMU_UNSAFE_DMA, and every default
23 * full image is checked to carry none of its code or strings. Such an image
24 * announces itself on the console and never counts toward a PASS of M4_STORE.
25 *
26 * Crash plan. The host writes one ASCII line into the last 4096-byte unit of
27 * the NVMe disk (the scratch unit of the devices-stage rw probe, which the
28 * probe restores byte for byte, dev/nvme_bind.c ck_disk_rw_probe):
29 * AIENCRSH v1 cp=<checkpoint> policy=<drop|all|newest|torn>\n
30 * checkpoint: a native/store st_checkpoint_name() name, or before_anchor /
31 * after_anchor (store_sealed.h SS_CP_*).
32 *
33 * With a valid plan the Store stage runs on a volatile write cache wrapped
34 * around the boot disk: writes stay in RAM until the Store flushes, reads see
35 * them. At the planned checkpoint the hook models a power cut: per the policy
36 * none (drop), all (all, = a QEMU process kill), only the newest write call
37 * (newest, a device that reordered) or the first half of the blocks of the
38 * newest write call (torn) of the unflushed writes reach the disk, the disk is
39 * flushed, "store_crash: HALT at ..." is printed and the CPU stops forever. The
40 * host then kills QEMU. Without a plan the Store runs on the disk directly. */
41#ifndef AIENOS_CK_STORE_CRASH_H
42#define AIENOS_CK_STORE_CRASH_H
43#include <stdint.h>
44#include "disk.h"
45
46#ifdef CK_TEST_STORE_CRASH
47#define CK_STORE_CRASH_POLICY_DROP 0
48#define CK_STORE_CRASH_POLICY_ALL 1
49#define CK_STORE_CRASH_POLICY_NEWEST 2
50#define CK_STORE_CRASH_POLICY_TORN 3
51
52/* Prints the TEST-ONLY banner, reads the plan from the last unit of d.
53 * Returns the disk the Store must use: d without a plan, else the cache. */
54const disk_dev *ck_store_crash_setup(const disk_dev *d);
55/* Generation the Store opened at (printed on every checkpoint line). */
56void ck_store_crash_opened(uint64_t generation);
57/* st_hook: prints every checkpoint; halts at the planned one. */
58void ck_store_crash_hook(void *arg, int checkpoint);
59#endif
60#endif