summary refs log tree commit diff
path: root/hypervisor
Commit message (Collapse)AuthorAge
* kvm: use MappedRegion traitGurchetan Singh2020-06-12
| | | | | | | | | | | | | | | | | | | - Reduces code duplication between MMIO and mmap arenas - Makes adding future types easier - Makes upcoming deprecation of kvm crate easier - Use BTreeMap instead of HashMap since it's more efficient BUG=chromium:924405 TEST=compile and test Change-Id: I520abed0926489e64aac046e0dc0cfeb72fae7b2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2216446 Tested-by: Gurchetan Singh <gurchetansingh@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org> Reviewed-by: Steven Richman <srichman@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org>
* hypervisor: add Vm user memory region functionsSteven Richman2020-06-10
| | | | | | | | | | | | | | | | | | The separate Vm functions for MemoryMappings and MemoryMappingArenas have been combined and now use a MappedRegion trait that the mappings implement. msync_memory_region replaces the get_mmap_arena function, which is used by VmMsyncRequest. Since Vm uses mutexes for cloning, it can't return mem region references. BUG=chromium:1077058 TEST=cargo test, cargo test -p sys_util, cargo test -p hypervisor Change-Id: If257b16ee34d07820ae7ebdb9a3a598a41df013c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2202845 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
* devices: irqchip: KvmKernelIrqchip x86_64 implColin Downs-Razouk2020-06-10
| | | | | | | | | | | | | | | | | | Implemented get/set_pic/ioapic/pit functions for the KvmKernelIrqchip. Added respective functions on KvmVm for interacting with the underlying KVM API. Added associated tests for get/set functions. BUG=chromium:1077058 TEST=ran devices tests and added get/set function tests Change-Id: I66a29828fe2f1fbdf54d7325656a003ac09e36d0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2219422 Reviewed-by: Udam Saini <udam@google.com> Reviewed-by: Stephen Barber <smbarber@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Colin Downs-Razouk <colindr@google.com>
* hypervisor: add get/set_pvclockSteven Richman2020-06-03
| | | | | | | | | | | | | | | | The clock functions on the Vm trait are for any arch, to support hypervisors that might have ARM pv clocks. The KVM implementation (x86 only) is mostly the same as before, but uses a hypervisor-agnostic ClockState struct instead of the KVM struct. BUG=chromium:1077058 TEST=cargo test -p hypervisor Change-Id: I0e77ae997d6a30851d28aeb5f73c9ef8ebc464a1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2202742 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Steven Richman <srichman@google.com>
* hypervisor: x86 irqchip structsColin Downs-Razouk2020-05-28
| | | | | | | | | | | | | | | | | | | | Hypervisor-agnostic structures for the pic, ioapic, lapic, and pit. These are derived from existing structures in the pic, ioapic, and pit implementations, as well as from the kvm_sys bindings. Includes From implementations converting these structures to their associated KVM structures. Also includes tests for these conversion implementations. BUG=chromium:1077058 TEST=added tests to convert kvm structures to hypervisor-agnostic structures Change-Id: Ie2f254bf2dba3aed755008296c00cb6a49f845fd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2197716 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Colin Downs-Razouk <colindr@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* hypervisor: add KvmVm new and try_cloneSteven Richman2020-05-21
| | | | | | | | | | | | | | | | | | | | | | | Vms and Vcpus will be try_cloneable and Send, so we can configure on vcpu threads and so IrqChips can reference all Vcpus. To support cloning, collection fields in Vm have been moved into arc mutexes, and Vm and Vcpu are now Sized. Because this breaks object safety, all usage of the traits will be via static binding. Add impl AsRawFd for SafeDescriptor, to get the sys_util ioctl functions working with SafeDescriptor; eventually the functions will change to take SafeDescriptors. Copy set_user_memory_region helper from kvm crate. BUG=chromium:1077058 TEST=cargo test -p hypervisor Change-Id: I23de47c4472a77632006d0d45de9754394b400c2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2197337 Reviewed-by: Udam Saini <udam@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Steven Richman <srichman@google.com>
* devices: irqchip: new irqchip moduleColin Downs-Razouk2020-05-18
| | | | | | | | | | | | | | | | | | This new module contains the irqchip trait and it's implementations. The irqchips will work with the new hypervisor crate to abstract the interaction between crosvm and kvm. This just defines the irqchip trait and an empty implementation of the KvmKernelIrqChip. BUG=chromium:1077058 TEST=added test for creating a KvmKernelIrqChip and adding a Vcpu to it Change-Id: Ic1609c965e0a057f5a9d4d74f1cae46edb46dcb4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2197398 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Stephen Barber <smbarber@chromium.org> Commit-Queue: Colin Downs-Razouk <colindr@google.com>
* Implements the Hypervisor trait for Kvm.Udam Saini2020-05-15
| | | | | | | | | | | | | | | This adds the ability for getting both supported/emulated cpuids from the kvm hypervisor. In addition, checking the available capabilities for kvm is now implemented. BUG=chromium:1077058 TEST=Added unit tests for each implemented function. Change-Id: Ide4c2840b7bfa022deae835eb734ea97c1859169 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2177641 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Udam Saini <udam@google.com>
* hypervisor: add Vm/Vcpu traits and Kvm implsSteven Richman2020-05-09
| | | | | | | | | | | | | | | Add arch-agnostic traits Vm and Vcpu. Add arch-specific traits HypervisorXXX, VmXXX, VcpuXXX, with impls for KVM. BUG=chromium:1077058 TEST=added test for functions and structs interacting with the traits Change-Id: I809f42f32a558c7835831c90e24fca82ce7744ab Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2176562 Reviewed-by: Udam Saini <udam@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Steven Richman <srichman@google.com>
* Adding hypervisor crate to abstract out Kvm implementationUdam Saini2020-05-03
This is a separate hypervisor crate for interacting with Kvm in an abstract manner. The intention is to not leak the internals of kvm with its specific calls in various places in the codebase. Currently, this just creates an initial structure for adding various implementations over time. In addition, a SafeDescriptor class is added, that wraps a raw file descriptor safely, without needing to wrap it in the rust file class. The intention is to use this for non file raw descriptors. BUG=chromium:1077058 TEST=added a basic kvm test that creates a Kvm struct Change-Id: I4229203902e480b52435cde12bf0d25a322c71be Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2174756 Commit-Queue: Udam Saini <udam@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>