use smallvec::SmallVec;
pub type ExitData = SmallVec<[u8; 8]>;
#[derive(Debug, Clone)]
#[non_exhaustive]
pub enum VmExit {
Mmio {
addr: u64,
write: bool,
data: ExitData,
},
Pio {
port: u16,
write: bool,
data: ExitData,
},
Hypercall {
func: u64,
args: [u64; 6],
},
Wfi,
Wfe,
Hlt,
Reset,
Shutdown,
Debug(DebugInfo),
InternalError(String),
}
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct DebugInfo {
pub pc: u64,
pub syndrome: u64,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn mmio_payload_inlines_for_small_widths() {
let data: ExitData = SmallVec::from_slice(&[0xAB, 0xCD]);
assert!(!data.spilled());
}
#[test]
fn variants_are_clone() {
let exit = VmExit::Wfi;
let _again = exit.clone();
}
}