Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interrupt manager #4

Closed
wants to merge 29 commits into from

Conversation

jiangliu
Copy link

This PR is based on and includes patches from upstream PR:
rust-vmm#20
It implements interrupt manager for vm-device, please refer to following links for related discussions:

rust-vmm#21
rust-vmm#23

Jing Liu and others added 11 commits January 14, 2020 22:03
Use u64 for guest memory address type since this can make
vm-device independent from on vm-memory.

Signed-off-by: Jing Liu <[email protected]>
Change DeviceIo interface parameters to base and offset, so that
devices with several IO ranges can use it to locate right range.

Signed-off-by: Jing Liu <[email protected]>
As suggested from
rust-vmm#18 (comment)

Suggested-by: Andreea Florescu <[email protected]>
Signed-off-by: Samuel Ortiz <[email protected]>
Signed-off-by: Jing Liu <[email protected]>
In order to get a real multiple threads handling to enhance
performance, the DeviceIo trait need adopt interior mutability
pattern.

Signed-off-by: Jing Liu <[email protected]>
Based on resources definition, this adds device IO manager to manage
all devices IO ranges.

Signed-off-by: Jing Liu <[email protected]>
IO manager is responsible for handling IO operation when VMExit.
It works out the specific device according to the address range and
hand over to DeviceIo trait.

Signed-off-by: Jing Liu <[email protected]>
Unit tests for IO manager.

Signed-off-by: Jing Liu <[email protected]>
Append missing tests for resources and fix some typo.

Signed-off-by: Jing Liu <[email protected]>
Many device backend drivers will mutate itself when handling IO
requests. The DeviceIo trait assumes interior mutability, but it's
a little complex to support interior mutability. So introduce the
Mutex<T: DeviceIoMut> adapter to ease device backend driver
implementations. And the Mutex<T: DeviceIoMut> adapter is an zero
overhead abstraction without performance penalty.

Signed-off-by: Liu Jiang <[email protected]>
Previously DeviceIo depends on Send, but doesn't depend on Sync,
which fails to share Arc<IoManager> among vCPU threads. So make
DeviceIo depend on Sync too.

Signed-off-by: Liu Jiang <[email protected]>
@jiangliu jiangliu force-pushed the interrupt_manager branch 2 times, most recently from 8a64aee to f04d968 Compare June 10, 2020 02:13
jiangliu and others added 15 commits June 10, 2020 13:32
Implement Clone for IoManager, which will be needed for RCU-style
device hotplug.

Signed-off-by: Liu Jiang <[email protected]>
Export IoSize and IoRange as pub, which may be reused.

Signed-off-by: Liu Jiang <[email protected]>
Implement Deref for DeviceResources, so we could walk all resource
entries in an Resources object.

Signed-off-by: Liu Jiang <[email protected]>
Add #[derive(Debug)] for resource related data structs, so we could
use assert!() and assert_eq!() etc in unit test cases.

Signed-off-by: Liu Jiang <[email protected]>
The design to multiplex IoAddress/IoSize for MMIO and PIO makes
the device driver implmentation a little complex, so build dedicated
data structs and interfaces to handle PIO requests. Also make PIO
related code x86 specific.

Signed-off-by: Liu Jiang <[email protected]>
PCI devices need to register/unregister itself onto the IoManager
instance when handling PCI BAR reprogramming. So introduce
IoManagerContext trait to support device manager operaiton
transaction at runtime.

Closure is another option, but it's hard to get information out of
a closure when during live upgrading.

Signed-off-by: Liu Jiang <[email protected]>
Now we have get_assigned_resources() to get resources assigned to the
device(), and get_trapped_io_resources() to get PIO/MMIO resources the
device wants to get trapped.

Signed-off-by: Liu Jiang <[email protected]>
Switch to rust 2018 edition and turn on deny(missing_docs).

Signed-off-by: Liu Jiang <[email protected]>
Introduce traits InterruptManager and InterruptSourceGroup to manage
interrupt sources for virtual devices.

Signed-off-by: Liu Jiang <[email protected]>
Signed-off-by: Bin Zha <[email protected]>
Implement infrastructure to manage interrupt sources based on Linux KVM
kernel module.

Signed-off-by: Liu Jiang <[email protected]>
Signed-off-by: Bin Zha <[email protected]>
Implement InterruptSourceGroup trait to manage x86 legacy interruts.
On x86 platforms, pin-based device interrupts connecting to the master
PIC, the slave PIC and IOAPICs are named as legacy interrupts. For
legacy interrupts, the interrupt routing logic are manged by the
PICs/IOAPICs and the interrupt group logic only takes responsibility
to enable/disable the interrupts.

Signed-off-by: Liu Jiang <[email protected]>
Signed-off-by: Bin Zha <[email protected]>
With some kvm version, setting irq_routing for non-existing legaccy
IRQs may cause system crash. So limit the number to available legacy
interrupts.

Signed-off-by: 守情 <[email protected]>
Introduce generic mechanism to support message signalled interrupts
based on KVM hypervisor.

Signed-off-by: Liu Jiang <[email protected]>
Signed-off-by: Bin Zha <[email protected]>
Implement interrupt source driver to manage PCI MSI/MSI-x interrupts.

Signed-off-by: Liu Jiang <[email protected]>
Signed-off-by: Bin Zha <[email protected]>
@jiangliu jiangliu force-pushed the interrupt_manager branch from f04d968 to 451a3f7 Compare June 10, 2020 05:32
Support generic MSI interrupts based on VFIO devices, this will be
needed when enabling VFIO device passthrough.

Signed-off-by: Liu Jiang <[email protected]>
jiangliu added 2 commits June 10, 2020 13:36
Mask/unmask/get_pendign_state is needed to support PCI MSI/MSIx when
enabling PCI device passthrough. Also document the overall design
about the interrupt system.

Signed-off-by: Liu Jiang <[email protected]>
A device may support multiple interrupt modes. For example, a PCI
device may support legacy, PCI MSI and PCI MSIx interrupts. So add
struct DeviceInterruptManager to manage the device interupt working
mode. This interrupt manager helps a device backend driver to manage
its interrupts and provides interfaces to switch interrupt working
modes.

Signed-off-by: Liu Jiang <[email protected]>
@jiangliu jiangliu force-pushed the interrupt_manager branch from 451a3f7 to 0e290b5 Compare June 10, 2020 05:36
@jiangliu
Copy link
Author

sorry, wrong target branch again:(

@jiangliu jiangliu closed this Jun 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants