vmm: Enable VCPU for AArch64

Added MPIDR which is needed in system configuration.

Signed-off-by: Michael Zhao <michael.zhao@arm.com>
This commit is contained in:
Michael Zhao
2020-06-09 15:24:23 +08:00
committed by Rob Bradford
parent b5f1c912d6
commit 917219fa92
2 changed files with 88 additions and 27 deletions
+28 -4
View File
@@ -239,6 +239,8 @@ pub struct Vcpu {
interrupt_controller: Option<Arc<Mutex<dyn InterruptController>>>,
#[cfg_attr(target_arch = "aarch64", allow(dead_code))]
vm_ts: std::time::Instant,
#[cfg(target_arch = "aarch64")]
mpidr: u64,
}
#[cfg(target_arch = "x86_64")]
@@ -284,6 +286,8 @@ impl Vcpu {
mmio_bus,
interrupt_controller,
vm_ts: creation_ts,
#[cfg(target_arch = "aarch64")]
mpidr: 0,
})))
}
@@ -296,14 +300,18 @@ impl Vcpu {
/// * `vm_memory` - Guest memory.
/// * `cpuid` - (x86_64) CpuId, wrapper over the `kvm_cpuid2` structure.
pub fn configure(
&self,
&mut self,
#[cfg(target_arch = "aarch64")] vm_fd: &VmFd,
kernel_entry_point: Option<EntryPoint>,
vm_memory: &GuestMemoryAtomic<GuestMemoryMmap>,
#[cfg(target_arch = "x86_64")] cpuid: CpuId,
) -> Result<()> {
#[cfg(target_arch = "aarch64")]
arch::configure_vcpu(&self.fd, self.id, kernel_entry_point, vm_memory)
.map_err(Error::VcpuConfiguration)?;
{
self.mpidr =
arch::configure_vcpu(&self.fd, self.id, vm_fd, kernel_entry_point, vm_memory)
.map_err(Error::VcpuConfiguration)?;
}
#[cfg(target_arch = "x86_64")]
arch::configure_vcpu(&self.fd, self.id, kernel_entry_point, vm_memory, cpuid)
@@ -312,6 +320,12 @@ impl Vcpu {
Ok(())
}
/// Gets the MPIDR register value.
#[cfg(target_arch = "aarch64")]
pub fn get_mpidr(&self) -> u64 {
self.mpidr
}
/// 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
@@ -784,7 +798,7 @@ impl CpuManager {
#[cfg(target_arch = "aarch64")]
vcpu.lock()
.unwrap()
.configure(entry_point, &vm_memory)
.configure(&self.fd, entry_point, &vm_memory)
.expect("Failed to configure vCPU");
}
@@ -985,6 +999,16 @@ impl CpuManager {
.fold(0, |acc, state| acc + state.active() as u8)
}
#[cfg(target_arch = "aarch64")]
pub fn get_mpidr(&self) -> Vec<u64> {
let vcpu_mpidr = self
.vcpus
.iter()
.map(|cpu| cpu.lock().unwrap().get_mpidr())
.collect();
vcpu_mpidr
}
#[cfg(feature = "acpi")]
pub fn create_madt(&self) -> SDT {
// This is also checked in the commandline parsing.