Commit graph

44 commits

Author SHA1 Message Date
Slava Malyugin
d1e391b8d4 plugin: allow retrieving and setting VCPU events
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>
2018-07-11 18:48:50 -07:00
Dmitry Torokhov
10668e6387 kvm: fix test for getting and setting xcrs
The extension condition was reversed, also SSE is not enabled by default
in guest VCPU, so limit the test to setting the FP bit.

BUG=b:79692549
TEST=cargo test -p kvm

Change-Id: I2959fe7dfff79703777d6254deae817fea892b00
Signed-off-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1062645
Reviewed-by: Zach Reizner <zachr@chromium.org>
2018-05-17 03:24:28 -07:00
Dmitry Torokhov
6051e7593a kvm: plumb accessors for VCPU XCR state
Plumb in KVM_GET_XCRS and KVM_SET_XCRS to allow saving and restoring
extended control registers of VCPUs.

BUG=b:79692549
TEST=cargo test -p kvm

Change-Id: I77dcb2ac488bf73b7503f49875d91e7c0cb21003
Signed-off-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1060613
Reviewed-by: Zach Reizner <zachr@chromium.org>
2018-05-16 05:08:21 -07:00
Sonny Rao
a7fae252b0 crosvm: aarch64: get kernel's preferred target type for vcpus
This fixes an issue on kevin where if we start on a little core, the
kernel doesn't like the generic ARMv8 target cpu type for some reason.  To
fix this we must query the preferred type from the vm device first and
supply that to the vcpu init ioctl.

We need to change the signature of the configure_vcpu method to pass
in the vm object even though we aren't using it on x86.

BUG=chromium:797868
TEST=./build_test passes on all architectures
TEST=crosvm runs on kevin

Change-Id: I460cb9db62a8805bb88f838956aa4f1c69183961
Reviewed-on: https://chromium-review.googlesource.com/982996
Commit-Ready: Sonny Rao <sonnyrao@chromium.org>
Tested-by: Sonny Rao <sonnyrao@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2018-04-03 12:50:39 -07:00
Sonny Rao
2ffa0cbe5b crosvm: aarch64 guest support
- removes old ARMv7a (32-bit) bindings as we're only supporting aarch64
  guests right now
- switches both ARMv7 and aarch64 builds to use aarch64 kvm bindings
- adds support for ARMv8 Linux guest with dynamic flattened-device-tree

CQ-DEPEND=990894
BUG=chromium:797868
TEST=./build_test passes on all architectures
TEST=crosvm runs on caroline
TEST=crosvm runs on kevin built with USE="kvm_host"

Change-Id: I7fc4fc4017ed87fd23a1bc50e3ebb05377040006
Reviewed-on: https://chromium-review.googlesource.com/969987
Commit-Ready: Sonny Rao <sonnyrao@chromium.org>
Tested-by: Sonny Rao <sonnyrao@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2018-04-03 12:50:37 -07:00
Dmitry Torokhov
eda8b21536 kvm: fix fetching irqchip state for PICs other than the first one
The KVM API to fetch interrupt controller state expects caller to supply
number (id) of the interrupt controller number in which state the caller
is interested. To allow crosvm to fetch the correct state and to improve
type safety we split the API into one that handles the PIC (primary and
secondary) and the one that handles IOAPIC.

BUG=b:76083711
TEST=cargo test -p kvm

Change-Id: Ia45b51cb218072a275c244af2de1b4a73a1d3352
Signed-off-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/986510
Reviewed-by: Zach Reizner <zachr@chromium.org>
2018-03-30 00:07:07 -07:00
Dmitry Torokhov
4757cf164b kvm: plumb accessors for VCPU MP state
Plumb in KVM_GET_MP_STATE and KVM_SET_MP_STATE to allow saving and
restoring "multiprocessing state" of VCPUs.

BUG=b:76083711
TEST=cargo test -p kvm

Change-Id: Ia6e98a09c12dcc859196908f865fac57d48b2ddd
Signed-off-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/982372
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2018-03-29 22:00:14 -07:00
Sonny Rao
00549b04a9 crosvm: fix documentation for SystemEvent
The documentation for the SystemEvent exit reason needs to specify
the positions for the two fields.

BUG=chromium:797868
TEST=./build_test passes on all architectures

Change-Id: Ida98ba4a6b383a1c10fa48356decc1c5264999ec
Reviewed-on: https://chromium-review.googlesource.com/986721
Commit-Ready: Sonny Rao <sonnyrao@chromium.org>
Tested-by: Sonny Rao <sonnyrao@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2018-03-29 19:51:34 -07:00
Sonny Rao
6ce158fb86 crosvm: support VM shutdown via SystemEvent
ARM systems don't have an exit event fd like x86, instead one of the Vcpus
will exit with the SystemEvent reason and put a code into the kvm run
union of either shutdown, reboot, or crash.  We currently don't handle
reboot or crash differently but can do so in the future.

BUG=chromium:797868
TEST=./build_test passes on all architectures
TEST=crosvm runs on kevin - manually test shutdown via maitred

Change-Id: I455cbe1ac653f61a1e9eae1ce22922d14cff4e3c
Reviewed-on: https://chromium-review.googlesource.com/982531
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Sonny Rao <sonnyrao@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2018-03-29 13:32:59 -07:00
Dmitry Torokhov
ca3a4822cc kvm: plumb accessors for IRQCHIP and PIT state
Plumb in KVM_GET_IRQCHIP/KVM_SET_IRQCHIP and KVM_GET_PIT2/KVM_SET_PIT2
to allow saving and restoring irqchip and PIT state.

BUG=b:76083711
TEST=cargo test -p kvm

Change-Id: I45a0beb3315f67af7cd9deee80dce0ca25f05001
Signed-off-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/981592
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2018-03-27 18:01:42 -07:00
Sonny Rao
657c1850ab kvm: silence a warning on non-x86 builds
We don't use this particular constant on non-x86 builds, so let's
leave it out if when it's not needed.

BUG=chromium:797868
TEST=build_test passes
TEST=crosvm runs on caroline

Change-Id: Ic752f9ae33d577d78c7df282e9803936aa181504
Reviewed-on: https://chromium-review.googlesource.com/952166
Commit-Ready: Sonny Rao <sonnyrao@chromium.org>
Tested-by: Sonny Rao <sonnyrao@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2018-03-12 12:52:39 -07:00
Dmitry Torokhov
8da6543e74 kvm: add tests for get_supported_cpuid() and get_emulated_cpuid()
TEST=cargo test -p kvm
BUG=None

Change-Id: I2af245cb94d68faf091bf6788842c1932240df3d
Signed-off-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/947320
Reviewed-by: Zach Reizner <zachr@chromium.org>
2018-03-08 00:37:34 -08:00
Dmitry Torokhov
e423460238 kvm: fix invocation of KVM_SET_SIGNAL_MASK ioctl
Linux kernel expects size of sigset passed in through KVM_SET_SIGNAL_MASK
ioctl to be exactly 8, but Rust's sigset size is 128 bytes, so we can
not use sizeof to set up the size.

Also let's add test set_signal_mask().

TEST=cargo test --features plugin; cargo test -p kvm; ./build_test
BUG=chromium:800626

Change-Id: Ica757ad63d6754d5c8008ba1735982c7ca026f33
Signed-off-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/944849
Reviewed-by: Zach Reizner <zachr@chromium.org>
2018-03-08 00:37:32 -08:00
Dmitry Torokhov
9c7508593d kvm: fix a couple of typos in comments
BUG=None
TEST=cargo test --features plugin; cargo test -p kvm

Change-Id: If3408984ebb4f9212aaaae6084353a411a7f902b
Signed-off-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/938845
Reviewed-by: Zach Reizner <zachr@chromium.org>
2018-02-28 21:30:22 -08:00
Dmitry Torokhov
c73d390522 kvm: plumb in KVM_GET_EMULATED_CPUID
This plumbs in KVM_GET_EMULATED_CPUID to allow userspace to figure out
whether a certain feature(s) can be used or whether they are too
expensive.

TEST=cargo test --features plugin; cargo test -p kvm
BUG=chromium:800626

Change-Id: I914415a311f40d079b1703efb5129fd91b0d24ad
Signed-off-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/933243
Reviewed-by: Zach Reizner <zachr@chromium.org>
2018-02-27 20:17:42 -08:00
Dmitry Torokhov
93b00ecca7 kvm: do not use negative error coded for errno-based errors
Errors derived from sysem errors delivered via -1 return code/errno
should use positive error codes, not negative, in order for them to be
recognized by other components. I.e. we should use
errno::Error::new(EINVAL) and not -EINVAL.

TEST=cargo test --features plugin; cargo test -p kvm
BUG=None

Change-Id: Ibe91745c36765c64aeab2f6aae5cd0ca8f243a42
Signed-off-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/939868
Reviewed-by: Zach Reizner <zachr@chromium.org>
2018-02-27 20:17:08 -08:00
Dmitry Torokhov
cda18d757b kvm: do not pass max number of cpuid entries in get_supported_cpuid()
It does not make sense to have users of the API limit number of cpuid
entries retrieved. Just have KVM select reasonable upper limit and
return the true number.

TEST=cargo test --features plugin; cargo test -p kvm
BUG=chromium:800626

Change-Id: I8ab7e8d901bc408d17c23bfe798d89f921488673
Signed-off-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/933242
Reviewed-by: Zach Reizner <zachr@chromium.org>
2018-02-27 17:33:20 -08:00
Dmitry Torokhov
42d194de3f kvm: plumb in KVM_SET_SIGNAL_MASK ioctl
We need this ioctl to implement race-free support for kicking/pausing VCPUs.

TEST=cargo test --features plugin; cargo test -p kvm; ./build_test
BUG=chromium:800626

Change-Id: I5dcff54f7eb34568a8d8503e0dde86b6a36ac693
Signed-off-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/932443
Reviewed-by: Zach Reizner <zachr@chromium.org>
2018-02-26 22:07:11 -08:00
Zach Reizner
dadb7625ea allow plugin to query for KVM extensions
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>
2018-02-12 22:42:40 -08:00
Zach Reizner
7a4d7b1f50 add plugin support for model specific registers
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>
2018-02-12 22:42:36 -08:00
Zach Reizner
53528e33ed add support for accessing debug registers in the plugin process
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>
2018-02-12 22:42:35 -08:00
Zach Reizner
3994c3964e kvm: support irqfds with resample eventfds
The plugin process may require resample events to implement a device
properly.

TEST=cargo test -p kvm; ./build_test
BUG=chromium:800626

Change-Id: I47a3336195f212c9f6c49adfaec24757803c3b7f
Reviewed-on: https://chromium-review.googlesource.com/900489
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2018-02-06 21:32:40 -08:00
Zach Reizner
e0e8e56732 kvm: support adding read only memory to VMs
Read only memory is useful for triggering VM exits when the VM writes to
memory while allowing reads transparently and quickly. For example, a
virtual device implementation might not care if the VM reads a memory
mapped device register, but a exit would be required if the VM wrote to
the same register.

TEST=cargo test -p kvm; ./build_test
BUG=chromium:800626

Change-Id: Ic605b2cfc2a1e44941d91945f9390b9abb820040
Reviewed-on: https://chromium-review.googlesource.com/903075
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2018-02-06 21:32:39 -08:00
Sonny Rao
29cd40a1d6 crosvm: change GuestAddress to always be a u64
We want to be able to run 64-bit ARM kernels using a 32-bit version of
crosvm, to make it more consistent use a u64 to represent
GuestAddress.

BUG=chromium:797868
TEST=./build_test passes on all architectures
TEST=crosvm runs on caroline

Change-Id: I43bf993592caf46891e3e5e05258ab70b6bf3045
Signed-off-by: Sonny Rao <sonnyrao@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/896398
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2018-02-01 18:08:55 -08:00
Zach Reizner
e07bd96ea9 kvm: fix and test set_identity_map_addr
The kernel expects a pointer to a physical address, not a physical
address directly in the ioctl argument.

TEST=cargo test -p kvm
BUG=chromium:800626

Change-Id: I4a7298149373c00b5b9c634cd1dead7053d053c3
Reviewed-on: https://chromium-review.googlesource.com/893215
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2018-01-30 17:47:18 -08:00
Zach Reizner
086922c222 kvm: add set_irq_routing method
This is used by the plugin process API, which may register an IRQ
routing table.

TEST=./build_test
BUG=chromium:800626

Change-Id: If40965e8abfb0c9074c90b5fc77f9042f06499e0
Reviewed-on: https://chromium-review.googlesource.com/857910
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2018-01-25 19:23:42 -08:00
Zach Reizner
d48d7f10b5 kvm: add dirty_log_bitmap_size helper
For the callers of get_dirty_log, they must pass in bitmap large enough
to hold the log. Instead of duplicating that calculation inside the
method and the caller, this change provides a public helper usable by
both to calculate the bitmap's minimum size.

TEST=./build_test
BUG=chromium:800626

Change-Id: I349aa0dd7e78e7f9ea3d35ba0acba8088fd77a4e
Reviewed-on: https://chromium-review.googlesource.com/857909
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>
2018-01-18 17:40:15 -08:00
Zach Reizner
0335dad57e kvm: add ioeventfd and irqfd unregister support
This is needed to support the plugin API, which might unregister such
eventfds.

BUG=chromium:800626
TEST=./build_test

Change-Id: Ic4e74ffd4b2374868644d1f6598509aba741ce00
Reviewed-on: https://chromium-review.googlesource.com/857908
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>
2018-01-18 17:40:14 -08:00
Zach Reizner
ee2f1fe770 sys_util: replace sysconf(_SC_PAGESIZE) with a safe wrapper
There were a few places that used this to get the page size inside of an
unsafe block, For convenience, this adds a safe wrapper in sys_util and
replaces all extant usage of sysconf with the wrapper version.

BUG=chromium:800626
TEST=./build_test

Change-Id: Ic65bf72aea90eabd4158fbdcdbe25c3f13ca93ac
Reviewed-on: https://chromium-review.googlesource.com/857907
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>
2018-01-10 15:44:31 -08:00
Zach Reizner
855ac29cf2 kvm: add dirty log support
This add safe support for KVM's KVM_GET_DIRTY_LOG ioctl.

TEST=./build_test
BUG=None

Change-Id: I3d0f996927844a33addd072f2bfc62361f8b7fe0
Reviewed-on: https://chromium-review.googlesource.com/848019
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2018-01-03 16:54:34 -08:00
Zach Reizner
df59500364 kvm: add KVM_SET_IDENTITY_MAP_ADDR ioctl
BUG=None
TEST=./build_test

Change-Id: Ic5b479487f45949fd0888af6d670293931a6a0a7
Reviewed-on: https://chromium-review.googlesource.com/848017
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2018-01-03 14:23:23 -08:00
Zach Reizner
d60bb1616c kvm: add KVM_GET_FPU ioctl
BUG=None
TEST=./build_test

Change-Id: I38ee166d9c7a0340d58fb3fd7f51895ca158f8b3
Reviewed-on: https://chromium-review.googlesource.com/848016
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2018-01-03 14:23:23 -08:00
Zach Reizner
ce4611cde2 kvm: open /dev/kvm with close on exec
Without this, the KVM FD may leak to child processes.

BUG=None
TEST=./build_test

Change-Id: Ic2f6db6c787d99865c2eefb40ad8993471ee82b2
Reviewed-on: https://chromium-review.googlesource.com/848015
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2018-01-03 14:23:23 -08:00
Sonny Rao
4aa86930ed kvm_sys: update bindings and add aarch64 bindings
Re-generated the bindings for x86_64 and arm which now use union types
so a little bit of code in the library also changed, and adds bindings
for aarch64 which are required to run an aarch64 guest.

Also, I manually fixed the zero-length array cases where rust bindgen
doesn't properly align the structs.  See rust bindgen bug 684.

BUG=chromium:797868
TEST=run crosvm on x86_64, ensure networking works
TEST=./build_test passes on x86

Change-Id: Iab2193a8f1d4c68bd3346ae683c74bbf16fe45d4
Signed-off-by: Sonny Rao <sonnyrao@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/845519
Reviewed-by: Zach Reizner <zachr@chromium.org>
2018-01-02 21:32:18 -08:00
Zach Reizner
d657af628a kvm: reuse memory region slots
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>
2017-10-30 01:31:35 -07:00
Zach Reizner
bb493dd02b convert println logs to logging macros
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>
2017-09-29 23:25:36 -07:00
Zach Reizner
3cbded2c51 fix armv7a and aarch64 build errors and warnings
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>
2017-09-01 12:39:18 -07:00
Zach Reizner
56077cf863 fix compiler errors and warnings
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>
2017-08-30 13:04:16 -07:00
Zach Reizner
29ad3c7d0f crosvm: refactor and expand vm control socket IPC
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>
2017-08-25 19:54:11 -07:00
Zach Reizner
09a95f5e74 kvm: add device memory interface to Vm
This interface is to dynamically add and remove memory mappings to guest
physical address space.

TEST=cargo test
BUG=chromium:738638

Change-Id: I695775289d56686ef16a1e3cf7640c97d5da2662
Reviewed-on: https://chromium-review.googlesource.com/599040
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2017-08-05 22:07:53 -07:00
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
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
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
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