summary refs log tree commit diff
path: root/tests
Commit message (Collapse)AuthorAge
* arch, main: add virtio-console parsing and creationDaniel Verkamp2020-04-23
| | | | | | | | | | | | | | | | | | | | | | This allows the creation of virtio-console devices using the new hardware=virtio-console parameter to the --serial option. Also add support for the serial earlycon option, which allows using virtio-console as the main console device with a traditional serial device as the early console. This allows logging during early boot before PCI device discovery (when virtio-console devices are set up). BUG=chromium:1059924 TEST=crosvm run -r vm_rootfs.img \ --serial hardware=serial,type=stdout,console=false,earlycon=true \ --serial hardware=virtio-console,type=stdout,console=true,stdin=true \ vm_kernel Change-Id: Iff48800272b154d49b1da00f3914799089268afe Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2127322 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* arch, devices: move serial creation to archDaniel Verkamp2020-04-23
| | | | | | | | | | | | | | | | | | | | | Split the serial code into two parts: - Configuration and setup: arch/src/serial.rs - Serial device emulation: devices/src/serial.rs No change in functionality - this is just preparation for generalizing the command line parsing/setup code so that it can be used with virtio console devices as well. BUG=chromium:1059924 TEST=emerge-nami crosvm TEST=emerge-kevin crosvm Change-Id: I0aaf9dd6f8096eac4a17077ab5bf569f57d64ff5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2127319 Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* Serial: add input path overriding stdin for --serialIliyan Malchev2020-04-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allowing the input to be specified for file-based serial ports allows the user of pipes as input/output. That enables kgdb over serial. TEST= Build a kernel with support for gdb ``` make x86_64_defconfig make kvmconfig ./scripts/config --enable GDB_SCRIPTS ./scripts/config --enable KGDB ./scripts/config --enable KGDB_SERIAL_CONSOLE ./scripts/config --enable KGDB_LOW_LEVEL_TRAP ./scripts/config --enable KGDB_KDB ./scripts/config --enable KDB_KEYBOARD ./scripts/config --enable GDB_SCRIPTS ./scripts/config --set-val KDB_CONTINUE_CATASTROPHIC 0 make -j33 ``` Setup devices for PTYs To make sure crosvm doesn't create an ordinary file if socat is started after it, create these named pipes first: ``` mkfifo ~/console_{in,out} ~/kgdb_{in,out} ``` Set up two PTYs: ~/kgdb for the debugger, and ~/serial for the console. PTY ~/kgdb connects to ~/kgdb{in,out}, and ~/serial connects to ~/console{in,out} ``` socat -d -d -d \ 'PIPE:$HOME/console_out,rdonly=1,nonblock=1,ignoreeof=1!!PIPE:$HOME/console_in,wronly=1' \ PTY,link=$HOME/serial,ctty,raw,echo=0 socat -d -d -d \ 'PIPE:$HOME/kgdb_out,rdonly=1,nonblock=1,ignoreeof=1!!PIPE:$HOME/kgdb_in,wronly=1' \ PTY,link=$HOME/kgdb,ctty,raw,echo=0 ``` Start crosvm with serial ports pointed at ~/console{in,out} and ~/kgdb{in,out}. ``` cargo run run -p 'init=/bin/sh panic=0 kgdboc=ttyS1,115200 kgdbwait kgdbcon' \ --serial type=file,path=$HOME/console_out,num=1,console=true,stdin=false,input=$HOME/console_in \ --serial type=file,path=$HOME/kgdb_out,input=$HOME/kgdb_in,num=2,console=false,stdin=false \ -r ~/rootfs.img \ ~/src/linux/arch/x86/boot/bzImage ``` Start GDB ``` gdb vmlinux -ex "target remote /home/dgreid/kgdb" ``` To break into gdb, open up the serial console, mount /proc and send a SysRq ``` minicom -D ~/serial mount -t proc none /proc echo g > /proc/sysrq-trigger ``` Change-Id: I18a9c1087d38301df49de08eeae2f8559b03463a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2151856 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Dylan Reid <dgreid@chromium.org>
* crosvm: Apply cargo fix for some clippy errorsKeiichi Watanabe2020-04-15
| | | | | | | | | | | | | | | | | Executed the following command to fix trivial style problems automatically. $ rustup run nightly cargo fix -Z unstable-options --clippy \ --all-features --all-targets BUG=chromium:908640 TEST=build Change-Id: I8a42806dc573b25d4ca918112e7b420793261d37 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2145537 Tested-by: Keiichi Watanabe <keiichiw@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* tests: enable logging for boot testZach Reizner2020-04-14
| | | | | | | | | | | | | | | | | | The logs are important for diagnosing errors for the boot integration testing. This change enables those logs. TEST=cargo test -- boot BUG=None Change-Id: I1cc64fecacb0334118fec748f5382bc16c301e14 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2079177 Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Zach Reizner <zachr@chromium.org> Auto-Submit: Zach Reizner <zachr@chromium.org>
* crosvm: add handling for hyperv exitsMatt Delco2020-03-05
| | | | | | | | | | | | | | | | | When features for Hyper-V are enabled there's a another type of exit that can be triggered. This change attempts to add support for those types of exits. BUG=b:150151095 TEST=ran build_test Change-Id: I3131a2c8d9c610576ac177dbfe82f78e8d5dbfb1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2073254 Reviewed-by: Matt Delco <delco@chromium.org> Tested-by: Matt Delco <delco@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Matt Delco <delco@chromium.org> Auto-Submit: Matt Delco <delco@chromium.org>
* crosvm: add ability to enable caps on vcpuMatt Delco2020-02-20
| | | | | | | | | | | | | | | | | This change primarily adds functionality to allow kvm features to be enabled on a vcpu (most of the current infra only supporst the ioctl for the vm fd). BUG=b:144746965 TEST=ran 'build_test' and verified that the added tests passed. Change-Id: I30c00b6f462377c21d477602ceba5853df953b37 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2055883 Tested-by: Matt Delco <delco@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Matt Delco <delco@chromium.org>
* crosvm: support kvm's hyper-v cpuid ioctlMatt Delco2020-02-20
| | | | | | | | | | | | | | | | | | | | | Kvm can emulate the hyper-v paravirt interface. Newer versions of kvm can advertise the features they support via an ioctl() that reports the cpuid leafs for this interface. This change adds some support for the ioctl() and plumbs it through the plugin interface so that plugins can determine the level of support available in kvm. BUG=b:144746965 TEST=Ran build_test on kernel that supports the ioctl. Added temporary code to print the cpuid leafs and verified that the output is as expected. Instrumented failure as expected from older kernels and verified that results still passed. Change-Id: I6cd7dade1793e4edb52b331d5b960685541f7ba3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2037919 Tested-by: Matt Delco <delco@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Matt Delco <delco@chromium.org>
* tests: avoid internal error in pause testMatt Delco2020-02-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When running plugin tests it's not uncommon to see: vcpu 0 has internal error Though the tests don't actually fail on this problem. This seems to occur as a side effect of the plugin_vcpu_pause.c calling crosvm_destory_memory() before the test VM has actually finished running. The main thread will call read() on the 'kill' eventfd 5 times for: init, pause, unpause, unpause, kill The vcpu thread will call write() on the eventfd up to 8 times: init, pause #1, unpause #1, pause #2, unpause #2, pause #3, unpause #3, kill The main thread's third pause request might occur before the second pause request has been processed, in which case the vcpu thread will only be paused twice (thus there will only be 6 calls to write()). Given the unpredictable # of events I've opted to split the init/pause/unpause events to a separate eventfd and keep the 'kill' eventfd solely for its intended purpose. BUG=None TEST=ran ./build_test several times and observed no failures in the pause plugin test. Change-Id: Ie0817a4419ae6199fcc5c53496360b2bd81556e3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2012788 Reviewed-by: Matt Delco <delco@chromium.org> Commit-Queue: Matt Delco <delco@chromium.org> Tested-by: Matt Delco <delco@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* devices: fs: Support fs crypto ioctlsChirantan Ekbote2019-12-10
| | | | | | | | | | | | | | | | | | Add support for FS_IOC_{GET,SET}_ENCRYPTION_POLICY. Unfortunately, since the I/O direction is encoded backwards in the ioctl definitions, these will only work with on a kernel that's compiled with a patch to mark them as unrestricted FUSE ioctls. BUG=b:136127632 TEST=Compile and run the vfs_crypto.c program on a virtio-fs mount inside a VM Change-Id: I124c5a943111b453dd44921a079a2baa1036dfd4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1952570 Reviewed-by: Chirantan Ekbote <chirantan@chromium.org> Tested-by: Chirantan Ekbote <chirantan@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
* crosvm: add plugin API for async writesMatt Delco2019-11-06
| | | | | | | | | | | | | | | | | | | | | | | A plugin might care to be immediately notified when a write is made to a port, but it doesn't care to have the VM stopped while the plugin calls back to resume the VM. Unfortunately this means that multiple messages can be queued up in the pipe and read() together by the plugin API. Protobuf's parsing function doesn't report how many bytes it read, so I've resorted to having crosvm prefix every message with a length and then have the plugin lib parse this number. Impact on performance has not been measured. BUG=b:143294496 TEST=Local build and run of build_test. Verified that new unit test was executed, exercised the case where multiple msgs are received together, and completed successfully. Change-Id: If6ef463e7b4d2e688e649f832a764fa644bf2d36 Signed-off-by: Matt Delco <delco@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1896376 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Stephen Barber <smbarber@chromium.org>
* crosvm: pre-cache answers to plugin get callsMatt Delco2019-10-31
| | | | | | | | | | | | | | | | This change tries to improve the performance of a plugin-based VM by adding a hint API that allows crosvm to proactively push cpu state to the plugin when certain ports for hypercalls are accessed by the VM. BUG=None TEST=build and run. See performance increase significantly. Change-Id: I71af24ebc034095ffea42eedb9ffda0afc719cd6 Signed-off-by: Matt Delco <delco@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1873005 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* tests: test to see if crosvm can boot a kernelZach Reizner2019-10-31
| | | | | | | | | | | | | | | | | | | | This is the first `cargo test` which uses a linux kernel binary in testing crosvm's major functionality. To get that binary, the test tries various sources which may be influenced by the enviroment. If need be, the chromiumos kernel is downloaded via git, configured, and built so that crosvm can use it. The resulting binary is cached so that other tests which need it can run much quicker. TEST=cargo test -- boot BUG=None Cq-Depend: chromium:1867729 Change-Id: I123441d358ef886e0d7369eaa4ebd87373026d99 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1742924 Reviewed-by: Stephen Barber <smbarber@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Commit-Queue: Zach Reizner <zachr@chromium.org> Auto-Submit: Zach Reizner <zachr@chromium.org>
* plugin: add missing #include <string.h> in testDaniel Verkamp2019-10-22
| | | | | | | | | | | | | | | | | | | Fixes warnings during test build: <stdin>: In function 'main': <stdin>:52:17: warning: implicit declaration of function 'strerror' [-Wimplicit-function-declaration] <stdin>:70:9: warning: implicit declaration of function 'memcmp' [-Wimplicit-function-declaration] BUG=None TEST=docker/wrapped_smoke_test.sh Change-Id: Ibec87db4ca289bec9b1a2c7080fdefebb6e86158 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1863822 Reviewed-by: Zach Reizner <zachr@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>
* 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>
* error: Print errors using Display implDavid Tolnay2019-02-20
| | | | | | | | | | | | | | | | | | | | | | | | | I have been running into Debug-printed error messages too often and needing to look up in the source code each level of nested errors to find out from the comment on the error variant what the short name of the variant means in human terms. Worse, many errors (like the one shown below) already had error strings written but were being printed from the calling code in the less helpful Debug representation anyway. Before: [ERROR:src/main.rs:705] The architecture failed to build the vm: NoVarEmpty After: [ERROR:src/main.rs:705] The architecture failed to build the vm: /var/empty doesn't exist, can't jail devices. TEST=cargo check --all-features TEST=FEATURES=test emerge-amd64-generic crosvm Change-Id: I77122c7d6861b2d610de2fff718896918ab21e10 Reviewed-on: https://chromium-review.googlesource.com/1469225 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>
* 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>
* remove rand crateDaniel Prilik2019-01-17
| | | | | | | | | | | | | | | | | | | the few uses of rand::thread_rng() have been replaced with either prngs or reads from /dev/urandom. the implementations are under the `rand_ish` minicrate. `protoc-rust` depends on `tempdir`, which relies on rand, so `tempdir` has been patched with a rewritten version that does not have rand as a dependency. BUG=chromium:921795 TEST=cargo test --features plugin Change-Id: I6f1c7d7a1aeef4dd55ac71e58294d16c291b8871 Reviewed-on: https://chromium-review.googlesource.com/1409705 Commit-Ready: Daniel Prilik <prilik@google.com> Tested-by: kokoro <noreply+kokoro@google.com> 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: add getpid and prlimit to seccompYunlian Jiang2018-10-23
| | | | | | | | | | | | | This is needed to make sure seccomp work with glibc 2.27 BUG=chromium:897477 TEST=None Change-Id: I101aa07bffd8db2b449be1a697dafcd7d6f1cb58 Reviewed-on: https://chromium-review.googlesource.com/1294729 Commit-Ready: Yunlian Jiang <yunlian@chromium.org> Tested-by: Yunlian Jiang <yunlian@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org>
* crosvm: add openat to seccompYunlian Jiang2018-10-21
| | | | | | | | | | | | | | This adds openat to a seccomp policy file if open is already there. We need this because glibc 2.25 changed it system call for open(). BUG=chromium:894614 TEST=None Change-Id: Ie5b45d858e8d9ea081fd7bfda81709bda048d965 Reviewed-on: https://chromium-review.googlesource.com/1292129 Commit-Ready: Yunlian Jiang <yunlian@chromium.org> Tested-by: Yunlian Jiang <yunlian@chromium.org> Reviewed-by: Manoj Gupta <manojgupta@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>
* fix warning and bit rotted tests uncovered by kokoroZach Reizner2018-09-22
| | | | | | | | | | | TEST=run kokoro presubmit BUG=None Change-Id: I301551f8f58263f1a8b7a8276867881cb17517ab Reviewed-on: https://chromium-review.googlesource.com/1236889 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Stephen Barber <smbarber@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: 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: 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>
* 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>
* Fix race between un-pausing vcpu and requesting vcpu pauseDmitry Torokhov2018-03-08
| | | | | | | | | | | | | | | | To ensure that we do not miss pause request sent while we were in paused state, or were exiting paused state, let's start using KVM_SET_SIGNAL_MASK. SIGRTMIN() + 0 signal will be blocked and thus is not delivered, and it will only be checked when KVM_RUN is being executed, reliably interrupting KVM_RUN. TEST=cargo test --features plugin; cargo test -p kvm; ./build_test BUG=chromium:800626 Change-Id: Iae67a411c23c2b14fbfcbc7d53d0bc86ec4b67d9 Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/944850 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>
* Ensure we are not holding per-cpu data lock when pausing VCPUDmitry Torokhov2018-02-16
| | | | | | | | | | | | | | We may want to issue additional crosvm_pause_vcpu() requests while VCPUs are waiting to be resumed, so we need to make sure we are not holding lock while waiting. TEST=cargo test --features plugin BUG=chromium:800626 Change-Id: Ia74836a567fc565fbd868abdcaa6d0174a4341ad Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/917426 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>
* crosvm: run plugin process in a jail by defaultZach Reizner2018-02-12
| | | | | | | | | | | | | | | The plugin process is similar to a virtual device from the perspective of crosvm. Therefore, the plugin process should be run in a jail, similar to the other devices in crosvm. TEST=cargo build --features plugin; ./build_test BUG=chromium:800626 Change-Id: I881d7b0f8a11e2626f69a5fa0eee0aa59bb6b6be Reviewed-on: https://chromium-review.googlesource.com/882131 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* crosvm: add support for plugin processZach Reizner2018-02-09
The plugin process is good for running a VM that depends substantially on devices that aren't implemented inside of crosvm. TEST=cargo build --features plugin; ./build_test BUG=chromium:800626 Change-Id: I7b4f656563742cd0bedc837205dd1240d497941d Reviewed-on: https://chromium-review.googlesource.com/869357 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>