forked from rust-vmm/vm-device
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
force-pushed
the
interrupt_manager
branch
2 times, most recently
from
June 10, 2020 02:13
8a64aee
to
f04d968
Compare
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]>
Signed-off-by: 守情 <[email protected]>
jiangliu
force-pushed
the
interrupt_manager
branch
from
June 10, 2020 05:32
f04d968
to
451a3f7
Compare
Support generic MSI interrupts based on VFIO devices, this will be needed when enabling VFIO device passthrough. Signed-off-by: Liu Jiang <[email protected]>
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
force-pushed
the
interrupt_manager
branch
from
June 10, 2020 05:36
451a3f7
to
0e290b5
Compare
sorry, wrong target branch again:( |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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