Skip to main content

cpu_local/
error.rs

1/// Failure to construct, install, or observe CPU-local state.
2#[derive(Clone, Copy, Debug, Eq, PartialEq, thiserror::Error)]
3pub enum CpuLocalError {
4    /// No runtime CPU area has been installed in the architecture register.
5    #[error("CPU-local area is not installed")]
6    AreaNotInstalled,
7    /// A runtime CPU-area address is null or does not meet prefix alignment.
8    #[error("CPU-local area base {base:#x} is null or misaligned")]
9    InvalidAreaBase {
10        /// Rejected runtime address.
11        base: usize,
12    },
13    /// Address arithmetic for the fixed CPU-area prefix overflowed.
14    #[error("CPU-local prefix address calculation overflowed")]
15    AddressOverflow,
16    /// The immutable area header does not describe its actual address.
17    #[error("CPU-local area header does not match its runtime address")]
18    AreaIdentityMismatch,
19    /// The kernel is running at an exception level unsupported by this backend.
20    #[error("CPU-local registers do not support host exception level {level}")]
21    UnsupportedHostLevel {
22        /// Architecture-specific live exception level.
23        level: usize,
24    },
25    /// The CPU runtime slot and architecture current-thread register disagree.
26    #[error("current-thread register and CPU runtime slot disagree")]
27    CurrentThreadMismatch,
28}
29
30/// Failure while preparing or completing a scheduler thread switch.
31#[derive(Clone, Copy, Debug, Eq, PartialEq, thiserror::Error)]
32pub enum ThreadSwitchError {
33    /// CPU-local state could not be validated.
34    #[error(transparent)]
35    CpuLocal(#[from] CpuLocalError),
36    /// The outgoing header is not the thread currently published on this CPU.
37    #[error("outgoing task does not match the published current thread")]
38    CurrentThreadMismatch,
39    /// The incoming switch tail was paired with another previous task.
40    #[error("previous-task token does not match the supplied task header")]
41    PreviousThreadMismatch,
42    /// The next task is already running or is in another binding transition.
43    #[error("next task is already bound to a CPU")]
44    NextThreadAlreadyBound,
45    /// The incoming switch tail attempted to consume an obsolete binding epoch.
46    #[error("previous-task binding epoch is stale")]
47    StalePreviousBinding,
48}