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

source

pub fn new(vm: KvmVm, num_vcpus: usize) -> Result<KvmKernelIrqChip>

Construct a new KvmKernelIrqchip.

source

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

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<()>

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

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<()>

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

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<()>

Unregister an event with level-trigger semantic for a particular GSI.

source§

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<()>

Replace all irq routes with the supplied routes

source§

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<()>

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<()>

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<()>

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<()>

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)

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>

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)

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>

Get the current MP state of the specified VCPU.

source§

fn set_mp_state(&mut self, vcpu_id: usize, state: &MPState) -> Result<()>

Set the current MP state of the specified VCPU.

source§

fn try_clone(&self) -> Result<Self>

Attempt to clone this IrqChip instance.

source§

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<()>

The KvmKernelIrqChip doesn’t process irq events itself so this function does nothing.

source§

fn irq_delayed_event_token(&self) -> Result<Option<Event>>

Return an event which is meant to trigger process of any irqs events that were delayed by calling process_delayed_irq_events(). This should be used by the main thread to wait for delayed irq event kick. It is process_delayed_irq_events() responsibility to read the event as long as there is no more irqs to be serviced.
source§

fn check_capability(&self, c: IrqChipCap) -> bool

Checks if a particular IrqChipCap is available.
source§

impl IrqChipX86_64 for KvmKernelIrqChip

source§

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<()>

Set the current state of the PIC

source§

fn get_ioapic_state(&self) -> Result<IoapicState>

Get the current state of the IOAPIC

source§

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>

Get the current state of the specified VCPU’s local APIC

source§

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

Get the lapic frequency in Hz

source§

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<()>

Sets the state of the PIT. Sets the pit state via the KVM API.

source§

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.

source§

fn try_box_clone(&self) -> Result<Box<dyn IrqChipX86_64>>

source§

fn as_irq_chip(&self) -> &dyn IrqChip

source§

fn as_irq_chip_mut(&mut self) -> &mut dyn IrqChip

source§

fn snapshot_chip_specific(&self) -> Result<Value>

Snapshot state specific to different IrqChips.
source§

fn restore_chip_specific(&mut self, data: Value) -> Result<()>

Restore state specific to different IrqChips.
source§

fn snapshot(&self, cpus_num: usize) -> Result<Value>

Snapshot state common to IrqChips.
source§

fn restore(&mut self, data: Value, vcpus_num: usize) -> Result<()>

Restore state common to IrqChips.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V