mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: hypervisor: Add support for injecting NMI for MSHV guest
Currently, we only support injecting NMI for KVM guests but we can do the same for MSHV guests as well to have feature parity. Signed-off-by: Jinank Jain <jinankjain@microsoft.com>
This commit is contained in:
@@ -515,7 +515,5 @@ pub trait Vcpu: Send + Sync {
|
||||
///
|
||||
/// Trigger NMI interrupt
|
||||
///
|
||||
fn nmi(&self) -> Result<()> {
|
||||
unimplemented!()
|
||||
}
|
||||
fn nmi(&self) -> Result<()>;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ use crate::vec_with_array_field;
|
||||
use crate::vm::{self, InterruptSourceConfig, VmOps};
|
||||
use crate::HypervisorType;
|
||||
pub use mshv_bindings::*;
|
||||
use mshv_ioctls::{set_registers_64, Mshv, NoDatamatch, VcpuFd, VmFd, VmType};
|
||||
use mshv_ioctls::{set_registers_64, InterruptRequest, Mshv, NoDatamatch, VcpuFd, VmFd, VmType};
|
||||
use std::any::Any;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::{Arc, RwLock};
|
||||
@@ -350,7 +350,6 @@ pub struct MshvVcpu {
|
||||
cpuid: Vec<CpuIdEntry>,
|
||||
msrs: Vec<MsrEntry>,
|
||||
vm_ops: Option<Arc<dyn vm::VmOps>>,
|
||||
#[cfg(feature = "sev_snp")]
|
||||
vm_fd: Arc<VmFd>,
|
||||
}
|
||||
|
||||
@@ -1328,6 +1327,22 @@ impl cpu::Vcpu for MshvVcpu {
|
||||
.set_sev_control_register(sev_control_reg)
|
||||
.map_err(|e| cpu::HypervisorCpuError::SetSevControlRegister(e.into()))
|
||||
}
|
||||
///
|
||||
/// Trigger NMI interrupt
|
||||
///
|
||||
fn nmi(&self) -> cpu::Result<()> {
|
||||
let cfg = InterruptRequest {
|
||||
interrupt_type: hv_interrupt_type_HV_X64_INTERRUPT_TYPE_NMI,
|
||||
apic_id: self.vp_index as u64,
|
||||
level_triggered: false,
|
||||
vector: 0,
|
||||
logical_destination_mode: false,
|
||||
long_mode: false,
|
||||
};
|
||||
self.vm_fd
|
||||
.request_virtual_interrupt(&cfg)
|
||||
.map_err(|e| cpu::HypervisorCpuError::Nmi(e.into()))
|
||||
}
|
||||
}
|
||||
|
||||
impl MshvVcpu {
|
||||
@@ -1623,7 +1638,6 @@ impl vm::Vm for MshvVm {
|
||||
cpuid: Vec::new(),
|
||||
msrs: self.msrs.clone(),
|
||||
vm_ops,
|
||||
#[cfg(feature = "sev_snp")]
|
||||
vm_fd: self.fd.clone(),
|
||||
};
|
||||
Ok(Arc::new(vcpu))
|
||||
|
||||
Reference in New Issue
Block a user