summary refs log tree commit diff
path: root/kvm
Commit message (Collapse)AuthorAge
* crosvm: add support for immediate exitMatt Delco2019-10-23
| | | | | | | | | | | | | Adds ability to set the immediate exit bit and ask kvm if it's supported. BUG=None TEST=local compile and test Change-Id: I5c58a5920ebda13267efeb079c0bb671f83464ee Signed-off-by: Matt Delco <delco@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1847857 Reviewed-by: Zach Reizner <zachr@chromium.org>
* vfio: Add msi supportXiong Zhang2019-10-17
| | | | | | | | | | | | | | | | | | | | crosvm doesn't support MSI/MSI-x, but kvmgt vgpu support MSI only through cfg msi capability. This is a simple msi implementation, it detects msi capability and track msi control, data and address info, then call vfio kernel to enable / disable msi interrupt. Currently it supports one vetor per MSI. It could extend to multi vetors and MSI-x. BUG=chromium:992270 TEST=none Change-Id: I04fc95f23a07f9698237c014d9f909d011f447ef Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1581142 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* kvm: Let device could modify its irq routingXiong Zhang2019-10-14
| | | | | | | | | | | | | | | | | | Current all devices use kvm default irq routing table, but when MSI or MSI-x are enabled, they have their own irq routing, here add_irq_route_entry() is added into vm's function, then device could add its irq routing into VM's irq routing table and replace the default kvm irq routing info. BUG=chromium:992270 TEST=none Change-Id: I111f9c3c09ef66b08c6f0432e936ec7e4fd6d270 Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1581145 Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* use `SharedMemory::{named, anon}` to replace `::new`Zach Reizner2019-09-11
| | | | | | | | | | | | | | | | The new constructors are shorter and omit the bare `None` in the `anon` call sites which gave no clues to the reader what the effect of that `None` was. This should improve readability. TEST=./build_test BUG=None Change-Id: I2e34e7df9a4ccc5da50edf4e963a6a42e3d84b22 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1797188 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* edition: Eliminate blocks superseded by NLLDavid Tolnay2019-04-17
| | | | | | | | | | | | | | | | | | | | Before the new borrow checker in the 2018 edition, we sometimes used to have to manually insert curly braced blocks to limit the scope of borrows. These are no longer needed. Details in: https://doc.rust-lang.org/edition-guide/rust-2018/ownership-and-lifetimes/non-lexical-lifetimes.html TEST=cargo check --all-features TEST=local kokoro Change-Id: I59f9f98dcc03c8790c53e080a527ad9b68c8d6f3 Reviewed-on: https://chromium-review.googlesource.com/1568075 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* clippy: Resolve single_matchDavid Tolnay2019-04-17
| | | | | | | | | | | TEST=bin/clippy Change-Id: Iea0d3539b3ab587a2d97f676e1d9c7a239504308 Reviewed-on: https://chromium-review.googlesource.com/1566748 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* clippy: Switch to tool attributes for suppressing lintsDavid Tolnay2019-04-15
| | | | | | | | | | | | | | | | | | | | | | | Tool attributes were stabilized in Rust 1.31: https://blog.rust-lang.org/2018/12/06/Rust-1.31-and-rust-2018.html#tool-lints Before: #[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment)] After: #[allow(clippy::cast_ptr_alignment)] TEST=cargo check --all-features Change-Id: If2f1511f6231d60578b5e0d5bd4210a68eb08caf Reviewed-on: https://chromium-review.googlesource.com/1566651 Commit-Ready: David Tolnay <dtolnay@chromium.org> Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>
* edition: Remove extern crate linesDavid Tolnay2019-04-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Rust 2018 edition, `extern crate` is no longer required for importing from other crates. Instead of writing: extern crate dep; use dep::Thing; we write: use dep::Thing; In this approach, macros are imported individually from the declaring crate rather than through #[macro_use]. Before: #[macro_use] extern crate sys_util; After: use sys_util::{debug, error}; The only place that `extern crate` continues to be required is in importing the compiler's proc_macro API into a procedural macro crate. This will hopefully be fixed in a future Rust release. extern crate proc_macro; TEST=cargo check TEST=cargo check --all-features TEST=cargo check --target aarch64-unknown-linux-gnu TEST=local kokoro Change-Id: I0b43768c0d81f2a250b1959fb97ba35cbac56293 Reviewed-on: https://chromium-review.googlesource.com/1565302 Commit-Ready: David Tolnay <dtolnay@chromium.org> Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>
* edition: Fill in macro importsDavid Tolnay2019-04-15
| | | | | | | | | | | | | | | | | | | | Macros were previously imported through `#[macro_use] extern crate`, which is basically a glob import of all macros from the crate. As of 2018 edition of Rust, `extern crate` is no longer required and macros are imported individually like any other item from a dependency. This CL fills in all the appropriate macro imports that will allow us to remove our use of `extern crate` in a subsequent CL. TEST=cargo check --all-features --tests TEST=kokoro Change-Id: If2ec08b06b743abf5f62677c6a9927c3d5d90a54 Reviewed-on: https://chromium-review.googlesource.com/1565546 Commit-Ready: David Tolnay <dtolnay@chromium.org> Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>
* sys_util: add MemoryMappingArenaDaniel Prilik2019-04-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | There is a hard-limit to the number of MemoryMaps that can be added to a KVM VM, a arch-dependent number defined as KVM_USER_MEM_SLOTS. e.g: on x86 this is 509 (512 - 3 internal slots). For most purposes, this isn't too much of an issue, but there are some cases where one might want to share a lot of mmaps with a Guest. e.g: virtio-fs uses a large cache region for mapping in slices of file fds directly into guest memory. If one tries to add a new KVM memory region for each mmap, the number of available slots is quickly exhausted. MemoryMappingArena is a way to work around this limitation by allocating a single KVM memory region for a large slice of memory, and then using mmap with MAP_FIXED to override slices of this "arena" hostside, thereby achieving the same effect without quickly exhausting the number of KVM memory region slots. BUG=chromium:936567 TEST=cargo test -p sys_util Change-Id: I89cc3b22cdba6756b2d76689176d7147cf238f07 Reviewed-on: https://chromium-review.googlesource.com/1546600 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* cargo: Sort all dependency lists in Cargo.tomlDavid Tolnay2019-04-09
| | | | | | | | | | | | | | | This may help reduce cases of conflicts between independent CLs each appending a dependency at the bottom of the list, of which I hit two today rebasing some of my open CLs. TEST=cargo check --all-features Change-Id: Ief10bb004cc7b44b107dc3841ce36c6b23632aed Reviewed-on: https://chromium-review.googlesource.com/1557172 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* edition: Update kvm and kvm_sys crates to 2018 editionDavid Tolnay2019-04-08
| | | | | | | | | | | | | | | | | | Separated out of CL:1513058 to make it possible to land parts individually while the affected crate has no other significant CLs pending. This avoids repeatedly introducing non-textual conflicts with new code that adds `use` statements. TEST=cargo check TEST=cargo check --all-features TEST=cargo check --target aarch64-unknown-linux-gnu Change-Id: If4140face2c291862f73a3bc095cbf968a442095 Reviewed-on: https://chromium-review.googlesource.com/1519699 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>
* crosvm: add memfd for GuestMemoryDaniel Prilik2019-03-25
| | | | | | | | | | | | | | | | | Building off CL:1290293 Instead of having a seperate GuestMemoryManager, this adds SharedMemory as a Arc'd member of GuestMemory. This is nice since it removes the need to plumb the Manager struct throughout the codebase. BUG=chromium:936567 TEST=cargo test -p sys_util Change-Id: I6fa5d73f7e0db495c2803a040479818445660345 Reviewed-on: https://chromium-review.googlesource.com/1493013 Commit-Ready: Daniel Prilik <prilik@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* Add IOAPIC device skeleton.Miriam Zimmerman2019-03-16
| | | | | | | | | | | | | | | | | | This CL adds some necessary constants and types, as well as a few skeleton function declarations, for an IOAPIC device. I'm sending this CL first in the interest of minimizing CL size and making future CLs easier to review. TEST=Built BUG=chromium:908689 Change-Id: Ib8ae37e0092c31d7cb8073070f9592baed236323 Reviewed-on: https://chromium-review.googlesource.com/1520809 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: Miriam Zimmerman <mutexlox@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>
* edition: Update absolute paths to 2018 styleDavid Tolnay2019-03-13
| | | | | | | | | | | | | | | | | | | | | | | | | | This is an easy step toward adopting 2018 edition eventually, and will make any future CL that sets `edition = "2018"` this much smaller. The module system changes in Rust 2018 are described here: https://doc.rust-lang.org/edition-guide/rust-2018/module-system/path-clarity.html Generated by running: cargo fix --edition --all in each workspace, followed by bin/fmt. TEST=cargo check TEST=cargo check --all-features TEST=cargo check --target aarch64-unknown-linux-gnu Change-Id: I000ab5e69d69aa222c272fae899464bbaf65f6d8 Reviewed-on: https://chromium-review.googlesource.com/1513054 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>
* crosvm: Add KVM_SIGNAL_MSI ioctl.Miriam Zimmerman2019-03-11
| | | | | | | | | | | | | | This ioctl is necessary for a userspace IOAPIC. TEST=Built BUG=chromium:908689 Change-Id: I52fc96baef2193e4f673bbce17a1b56ded9aa6a6 Reviewed-on: https://chromium-review.googlesource.com/1515992 Commit-Ready: Miriam Zimmerman <mutexlox@chromium.org> Tested-by: Miriam Zimmerman <mutexlox@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm: Add ioctl wrappers for split-irqchip API.Miriam Zimmerman2019-03-08
| | | | | | | | | | | | | | | | | This includes: * KVM_ENABLE_CAP * enabling KVM_CAP_SPLIT_IRQCHIP * KVM_INTERRUPT TEST=Built BUG=chromium:908689 Change-Id: I7bae5fbc0b016a47f6e91f6501fab66373f9b106 Reviewed-on: https://chromium-review.googlesource.com/1509694 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Miriam Zimmerman <mutexlox@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* kvm: take a reference to GuestMemory in VcpuZach Reizner2019-01-30
| | | | | | | | | | | | | | | | | | | | | | Logically, each VCPU is using GuestMemory, which holds a ref count to the underlying memory mappings. This change formalizes this by giving an actual reference of GuestMemory to each Vcpu struct. This change is needed because the Vm can go out of scope and clean up its reference, but the Vcpus may still be running, triggering an EFAULT and a lot of confused days spent debugging. TEST=With the unwind panic handler, trigger a panic right after the final vcpu thread barrier. If the VCPU threads do not complain about EFAULT (errno 14), this change worked. BUG=None Change-Id: I6289147de0adde61c81630357701487937b17ade Reviewed-on: https://chromium-review.googlesource.com/1441355 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* kvm: annotate tests for x86-specific APIsDmitry Torokhov2019-01-24
| | | | | | | | | | | | | Not all tests can run on arches other than x86, annotate them accordingly. BUG=None TEST=cargo test -p kvm Change-Id: I38c90f1431b7fbd9059f5c309dc28264bbbcdb99 Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1419206 Tested-by: kokoro <noreply+kokoro@google.com>
* kvm: add wrapper for KVM_KVMCLOCK_CTRL VM ioctlZach Reizner2019-01-23
| | | | | | | | | | | | | | | | | This ioctl will be used to resolve an issue where the jump forward in kvmclock on suspended VCPUs upon resume triggers the soft lockup detection. Using this ioctl prevents this detection from triggering, preventing a kernel panic on resume. TEST=cargo test -p kvm BUG=chromium:920875 Change-Id: Id1402a9d67d790e5e7e8655f2e5916210cc6e7cc Reviewed-on: https://chromium-review.googlesource.com/1415849 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* kvm: plumb accessors for KVM_GET_CLOCK/KVM_SET_CLOCKDmitry Torokhov2019-01-22
| | | | | | | | | | | | | | | Plumb in KVM_GET_CLOCK and KVM_SET_CLOCK to allow clients synchronize timers handled by KVM (LAPIC, PIT) with timers handled by the virtual device layer. BUG=b:122878975 TEST=cargo test -p kvm Change-Id: I2f8867918b82f8ac303e6b60fce2736e38ce2883 Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1419372 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* memory: Add methods to return error on short writes and readsDavid Tolnay2019-01-13
| | | | | | | | | | | | | | | | | | | | Add GuestMemory::write_all_at_addr, GuestMemory::read_exact_at_addr which return error if the entire write or read cannot be completed. Also rename write_slice_at_addr to write_at_addr, read_slice_at_addr to read_at_addr to make the entire set of four methods consistent in naming with the methods of std::io::Write and std::io::Read. Context: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1387624/16/devices/src/virtio/tpm.rs#75 TEST=cargo test Change-Id: Ia0775b75281ccf8030c84b41f9018a511204b8c9 Reviewed-on: https://chromium-review.googlesource.com/1407156 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* kvm: add Debug to IoeventAddressJingkui Wang2018-12-25
| | | | | | | | | | | | BUG=None TEST=local build Change-Id: I5edede32f4289c1e369aa46311966cfcd0c48f2c Reviewed-on: https://chromium-review.googlesource.com/1327515 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Jingkui Wang <jkwang@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* toolchain: Update to Rust 1.31.0David Tolnay2018-12-13
| | | | | | | | | | | | | | | | | | We updated the production toolchain from 1.30 to 1.31 in CL:1366446. This CL does the same upgrade for the local developer toolchain and Kokoro. The relevant changes are in rust-toolchain and kokoro/Dockerfile. The rest are from rustfmt. TEST=cargo fmt --all -- --check TEST=as described in kokoro/README.md Change-Id: I3b4913f3e237baa36c664b4953be360c09efffd4 Reviewed-on: https://chromium-review.googlesource.com/1374376 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm: use msg_socket in vm_controlJingkui Wang2018-11-19
| | | | | | | | | | | | | Refactor existing code to use msg_socket. BUG=None TEST=local build and run Change-Id: Iee72326b330e035303f679e1aedd6e5d18ad4f8a Reviewed-on: https://chromium-review.googlesource.com/1260260 Commit-Ready: Jingkui Wang <jkwang@google.com> Tested-by: Jingkui Wang <jkwang@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* cargo fmt with Rust 1.30.0Daniel Verkamp2018-10-31
| | | | | | | | | | | | | | | Rust 1.30.0 ships a new rustfmt that causes a few more formatting changes. BUG=None TEST=Run kokoro tests with updated Rust version Change-Id: I803765ec0f3d2447f627b1e990bce438512367f7 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1307816 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* cargo fmt aarch64 and kvmDaniel Verkamp2018-10-18
| | | | | | | | | | | | | | A few non-rustfmt changes slipped in since the tree-wide formatting pass. BUG=None TEST=Re-run `cargo fmt` and verify that it makes no further changes. Change-Id: Ic5afb20dabc1087e5d6f54862e6b8b47c5f5608d Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1287369 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* kvm: fix clippy error about mis-aligned pointer castsZach Reizner2018-10-12
| | | | | | | | | | | BUG=None TEST=cargo test -p kvm Change-Id: I43321d01a02821495fb8a8f0f03df21eacc688ee Reviewed-on: https://chromium-review.googlesource.com/1277873 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* kvm: fix clippy error about multiple mut referencesZach Reizner2018-10-12
| | | | | | | | | | | TEST=cargo test -p kvm BUG=None Change-Id: I2d4552b693f253f8411199ecf4583553c80e37a6 Reviewed-on: https://chromium-review.googlesource.com/1277874 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* kvm: refactor ioeventfd datamatch interfaceDaniel Verkamp2018-10-11
| | | | | | | | | | | | | | | This allows the caller to specify the full range of datamatch options defined in the KVM ioeventfd API, including matching accesses of a particular size with or without matching a specific data value. BUG=None TEST=cargo test -p kvm Change-Id: I28b543f7c0b35eb2a6d47a14a33145ea00d09d1d Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1271836 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* cargo fmt all source codeZach Reizner2018-10-09
| | | | | | | | | | | | | | Now that cargo fmt has landed, run it over everything at once to bring rust source to the standard formatting. TEST=cargo test BUG=None Change-Id: Ic95a48725e5a40dcbd33ba6d5aef2bd01e91865b Reviewed-on: https://chromium-review.googlesource.com/1259287 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* kvm: fix get_msrs() to handle case where KVM does not fetch all MSRsDmitry Torokhov2018-08-31
| | | | | | | | | | | | | | KVM may not return all MSRs that were requested in KVM_GET_MSRS call and instead stop early. We should handle this case. BUG=None TEST=cargo test -p kvm Change-Id: I18402c0a07b1d0c7657c171873d521fd2f223611 Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1192231 Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* kvm: fix set_gsi_routing() testDmitry Torokhov2018-08-31
| | | | | | | | | | | | | | We have to create irqchip in kernel before we are allowed to set up routing. BUG=None TEST=cargo test -p kvm Change-Id: Icee680ce3cc16af9cf4492c048f0b9b3cbe98d09 Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1192230 Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* kvm: plumb accessor for KVM_GET_MSR_INDEX_LISTDmitry Torokhov2018-07-31
| | | | | | | | | | | | | Plumb in KVM_GET_MSR_INDEX_LIST to allow clients to figure out what MSRs are supported. BUG=b:111083877 TEST=cargo test -p kvm Change-Id: I69deba32a21fb9360f8cd53001d717338523fb71 Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1152228 Reviewed-by: Zach Reizner <zachr@chromium.org>
* plugin: allow retrieving and setting VCPU eventsSlava Malyugin2018-07-11
| | | | | | | | | | | | | Add crosvm plugin API to allow fetching and setting VCPU events. BUG=b:110056268 TEST=cargo test --features plugin -p kvm Change-Id: Id66230f180f4bdb95bd1850ed050e439083701cc Reviewed-on: https://chromium-review.googlesource.com/1128045 Commit-Ready: Slava Malyugin <slavamn@chromium.org> Tested-by: Slava Malyugin <slavamn@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* kvm: fix test for getting and setting xcrsDmitry Torokhov2018-05-17
| | | | | | | | | | | | | The extension condition was reversed, also SSE is not enabled by default in guest VCPU, so limit the test to setting the FP bit. BUG=b:79692549 TEST=cargo test -p kvm Change-Id: I2959fe7dfff79703777d6254deae817fea892b00 Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1062645 Reviewed-by: Zach Reizner <zachr@chromium.org>
* kvm: plumb accessors for VCPU XCR stateDmitry Torokhov2018-05-16
| | | | | | | | | | | | | Plumb in KVM_GET_XCRS and KVM_SET_XCRS to allow saving and restoring extended control registers of VCPUs. BUG=b:79692549 TEST=cargo test -p kvm Change-Id: I77dcb2ac488bf73b7503f49875d91e7c0cb21003 Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1060613 Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm: aarch64: get kernel's preferred target type for vcpusSonny Rao2018-04-03
| | | | | | | | | | | | | | | | | | | | This fixes an issue on kevin where if we start on a little core, the kernel doesn't like the generic ARMv8 target cpu type for some reason. To fix this we must query the preferred type from the vm device first and supply that to the vcpu init ioctl. We need to change the signature of the configure_vcpu method to pass in the vm object even though we aren't using it on x86. BUG=chromium:797868 TEST=./build_test passes on all architectures TEST=crosvm runs on kevin Change-Id: I460cb9db62a8805bb88f838956aa4f1c69183961 Reviewed-on: https://chromium-review.googlesource.com/982996 Commit-Ready: Sonny Rao <sonnyrao@chromium.org> Tested-by: Sonny Rao <sonnyrao@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm: aarch64 guest supportSonny Rao2018-04-03
| | | | | | | | | | | | | | | | | | | - removes old ARMv7a (32-bit) bindings as we're only supporting aarch64 guests right now - switches both ARMv7 and aarch64 builds to use aarch64 kvm bindings - adds support for ARMv8 Linux guest with dynamic flattened-device-tree CQ-DEPEND=990894 BUG=chromium:797868 TEST=./build_test passes on all architectures TEST=crosvm runs on caroline TEST=crosvm runs on kevin built with USE="kvm_host" Change-Id: I7fc4fc4017ed87fd23a1bc50e3ebb05377040006 Reviewed-on: https://chromium-review.googlesource.com/969987 Commit-Ready: Sonny Rao <sonnyrao@chromium.org> Tested-by: Sonny Rao <sonnyrao@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* kvm: fix fetching irqchip state for PICs other than the first oneDmitry Torokhov2018-03-30
| | | | | | | | | | | | | | | | The KVM API to fetch interrupt controller state expects caller to supply number (id) of the interrupt controller number in which state the caller is interested. To allow crosvm to fetch the correct state and to improve type safety we split the API into one that handles the PIC (primary and secondary) and the one that handles IOAPIC. BUG=b:76083711 TEST=cargo test -p kvm Change-Id: Ia45b51cb218072a275c244af2de1b4a73a1d3352 Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/986510 Reviewed-by: Zach Reizner <zachr@chromium.org>
* kvm: plumb accessors for VCPU MP stateDmitry Torokhov2018-03-29
| | | | | | | | | | | | | Plumb in KVM_GET_MP_STATE and KVM_SET_MP_STATE to allow saving and restoring "multiprocessing state" of VCPUs. BUG=b:76083711 TEST=cargo test -p kvm Change-Id: Ia6e98a09c12dcc859196908f865fac57d48b2ddd Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/982372 Reviewed-by: Dylan Reid <dgreid@chromium.org>
* crosvm: fix documentation for SystemEventSonny Rao2018-03-29
| | | | | | | | | | | | | | The documentation for the SystemEvent exit reason needs to specify the positions for the two fields. BUG=chromium:797868 TEST=./build_test passes on all architectures Change-Id: Ida98ba4a6b383a1c10fa48356decc1c5264999ec Reviewed-on: https://chromium-review.googlesource.com/986721 Commit-Ready: Sonny Rao <sonnyrao@chromium.org> Tested-by: Sonny Rao <sonnyrao@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm: support VM shutdown via SystemEventSonny Rao2018-03-29
| | | | | | | | | | | | | | | | | ARM systems don't have an exit event fd like x86, instead one of the Vcpus will exit with the SystemEvent reason and put a code into the kvm run union of either shutdown, reboot, or crash. We currently don't handle reboot or crash differently but can do so in the future. BUG=chromium:797868 TEST=./build_test passes on all architectures TEST=crosvm runs on kevin - manually test shutdown via maitred Change-Id: I455cbe1ac653f61a1e9eae1ce22922d14cff4e3c Reviewed-on: https://chromium-review.googlesource.com/982531 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Sonny Rao <sonnyrao@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* kvm: plumb accessors for IRQCHIP and PIT stateDmitry Torokhov2018-03-27
| | | | | | | | | | | | | | Plumb in KVM_GET_IRQCHIP/KVM_SET_IRQCHIP and KVM_GET_PIT2/KVM_SET_PIT2 to allow saving and restoring irqchip and PIT state. BUG=b:76083711 TEST=cargo test -p kvm Change-Id: I45a0beb3315f67af7cd9deee80dce0ca25f05001 Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/981592 Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* kvm: silence a warning on non-x86 buildsSonny Rao2018-03-12
| | | | | | | | | | | | | | | We don't use this particular constant on non-x86 builds, so let's leave it out if when it's not needed. BUG=chromium:797868 TEST=build_test passes TEST=crosvm runs on caroline Change-Id: Ic752f9ae33d577d78c7df282e9803936aa181504 Reviewed-on: https://chromium-review.googlesource.com/952166 Commit-Ready: Sonny Rao <sonnyrao@chromium.org> Tested-by: Sonny Rao <sonnyrao@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* kvm: add tests for get_supported_cpuid() and get_emulated_cpuid()Dmitry Torokhov2018-03-08
| | | | | | | | | | TEST=cargo test -p kvm BUG=None Change-Id: I2af245cb94d68faf091bf6788842c1932240df3d Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/947320 Reviewed-by: Zach Reizner <zachr@chromium.org>
* kvm: fix invocation of KVM_SET_SIGNAL_MASK ioctlDmitry Torokhov2018-03-08
| | | | | | | | | | | | | | | | Linux kernel expects size of sigset passed in through KVM_SET_SIGNAL_MASK ioctl to be exactly 8, but Rust's sigset size is 128 bytes, so we can not use sizeof to set up the size. Also let's add test set_signal_mask(). TEST=cargo test --features plugin; cargo test -p kvm; ./build_test BUG=chromium:800626 Change-Id: Ica757ad63d6754d5c8008ba1735982c7ca026f33 Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/944849 Reviewed-by: Zach Reizner <zachr@chromium.org>
* kvm: fix a couple of typos in commentsDmitry Torokhov2018-02-28
| | | | | | | | | | BUG=None TEST=cargo test --features plugin; cargo test -p kvm Change-Id: If3408984ebb4f9212aaaae6084353a411a7f902b Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/938845 Reviewed-by: Zach Reizner <zachr@chromium.org>
* kvm: plumb in KVM_GET_EMULATED_CPUIDDmitry Torokhov2018-02-27
| | | | | | | | | | | | | | This plumbs in KVM_GET_EMULATED_CPUID to allow userspace to figure out whether a certain feature(s) can be used or whether they are too expensive. TEST=cargo test --features plugin; cargo test -p kvm BUG=chromium:800626 Change-Id: I914415a311f40d079b1703efb5129fd91b0d24ad Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/933243 Reviewed-by: Zach Reizner <zachr@chromium.org>
* kvm: do not use negative error coded for errno-based errorsDmitry Torokhov2018-02-27
| | | | | | | | | | | | | | | Errors derived from sysem errors delivered via -1 return code/errno should use positive error codes, not negative, in order for them to be recognized by other components. I.e. we should use errno::Error::new(EINVAL) and not -EINVAL. TEST=cargo test --features plugin; cargo test -p kvm BUG=None Change-Id: Ibe91745c36765c64aeab2f6aae5cd0ca8f243a42 Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/939868 Reviewed-by: Zach Reizner <zachr@chromium.org>