use super::super::*;
pub(super) const PAGE_OFFSET: u64 = 0xFFFF_8880_0000_0000;
pub(super) const EXT_KVA: u64 = 0xFFFF_FFFF_8200_0100;
pub(super) const DEFAULT_START_TIME: u64 = 1_700_000_000_000;
pub(super) mod synth_task {
pub(in crate::vmm::freeze_coord::kernel_op_dispatch::tests) const PID_OFF: usize = 0x10;
pub(in crate::vmm::freeze_coord::kernel_op_dispatch::tests) const START_TIME_OFF: usize = 0x18;
pub(in crate::vmm::freeze_coord::kernel_op_dispatch::tests) const STATE_OFF: usize = 0x20;
pub(in crate::vmm::freeze_coord::kernel_op_dispatch::tests) const ON_RQ_OFF: usize = 0x28;
pub(in crate::vmm::freeze_coord::kernel_op_dispatch::tests) const SCHED_CLASS_OFF: usize = 0x30;
pub(in crate::vmm::freeze_coord::kernel_op_dispatch::tests) const START_BOOTTIME_OFF: usize =
0x40;
pub(in crate::vmm::freeze_coord::kernel_op_dispatch::tests) const SCX_DSQ_OFF: usize = 0x48;
pub(in crate::vmm::freeze_coord::kernel_op_dispatch::tests) const SCX_RUNNABLE_NODE_OFF: usize =
0x50;
pub(in crate::vmm::freeze_coord::kernel_op_dispatch::tests) const TASKS_OFF: usize = 0x60;
pub(in crate::vmm::freeze_coord::kernel_op_dispatch::tests) const SIGNAL_OFF: usize = 0x70;
pub(in crate::vmm::freeze_coord::kernel_op_dispatch::tests) const SIGNAL_THREAD_HEAD_OFF:
usize = 0x10;
pub(in crate::vmm::freeze_coord::kernel_op_dispatch::tests) const THREAD_NODE_OFF: usize = 0x78;
}
pub(super) fn synth_validation_offsets() -> TaskValidationOffsets {
TaskValidationOffsets {
pid: synth_task::PID_OFF,
start_time: synth_task::START_TIME_OFF,
state: synth_task::STATE_OFF,
on_rq: synth_task::ON_RQ_OFF,
sched_class: synth_task::SCHED_CLASS_OFF,
start_boottime: synth_task::START_BOOTTIME_OFF,
scx_dsq: synth_task::SCX_DSQ_OFF,
scx_runnable_node: synth_task::SCX_RUNNABLE_NODE_OFF,
tasks: synth_task::TASKS_OFF,
signal: synth_task::SIGNAL_OFF,
signal_thread_head: synth_task::SIGNAL_THREAD_HEAD_OFF,
thread_node: synth_task::THREAD_NODE_OFF,
}
}
pub(super) fn paint_valid_task(buf: &mut [u8], pa: usize, pid: u32) {
buf[pa + synth_task::PID_OFF..pa + synth_task::PID_OFF + 4].copy_from_slice(&pid.to_le_bytes());
buf[pa + synth_task::START_TIME_OFF..pa + synth_task::START_TIME_OFF + 8]
.copy_from_slice(&DEFAULT_START_TIME.to_le_bytes());
buf[pa + synth_task::STATE_OFF..pa + synth_task::STATE_OFF + 4]
.copy_from_slice(&0u32.to_le_bytes());
buf[pa + synth_task::ON_RQ_OFF..pa + synth_task::ON_RQ_OFF + 4]
.copy_from_slice(&0u32.to_le_bytes());
buf[pa + synth_task::SCHED_CLASS_OFF..pa + synth_task::SCHED_CLASS_OFF + 8]
.copy_from_slice(&EXT_KVA.to_le_bytes());
buf[pa + synth_task::START_BOOTTIME_OFF..pa + synth_task::START_BOOTTIME_OFF + 8]
.copy_from_slice(&3_600_000_000_000u64.to_le_bytes());
buf[pa + synth_task::SCX_DSQ_OFF..pa + synth_task::SCX_DSQ_OFF + 8]
.copy_from_slice(&0u64.to_le_bytes());
let task_kva = (pa as u64).wrapping_add(PAGE_OFFSET);
let self_kva = task_kva.wrapping_add(synth_task::SCX_RUNNABLE_NODE_OFF as u64);
buf[pa + synth_task::SCX_RUNNABLE_NODE_OFF..pa + synth_task::SCX_RUNNABLE_NODE_OFF + 8]
.copy_from_slice(&self_kva.to_le_bytes());
}
pub(super) fn build_test_kernel(
buf: &mut [u8],
symbols: std::collections::HashMap<String, u64>,
) -> crate::monitor::guest::GuestKernel {
let mem = unsafe {
std::sync::Arc::new(crate::monitor::reader::GuestMem::new(
buf.as_mut_ptr(),
buf.len() as u64,
))
};
crate::monitor::guest::GuestKernel::new_for_test(
mem,
symbols,
PAGE_OFFSET,
0, false, )
}