New issue
Advanced search Search tips

Issue 711556 link

Starred by 1 user

Issue metadata

Status: Verified
Owner:
Closed: Jul 2017
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Feature

Blocking:
issue 712319



Sign in to add a comment

crosvm low-level bindings

Project Member Reported by za...@chromium.org, Apr 14 2017

Issue description

Create bindings to access the kernel kvm interfaces.
 

Comment 1 by za...@chromium.org, Apr 17 2017

Blocking: 712319
Project Member

Comment 2 by bugdroid1@chromium.org, Apr 19 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform/crosvm/+/09a0a323459c296ff30dcb0430a24a49d000ec3e

commit 09a0a323459c296ff30dcb0430a24a49d000ec3e
Author: Zach Reizner <zachr@google.com>
Date: Wed Apr 19 16:30:31 2017

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>

[add] https://crrev.com/09a0a323459c296ff30dcb0430a24a49d000ec3e/kvm-sys/src/lib.rs
[add] https://crrev.com/09a0a323459c296ff30dcb0430a24a49d000ec3e/kvm-sys/tests/sanity.rs
[add] https://crrev.com/09a0a323459c296ff30dcb0430a24a49d000ec3e/kvm-sys/Cargo.toml
[add] https://crrev.com/09a0a323459c296ff30dcb0430a24a49d000ec3e/kvm-sys/src/bindings.rs
[add] https://crrev.com/09a0a323459c296ff30dcb0430a24a49d000ec3e/.gitignore

Project Member

Comment 3 by bugdroid1@chromium.org, Apr 22 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform/crosvm/+/034134b2db2d5b5ff43cb9d5f0197057338ec960

commit 034134b2db2d5b5ff43cb9d5f0197057338ec960
Author: Zach Reizner <zachr@google.com>
Date: Sat Apr 22 04:57:31 2017

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>

[modify] https://crrev.com/034134b2db2d5b5ff43cb9d5f0197057338ec960/kvm-sys/src/x86/bindings.rs
[modify] https://crrev.com/034134b2db2d5b5ff43cb9d5f0197057338ec960/kvm-sys/src/arm/bindings.rs

Project Member

Comment 4 by bugdroid1@chromium.org, Apr 22 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform/crosvm/+/30055ecabd01934b05ef3ef35403a04e26973a7a

commit 30055ecabd01934b05ef3ef35403a04e26973a7a
Author: Zach Reizner <zachr@google.com>
Date: Sat Apr 22 04:57:31 2017

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>

[modify] https://crrev.com/30055ecabd01934b05ef3ef35403a04e26973a7a/kvm-sys/src/lib.rs
[modify] https://crrev.com/30055ecabd01934b05ef3ef35403a04e26973a7a/kvm-sys/tests/sanity.rs
[rename] https://crrev.com/30055ecabd01934b05ef3ef35403a04e26973a7a/kvm-sys/src/x86/bindings.rs
[add] https://crrev.com/30055ecabd01934b05ef3ef35403a04e26973a7a/kvm-sys/src/arm/bindings.rs

Project Member

Comment 5 by bugdroid1@chromium.org, May 2 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform/crosvm/+/bf86e0fc86d7bf8b11804a2e89c174798259beee

commit bf86e0fc86d7bf8b11804a2e89c174798259beee
Author: Zach Reizner <zachr@google.com>
Date: Tue May 02 12:20:27 2017

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>

[modify] https://crrev.com/bf86e0fc86d7bf8b11804a2e89c174798259beee/kvm-sys/src/lib.rs
[modify] https://crrev.com/bf86e0fc86d7bf8b11804a2e89c174798259beee/kvm-sys/src/x86/bindings.rs
[modify] https://crrev.com/bf86e0fc86d7bf8b11804a2e89c174798259beee/kvm-sys/src/arm/bindings.rs

Project Member

Comment 6 by bugdroid1@chromium.org, May 8 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform/crosvm/+/66b86b50cad0ee726194bee54c60bfbb7abb4fbe

commit 66b86b50cad0ee726194bee54c60bfbb7abb4fbe
Author: Zach Reizner <zachr@google.com>
Date: Mon May 08 19:40:51 2017

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>

[add] https://crrev.com/66b86b50cad0ee726194bee54c60bfbb7abb4fbe/kvm/src/lib.rs
[add] https://crrev.com/66b86b50cad0ee726194bee54c60bfbb7abb4fbe/kvm/tests/real_run_adder.rs
[add] https://crrev.com/66b86b50cad0ee726194bee54c60bfbb7abb4fbe/kvm/Cargo.toml
[add] https://crrev.com/66b86b50cad0ee726194bee54c60bfbb7abb4fbe/kvm/src/cap.rs

Comment 7 by za...@chromium.org, Jul 1 2017

Status: Verified (was: Started)
Components: OS>Systems>Containers

Sign in to add a comment