summary refs log tree commit diff
path: root/crosvm_plugin
Commit message (Collapse)AuthorAge
* plugin: allow retrieving and setting VM clockDmitry Torokhov2019-01-22
| | | | | | | | | | | | | Add crossvm plugin API to allow reading and setting guest clock. BUG=b:122878975 TEST=cargo test -p kvm; cargo test --features=plugin Change-Id: I3fd656c06b0e7e43ac88a337ac5d0caec8c59dba Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1419373 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm_plugin: Remove underscores in variable nameChirantan Ekbote2018-11-20
| | | | | | | | | | | | | | | | | | | | | Remove the double underscore in front of `__has_extension` in crosvm.h. Double underscores in identifiers are reserved for the compiler's internal use and as it so happens, `__has_extension` is a macro that clang defines for code to determine whether the compiler supports a given feature. We shouldn't be using double underscores in any of the variable names in this header file but for now just fix the problematic one so that the code can actually compile under clang. BUG=b:80150167 TEST=Compile one of the test plugins with clang Change-Id: Ibb59e72c968a7f245bd6cc693da99f9263eedf33 Signed-off-by: Chirantan Ekbote <chirantan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1341100 Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@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>
* sys_util: remove Scm struct and sock_ctrl_msg C libraryZach Reizner2018-09-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Scm object was made to reduce the number of heap allocations in the hot paths of poll loops, at the cost of some code complexity. As it turns out, the number of file descriptors being sent or received is usually just one or limited to a fixed amount that can easily be covered with a fixed size stack allocated buffer. This change implements that solution, with heap allocation as a backup in the rare case that many file descriptors must be sent or received. This change also moves the msg and cmsg manipulation code out of C and into pure Rust. The move was necessary to allocate the correct amount of buffer space at compile time. It also improves safety by reducing the scope of unsafe code. Deleting the code for building the C library is also a nice bonus. Finally, the removal of the commonly used Scm struct required transitioning existing usage to the ScmSocket trait based methods. This includes all those changes. TEST=cargo test BUG=None Change-Id: If27ba297f5416dd9b8bc686ce740866912fa0aa0 Reviewed-on: https://chromium-review.googlesource.com/1186146 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>
* plugin: do not fail crosvm_vcpu_get_msrs() if we failed to fetch someDmitry Torokhov2018-08-31
| | | | | | | | | | | | | | KVM_GET_MSRS may return less MSRs that were requested; do not fail but instead let callers to know how many were fetched. BUG=None TEST=cargo test --features plugin Change-Id: Ie14a3d38b66bfe34f5279543bea9c6c78423527e Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1192232 Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* plugin: return number of supported MSRS even if buffer is too smallDmitry Torokhov2018-08-29
| | | | | | | | | | | | | | | | | | | | | Userspace is interested in number of supported MSRs even if supplied buffer is too small, as then it can intelligently [re]allocate the buffer and repeat the call instead of doing this blindly. So let's always populate 'out_count'in crosvm_get_msr_index_list() call. Obviously if there is hard error we will not be able to supply a meaningful number, so 0 will be returned, but in case of E2BIG error we can return the real number. Also let's do the same for get_supported_cpuids() and get_emulated_cpuids() calls. BUG=b:111083877 TEST=cargo test -p kvm; cargo test --features=plugin Change-Id: I37a8d719103fac44597b88ddecb6b8af2dd54ac8 Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1185293 Reviewed-by: Zach Reizner <zachr@chromium.org>
* plugin: allow retrieving list of supported MSRsDmitry Torokhov2018-07-31
| | | | | | | | | | | | Add crossvm plugin API to allow fetching list of supported MSRs. BUG=b:111083877 TEST=cargo test -p kvm; cargo test --features=plugin Change-Id: I178c7bc33d606bef10422faac6bb9afb3fe0a014 Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1152229 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>
* plugin: allow retrieving and setting XCR VCPU statesDmitry Torokhov2018-05-18
| | | | | | | | | | | | | Add crossvm plugin API to allow fetching and setting XCRs for VCPU. BUG=b:79692549 TEST=cargo test -p kvm Change-Id: I2a988279c08051a8d8865efc1e60f9692fa26272 Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1062646 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* plugin: measure max/avg latencies of all plugin APISlava Malyugin2018-05-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | A simple stat collecting. Uses RAII to gather latency on all exit paths from function/block. The underscore in "let _u = STATS.u(...)" is to pacify "unused variable" warning. Using "let _ = " makes compiler optimize out the call. Rust makes it particularly hard to convert enums from integers, so I had to add a hack that stores Enum on every invocation of the STATS.u. Looking at disassembly, it added one move of constant to the field of STATS.entries; no heap operations or cloning. A clever alternative using macros was suggested by semenzato@, but I decided saving an instruction was not worth the complexity. The output is currently printed on the destruction of crosvm, so tests print out stats on exit. We probably should find a better place for it though. BUG=None TEST=cargo test --release --features plugin Change-Id: I78a8920e9896b717af3aaea14f8ed6013be6b94f Reviewed-on: https://chromium-review.googlesource.com/1036473 Commit-Ready: Slava Malyugin <slavamn@chromium.org> Tested-by: Slava Malyugin <slavamn@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* plugin: allow retrieving and setting VM and VCPU statesDmitry Torokhov2018-03-30
| | | | | | | | | | | | | This change allows plugin to retrieve and set various VM and VCPU states: interrupt controller, PIT, LAPIC and MP state. BUG=b:76083711 TEST=cargo test -p kvm Change-Id: Ie32a67b0cd4a1f0a19ccd826a6e1c9dc25670f95 Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/986511 Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm_plugin: be more RustyDmitry Torokhov2018-03-08
| | | | | | | | | | | | | | Instead of writing "if let Some(x) = ret.ok()" let's write more idiomatic "if let Ok(x) = ret". BUG=none TEST=sudo cargo test --features plugin Change-Id: Id8c4d0fd2a05783759b5699b65d2333b2a1a6776 Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/956229 Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* plugin: add crosvm_net_get_configStephen Barber2018-03-08
| | | | | | | | | | | BUG=none TEST=sudo cargo test --features plugin Change-Id: Ib38fad250295d73529dff0451345b4274a261073 Reviewed-on: https://chromium-review.googlesource.com/911943 Commit-Ready: Stephen Barber <smbarber@chromium.org> Tested-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* plugin: only convert to negative errors on crosvm.h boundaryDmitry Torokhov2018-03-07
| | | | | | | | | | | | | | | | We have decided that API defined in crosvm.h should signal errors by returning negative values derived from common errno error codes. To avoid confusion within the rest of crosvm code that is using positive erro codes, let's perform the conversion to negative on that crosvm API boundary, so it is contained. TEST=cargo test --features plugin BUG=None Change-Id: Icb1e719c8e99c95fdc32dce13a30d6ff8d3d9dc7 Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/947563 Reviewed-by: Zach Reizner <zachr@chromium.org>
* allow plugin to query KVM for supported/emulated CPUIDsDmitry Torokhov2018-02-28
| | | | | | | | | | | | | This plumbs calls to KVM_GET_SUPPORTED_CPUID and KVM_GET_EMULATED_CPUID to be available to plugins. TEST=cargo test --features plugin; cargo test -p kvm BUG=chromium:800626 Change-Id: I98879599b5f970c6c2720772658689a505d8abe1 Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/938674 Reviewed-by: Zach Reizner <zachr@chromium.org>
* plugin_proto: add helpers to convert CPUID data between KVM and protobufDmitry Torokhov2018-02-27
| | | | | | | | | | | | | We need to convert between protobuf and KVM format of cpuid data in several places, so let's add helpers to plugin_proto crate. TEST=cargo test --features plugin; cargo test -p kvm BUG=chromium:800626 Change-Id: Ida7b59825d2146b0d02711e441f477d90dd4263a Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/939660 Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm_plugin: fix errno conversionsDmitry Torokhov2018-02-27
| | | | | | | | | | | | | | | The raw_os_error() and errno() return positive values (errno values are all positive), but the rest of crosvm plugin C API works with negative return codes, so we need to convert raw_os_error()/errno() into negatives as well. TEST=cargo test --features plugin; cargo test -p kvm BUG=None Change-Id: I8bd72c2e67cb227a638e5c9478cd2f781f0783d0 Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/939865 Reviewed-by: Zach Reizner <zachr@chromium.org>
* allow plugin to query for KVM extensionsZach Reizner2018-02-12
| | | | | | | | | | | | | | The guest may need to check for KVM extensions before blindly using them. TEST=cargo test --features plugin; cargo test -p kvm; ./build_test BUG=chromium:800626 Change-Id: If87b928753cd71adeabac4fc7732c3fce7265834 Reviewed-on: https://chromium-review.googlesource.com/906008 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* add plugin support for configuring CPUIDZach Reizner2018-02-12
| | | | | | | | | | | | | | The guest expects to be able to read the CPUID, so the plugin process needs to specify what the CPUID for each VCPU will have. TEST=cargo test --features plugin; ./build_test BUG=chromium:800626 Change-Id: I9258540ab2501126c3d8cadbd09b7fc01d19f7a9 Reviewed-on: https://chromium-review.googlesource.com/906006 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* allow non-dirty log memory regions from the plugin processZach Reizner2018-02-12
| | | | | | | | | | | | | | | Dirty logging is not necessary for every memory region, so the plugin process should be able to specific exactly which regions it would like dirty logging enabled for. TEST=cargo test --features plugin BUG=chromium:800626 Change-Id: I28b8285357e7de1c8c3a1392bdfdb4853ec5a654 Reviewed-on: https://chromium-review.googlesource.com/900294 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* add plugin support for model specific registersZach Reizner2018-02-12
| | | | | | | | | | | | | | The MSRs are useful for booting a full operating system that requires them. TEST=cargo test --features plugin; cargo test -p kvm; ./build_test BUG=chromium:800626 Change-Id: I817fbf3e6868c85b373808bd48e568b5b2b458eb Reviewed-on: https://chromium-review.googlesource.com/897412 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* add support for accessing debug registers in the plugin processZach Reizner2018-02-12
| | | | | | | | | | | | | | The debug registers are useful to access for the plugin process in some cases. TEST=cargo test --features plugin; cargo test -p kvm; ./build_test BUG=chromium:800626 Change-Id: I8f3f6c31c6989061a43cef948cf5b4e64bd52d30 Reviewed-on: https://chromium-review.googlesource.com/896945 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* add crosvm_plugin dynamic library crateZach Reizner2018-02-07
| | | | | | | | | | | | | | This is the shared library used by the plugin process to speak to a crosvm main process that spawned it. TEST=cargo build --features plugin BUG=chromium:800626 Change-Id: I100e7ddfc1099fbdf1462c171785a861e075d5d7 Reviewed-on: https://chromium-review.googlesource.com/869356 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* add crosvm plugin C header fileZach Reizner2018-01-26
This header file defines the C API used to interface with crosvm as a plugin process. TEST=None BUG=chromium:800626 Change-Id: Ie06b833e25dab8f31f64d8bc8b4b521b61d1ca04 Reviewed-on: https://chromium-review.googlesource.com/764267 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>