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

Add Interrupt manager to vm-device crate #5

Merged
merged 29 commits into from
Jul 1, 2020

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 29 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>
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>
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>
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>
@sameo
Copy link
Member

sameo commented Jul 1, 2020

Merging to allow for the initial vm-pci crate submission from @jiangliu.
As this currently conflicts with the Cloud Hypervisor interrupt trait implementation, there are no plans for switching to that crate at the moment. If Cloud Hypervisor would be switching, it would follow the ch branch.

@sameo sameo merged commit 50ac0d3 into cloud-hypervisor:dragonball Jul 1, 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.

3 participants