AArch64: Preparation for vCPU save/restore

This commit ports code from firecracker and refactors the existing
AArch64 code as the preparation for implementing save/restore
AArch64 vCPU, including:

1. Modification of `arm64_core_reg` macro to retrive the index of
arm64 core register and implemention of a helper to determine if
a register is a system register.

2. Move some macros and helpers in `arch` crate to the `hypervisor`
crate.

3. Added related unit tests for above functions and macros.

Signed-off-by: Henry Wang <Henry.Wang@arm.com>
This commit is contained in:
Henry Wang
2020-08-28 17:06:54 +08:00
committed by Rob Bradford
parent 5c3f4dbe6f
commit e3d45be6f7
6 changed files with 171 additions and 99 deletions
+4 -1
View File
@@ -42,6 +42,9 @@ pub enum Error {
/// Error configuring the general purpose registers
REGSConfiguration(regs::Error),
/// Error configuring the MPIDR register
VcpuRegMPIDR(hypervisor::HypervisorCpuError),
/// Error fetching prefered target
VcpuArmPreferredTarget(hypervisor::HypervisorVmError),
@@ -94,7 +97,7 @@ pub fn configure_vcpu(
.map_err(Error::REGSConfiguration)?;
}
let mpidr = regs::read_mpidr(fd).map_err(Error::REGSConfiguration)?;
let mpidr = fd.read_mpidr().map_err(Error::VcpuRegMPIDR)?;
Ok(mpidr)
}