mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-03-07 17:26:14 +00:00
arch: AArch64: support saving RDIST pending tables into guest RAM
This commit adds a function which allows to save RDIST pending tables to the guest RAM, as well as unit test case for it. Signed-off-by: Henry Wang <Henry.Wang@arm.com>
This commit is contained in:
parent
29ce3076c2
commit
e7acbcc184
@ -204,4 +204,18 @@ pub mod kvm {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Function that saves RDIST pending tables into guest RAM.
|
||||||
|
///
|
||||||
|
/// The tables get flushed to guest RAM whenever the VM gets stopped.
|
||||||
|
pub fn save_pending_tables(gic: &Arc<dyn hypervisor::Device>) -> Result<()> {
|
||||||
|
let init_gic_attr = kvm_bindings::kvm_device_attr {
|
||||||
|
group: kvm_bindings::KVM_DEV_ARM_VGIC_GRP_CTRL,
|
||||||
|
attr: u64::from(kvm_bindings::KVM_DEV_ARM_VGIC_SAVE_PENDING_TABLES),
|
||||||
|
addr: 0,
|
||||||
|
flags: 0,
|
||||||
|
};
|
||||||
|
gic.set_device_attr(&init_gic_attr)
|
||||||
|
.map_err(super::Error::SetDeviceAttribute)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -395,7 +395,7 @@ pub mod kvm {
|
|||||||
#[cfg(target_arch = "aarch64")]
|
#[cfg(target_arch = "aarch64")]
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use arch::aarch64::gic::kvm::create_gic;
|
use arch::aarch64::gic::kvm::{create_gic, save_pending_tables};
|
||||||
use arch::aarch64::gic::{
|
use arch::aarch64::gic::{
|
||||||
get_dist_regs, get_icc_regs, get_redist_regs, set_dist_regs, set_icc_regs, set_redist_regs,
|
get_dist_regs, get_icc_regs, get_redist_regs, set_dist_regs, set_icc_regs, set_redist_regs,
|
||||||
};
|
};
|
||||||
@ -459,4 +459,14 @@ mod tests {
|
|||||||
|
|
||||||
assert!(set_icc_regs(gic.device(), &gicr_typer, &state).is_ok());
|
assert!(set_icc_regs(gic.device(), &gicr_typer, &state).is_ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_save_pending_tables() {
|
||||||
|
let hv = hypervisor::new().unwrap();
|
||||||
|
let vm = hv.create_vm().unwrap();
|
||||||
|
let _ = vm.create_vcpu(0).unwrap();
|
||||||
|
let gic = create_gic(&vm, 1, false).expect("Cannot create gic");
|
||||||
|
|
||||||
|
assert!(save_pending_tables(gic.device()).is_ok());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user