mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
hypervisor: Set additional partition property for MSHV guest
For ARM64 guests we need to set three important partition property: 1) PPI interrupt ID for timer interrupt 2) PPI interrupt ID for PMU interrupts. 3) Hiding LPI support from the guest because MSHV does emulate ITS for the guest. Signed-off-by: Jinank Jain <jinankjain@microsoft.com>
This commit is contained in:
@@ -224,3 +224,5 @@ pub const AARCH64_ARCH_TIMER_HYP_IRQ: u32 = 10;
|
||||
|
||||
// PMU PPI interrupt number
|
||||
pub const AARCH64_PMU_IRQ: u32 = 7;
|
||||
|
||||
pub const AARCH64_MIN_PPI_IRQ: u32 = 16;
|
||||
|
||||
@@ -20,6 +20,10 @@ use vm::DataMatch;
|
||||
#[cfg(feature = "sev_snp")]
|
||||
use vm_memory::bitmap::AtomicBitmap;
|
||||
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
use crate::arch::aarch64::regs::{
|
||||
AARCH64_ARCH_TIMER_VIRT_IRQ, AARCH64_MIN_PPI_IRQ, AARCH64_PMU_IRQ,
|
||||
};
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use crate::arch::emulator::PlatformEmulator;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
@@ -2370,6 +2374,45 @@ impl vm::Vm for MshvVm {
|
||||
}
|
||||
|
||||
fn init(&self) -> vm::Result<()> {
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
{
|
||||
self.fd
|
||||
.set_partition_property(
|
||||
hv_partition_property_code_HV_PARTITION_PROPERTY_GIC_LPI_INT_ID_BITS,
|
||||
0,
|
||||
)
|
||||
.map_err(|e| {
|
||||
vm::HypervisorVmError::InitializeVm(anyhow!(
|
||||
"Failed to set GIC LPI support: {}",
|
||||
e
|
||||
))
|
||||
})?;
|
||||
|
||||
self.fd
|
||||
.set_partition_property(
|
||||
hv_partition_property_code_HV_PARTITION_PROPERTY_GIC_PPI_OVERFLOW_INTERRUPT_FROM_CNTV,
|
||||
(AARCH64_ARCH_TIMER_VIRT_IRQ + AARCH64_MIN_PPI_IRQ) as u64,
|
||||
)
|
||||
.map_err(|e| {
|
||||
vm::HypervisorVmError::InitializeVm(anyhow!(
|
||||
"Failed to set arch timer interrupt ID: {}",
|
||||
e
|
||||
))
|
||||
})?;
|
||||
|
||||
self.fd
|
||||
.set_partition_property(
|
||||
hv_partition_property_code_HV_PARTITION_PROPERTY_GIC_PPI_PERFORMANCE_MONITORS_INTERRUPT,
|
||||
(AARCH64_PMU_IRQ + AARCH64_MIN_PPI_IRQ) as u64,
|
||||
)
|
||||
.map_err(|e| {
|
||||
vm::HypervisorVmError::InitializeVm(anyhow!(
|
||||
"Failed to set PMU interrupt ID: {}",
|
||||
e
|
||||
))
|
||||
})?;
|
||||
}
|
||||
|
||||
self.fd
|
||||
.initialize()
|
||||
.map_err(|e| vm::HypervisorVmError::InitializeVm(e.into()))?;
|
||||
|
||||
Reference in New Issue
Block a user