pub struct KvmKernelIrqChip {
pub(super) vm: Arc<KvmVm>,
pub(super) vcpus: Mutex<Vec<Option<Arc<KvmVcpu>>>>,
pub(super) routes: Mutex<Vec<IrqRoute>>,
}Expand description
IrqChip implementation where the entire IrqChip is emulated by KVM.
This implementation will use the KVM API to create and configure the in-kernel irqchip.
Fields§
§vm: Arc<KvmVm>§vcpus: Mutex<Vec<Option<Arc<KvmVcpu>>>>§routes: Mutex<Vec<IrqRoute>>Implementations§
Trait Implementations§
Source§impl IrqChip for KvmKernelIrqChip
This IrqChip only works with Kvm so we only implement it for KvmVcpu.
impl IrqChip for KvmKernelIrqChip
This IrqChip only works with Kvm so we only implement it for KvmVcpu.
Source§fn add_vcpu(&self, vcpu_id: usize, vcpu: Arc<dyn VcpuArch>) -> Result<()>
fn add_vcpu(&self, vcpu_id: usize, vcpu: Arc<dyn VcpuArch>) -> Result<()>
Add a vcpu to the irq chip.
Source§fn register_edge_irq_event(
&self,
irq: u32,
irq_event: &IrqEdgeEvent,
_source: IrqEventSource,
) -> Result<Option<IrqEventIndex>>
fn register_edge_irq_event( &self, irq: u32, irq_event: &IrqEdgeEvent, _source: IrqEventSource, ) -> Result<Option<IrqEventIndex>>
Register an event with edge-trigger semantic that can trigger an interrupt for a particular GSI.
Source§fn unregister_edge_irq_event(
&self,
irq: u32,
irq_event: &IrqEdgeEvent,
) -> Result<()>
fn unregister_edge_irq_event( &self, irq: u32, irq_event: &IrqEdgeEvent, ) -> Result<()>
Unregister an event with edge-trigger semantic for a particular GSI.
Source§fn register_level_irq_event(
&self,
irq: u32,
irq_event: &IrqLevelEvent,
_source: IrqEventSource,
) -> Result<Option<IrqEventIndex>>
fn register_level_irq_event( &self, irq: u32, irq_event: &IrqLevelEvent, _source: IrqEventSource, ) -> Result<Option<IrqEventIndex>>
Register an event with level-trigger semantic that can trigger an interrupt for a particular GSI.
Source§fn unregister_level_irq_event(
&self,
irq: u32,
irq_event: &IrqLevelEvent,
) -> Result<()>
fn unregister_level_irq_event( &self, irq: u32, irq_event: &IrqLevelEvent, ) -> Result<()>
Unregister an event with level-trigger semantic for a particular GSI.
Source§fn route_irq(&self, route: IrqRoute) -> Result<()>
fn route_irq(&self, route: IrqRoute) -> Result<()>
Route an IRQ line to an interrupt controller, or to a particular MSI vector.
Source§fn set_irq_routes(&self, routes: &[IrqRoute]) -> Result<()>
fn set_irq_routes(&self, routes: &[IrqRoute]) -> Result<()>
Replace all irq routes with the supplied routes
Source§fn irq_event_tokens(
&self,
) -> Result<Vec<(IrqEventIndex, IrqEventSource, Event)>>
fn irq_event_tokens( &self, ) -> Result<Vec<(IrqEventIndex, IrqEventSource, Event)>>
Return a vector of all registered irq numbers and their associated events and event indices. These should be used by the main thread to wait for irq events. For the KvmKernelIrqChip, the kernel handles listening to irq events being triggered by devices, so this function always returns an empty Vec.
Source§fn service_irq(&self, irq: u32, level: bool) -> Result<()>
fn service_irq(&self, irq: u32, level: bool) -> Result<()>
Either assert or deassert an IRQ line. Sends to either an interrupt controller, or does a send_msi if the irq is associated with an MSI. For the KvmKernelIrqChip this simply calls the KVM_SET_IRQ_LINE ioctl.
Source§fn service_irq_event(&self, _event_index: IrqEventIndex) -> Result<()>
fn service_irq_event(&self, _event_index: IrqEventIndex) -> Result<()>
Service an IRQ event by asserting then deasserting an IRQ line. The associated Event that triggered the irq event will be read from. If the irq is associated with a resample Event, then the deassert will only happen after an EOI is broadcast for a vector associated with the irq line. This function should never be called on KvmKernelIrqChip.
Source§fn broadcast_eoi(&self, _vector: u8) -> Result<()>
fn broadcast_eoi(&self, _vector: u8) -> Result<()>
Broadcast an end of interrupt. This should never be called on a KvmKernelIrqChip because a KVM vcpu should never exit with the KVM_EXIT_EOI_BROADCAST reason when an in-kernel irqchip exists.
Source§fn inject_interrupts(&self, _vcpu: &dyn VcpuArch) -> Result<()>
fn inject_interrupts(&self, _vcpu: &dyn VcpuArch) -> Result<()>
Injects any pending interrupts for vcpu.
For KvmKernelIrqChip this is a no-op because KVM is responsible for injecting all
interrupts.
Source§fn halted(&self, _vcpu_id: usize)
fn halted(&self, _vcpu_id: usize)
Notifies the irq chip that the specified VCPU has executed a halt instruction. For KvmKernelIrqChip this is a no-op because KVM handles VCPU blocking.
Source§fn wait_until_runnable(&self, _vcpu: &dyn VcpuArch) -> Result<VcpuRunState>
fn wait_until_runnable(&self, _vcpu: &dyn VcpuArch) -> Result<VcpuRunState>
Blocks until vcpu is in a runnable state or until interrupted by
IrqChip::kick_halted_vcpus. Returns VcpuRunState::Runnable if vcpu is runnable, or VcpuRunState::Interrupted` if the wait was interrupted.
For KvmKernelIrqChip this is a no-op and always returns Runnable because KVM handles VCPU
blocking.
Source§fn kick_halted_vcpus(&self)
fn kick_halted_vcpus(&self)
Makes unrunnable VCPUs return immediately from wait_until_runnable.
For KvmKernelIrqChip this is a no-op because KVM handles VCPU blocking.
Source§fn get_mp_state(&self, vcpu_id: usize) -> Result<MPState>
fn get_mp_state(&self, vcpu_id: usize) -> Result<MPState>
Get the current MP state of the specified VCPU.
Source§fn set_mp_state(&self, vcpu_id: usize, state: &MPState) -> Result<()>
fn set_mp_state(&self, vcpu_id: usize, state: &MPState) -> Result<()>
Set the current MP state of the specified VCPU.
Source§fn finalize_devices(
self: Arc<Self>,
_resources: &mut SystemAllocator,
_io_bus: &Bus,
_mmio_bus: &Bus,
) -> Result<()>
fn finalize_devices( self: Arc<Self>, _resources: &mut SystemAllocator, _io_bus: &Bus, _mmio_bus: &Bus, ) -> Result<()>
Finalize irqchip setup. Should be called once all devices have registered irq events and been added to the io_bus and mmio_bus. KvmKernelIrqChip does not need to do anything here.
Source§fn process_delayed_irq_events(&self) -> Result<()>
fn process_delayed_irq_events(&self) -> Result<()>
The KvmKernelIrqChip doesn’t process irq events itself so this function does nothing.
Source§fn irq_delayed_event_token(&self) -> Result<Option<Event>>
fn irq_delayed_event_token(&self) -> Result<Option<Event>>
Source§fn check_capability(&self, c: IrqChipCap) -> bool
fn check_capability(&self, c: IrqChipCap) -> bool
IrqChipCap is available.Source§impl IrqChipX86_64 for KvmKernelIrqChip
impl IrqChipX86_64 for KvmKernelIrqChip
Source§fn get_pic_state(&self, select: PicSelect) -> Result<PicState>
fn get_pic_state(&self, select: PicSelect) -> Result<PicState>
Get the current state of the PIC
Source§fn set_pic_state(&self, select: PicSelect, state: &PicState) -> Result<()>
fn set_pic_state(&self, select: PicSelect, state: &PicState) -> Result<()>
Set the current state of the PIC
Source§fn get_ioapic_state(&self) -> Result<IoapicState>
fn get_ioapic_state(&self) -> Result<IoapicState>
Get the current state of the IOAPIC
Source§fn set_ioapic_state(&self, state: &IoapicState) -> Result<()>
fn set_ioapic_state(&self, state: &IoapicState) -> Result<()>
Set the current state of the IOAPIC
Source§fn get_lapic_state(&self, vcpu_id: usize) -> Result<LapicState>
fn get_lapic_state(&self, vcpu_id: usize) -> Result<LapicState>
Get the current state of the specified VCPU’s local APIC
Source§fn set_lapic_state(&self, vcpu_id: usize, state: &LapicState) -> Result<()>
fn set_lapic_state(&self, vcpu_id: usize, state: &LapicState) -> Result<()>
Set the current state of the specified VCPU’s local APIC
Source§fn lapic_frequency(&self) -> u32
fn lapic_frequency(&self) -> u32
Get the lapic frequency in Hz
Source§fn get_pit(&self) -> Result<PitState>
fn get_pit(&self) -> Result<PitState>
Retrieves the state of the PIT. Gets the pit state via the KVM API.
Source§fn set_pit(&self, state: &PitState) -> Result<()>
fn set_pit(&self, state: &PitState) -> Result<()>
Sets the state of the PIT. Sets the pit state via the KVM API.
Source§fn pit_uses_speaker_port(&self) -> bool
fn pit_uses_speaker_port(&self) -> bool
Returns true if the PIT uses port 0x61 for the PC speaker, false if 0x61 is unused. KVM’s kernel PIT doesn’t use 0x61.