Closed pengzechen closed 2 weeks ago
vmexit_handler
only handle sync exceptions, how do we handle irqs ?
If you mimic the x86 "vmexit," an IRQ arrival would also count as a vmexit, wouldn't it?
Can this work?
Can this work?
Yes, and I think you can modify run_guest
to something like
#[inline(never)]
fn run_guest(&mut self) -> usize {
unsafe {
core::arch::asm!(
save_regs_to_stack!(), // save host context
"mov x9, sp",
"mov x10, {0}",
"str x9, [x10]", // save host stack top in the vcpu struct
"mov x0, {0}",
"b context_vm_entry",
in(reg) &self.host_stack_top as *const _ as usize,
options(nostack)
);
}
}
Remember that ARM use x0
register to store the return value, you may need to modify some Rust inline assembly to ensure the return value is correct.
Also, you need to simplify the save_regs_to_stack
and restore_regs_from_stack
macro, since run_guest
is just a function call and we only need to maintain the "callee saved registers".
Such semantic can refer to task context switch design in ArceOS, since switch_to()
is alse a function call.
How to distinguish different exceptions with vmexit_aarch64_handler?