From 500d91311f749ac527568b7e84c53de5bb776dbe Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Wed, 20 Jul 2022 12:54:48 +0000 Subject: [PATCH] hypervisor: aarch64: kvm: use concrete KvmVm type where possible The code was moved from the vmm crate to the hypervisor crate. After the move it is trivially obvious that it only works with KVM. Use concrete types where possible. This allows us to drop create_device from the Vm trait. No functional change intended. Signed-off-by: Wei Liu --- hypervisor/src/kvm/aarch64/gic/mod.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hypervisor/src/kvm/aarch64/gic/mod.rs b/hypervisor/src/kvm/aarch64/gic/mod.rs index ae00dc50a..74cbc015b 100644 --- a/hypervisor/src/kvm/aarch64/gic/mod.rs +++ b/hypervisor/src/kvm/aarch64/gic/mod.rs @@ -5,7 +5,7 @@ mod icc_regs; mod redist_regs; use crate::arch::aarch64::gic::{Error, Result, Vgic}; -use crate::kvm::kvm_bindings; +use crate::kvm::{kvm_bindings, KvmVm}; use crate::{CpuState, Device, Vm}; use dist_regs::{get_dist_regs, read_ctlr, set_dist_regs, write_ctlr}; use icc_regs::{get_icc_regs, set_icc_regs}; @@ -136,7 +136,7 @@ impl KvmGicV3Its { } /// Setup the device-specific attributes - fn init_device_attributes(&mut self, vm: &dyn Vm, nr_irqs: u32) -> Result<()> { + fn init_device_attributes(&mut self, vm: &KvmVm, nr_irqs: u32) -> Result<()> { // GicV3 part attributes /* Setting up the distributor attribute. We are placing the GIC below 1GB so we need to substract the size of the distributor. @@ -214,7 +214,7 @@ impl KvmGicV3Its { } /// Create a KVM Vgic device - fn create_device(vm: &dyn Vm) -> Result> { + fn create_device(vm: &KvmVm) -> Result> { let mut gic_device = kvm_bindings::kvm_create_device { type_: Self::version(), fd: 0, @@ -254,6 +254,9 @@ impl KvmGicV3Its { msi_size: u64, nr_irqs: u32, ) -> Result { + // This is inside KVM module + let vm = vm.as_any().downcast_ref::().expect("Wrong VM type?"); + let vgic = Self::create_device(vm)?; let redists_size: u64 = redist_size * vcpu_count; let redists_addr: u64 = dist_addr - redists_size;