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 selected current-context source does not identify a valid context.
26    #[error("current-context source does not identify this CPU's execution context")]
27    CurrentContextMismatch,
28}
29
30/// Failure while preparing or completing an execution-context switch.
31#[derive(Clone, Copy, Debug, Eq, PartialEq, thiserror::Error)]
32pub enum ContextSwitchError {
33    /// CPU-local state could not be validated.
34    #[error(transparent)]
35    CpuLocal(#[from] CpuLocalError),
36    /// The outgoing header is not the context currently selected on this CPU.
37    #[error("outgoing context does not match the selected current context")]
38    CurrentContextMismatch,
39    /// The switch tail was paired with another previous context.
40    #[error("previous-context token does not match the supplied context header")]
41    PreviousContextMismatch,
42    /// The next context is already running or is in another binding transition.
43    #[error("next context is already bound to a CPU")]
44    NextContextAlreadyBound,
45    /// The incoming switch tail attempted to consume an obsolete binding epoch.
46    #[error("previous-context binding epoch is stale")]
47    StalePreviousBinding,
48}