From 47e65cd34147a04e27b2faf3b0a2a5582fb6867c Mon Sep 17 00:00:00 2001 From: Henry Wang Date: Fri, 4 Sep 2020 23:37:52 +0800 Subject: [PATCH] vmm: AArch64: add methods to get saved vCPU states The construction of `GICR_TYPER` register will need vCPU states. Therefore this commit adds methods to extract saved vCPU states from the cpu manager. Signed-off-by: Henry Wang --- vmm/src/cpu.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/vmm/src/cpu.rs b/vmm/src/cpu.rs index 45556bbb1..05e522fe0 100644 --- a/vmm/src/cpu.rs +++ b/vmm/src/cpu.rs @@ -328,6 +328,12 @@ impl Vcpu { self.mpidr } + /// Gets the saved vCPU state. + #[cfg(target_arch = "aarch64")] + pub fn get_saved_state(&self) -> Option { + self.saved_state.clone() + } + /// Runs the VCPU until it exits, returning the reason. /// /// Note that the state of the VCPU and associated VM must be setup first for this to do @@ -1041,6 +1047,14 @@ impl CpuManager { .collect() } + #[cfg(target_arch = "aarch64")] + pub fn get_saved_states(&self) -> Vec { + self.vcpus + .iter() + .map(|cpu| cpu.lock().unwrap().get_saved_state().unwrap()) + .collect() + } + #[cfg(feature = "acpi")] pub fn create_madt(&self) -> SDT { // This is also checked in the commandline parsing.