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:
Jinank Jain
2025-05-07 05:36:33 +00:00
parent 691fe0ca68
commit a072b9a356
2 changed files with 45 additions and 0 deletions

View File

@@ -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;

View File

@@ -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()))?;