Skip to content

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 <jing2.liu@linux.intel.com>
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 <jing2.liu@linux.intel.com>
As suggested from
rust-vmm#18 (comment)

Suggested-by: Andreea Florescu <fandree@amazon.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Jing Liu <jing2.liu@linux.intel.com>
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 <jing2.liu@linux.intel.com>
Based on resources definition, this adds device IO manager to manage
all devices IO ranges.

Signed-off-by: Jing Liu <jing2.liu@linux.intel.com>
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 <jing2.liu@linux.intel.com>
Unit tests for IO manager.

Signed-off-by: Jing Liu <jing2.liu@linux.intel.com>
Append missing tests for resources and fix some typo.

Signed-off-by: Jing Liu <jing2.liu@linux.intel.com>
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 <gerry@linux.alibaba.com>
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 <gerry@linux.alibaba.com>
@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 <gerry@linux.alibaba.com>
Export IoSize and IoRange as pub, which may be reused.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Implement Deref for DeviceResources, so we could walk all resource
entries in an Resources object.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
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 <gerry@linux.alibaba.com>
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 <gerry@linux.alibaba.com>
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 <gerry@linux.alibaba.com>
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 <gerry@linux.alibaba.com>
Switch to rust 2018 edition and turn on deny(missing_docs).

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Introduce traits InterruptManager and InterruptSourceGroup to manage
interrupt sources for virtual devices.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Signed-off-by: Bin Zha <zhabin@linux.alibaba.com>
Implement infrastructure to manage interrupt sources based on Linux KVM
kernel module.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Signed-off-by: Bin Zha <zhabin@linux.alibaba.com>
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 <gerry@linux.alibaba.com>
Signed-off-by: Bin Zha <zhabin@linux.alibaba.com>
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: 守情 <liheng.xlh@alibaba-inc.com>
Introduce generic mechanism to support message signalled interrupts
based on KVM hypervisor.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Signed-off-by: Bin Zha <zhabin@linux.alibaba.com>
Implement interrupt source driver to manage PCI MSI/MSI-x interrupts.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Signed-off-by: Bin Zha <zhabin@linux.alibaba.com>
Signed-off-by: 守情 <liheng.xlh@alibaba-inc.com>
@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 <gerry@linux.alibaba.com>
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 <gerry@linux.alibaba.com>
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 <gerry@linux.alibaba.com>
@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