summary refs log tree commit diff
Commit message (Collapse)AuthorAge
* crosvm: fix MPTable, enable apicSlava Malyugin2017-11-15
| | | | | | | | | | | | | | The mptable inherited from kvmtool had some missing pieces. On top of that, crosvm does not use KVM_SET_GSI_ROUTING. The addresses makes mptable match the default routing in host kernel and removes "noapic". TEST=cargo build (--release). tatl boot tested on 4.4.0 and 4.4.9 Change-Id: Ibc55abf245cd9d8fca601da204d5a189321c09c7 Reviewed-on: https://chromium-review.googlesource.com/772820 Commit-Ready: Slava Malyugin <slavamn@google.com> Tested-by: Slava Malyugin <slavamn@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* wl: increase max FDs to send/recvZach Reizner2017-11-15
| | | | | | | | | | | | | | This change is to support a related kernel change but is backwards compatible with kernels without that change. BUG=chromium:782474 TEST=None Change-Id: Ic1224b65ed9685f246002f946cfc6bfa2dbb2856 Reviewed-on: https://chromium-review.googlesource.com/770593 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org>
* crosvm: don't die on suspend/resumeStephen Barber2017-11-02
| | | | | | | | | | | | | | | Suspend/resume can cause syscall restarts and will cause KVM_RUN ioctls to return with EINTR. Handle these so the VM doesn't shut down. BUG=none TEST=vm survives suspend/resume Change-Id: I1fab624cb8fe0949d341408f0c962c859a034205 Reviewed-on: https://chromium-review.googlesource.com/750054 Commit-Ready: Stephen Barber <smbarber@chromium.org> Tested-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* io_jail: correct io_jail tests that used Minijail::enter()Zach Reizner2017-11-01
| | | | | | | | | | | | | | This also updates the `build_test.py` to use the command line option to run certain certain test modules serially. TEST=./build_test BUG=None Change-Id: I8a498514cb6b89fab01f02d0ef8faf39629f717c Reviewed-on: https://chromium-review.googlesource.com/748824 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* crosvm: remove stdin from pollables at EOF/errorStephen Barber2017-10-31
| | | | | | | | | | | | | | If reading from stdin returns EOF or an error, remove it from the list of pollables. BUG=none TEST=`vm_launcher start` and check that crosvm no longer pegs CPU Change-Id: I7971058701e6145884de9c52a8dd5b829373637b Reviewed-on: https://chromium-review.googlesource.com/745961 Commit-Ready: Stephen Barber <smbarber@chromium.org> Tested-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm/devices: set thread namesStephen Barber2017-10-30
| | | | | | | | | | | | | | | | crosvm spawns a lot of processes/threads, and having these all use the same name as the original process can be confusing. So at least in the instances where Rust threads are spawned (vs. minijail_fork()), use a thread::Builder to allow setting the thread name. BUG=none TEST=start crosvm, check thread names with top Change-Id: I6e55ff5fd60f258880bda8e656ab7f9da82c656e Reviewed-on: https://chromium-review.googlesource.com/742394 Commit-Ready: Stephen Barber <smbarber@chromium.org> Tested-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org>
* kvm: reuse memory region slotsZach Reizner2017-10-30
| | | | | | | | | | | | | | | | | | | | There is a low limit on the maximum memory slot number imposed by the kernel. On x86_64, that limit is 509. In order to delay hitting that limit, we attempt to use the lowest unused slot number. As memory regions are removed from the VM, the slot for that region is stored in a heap so that that slot number can quickly be reused next time a memory region is added. BUG=None TEST=finish a game of gnome-mahjong using virtio-wayland Change-Id: I786c2e2b8ff239c19b3c8a18bd0f6e8f8dc2acbf Reviewed-on: https://chromium-review.googlesource.com/740102 Commit-Ready: Stephen Barber <smbarber@chromium.org> Tested-by: Stephen Barber <smbarber@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* crosvm: allow specifying wayland path and groupStephen Barber2017-10-26
| | | | | | | | | | | | | | | Add a wayland-sock argument for specifying the path to the wayland socket. Also add a wayland-group argument for specifying the group that has access to that socket. BUG=none TEST=crosvm starts with wayland Change-Id: I3e53eb697951200340613663dc3e4ed28d8ed7f8 Reviewed-on: https://chromium-review.googlesource.com/733732 Commit-Ready: Stephen Barber <smbarber@chromium.org> Tested-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* sys_util: add chown wrapperStephen Barber2017-10-26
| | | | | | | | | | | BUG=none TEST=compile Change-Id: I3ae66955b48c8cd7ae2f468da8780c85fce539d2 Reviewed-on: https://chromium-review.googlesource.com/733731 Commit-Ready: Stephen Barber <smbarber@chromium.org> Tested-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org>
* sys_util: add get_user_id and get_group_id functionsStephen Barber2017-10-26
| | | | | | | | | | | | | Add safe wrappers for getpwnam_r and getgrnam_r. BUG=none TEST=./build_test Change-Id: I737b4d264334ed788884a7320f5649cfc2266709 Reviewed-on: https://chromium-review.googlesource.com/733730 Commit-Ready: Stephen Barber <smbarber@chromium.org> Tested-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* crosvm: bump libc version to 0.2.32Stephen Barber2017-10-25
| | | | | | | | | | | | | | Uprev to 0.2.32 for getgrnam_r. BUG=none TEST=./build_test CQ-DEPEND=CL:734622 Change-Id: I4bc924633b179258c815eaf38f25e7e53d3f0fa5 Reviewed-on: https://chromium-review.googlesource.com/733729 Commit-Ready: Stephen Barber <smbarber@chromium.org> Tested-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* Use minijail_forkDylan Reid2017-10-25
| | | | | | | | | | | Using minijail_fork removes the need to manage user and pid namespace explicitly in crosvm and removes some parent/child synchonization requirements too. Change-Id: I47f9d39527d0a3ccf625600e9bfc2cccc3cb27ca Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/719443 Reviewed-by: Stephen Barber <smbarber@chromium.org>
* Add ability to minijail_forkDylan Reid2017-10-25
| | | | | | | | Change-Id: I0c774816067449cbb838dcf29c6fa947ae5916e1 Reviewed-on: https://chromium-review.googlesource.com/719442 Commit-Ready: Dylan Reid <dgreid@chromium.org> Tested-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* README: use /run pathsMike Frysinger2017-10-23
| | | | | | | | | | | | | | Since /var/run is a symlink to /run, and we want to avoid going through the stateful /var whenever possible, use the direct path. BUG=chromium:699880 TEST=precq passes Change-Id: I5d95f5358c1fb0cb2ca73f9c4b145d8e36b4a361 Reviewed-on: https://chromium-review.googlesource.com/734225 Commit-Ready: Mike Frysinger <vapier@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* Fix new warning with rust 1.21Dylan Reid2017-10-13
| | | | | | | | | | | Mutable references being declared mutable themselves is unnecessary and now generates a warning. Change-Id: I29c7652fb86e17a8eda21efc728dd09b726c304f Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/717733 Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* Move crosvm/hw to a new devices moduleDylan Reid2017-10-09
| | | | | | | | | | Moving the devices to their own module makes it easier to add tests that use them. Change-Id: I61bfef4037d16b20145b5fddce604835cdc4f67b Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/706559 Reviewed-by: Zach Reizner <zachr@chromium.org>
* Move vm_control to a top-level crateDylan Reid2017-10-09
| | | | | | | | | | | Break out vm_control to a crate that will be able to used by more modules. Having vm_control usable from outside crosvm makes it possible to move the devices out of crosvm in a later commit. Change-Id: I1f060700ed49b5d77519d55efa2430490d521256 Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/706558 Reviewed-by: Zach Reizner <zachr@chromium.org>
* main: Default to sandboxed devicesDylan Reid2017-10-03
| | | | | | | | | | Change the default option to use a sanboxxed process for each device. The old behavior can be re-enabled with the `--disable-sandbox` flag. Change-Id: I65762a6cb52afac210fc0e683d999f20fe67a57e Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/696715 Reviewed-by: Zach Reizner <zachr@chromium.org>
* main: use - instead of _ for seccomp policy argumentDylan Reid2017-10-03
| | | | | | | | | The other options all user hyphens. Change-Id: I7f0ab307fd5e50deea8c276bc7a73e43cf692195 Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/696714 Reviewed-by: Stephen Barber <smbarber@chromium.org>
* Load seccomp files from standard locationChirantan Ekbote2017-10-02
| | | | | | | | | | | | | | | | All seccomp policy files get installed in /usr/share/policy on chrome os. Load the virtio device seccomp policy files from there as well. BUG=none TEST=run crosvm under strace -e trace=open and verify that it is loading the policy files from /usr/share/policy Change-Id: I87fa3c57babfd256fb1ac1a827337a95e9c003ad Signed-off-by: Chirantan Ekbote <chirantan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/630059 Commit-Ready: Dylan Reid <dgreid@chromium.org> Tested-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* convert println logs to logging macrosZach Reizner2017-09-29
| | | | | | | | | | | | TEST=build_test BUG=None Change-Id: Ia184e994e996eef427e1b50ce019403f4521f008 Reviewed-on: https://chromium-review.googlesource.com/693138 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org>
* add usage information to READMEZach Reizner2017-09-27
| | | | | | | | | | | | TEST=None BUG=None Change-Id: Iab070c5788e19e63140643115af6e48421989f9b Reviewed-on: https://chromium-review.googlesource.com/683798 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Jason Clinton <jclinton@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org>
* build_test: use command line arguments instead of enviroment variablesZach Reizner2017-09-22
| | | | | | | | | | | | | This change also includes bikeshed style fixes and adds doc strings. TEST=build_test BUG=None Change-Id: I2fec9a3f4488ccf3629e70e5c507695c49389e0d Reviewed-on: https://chromium-review.googlesource.com/679574 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org>
* fix dependency versions and add Cargo.lockZach Reizner2017-09-20
| | | | | | | | | | | | | | | | | | | To ensure dependencies don't accidentally get updated, their versions are fixed using the equals constraint. The Cargo.lock file is also checked in so that the registry won't need to be downloaded by cargo. These changes are needed so that the crosvm ebuild will not need to download anything outside of its list of source packages. TEST=./build_test BUG=None Change-Id: Iae8472de77e3589a453685717b26fb1ceb44e257 Reviewed-on: https://chromium-review.googlesource.com/674092 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* net_util: Remove unused importChirantan Ekbote2017-09-18
| | | | | | | | | | | | | | | | The compiler was complaining about std::fmt::Debug being an unused import. Remove the import. BUG=none TEST=build_test and see no warnings about unused imports Change-Id: I5e606982dffee575b3048b6c45cb5222e63ae3dc Signed-off-by: Chirantan Ekbote <chirantan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/669305 Reviewed-by: Jason Clinton <jclinton@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* Implement virtio-vsockChirantan Ekbote2017-09-18
| | | | | | | | | | | | | Implement the virtual sockets device using vhost subsystem of the host kernel to handle data transfer. BUG=chromium:708267 TEST=build and run maitred in guest VM without issue Change-Id: I35b542c0fc7e0fd9296f7ba3e1dfce60bf524d15 Signed-off-by: Chirantan Ekbote <chirantan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/638838 Reviewed-by: Stephen Barber <smbarber@chromium.org>
* Improve guest memory error handlingDylan Reid2017-09-11
| | | | | | | | | | | | | Pass better errors from mmap and guest_memory. These modules were written before I understood errors. Now the errors passed back to block can be propagated. Change-Id: I1842808a4114a715321c555281aacc211f23511c Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/656837 Reviewed-by: Jason Clinton <jclinton@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* vhost: Fix-up failing tests and add a little more coverageJason D. Clinton2017-09-09
| | | | | | | | | | | | | | | | | | | | | | | | | This fakes out the underlying Net implementation with FakeNet to try and get some of the code a little further along before it explodes. Then, we test for known failures when running without a real vhost file descriptors. This allows us to pass without running as root as we would expect running on Paladins. This is also the final module that was failing at ToT. Also adds vhost to the build_test test targets. BUG=none TEST=Run unit tests: cargo test -p crosvm -p data_model -p syscall_defines -p kernel_loader -p net_util -p x86_64 -p virtio_sys -p kvm_sys -p vhost -p io_jail -p net_sys -p sys_util -p kvm Also ran ./build_test Change-Id: Ie12d05c044634a660a234483532cf783e2a7fe84 Reviewed-on: https://chromium-review.googlesource.com/656278 Commit-Ready: Jason Clinton <jclinton@chromium.org> Tested-by: Jason Clinton <jclinton@chromium.org> Reviewed-by: Jason Clinton <jclinton@chromium.org>
* crosvm: add virtio wayland deviceZach Reizner2017-09-08
| | | | | | | | | | | | | | | This adds the virtio wayland device which is activated by default. The wayland device needs the XDG_RUNTIME_DIR env variable to be set and a running wayland compositor to connect to in that directory. TEST=crosvm run <other args> BUG=chromium:738638 Change-Id: Iaa417c6bb74739896042318451b4befcac0c1d0e Reviewed-on: https://chromium-review.googlesource.com/559860 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* crosvm: add uid_map/gid_map support to jailed devicesZach Reizner2017-09-08
| | | | | | | | | | | | | | | | | | | | | This CL includes a small tweak to sys_util so that cloned processes PIDs are returned. The proxy device CHILD_SIGNATURE check was removed because it would deadlock with the synchronization that DeviceManager's post clone callback uses to wait for the id maps to be set. The check wasn't that useful to begin with. This also bumps the libc version. TEST=None BUG=None Change-Id: I881e08c9626e035044b0be1dd2e9fff3e7e61ec1 Reviewed-on: https://chromium-review.googlesource.com/634270 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* net_util: Fix-up failing tests and add a little more coverageJason D. Clinton2017-09-08
| | | | | | | | | | | | | | | | | | | | We can't really mock out the underlying TAP ioctls unless we introduce another layer of abstraction. Instead, this CL allows a test to pass if the reason that it failed was a permission denial as we would expect running on Paladins as non-root. Also adds net_util to the build_test test targets. BUG=none TEST=Run unit tests: cargo test -p crosvm -p data_model -p syscall_defines -p kernel_loader -p net_util -p x86_64 -p virtio_sys -p kvm_sys -p vhost -p io_jail -p net_sys -p sys_util -p kvm Also ran ./build_test Change-Id: I5c761bd75d3a6d5829f4dd07fb8031612944e912 Reviewed-on: https://chromium-review.googlesource.com/649958 Commit-Ready: Jason Clinton <jclinton@chromium.org> Tested-by: Jason Clinton <jclinton@chromium.org> Reviewed-by: Jason Clinton <jclinton@chromium.org>
* crosvm: bump libc version to 0.2.29Zach Reizner2017-09-07
| | | | | | | | | | | | | | This is so future changes can use getresuid/setresuid and similar syscalls. BUG=chromium:738638 TEST=./build_test Change-Id: I47765fa1f45c549d8e148d02655dd61993a10f58 Reviewed-on: https://chromium-review.googlesource.com/655143 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* io_jail: add ui_map/gid_map support to minijailZach Reizner2017-09-07
| | | | | | | | Change-Id: I6343e879ba75e8ac912590779c620bd0045e74d9 Reviewed-on: https://chromium-review.googlesource.com/634269 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* sys_util: use libc's openlog to connect to syslogZach Reizner2017-09-06
| | | | | | | | | | | | | | | | | | | | | | | By using libc's openlog, we can ensure that the internal state of the libc syslogger is consistent with the syslog module. Minijail will be able to print to stderr and the syslog in the same way the logging macros in crosvm do. The FD the syslog module uses is shared with libc and via `syslog::get_fds`, jailed processes can inherit the needed FDs to continue logging. Now that `sys_log::init()` must be called in single threaded process, this moves its tests to the list of the serially run ones in build_test.py. TEST=./build_test BUG=None Change-Id: I8dbc8ebf9d97ef670185259eceac5f6d3d6824ea Reviewed-on: https://chromium-review.googlesource.com/649951 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Jason Clinton <jclinton@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* crosvm: jailed child processes inherit stderrZach Reizner2017-09-06
| | | | | | | | | | | | | | By inheriting stderr, logs from minijail and the logging macros can be seen in the stderr of crosvm, which is convenient for debugging. BUG=None TEST=None Change-Id: I6d6506776add780b243da50e635c25d27a8976ce Reviewed-on: https://chromium-review.googlesource.com/649952 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Jason Clinton <jclinton@chromium.org>
* io_jail: implement Display for ErrorZach Reizner2017-09-06
| | | | | | | | | | | | | | | | | | | | Running crosvm in multiprocess mode includes setting up an io_jail for each device and it can very often fail due to problems in the enviroment, such as missing policy files or lack of privilege. The auto generated debug error messages were not very good (based on initial user feedback) and so this CL implements display to help make the errors more understandable when they are printed. BUG=None TEST=./build_test Change-Id: If51c00e60abb9b0d482515fa1e401f2fa6fb9e8f Reviewed-on: https://chromium-review.googlesource.com/649950 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Jason Clinton <jclinton@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* crosvm: argument parsing without clapZach Reizner2017-09-02
| | | | | | | | | | | | | | | This removes the clap dependency by replacing that functionality with a custom written parser. Binary size is reduced by about 60% in optimized and stripped mode. TEST=cargo run -- run -h BUG=None Change-Id: I2eaf6fcff121ab16613c444693d95fdf3ad04da3 Reviewed-on: https://chromium-review.googlesource.com/636011 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* data_model: add copy functions for copying slices in VolatileSlice'sZach Reizner2017-09-01
| | | | | | | | | | | | | | | | These copy functions are functionally similar to read_from and write_to, but have stronger guarantees because they are copying to/from concrete slices. In particular, the volatile access pattern is specified and the copy operation never returns an error. TEST=cargo test BUG=chromium:738638 Change-Id: Ie10152e10bc8a36058f5d5001ff392ff8975ee36 Reviewed-on: https://chromium-review.googlesource.com/599043 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* add build_test script to automate crosvm test runningZach Reizner2017-09-01
| | | | | | | | | | | TEST=./build_test && cros lint build_test.py BUG=None Change-Id: I11de92ab1c854264b762c3bb2e3ebda9d3f4b007 Reviewed-on: https://chromium-review.googlesource.com/644409 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* fix armv7a and aarch64 build errors and warningsZach Reizner2017-09-01
| | | | | | | | | | | | | | BUG=None TEST=cargo build --target=armv7a-cros-linux-gnueabi && cargo build --target=aarch64-cros-linux-gnu Change-Id: I954c152f3c8086e24c4809dd5aabb5043fdd63af Reviewed-on: https://chromium-review.googlesource.com/644408 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Jason Clinton <jclinton@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* Refactor the VhostNet virtio deviceChirantan Ekbote2017-08-30
| | | | | | | | | | | | | | | | | | | | | Split the VhostNet virtio device into generic and specific bits. Almost the entire Worker implementation is generic between all vhost devices. The only non-generic bit is a device-specific ioctl to activate a virtqueue. To deal with this add a callback to the Worker's Run function to activate all the virtqueues after they have been set up. BUG=chromium:708267 TEST=build and run with a vhost-net enabled kernel and see that everything still works Change-Id: I262c07e4d2c289f9528924ba708d0b88bd0379bb Signed-off-by: Chirantan Ekbote <chirantan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/636121 Reviewed-by: Jason Clinton <jclinton@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm: unlink control sockets bound to filesZach Reizner2017-08-30
| | | | | | | | | | | | | | | | | | This is a regression from the control socket refactoring. The removal of the control socket receiver class, whose drop impl handled the removal of the socket's files, meant that no code took care of cleaning them up. BUG=None TEST=Run with `-s./` and after a clean exit, make sure there is no *.sock files in the current directory. Change-Id: I0064900f4eec6d054d174d59a4aefdf36ab4d3b3 Reviewed-on: https://chromium-review.googlesource.com/642510 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Jason Clinton <jclinton@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* fix compiler errors and warningsZach Reizner2017-08-30
| | | | | | | | | | | | | | | | | | | | | | Problems that were fixed: - gcc crate deprecated compile_library - `cargo test -p kvm` had a compile error - `cargo test -p kvm_sys` failed to link with libc - main.rs failed to include `getpid` and had dead code - fork.rs had a warning in `cargo test -p sys_util` - unused const in serial.rs BUG=None TEST=sudo cargo test -p data_model -p io_jail -p kernel_loader -p kvm \ -p kvm_sys -p net_sys -p net_util -p syscall_defines -p sys_util \ -p virtio_sys -p vhost -p x86_64 -p crosvm Change-Id: Iaf0389013fbcdfbfaa7cf37ea1a1fc045f480ada Reviewed-on: https://chromium-review.googlesource.com/642509 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Jason Clinton <jclinton@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org>
* Refactor VhostNet into separate vhost and net piecesChirantan Ekbote2017-08-28
| | | | | | | | | | | | | | | | | | A large portion of the VhostNet implementation is common to all vhost devices. Create a new Vhost trait that encapsulates this behavior and split the network specific bits into a new Net type and implement the Vhost trait for it. BUG=chromium:708267 TEST=build and run with a VHOST_NET enabled kernel and see that everything still works fine Change-Id: Ia6b7591f9428c1fba1e13b11791fe40e1bd3942b Signed-off-by: Chirantan Ekbote <chirantan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/630060 Reviewed-by: Jason Clinton <jclinton@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* sys_util: add safe wrappers getpid,geteuid,getguid,waitpid,killZach Reizner2017-08-28
| | | | | | | | | | | | | | | | | | These functions are trivially safe and by adding them to sys_util, we can remove some unsafe blocks from crosvm. This CL also replaces the unsafe call sites with the safe alternatives. There are no previous usages of gete{g,u}id(2), but they will be needed in a future change. TEST=None BUG=None Change-Id: Ief8787b298cfaa5b7fd1b83f0eba6660369e687d Reviewed-on: https://chromium-review.googlesource.com/634268 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* Put seccomp policy files in a common directoryChirantan Ekbote2017-08-25
| | | | | | | | | | | | | | | | | We will almost certainly require different seccomp policy files for different architectures. Move all the existing secommp policy files into a common directory grouped by architecture. This will make it easier to install them via the ebuild later. BUG=none TEST=none Change-Id: I0495789cd4143dc374ee6ebe083dc20ce724edbb Signed-off-by: Chirantan Ekbote <chirantan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/630058 Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* crosvm: refactor and expand vm control socket IPCZach Reizner2017-08-25
| | | | | | | | | | | | | | | | This CL adds VM request capabilities to the control socket. These requests include the basic exit as well as the essential ioeventfd and irqfd requests. For virtio wayland, the register/unregister device memory request was added. TEST=cargo test BUG=chromium:738638 Change-Id: I0cbf62d85a299cf454bcf6924a4e1d52d5b7183f Reviewed-on: https://chromium-review.googlesource.com/602593 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* crosvm: add pure virtio net deviceStephen Barber2017-08-16
| | | | | | | | | | | | | | | | | | | | While vhost_net can provide better performance than a userspace virtio device, it also requires a kernel module to function. This also prevents jailing the virtio device, since virtqueue operations (which necessarily touch guest memory) will be running directly in the kernel. Add a userspace virtio net device that can be jailed and works without vhost support in the kernel. BUG=chromium:703920 TEST=networking works Change-Id: I468114b48abd8e30e967ff16329a5dce6a75018f Signed-off-by: Stephen Barber <smbarber@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/604937 Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm: Add barrier before updating used_ring indexDylan Reid2017-08-14
| | | | | | | | | | | We have to guarantee that all the descriptor writes are visible to the guest before the index update is. Change-Id: I35f1c8d3f5fc9a6ac54de1eb4be66e1c5ac81fc8 Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/611215 Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm: Add virtio randomDylan Reid2017-08-10
| | | | | | | | | Provide the guest OS with /dev/random. Change-Id: I1323836392f3f1d59a6be276ce495e0d78ea9669 Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/603531 Reviewed-by: Zach Reizner <zachr@chromium.org>