Commit graph

62 commits

Author SHA1 Message Date
Stephen Barber
c4968f7de9 sys_util: add ioctl module
Factor out common ioctl wrappers and macros into their own module.

Signed-off-by: Stephen Barber <smbarber@chromium.org>

BUG=none
TEST=cargo test

Change-Id: Ibede8a853f5cc6c6d62565930f312b11024cc5b5
Reviewed-on: https://chromium-review.googlesource.com/566540
Commit-Ready: Stephen Barber <smbarber@chromium.org>
Tested-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-07-13 22:03:30 -07:00
Stephen Barber
8686d9ff5b crosvm: refactor mmio device setup
In preparation for adding a net device, factor out some of the common code
for setting up an mmio device and jailing it.

Signed-off-by: Stephen Barber <smbarber@chromium.org>

BUG=none
TEST=cargo test

Change-Id: I94f02e56a2b0938d860322b731d8b17a25357128
Reviewed-on: https://chromium-review.googlesource.com/543910
Commit-Ready: Stephen Barber <smbarber@chromium.org>
Tested-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-07-13 22:03:30 -07:00
Dylan Reid
861d672430 crosvm: Remove obsolete help message
The cpus option is now used.

Change-Id: I64bcc7cf27427f20b093c70eec3b58cd2c55e290
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/569098
Commit-Ready: Stephen Barber <smbarber@chromium.org>
Tested-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2017-07-13 22:03:30 -07:00
Dylan Reid
e60336cc79 sys_util: syslog - Scope access from within macros
When syslog is used from another crate, the compiler needs a specific
place to look for the symbols.

Change-Id: I5ba1b7ae0e8f6825aaf2a0d0b6ff31dcab21aa0c
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/569360
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-07-13 19:46:09 -07:00
Stephen Barber
79d07c9727 sys_util: add signalfd module
Dealing with signals is unpleasant business. SignalFd wraps a kernel
signalfd for a signal, and blocks the default handling for the signal.

Signed-off-by: Stephen Barber <smbarber@chromium.org>

BUG=none
TEST=cargo test

Change-Id: I161c992b65b98ffa5c07d546f13efa6b56890df4
Reviewed-on: https://chromium-review.googlesource.com/557459
Commit-Ready: Stephen Barber <smbarber@chromium.org>
Tested-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-07-13 11:44:37 -07:00
Zach Reizner
f651357433 crosvm: use sys_util::clone_process to create proxy device
The `clone_process` function was created to safely encapsulate
fork/clone usage for the proxy device. This patch changes proxy device
to do utilize that.

TEST=cargo run -- -u <other crosvm args>...
BUG=None

Change-Id: I2d9f1794be61be31f3aae21037c7df14b7691172
Reviewed-on: https://chromium-review.googlesource.com/518935
Commit-Ready: Stephen Barber <smbarber@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-07-13 11:44:36 -07:00
Zach Reizner
2b2952ff1f sys_util: add fork module for cloning process
This module is designed as a safe wrapper around clone for use by the
proxy device. It includes safe guards that prevent errors with typical
forking applications in rust.

TEST=cargo test
BUG=None

Change-Id: I09132a4cae61ebdaa97ec3b95d22567c36c5f15d
Reviewed-on: https://chromium-review.googlesource.com/518446
Commit-Ready: Stephen Barber <smbarber@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-07-13 11:44:36 -07:00
Zach Reizner
fd3425db47 sys_util: add shared memory module
This CL adds the SharedMemory structure for managing memory attached to
a file descriptor, which can be sent to external processes.

TEST=cargo test
BUG=chromium:738638

Change-Id: I2b6a10e0e7275367ddb578831a73de6956d231bb
Reviewed-on: https://chromium-review.googlesource.com/562509
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-07-10 11:22:37 -07:00
Stephen Barber
f98d8f3ba6 sys_util: add with_regions_mut and make do_in_region pub
Add a new method to GuestMemory that allows running a FnMut over all
regions. This will allow the virtio module to generate a vhost memory
table.

Also make do_in_region public, so that VHOST_NET can find the host
userspace address of vrings (necessary for VHOST ioctls).

BUG=none
TEST=cargo build

Change-Id: I43611dcc56146ed4d160f0e189b9328ca0e6d87d
Reviewed-on: https://chromium-review.googlesource.com/543909
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-07-07 13:15:46 -07:00
Stephen Barber
e4c8c1463e crosvm: fix ordering of args for ack_features
BUG=none
TEST=cargo build

Change-Id: I58b475a4890d1d900c26b3d1c0598936f6f243ac
Reviewed-on: https://chromium-review.googlesource.com/538105
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-07-07 13:15:46 -07:00
Stephen Barber
6a4ca7556a crosvm: add device type for VirtioDevice
A VirtioDevice should expose its type so that the guest can probe it
correctly.

BUG=none
TEST=boot with block device

Change-Id: I6a8cae3afbdc5ae9f6af23eea928c83e67719c12
Reviewed-on: https://chromium-review.googlesource.com/538104
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2017-07-07 13:15:46 -07:00
Dylan Reid
a2b0fc1b8e main: Dynamically create block device pivot root
The block device should get a random, empty directory for its root FS.

Change-Id: I79578b2e2384a2616a55ee02b6777f6cfa42b483
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/520707
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-07-07 13:15:45 -07:00
Dylan Reid
61edbbff53 crosvm: Put block device process in a minijail
Run with the new seccomp filter and drop all capabilities.  In addition enter a
new user, mount, network, and ipc namespace.  Leave the mount namespace empty
after pivot-rooting to an empty directory.

Change-Id: Iee583cf260ede8ca13f005836684eb80c2c3ac3e
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/515603
2017-07-06 21:13:55 -07:00
Zach Reizner
f2164a18bf crosvm: fix serial device panic on write to read-only registers
There were a few cases of a write into the serial device that would
panic because the registers were read-only. This change simply ignores
those writes instead of raising a panic.

This is also the first bug that was found by cargo-fuzz! Wohoo!

TEST=None
BUG=None

Change-Id: I8b6805617ac3dcfddd0555c1bb394a7bc1a7cf6d
Reviewed-on: https://chromium-review.googlesource.com/518445
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-07-05 21:54:53 -07:00
Zach Reizner
639d96775c crosvm: Add crosvm main program
This program is used to boot a 64-bit kernel elf. It has support for
basic devices that are exposed to the kernel, including a block device.

TEST=cargo test;
     cargo run -- -m 512 -c 4 -d rootfs.squashfs -u -p "init=/bin/bash" vmlinux
BUG=chromium:712319

Change-Id: I25a8349a4624d8643fefe2ad70e517fe03b16b8c
Reviewed-on: https://chromium-review.googlesource.com/514417
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-07-05 21:54:52 -07:00
Zach Reizner
61e2a71b32 sys_util: add syslog module for logging to syslog
TEST=cargo test
BUG=None

Change-Id: Ia7ae04976d0ccbabd6d1656ddd9275f16cce218a
Reviewed-on: https://chromium-review.googlesource.com/553741
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-07-05 21:54:50 -07:00
Zach Reizner
848b9ff625 io_jail: add bind mount
This will be used by some device jails to get access to unix sockets
after being jailed.

TEST=None
BUG=None

Change-Id: I870bfb155b275769ccb3248b1441e7c0b8f20ad7
Reviewed-on: https://chromium-review.googlesource.com/558447
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-06-30 22:24:50 -07:00
Zach Reizner
1247525aac crosvm: remove unusued error type from hw::virtio::queue
TEST=cargo build
BUG=None

Change-Id: I651ea4a3e96e459cb8455cdc5a1a8af137af2816
Reviewed-on: https://chromium-review.googlesource.com/558507
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-06-30 22:24:50 -07:00
Dylan Reid
222f732821 kernel_loader: Fix clippy warnings.
Should use &<vec> instead of <vec>.iter() in a for loop.
cmdline returns a size that can't be negative.

Change-Id: I5f0ee3584d8890ac26feaadb99360b2d23f67d70
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/515604
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-06-30 22:24:49 -07:00
Zach Reizner
db8a35a1b1 sys_util: remove accidental HTML from doc comments
For some reason, the angle brackets in the comments confused doc-tests
such that they hung everytime `cargo test` was run on sys_util on my
machine. My theory is that the angle brackets triggered some strange
HTML behavior in `cargo test`.

BUG=None
TEST=cd sys_util; cargo test

Change-Id: Iceb81e64aecc4cc2a9397f2d1af2e64aeb8e2b5e
Reviewed-on: https://chromium-review.googlesource.com/518444
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-06-30 22:24:49 -07:00
Zach Reizner
66cf8bbb34 crosvm: add control socket for crosvm inter-process control
This change adds the control socket, a unix domain socket on the
filesystem that other programs can use to control the operation of
crosvm during runtime. Currently only shutdown is supported.

BUG=None
TEST=cargo test

Change-Id: Ic5f91647e28d279debaa2f9f7dbcb606ca96439b
Reviewed-on: https://chromium-review.googlesource.com/514416
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-06-30 12:51:24 -07:00
Zach Reizner
422e6502de sys_util: add signal module for killing threads
The signal module is used for registering signal handlers and for
signalling threads. Normally signals would be a method of last resort,
but in this case it's the only possible way to trigger a VM exit on a
thread currently inside of a KVM_RUN call.

BUG=None
TEST=None

Change-Id: If1db1e17937d1af08fc24b422c460be754cf9d22
Reviewed-on: https://chromium-review.googlesource.com/514415
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-06-30 12:51:24 -07:00
Zach Reizner
8266b87e0e src_util: add terminal module
The terminal module is for configuring pseudo-terminals in raw mode.

TEST=None
BUG=None

Change-Id: Ic724309e0a0f338fb3b35974643c5ab281eb525e
Reviewed-on: https://chromium-review.googlesource.com/514414
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-06-30 12:51:24 -07:00
Zach Reizner
a053a28685 src_util: add poll module
The poll module adds the Poller object for waiting on mutliple file
descriptors at once. The Pollable trait is introduced so rust objects
can expose a file descriptor useful for polling. An impl for EventFd is
included with this change for testing.

TEST=cargo test
BUG=None

Change-Id: I94fd15a17fe0527c0d29c623badb90668d708689
Reviewed-on: https://chromium-review.googlesource.com/514413
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-06-30 12:51:24 -07:00
Zach Reizner
79b2a73272 sys_util: move handle_eintr!() to sys_util so it can be reused
This CL takes the handle_intr!() macro, changes its name to
handle_eintr!(), and overloads it so it can handle EINTR embedded in
other kinds of Result types.

BUG=None
TEST=cargo test

Change-Id: I920ea7d9f156137f42e9e8ea44a3e6946d06b746
Reviewed-on: https://chromium-review.googlesource.com/556348
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-06-30 12:51:24 -07:00
Dylan Reid
fa8c6802b6 io_jail: Overwrite standard I/O FDs
The FDs for stdin, stdout, and stderr shouldn't be left empty.  Just
closing these FDs causes the next open() call from the jailed process to
reuse the 0, 1, or 2 FD.  This confuses basic infrastructure like
println!.

Change-Id: I40ea471b4a011f2be5132e1a0ff50656ae2ec14a
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/549659
2017-06-28 00:59:00 -07:00
Zach Reizner
b4af07af9c crosvm: add kernel command line builder
The kernel command line is dynamically built up based on what devices
are added and what extra parameters are passed in my the user. The
module this CL adds ensures the kernel command line that is built is a
valid one.

TEST=None
BUG=None

Change-Id: Ia2b7b9fae7eb29140ae25ab34119d050984f8ef2
Reviewed-on: https://chromium-review.googlesource.com/514689
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-06-27 10:55:48 -07:00
Zach Reizner
b3fba4535c sys_util: implement VolatileMemory for Mmap and GuestMemory
Mmap and GuestMemory are the intended targets for the VolatileMemory
trait.

TEST=cargo test
BUG=None

Change-Id: Ie228b5daef691a6dcb80841be1c3dddb4b19ffc4
Reviewed-on: https://chromium-review.googlesource.com/547335
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-06-27 10:55:46 -07:00
Zach Reizner
34959d42c1 data_model: add volatile_memory module for volatile access
This includes both VolatileRef, for accessing DataInit, and
VolatileSlice, for accessing bulk raw memory.

BUG=None
TEST=cargo test

Change-Id: I356c7e6f05361fa711dc91555f68e4323667884a
Reviewed-on: https://chromium-review.googlesource.com/547050
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-06-27 10:55:45 -07:00
Zach Reizner
0d4f8dff72 crosvm: add virtio block device
This device is useful for exposing a block device, for example a rootfs
image, to the guest.

TEST=None
BUG=None

Change-Id: Ida0d24ed57602f25352563893a1c85b171771c7a
Reviewed-on: https://chromium-review.googlesource.com/514688
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-06-27 06:39:56 -07:00
Zach Reizner
8c04d70b7d data_model: add unsigned endian types
These types are just like normal unsigned primitives, except their
endian is explicit.

TEST=cargo test
BUG=None

Change-Id: I3d0a7f7ccbf276e2cfdb34310f173df193c70c79
Reviewed-on: https://chromium-review.googlesource.com/544692
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2017-06-27 06:39:56 -07:00
Dylan Reid
0584fe9fb2 Limit types that can be read from guest memory
Not all types are safe to read from guest memory.  Any type with a
reference or pointer will be initialized to random bits that don't refer
to a valid address.  This can cause dangling pointer and general
unsafe behavior.

To fix this, limit types that can be read with read_obj to those that
implement the unsafe trait `DataInit`.  Provide implementations of
`DataInit` for intrinsic types that are obviously safe to initialize
with random data.

Implement the needed traits for bootparam types as they are read from
the kernel image directly.

Change-Id: I1040f5bc1b2fc4c58c87d8a2ce3f618edcf6f9b1
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/540750
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-06-27 00:20:33 -07:00
Dylan Reid
045c7133dd Add data_model with DataInit trait
The data_model crate is created to hold the DataInit trait.  Types
implementing this unsafe trait must guarantee that the type can be
initialized with random data and the resulting object will be valid.

Change-Id: Id6314d114805ec502adabe50a8bd6aa42fdb2c52
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/541681
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-06-26 15:28:36 -07:00
Dylan Reid
be4a4c97be gitignore: Remove Cargo.lock
Cargo.lock will need to be checked in to ensure reproducible builds.
However continue to ignore Cargo.lock in subdirectories as the main Cargo.lock
shouls dictate the versions of everything.

Change-Id: I448527b3c23bb9de939682ec1a78fd06a2530857
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/538067
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-06-17 01:12:44 -07:00
Dylan Reid
71501e0937 sys_util: Add TempDir class
This will be used to create temporary directories that are lifetime
managed for running jails.

Change-Id: I35dfeae76a211c820db090b65baf72277d9e2d8a
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/520706
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-06-09 21:44:04 -07:00
Zach Reizner
7e33f619c4 crosvm: add virtio MMIO transport module
The MMIO transport, along with PCI, is a standard transport for
discovering and configuring virtio devices and their associated queues.
MMIO is by far easier and simpler and so gets implemented first.

BUG=None
TEST=None

Change-Id: Icdaa02284aedf8ec726199784da45d22c8dbab87
Reviewed-on: https://chromium-review.googlesource.com/514687
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-06-01 23:49:24 -07:00
Zach Reizner
f61e803c48 crosvm: add virtio module with queue module
The queue module is for navigating virtio queues using guest memory. It
is the basis of the virtio protocol post-configuration.

TEST=None
BUG=None

Change-Id: I2e6f9a1398ee06f3e766fe5edcb1c4283ebe7be8
Reviewed-on: https://chromium-review.googlesource.com/514686
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-06-01 23:49:24 -07:00
Zach Reizner
c1c23a86e1 crosvm: add child process device proxy
The purpose of the child process is to enable an extra layer of
isolation between the emulated devices, which have to deal with much
more untrusted guest memory, and the main process which has access to
the kernel's KVM ioctls.

BUG=None
TEST=None

Change-Id: I13c1fcf29e6da88a8a390e1cb174915fa2d86596
Reviewed-on: https://chromium-review.googlesource.com/514685
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-06-01 23:49:24 -07:00
Zach Reizner
cce4a96fcd crosvm: add bus module for address space routing
The Bus object is meant to be useful for arbitrary address space access
routing. In practice, this is used for MMIO and I/O ports.

TEST=None
BUG=None

Change-Id: I1ac7f231ac630a29195773425ce461fa7ade1753
Reviewed-on: https://chromium-review.googlesource.com/514684
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-06-01 23:49:24 -07:00
Zach Reizner
dfda191c8a crosvm: Add hardware module
This initial commit includes a basic serial port, CMOS/RTC device, and
i8042 microcontroller.

TEST=cargo test
BUG=None

Change-Id: Ibdeaca0a9ed6ccbbf575666300d334fad5fdd557
Reviewed-on: https://chromium-review.googlesource.com/514683
Commit-Ready: Dylan Reid <dgreid@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-05-29 21:49:05 -07:00
Dylan Reid
b2ae5fabd3 x86_64: Remove extra closure args and double-derefs
A few places were passing a reference to a reference, which just gets
compiled out anyways.

Some other places where passing `|e| ErrorName(e)` as a closure when
just `ErrorName` would be more succinct.

Change-Id: Ic097a81b956ef82b29fc1a15196c245bee61c251
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/510782
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-05-29 21:49:05 -07:00
Dylan Reid
1a07d1e8d0 syscall_defines: Add linux syscall defines.
Currently used for SYS_clone.

Change-Id: I69c39e0b0a25a93e3e4dd7b4595bd0df1d41418f
Reviewed-on: https://chromium-review.googlesource.com/509920
Commit-Ready: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-05-29 21:49:05 -07:00
Zach Reizner
664bbcb970 x86_64: add multi-cpu setup support
This change includes support for setting up the Intel MP Spec v1.4 table
necessary for emulating multiprocessor x86 systems.

BUG=None
TEST=cargo test

Change-Id: I02ffce49dc9eecfc98f56e5bc6ac009b3e680e27
Reviewed-on: https://chromium-review.googlesource.com/514349
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-05-25 22:51:15 -07:00
Dylan Reid
d4eaa4056f sys_util: Add guest_memory
Add a module for accessing guest memory.
This module will replace all the slices that are used to access it
currently as those slices aren't valid because the memory is volatile
and a volatile slice doesn't exist in rust.

Modify the existing users so they no longer depend on the deprecated slice
access.

Change-Id: Ic0e86dacf66f68bd88ed9cc197cb14e45ada891d
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/509919
2017-05-25 22:51:14 -07:00
Zach Reizner
37285dc09d sys_util: Add conversion from errno io::Error.
Change-Id: Ia49aa8eac1dedbc4e3f6277120bf332404e8b818
Reviewed-on: https://chromium-review.googlesource.com/509918
Commit-Ready: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-05-25 17:16:02 -07:00
Dylan Reid
d6c579fcef io_jail: Add a wrapper around minijail
The io_jail is used to jail io processes run from crosvm. Under the hood
it mostly configures a minijail jail to run in.  The minijail
restrictions are applied when iojail::enter is called.  This closes
extra FDs and calls minijail_enter.

The minijail_run* functions are left out as we don't have a need to exec
foreign programs.  libminijail will be used to jail separate processes
spawned from the main crosvm process.

The ability to close all open file descriptors is added.  Minijail only
closes FDs after forking and before exec.

Change-Id: Ida7f52022c934e9e6edeb7b604cd6e6399860cb9
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/505100
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-05-25 12:25:27 -07:00
Dylan Reid
9195ec9b23 kernel_loader: Add loading of 64 bit elf x86 vmlinux
Change-Id: I2db4beb983e302216949e5de8b250932aa4810b8
Reviewed-on: https://chromium-review.googlesource.com/485019
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-05-17 19:06:31 -07:00
Dylan Reid
67030be903 x86_64: Add x86_64 setup code
Change-Id: Ibdf83f8efcc92bf1f45ed9a5f95117fd9ae3ad5a
Reviewed-on: https://chromium-review.googlesource.com/483868
Commit-Ready: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-05-12 20:58:07 -07:00
Dylan Reid
abd3707450 x86_64: Add bootparams.rs
created from bindgen bootparams.h then run rustfmt

Change-Id: I46fde6aefefb13db5f5bd79378eb17598cf890ec
Reviewed-on: https://chromium-review.googlesource.com/490908
Commit-Ready: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-05-11 22:27:38 -07:00
Dylan Reid
7e742df987 kvm: Add reg setting to kvm
Add the ability to set sregs, lapic, and msrs as they are needed before
running the VM.

Change-Id: I5c6f01f6e5302e3c3519f8748dd292a60180b6d5
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/498129
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-05-11 22:27:38 -07:00