Commit graph

21 commits

Author SHA1 Message Date
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
Dylan Reid
5d084600e9 sys_util: Add struct utils
These utilities are used for reading structs from u8 slices.
Often the kernel returns pointers to void pointers that represent a struct.
This helps convert back to the struct.

Change-Id: I6e59fb772f3ba75f006c9370412267ff565dfe4c
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/497768
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-05-10 20:58:06 -07:00
Zach Reizner
66b86b50ca kvm: add kvm crate to safely use kvm
This change adds a library that makes the usage of kvm safe. Features
that are in this initial patch are:
- checking for kvm extensions
- creating vms and vcpus
- adding memory regions
- accessing cpu registers
- running vcpus
- using kvm_run structure on kvm exit
- registering ioevents and irqevents

TEST=cargo test [--target=armv7a-cros-linux-gnueabi]
BUG=chromium:711556

Change-Id: I1f18aad0341ef5129bc5504e9419a3c422d8bdfd
Reviewed-on: https://chromium-review.googlesource.com/478551
Commit-Ready: Dylan Reid <dgreid@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-05-08 12:40:51 -07:00
Zach Reizner
48faad1bc6 sys_util: add eventfd module
In KVM, eventfd's are essential for sending and receiving signals to the
VM. This CL adds a safe wrapper around their usage.

TEST=cargo test
BUG=None

Change-Id: I04cd9036db156bfa8b9bd49281347a2460fbff2c
Reviewed-on: https://chromium-review.googlesource.com/496988
Commit-Ready: Dylan Reid <dgreid@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-05-08 12:40:51 -07:00
Zach Reizner
00f90a4bba sys_util: add sys_util crate for misc system modules
This initial commit includes an mmap wrapper.

TEST=cargo test
BUG=None

Change-Id: I9625bd446fcd4801b2e16188897e84714b4e4ce0
Reviewed-on: https://chromium-review.googlesource.com/496987
Commit-Ready: Dylan Reid <dgreid@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-05-08 12:40:50 -07:00
Dylan Reid
303f86fa21 kvm-sys: rename to kvm_sys
underscores are better

Change-Id: Ida36de419f6ecf704f40d868cf7296d4d4fc41e6
Reviewed-on: https://chromium-review.googlesource.com/492666
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-05-02 05:20:27 -07:00
Zach Reizner
bf86e0fc86 kvm_sys: add default trait to generated types
The defaults all produce zeroed out structures, which are convenient to
use for the larger structures or ones with padding.

TEST=cargo test [--target=armv7a-cros-linux-gnueabi]
BUG=chromium:711556

Change-Id: I2910791b222e12381e0bbb65331d83f068ad7529
Reviewed-on: https://chromium-review.googlesource.com/484740
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-05-02 05:20:27 -07:00
Dylan Reid
ee8293fd60 Add editor temp files to .gitignore
Change-Id: Ib15b732192de4d59798501f662b1806bc26ad1c3
Reviewed-on: https://chromium-review.googlesource.com/490907
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-05-02 05:20:26 -07:00
Zach Reizner
034134b2db kvm-sys: fix alignment and size errors in bindings
These errors were caught by the autogenerated test but required manual
fixing. The alignment issues are there because bindgen uses PhantomData
to emulate zero sized arrays at the end of structs, but rust will align
the structs as if PhantomData is not there. The single size issue seems
to be a bindgen bug in which an extra bitfield u8 was added.

BUG=chromium:711556
TEST=cargo test

Change-Id: Ib42674bc485e8b93b77d4d9e2f424c05f9746757
Reviewed-on: https://chromium-review.googlesource.com/477613
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-04-21 21:57:31 -07:00
Zach Reizner
30055ecabd kvm-sys: add arm bindings
Depending on which linux kernel headers are used, different outputs for
bindgen are given. In particular, some structs in x86's kvm.h are not in
arm's kvm.h and the other way around. This presented as compile time
failures when compiling the ioctl number functions which take these
struct types as parameters.

This change solves this my lumping ioctls into an x86 module, arm
module, and common module. Additionally, bindgen is run with the x86
kvm.h and the arm kvm.h header and only the appropriate one is included
at build time.

This change also fixes a few ioctls with the incorrect direction label.

TEST=cargo test [--target=armv7a-cros-linux-gnueabi]
BUG=chromium:711556

Change-Id: I7fc0e10587978006b89d16167df1107582b34670
Reviewed-on: https://chromium-review.googlesource.com/482411
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-04-21 21:57:31 -07:00
Zach Reizner
09a0a32345 kvm-sys: start low-level kvm bindings
These bindings are autogenerated via a manual invocation to bindgen.
Also included are the calculations for ioctl numbers, which bindgen was
not capable of generating. Note that a few of the autogenerated tests
fail currently.

BUG=chromium:711556
TEST=cargo test # note there are 4 failures

Change-Id: I818c5bba1f032aec131459de1346c548148e6612
Reviewed-on: https://chromium-review.googlesource.com/477375
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
2017-04-19 16:30:31 +00:00
Zach Reizner
be9feaa3d2 add LICENSE and README
TEST=None
BUG=None

Change-Id: I78e61545c6db18ae37925d02f7b0d6538deb6275
Reviewed-on: https://chromium-review.googlesource.com/478458
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>
2017-04-17 14:06:21 -07:00
Bernie Thompson
8bd0267331 Initial empty repository 2017-04-13 16:43:21 +00:00