Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions openhcl/virt_mshv_vtl/src/processor/hardware_cvm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use hv1_hypercall::HvRepResult;
use hv1_structs::ProcessorSet;
use hvdef::HvCacheType;
use hvdef::HvError;
use hvdef::HvInterruptType;
use hvdef::HvMapGpaFlags;
use hvdef::HvRegisterVsmPartitionConfig;
use hvdef::HvRegisterVsmVpSecureVtlConfig;
Expand All @@ -41,6 +42,7 @@ use hvdef::hypercall::TranslateGvaResultCode;
use std::iter::zip;
use virt::Processor;
use virt::io::CpuIo;
use virt::irqcon::MsiRequest;
use virt::vp::AccessVpState;
use virt::x86::MsrError;
use virt::x86::MsrErrorExt;
Expand Down Expand Up @@ -2483,3 +2485,53 @@ impl<T, B: HardwareIsolatedBacking> hv1_hypercall::InstallIntercept
Ok(())
}
}

impl<T, B: HardwareIsolatedBacking> hv1_hypercall::AssertVirtualInterrupt
for UhHypercallHandler<'_, '_, T, B>
{
fn assert_virtual_interrupt(
&mut self,
partition_id: u64,
interrupt_control: hvdef::HvInterruptControl,
destination_address: u64,
requested_vector: u32,
target_vtl: Vtl,
) -> HvResult<()> {
let target_vtl = self.target_vtl_no_higher(target_vtl)?;

if partition_id != hvdef::HV_PARTITION_ID_SELF || target_vtl == self.intercepted_vtl {
return Err(HvError::AccessDenied);
}

// Only fixed interrupts and NMIs are supported today.
if !matches!(
interrupt_control.interrupt_type(),
HvInterruptType::HvX64InterruptTypeFixed | HvInterruptType::HvX64InterruptTypeNmi
) {
return Err(HvError::InvalidParameter);
}

self.vp.partition.request_msi(
target_vtl,
MsiRequest::new_x86(
x86defs::apic::DeliveryMode(
interrupt_control
.interrupt_type()
.0
.try_into()
.map_err(|_| HvError::InvalidParameter)?,
),
destination_address
.try_into()
.map_err(|_| HvError::InvalidParameter)?,
interrupt_control.x86_logical_destination_mode(),
requested_vector
.try_into()
.map_err(|_| HvError::InvalidParameter)?,
interrupt_control.x86_level_triggered(),
),
);

Ok(())
}
}
1 change: 1 addition & 0 deletions openhcl/virt_mshv_vtl/src/processor/snp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@ impl<T: CpuIo> UhHypercallHandler<'_, '_, T, SnpBacked> {
hv1_hypercall::HvSendSyntheticClusterIpi,
hv1_hypercall::HvSendSyntheticClusterIpiEx,
hv1_hypercall::HvInstallIntercept,
hv1_hypercall::HvAssertVirtualInterrupt,
],
);

Expand Down
1 change: 1 addition & 0 deletions openhcl/virt_mshv_vtl/src/processor/tdx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3500,6 +3500,7 @@ impl<T: CpuIo> UhHypercallHandler<'_, '_, T, TdxBacked> {
hv1_hypercall::HvSendSyntheticClusterIpi,
hv1_hypercall::HvSendSyntheticClusterIpiEx,
hv1_hypercall::HvInstallIntercept,
hv1_hypercall::HvAssertVirtualInterrupt,
]
);

Expand Down
3 changes: 3 additions & 0 deletions vm/hv1/hv1_hypercall/src/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ pub trait AssertVirtualInterrupt {
impl<T: AssertVirtualInterrupt> HypercallDispatch<HvAssertVirtualInterrupt> for T {
fn dispatch(&mut self, params: HypercallParameters<'_>) -> HypercallOutput {
HvAssertVirtualInterrupt::run(params, |input| {
if input.rsvd0 != 0 || input.rsvd1 != 0 {
return Err(HvError::InvalidParameter);
}
self.assert_virtual_interrupt(
input.partition_id,
input.interrupt_control,
Expand Down