pub struct KvmKernelIrqChip {
pub(super) vm: KvmVm,
pub(super) vcpus: Arc<Mutex<Vec<Option<KvmVcpu>>>>,
pub(super) routes: Arc<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: KvmVm
§vcpus: Arc<Mutex<Vec<Option<KvmVcpu>>>>
§routes: Arc<Mutex<Vec<IrqRoute>>>
Implementations§
source§impl KvmKernelIrqChip
impl KvmKernelIrqChip
sourcepub fn new(vm: KvmVm, num_vcpus: usize) -> Result<KvmKernelIrqChip>
pub fn new(vm: KvmVm, num_vcpus: usize) -> Result<KvmKernelIrqChip>
Construct a new KvmKernelIrqchip.
sourcepub(super) fn arch_try_clone(&self) -> Result<Self>
pub(super) fn arch_try_clone(&self) -> Result<Self>
Attempt to create a shallow clone of this x86_64 KvmKernelIrqChip instance.
Trait Implementations§
source§impl IrqChip for KvmKernelIrqChip
impl IrqChip for KvmKernelIrqChip
This IrqChip only works with Kvm so we only implement it for KvmVcpu.
source§fn add_vcpu(&mut self, vcpu_id: usize, vcpu: &dyn Vcpu) -> Result<()>
fn add_vcpu(&mut self, vcpu_id: usize, vcpu: &dyn Vcpu) -> Result<()>
Add a vcpu to the irq chip.
source§fn register_edge_irq_event(
&mut self,
irq: u32,
irq_event: &IrqEdgeEvent,
_source: IrqEventSource
) -> Result<Option<IrqEventIndex>>
fn register_edge_irq_event( &mut 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(
&mut self,
irq: u32,
irq_event: &IrqEdgeEvent
) -> Result<()>
fn unregister_edge_irq_event( &mut self, irq: u32, irq_event: &IrqEdgeEvent ) -> Result<()>
Unregister an event with edge-trigger semantic for a particular GSI.
source§fn register_level_irq_event(
&mut self,
irq: u32,
irq_event: &IrqLevelEvent,
_source: IrqEventSource
) -> Result<Option<IrqEventIndex>>
fn register_level_irq_event( &mut 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(
&mut self,
irq: u32,
irq_event: &IrqLevelEvent
) -> Result<()>
fn unregister_level_irq_event( &mut self, irq: u32, irq_event: &IrqLevelEvent ) -> Result<()>
Unregister an event with level-trigger semantic for a particular GSI.
source§fn route_irq(&mut self, route: IrqRoute) -> Result<()>
fn route_irq(&mut self, route: IrqRoute) -> Result<()>
Route an IRQ line to an interrupt controller, or to a particular MSI vector.
source§fn set_irq_routes(&mut self, routes: &[IrqRoute]) -> Result<()>
fn set_irq_routes(&mut 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(&mut self, irq: u32, level: bool) -> Result<()>
fn service_irq(&mut 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(&mut self, _event_index: IrqEventIndex) -> Result<()>
fn service_irq_event(&mut 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 Vcpu) -> Result<()>
fn inject_interrupts(&self, _vcpu: &dyn Vcpu) -> 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 Vcpu) -> Result<VcpuRunState>
fn wait_until_runnable(&self, _vcpu: &dyn Vcpu) -> 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(&mut self, vcpu_id: usize, state: &MPState) -> Result<()>
fn set_mp_state(&mut self, vcpu_id: usize, state: &MPState) -> Result<()>
Set the current MP state of the specified VCPU.
source§fn finalize_devices(
&mut self,
_resources: &mut SystemAllocator,
_io_bus: &Bus,
_mmio_bus: &Bus
) -> Result<()>
fn finalize_devices( &mut 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(&mut self) -> Result<()>
fn process_delayed_irq_events(&mut 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(&mut self, select: PicSelect, state: &PicState) -> Result<()>
fn set_pic_state(&mut 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(&mut self, state: &IoapicState) -> Result<()>
fn set_ioapic_state(&mut 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(&mut self, vcpu_id: usize, state: &LapicState) -> Result<()>
fn set_lapic_state(&mut 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(&mut self, state: &PitState) -> Result<()>
fn set_pit(&mut 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.
fn try_box_clone(&self) -> Result<Box<dyn IrqChipX86_64>>
fn as_irq_chip(&self) -> &dyn IrqChip
fn as_irq_chip_mut(&mut self) -> &mut dyn IrqChip
source§fn snapshot_chip_specific(&self) -> Result<Value>
fn snapshot_chip_specific(&self) -> Result<Value>
Auto Trait Implementations§
impl RefUnwindSafe for KvmKernelIrqChip
impl Send for KvmKernelIrqChip
impl Sync for KvmKernelIrqChip
impl Unpin for KvmKernelIrqChip
impl UnwindSafe for KvmKernelIrqChip
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.