Commit graph

823 commits

Author SHA1 Message Date
Jianxun Zhang
1bc4a06801 run serial test even when parallel test fails
The serial test won't run when parallel group fails
because of the short-circuiting effect of logical
operators.

Assuming the tool was not designed to fail the whole
test prematurely, this change ensures both test groups
executed every time.

BUG=None
TEST=build_test and observe the test cases in serial
group (io_jail and sys_util) are executed when the
parallel group fails.

Change-Id: I86e57069490c58dfed48960d87ea35c2403450b7
Signed-off-by: Jianxun Zhang <jianxun.zhang@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/1488611
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-03-14 20:53:53 -07:00
Lepton Wu
9105e9fbe5 Remove "multiprocess" argument.
Both "multiprocess" and "disable-sandbox" control the same config
and actually they have same final effects. So just remove "multiprocess"
argument and also rename "multiprocess" to "sandbox" to make it more
clear.

BUG=None
TEST=`cros_run_unit_tests --board=eve --packages=crosvm`

Change-Id: I313d110af48b43231b1426332b63868cb0218490
Reviewed-on: https://chromium-review.googlesource.com/1524375
Commit-Ready: Lepton Wu <lepton@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-03-14 20:53:52 -07:00
Zach Reizner
4725a399f7 seccomp: tpm: remove fseek syscall from policy
There is no such syscall as fseek as far as I can tell. There is lseek,
which would be how fseek is implemented in libc, and it is already
included in the policy.

BUG=chromium:936633
TEST=parse_seccomp_policy seccomp/x86_64/tpm_device.policy

Change-Id: Ifb891395d7447d8b81cb1b17af18c49e5d5fc96f
Reviewed-on: https://chromium-review.googlesource.com/1518490
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2019-03-14 20:53:40 -07:00
Chirantan Ekbote
e00faed85c register_space: Only run panic test when debug assertions are on
The regs_reg_overlap() test is a panic test but the function that it is
testing only uses debug_asserts so the test will fail if debug
assertions are disabled.  Only run the test when debug assertions are
enabled.

BUG=chromium:940668
TEST=`FEATURES=test USE=-cros-debug emerge-nami crosvm`

Change-Id: Ie722cb49908ae4c4a9ecc5f248a6ec25fbcc05c9
Reviewed-on: https://chromium-review.googlesource.com/1518729
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jeffrey Kardatzke <jkardatzke@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2019-03-13 21:05:14 -07:00
David Tolnay
2727413c10 edition: Update assertions crate to 2018 edition
Separated out of CL:1513058 to make it possible to land parts
individually while the affected crate has no other significant CLs
pending. This avoids repeatedly introducing non-textual conflicts with
new code that adds `use` statements.

TEST=cargo check
TEST=cargo check --all-features
TEST=cargo check --target aarch64-unknown-linux-gnu

Change-Id: I99843b923094e4df7a139f22a30eb19527d11d98
Reviewed-on: https://chromium-review.googlesource.com/1519689
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: David Tolnay <dtolnay@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Tolnay <dtolnay@chromium.org>
2019-03-13 21:05:03 -07:00
David Tolnay
fe3ef7d998 edition: Update absolute paths to 2018 style
This is an easy step toward adopting 2018 edition eventually, and will
make any future CL that sets `edition = "2018"` this much smaller.

The module system changes in Rust 2018 are described here:

https://doc.rust-lang.org/edition-guide/rust-2018/module-system/path-clarity.html

Generated by running:

    cargo fix --edition --all

in each workspace, followed by bin/fmt.

TEST=cargo check
TEST=cargo check --all-features
TEST=cargo check --target aarch64-unknown-linux-gnu

Change-Id: I000ab5e69d69aa222c272fae899464bbaf65f6d8
Reviewed-on: https://chromium-review.googlesource.com/1513054
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: David Tolnay <dtolnay@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Tolnay <dtolnay@chromium.org>
2019-03-13 21:05:03 -07:00
Jingkui Wang
fa13275942 add scatter gather buffer
scatter gather buffer is a buffer with segments.

CQ-DEPEND=CL:1510816
BUG=chromium:831850
TEST=cargo test

Change-Id: Iea54d5b3d6f9194113f6237eb14aafab71ca2ff9
Reviewed-on: https://chromium-review.googlesource.com/1510817
Commit-Ready: Jingkui Wang <jkwang@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Jingkui Wang <jkwang@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-03-13 21:04:58 -07:00
Jingkui Wang
115fe4e233 usb: add interrupter and resample handler for xhci
Interrupter owns event ring and send interrupt. Resample handler will
reassert interrupt when resample happens.

CQ-DEPEND=CL:1510815
BUG=chromium:831850
TEST=local build

Change-Id: If2c4349e50d0ab275f29dfa48b0860c86f0c8ea3
Reviewed-on: https://chromium-review.googlesource.com/1510816
Commit-Ready: Jingkui Wang <jkwang@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Jingkui Wang <jkwang@google.com>
2019-03-13 21:04:58 -07:00
Jingkui Wang
e9f5cae48f allow dead code for usb modules
This will remove warning messages for dead code.

TEST=run crosvm locally
BUG=chromium:831850
CQ-DEPEND=CL:1510814
Change-Id: Ia5c8768647737e3091e1a0b5e435d3c25bbbe383
Reviewed-on: https://chromium-review.googlesource.com/1510815
Commit-Ready: Jingkui Wang <jkwang@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Jingkui Wang <jkwang@google.com>
2019-03-13 21:04:58 -07:00
Jingkui Wang
199d622703 devices: compile usb module and update current code
This patch did the following:
    start compile usb module
    fix register macro
    update error handling
    reformat code
    update xhci reg setup to support usb3 and usb2

BUG=chromium:831850
TEST=local build
CQ-DEPEND=CL:1510813
Change-Id: I851cf02d01ae6e988b2628552cf57c1f43aa86c8
Reviewed-on: https://chromium-review.googlesource.com/1510814
Commit-Ready: Jingkui Wang <jkwang@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Jingkui Wang <jkwang@google.com>
2019-03-13 21:04:58 -07:00
Jingkui Wang
280ff78675 Add usb log macro
Usb implementation will use usb_debug to log verbose debug logs. It will
be turned off by default.

BUG=chromium:831850
TEST=local build

Change-Id: Ieaa22e57e624841a5f78a6a1a1874351bbd77a86
Reviewed-on: https://chromium-review.googlesource.com/1510813
Commit-Ready: Jingkui Wang <jkwang@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-03-13 21:04:57 -07:00
Jingkui Wang
415ee63e04 add utils for device implementations
event_loop: event loop based on poll context.

async_job_queue: queue a job, it will be invoked on event loop. This
could be used to invoke a function without holding any locks.

BUG=chromium:831850
TEST=local build

Change-Id: Iab61ac43221bf5d635a0138073d7f88401e5ab07
Reviewed-on: https://chromium-review.googlesource.com/1509852
Commit-Ready: Jingkui Wang <jkwang@google.com>
Tested-by: Jingkui Wang <jkwang@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-03-13 21:04:57 -07:00
Miriam Zimmerman
ea75bd164a Add common types and constants for split IRQ chip.
These will come in handy for reducing code duplication and simplifying
PIC/IOAPIC/PIT/interrupt routing code.

TEST=Built
BUG=chromium:908689

Change-Id: I696e9f51231a8e39640f1fd0af055b48048bc134
Reviewed-on: https://chromium-review.googlesource.com/1518557
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Miriam Zimmerman <mutexlox@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Tolnay <dtolnay@chromium.org>
2019-03-13 10:38:57 -07:00
Lepton Wu
28716ea430 gpu_renderer: Enable DRM_FORMAT_RGB565 format.
Some games under arcvm tried to create gbu buffer in this format.

BUG=b:128019372
TEST=manual - Run Asphalt 8 in ARCVM.

Change-Id: I12e67981b4a0b50574ff57cd6bfe94c042feedac
Reviewed-on: https://chromium-review.googlesource.com/1518731
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Lepton Wu <lepton@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-03-13 10:38:47 -07:00
Gabriel
cdae1067c3 kokoro: Fix docker build step in simulator script
The old command no longer works as of CL:1419397 because the pkgconfig
path in COPY needs to be interpreted relative to the Dockerfile path.
The kokoro/README.md instructions were updated in CL:1431356 but the
simulator script was not.

Patch received via email from Gabriel <g2p.code@gmail.com>.
0e6bb00b90

TEST=run kokoro simulator

Change-Id: I09d556cab9a4c1942098e0796e39e221f365c3af
Reviewed-on: https://chromium-review.googlesource.com/1513497
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: David Tolnay <dtolnay@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2019-03-12 18:54:16 -07:00
Dylan Reid
8d7f4ac63c sys_util: guest_address: take self by value in methods
clippy says that it is more efficient. Since self is a u64 in this case,
it is correct.

Signed-off-by: Dylan Reid <dgreid@chromium.org>
Change-Id: Id7674db500a01640f650b239374fe9f83e2bc595
Reviewed-on: https://chromium-review.googlesource.com/1510065
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2019-03-12 18:54:14 -07:00
Lepton Wu
39133a0fd5 linux: clean up: Sort enum in alphabet order.
BUG=None
TEST=None

Change-Id: I11295f778f4d9dc919a41f5cccd85e9608d33358
Reviewed-on: https://chromium-review.googlesource.com/1492612
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Lepton Wu <lepton@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-03-12 18:54:12 -07:00
Jorge E. Moreira
ea8721ad1b Add tests for virtio input device
These tests would have caught chromium:939585

Test=cargo test -p devices

Change-Id: If980fe8b56b9d76e77b652fb727b8849dbedd9cc
Reviewed-on: https://chromium-review.googlesource.com/1512759
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Jorge Moreira Broche <jemoreira@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2019-03-12 18:54:11 -07:00
Miriam Zimmerman
49f071ad4f crosvm: Add KVM_SIGNAL_MSI ioctl.
This ioctl is necessary for a userspace IOAPIC.

TEST=Built
BUG=chromium:908689

Change-Id: I52fc96baef2193e4f673bbce17a1b56ded9aa6a6
Reviewed-on: https://chromium-review.googlesource.com/1515992
Commit-Ready: Miriam Zimmerman <mutexlox@chromium.org>
Tested-by: Miriam Zimmerman <mutexlox@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-03-11 19:53:05 -07:00
Daniel Prilik
7374f32ba4 devices: PCI: add capabilities callback
virtio devices should be able to specify capabilities

BUG=chromium:936567
TEST=boot vm

Change-Id: I049f9967eb59a7904528fff5aea844e30c636e28
Reviewed-on: https://chromium-review.googlesource.com/1493012
Commit-Ready: Daniel Prilik <prilik@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2019-03-11 19:52:59 -07:00
David Tolnay
be03426408 arch: Replace Box<dyn Error> with error enum
Avoiding Box<dyn Error> makes it less likely that we display errors with
insufficient context by accident.

Many of the errors touched in this CL already had helpful message
written! But those corresponding enum variants were never being
instantiated, and that bug was masked by Box<dyn Error>. For example see
the Error::LoadCmdline and Error::LoadKernel.

    pub enum Error {
        LoadCmdline(kernel_loader::Error),
        ...
    }

Before this CL:

    // Bug: boxes the underlying error without adding LoadCmdline
    kernel_loader::load_cmdline(...)?;

After this CL:

    kernel_loader::load_cmdline(...).map_err(Error::LoadCmdline)?;

TEST=cargo check
TEST=cargo check --all-features
TEST=cargo check --target aarch64-unknown-linux-gnu

Change-Id: I7c0cff843c2211565226b9dfb4142ad6b7fa15ac
Reviewed-on: https://chromium-review.googlesource.com/1502112
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: David Tolnay <dtolnay@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-03-09 22:14:46 -08:00
Dylan Reid
e54188bf31 data_model: ignore clippy error for mut from non-mut
A bug has been filed to fix this differently. Until then, add a TODO and
a clippy disable so that clippy can be used to test for other issues
without stopping on this error.

BUG=928767
TEST=cargo clippy

Signed-off-by: Dylan Reid <dgreid@chromium.org>
Change-Id: Ic264bc9101653c30354415c913e9ee3752985706
Reviewed-on: https://chromium-review.googlesource.com/1506308
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-03-09 22:14:45 -08:00
Jorge E. Moreira
99d3f08dc5 Add a (single touch only) touch screen input device
Very similar to the trackpad device, it has the INPUT_PROP_DIRECT
property and does not support any buttons, just touch events.

Change-Id: I2c963013e402ff2aa1b4b529c6c494dd57f4add9
Reviewed-on: https://chromium-review.googlesource.com/1509697
Commit-Ready: Jorge Moreira Broche <jemoreira@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2019-03-09 01:18:59 -08:00
Zach Reizner
e5828e7ecd msg_socket: implement MsgOnSocket for Option<MsgOnSocket>
This is convenient for types that embed Option<...>.

BUG=chromium:831850
TEST=cargo test

Change-Id: I65aa3515f49e4424eff54f17ae18dac8e85b0afa
Reviewed-on: https://chromium-review.googlesource.com/1510812
Commit-Ready: David Tolnay <dtolnay@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Tolnay <dtolnay@chromium.org>
Reviewed-by: Jingkui Wang <jkwang@google.com>
2019-03-08 21:21:11 -08:00
Miriam Zimmerman
de86ae0d33 crosvm: PIT: Remove debug! logs.
BUG=chromium:908689
TEST=None

Change-Id: I5bd59e294b8bb48d99cac0752ddd5058987bf79c
Reviewed-on: https://chromium-review.googlesource.com/1503665
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Miriam Zimmerman <mutexlox@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-03-08 21:21:05 -08:00
Jorge E. Moreira
811a2359eb Input device: Don't send more events than received from the source
Bug=chromium:939585

Change-Id: Ie7215da519b2f92ab3ef35dc401a83fa98808b37
Reviewed-on: https://chromium-review.googlesource.com/1509855
Commit-Ready: Jorge Moreira Broche <jemoreira@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2019-03-08 21:21:04 -08:00
Daniel Prilik
df4cf17d56 devices: PCI: fix underflow for 64 bit BAR config
underflow occurs when configuring a 64 bit register with a <33 bit
address.

BUG=chromium:924405
TEST=boot VM

Change-Id: I53a309b7bff3c91012bacb12d9fc9f8ceed68699
Reviewed-on: https://chromium-review.googlesource.com/1493011
Commit-Ready: Daniel Prilik <prilik@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-03-08 21:20:53 -08:00
Miriam Zimmerman
b0f54b9020 crosvm: Add ioctl wrappers for split-irqchip API.
This includes:
  * KVM_ENABLE_CAP
    * enabling KVM_CAP_SPLIT_IRQCHIP
  * KVM_INTERRUPT

TEST=Built
BUG=chromium:908689

Change-Id: I7bae5fbc0b016a47f6e91f6501fab66373f9b106
Reviewed-on: https://chromium-review.googlesource.com/1509694
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Miriam Zimmerman <mutexlox@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2019-03-08 21:20:48 -08:00
Dmitry Torokhov
7100607448 Drop capabilities before spawning any vcpu thread
In case crosvm starts with elevated capabilities (for example, we need
to start with CAP_SETGID to be able to map additional gids into plugin
jail), we should drop them before spawning VCPU threads.

BUG=b:117989168
TEST=Start plugin via concierge_client and verify the process does not
     have any effective or permitted privileges.
     tast run [] 'vm.*'

Change-Id: Ia1e80bfe19b296936d77fe9ffeda361211b41eed
Reviewed-on: https://chromium-review.googlesource.com/1506296
Commit-Ready: Dmitry Torokhov <dtor@chromium.org>
Tested-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2019-03-08 21:20:23 -08:00
Jingkui Wang
766f8108b3 rename mmio_space to register space
rename mmio_space to register_space, mmio_register to register.

BUG=chromium:831850
TEST=local build
CQ-DEPEND=CL:1509515

Change-Id: Ia229be984d38ca8445828fdfa132bdbbedb74c33
Reviewed-on: https://chromium-review.googlesource.com/1509516
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Jingkui Wang <jkwang@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jingkui Wang <jkwang@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-03-08 21:20:20 -08:00
Jingkui Wang
886ed246b3 register_space: fix u64 write callback
u64 register callback will only be invoked when the write is done.

BUG=chromium:831850
TEST=local build
CQ-DEPEND=CL:1509514

Change-Id: Id0be69535898fdcc4ba24d3151df7a5107a2725b
Reviewed-on: https://chromium-review.googlesource.com/1509515
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Jingkui Wang <jkwang@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-03-08 21:20:19 -08:00
Jingkui Wang
9fc96ec8fb register_space: use sync::Mutex instead of std::sync::Mutex
Then we don't need to unwrap

BUG=chromium:831850
TEST=cargo test
CQ-DEPEND=CL:1506828
Change-Id: I4200ea6351d61df1974e5e4c8583e783b21ea0eb
Reviewed-on: https://chromium-review.googlesource.com/1509514
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Jingkui Wang <jkwang@google.com>
Reviewed-by: Jingkui Wang <jkwang@google.com>
2019-03-08 21:20:19 -08:00
Jingkui Wang
b771521aa6 Move and rename mmio_register to devices/src
A later CL will rename structs.

BUG=chromium:831850
TEST=local build

Change-Id: I8cf70da16918035a6fad2e925f91a315693ff1ed
Reviewed-on: https://chromium-review.googlesource.com/1506828
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Jingkui Wang <jkwang@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-03-08 21:20:19 -08:00
Jingkui Wang
699170b6b7 usb_utils: Add hotplug interface
Hotplug callback would be invoked when device attach or detach

TEST=run crosvm locally
BUG=chromium:831850
CQ-DEPEND=CL:1506826

Change-Id: Ifc1acc00a12c32dd00abbb5467874632e94f60b4
Reviewed-on: https://chromium-review.googlesource.com/1506827
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Jingkui Wang <jkwang@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-03-08 21:20:19 -08:00
Jingkui Wang
b07540c7f9 usb_util: Add libusb jailed api
This patch add bindings for libusb_init_jailed, and
libusb_get_device_from_fd.

TEST=run crosvm locally
BUG=chromium:831850

Change-Id: I948594c8293b185bd873fd98b497ea9171b84c86
Reviewed-on: https://chromium-review.googlesource.com/1506826
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-03-08 21:20:18 -08:00
David Tolnay
9deb7d7803 setup: Remove outdated comment about deref &PathBuf to &Path
The double deref `&**src` was removed in CL:1501652.

TEST=cargo check

Change-Id: I9104e159c1af2ab730f47b053e15492378dbe355
Reviewed-on: https://chromium-review.googlesource.com/1504776
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: David Tolnay <dtolnay@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2019-03-07 20:21:30 -08:00
David Tolnay
fd0971d80c setup: Replace Box<dyn Error> with error enum
Avoiding Box<dyn Error> makes it less likely that we display errors with
insufficient context by accident.

For example the following code which existed before this CL:

    let dev_file = OpenOptions::new()
        .read(true)
        .write(true)
        .open(dev_path)
        .map_err(|e| Box::new(e))?;

This code converts io::Error directly to Box<dyn Error> without
providing enough context to debug what happened just from the io error
message.

The new code is forced to provide a dedicated Error enum variant which
carries a handwritten message and possibly further context:

        .map_err(|e| Error::OpenVinput(dev_path.to_owned(), e))?;

TEST=cargo check
TEST=cargo check --all-features
TEST=cargo check --target aarch64-unknown-linux-gnu

Change-Id: I67d3f1f6f3f92a10d63462584e9546f8ad7074b2
Reviewed-on: https://chromium-review.googlesource.com/1501656
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: David Tolnay <dtolnay@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2019-03-07 20:21:30 -08:00
David Tolnay
2b089fcd45 setup: Break up independent parts of create_devices
I made a separate function to create each distinct VirtioDeviceStub.
Some advantages:

  - Makes it easier to see the top level structure of create_devices
    (which used to be 463 lines all in one function) -- how it loops
    over inputs, how it decides to conditionally create particular
    device types.

  - Makes it clearer to follow when resources are shared across multiple
    devices, particularly resource_bridge_wl_socket. The uses of
    resource_bridge_wl_socket used to be 87 lines apart before this CL.
    Now it spans only 27 lines so fits on one screen.

  - Reduces indentation to leave more space for rustfmt to format the
    device creation in a more readable way.

  - Improves the ability to use short variable names whose meanings are
    scoped to one device. For example wayland and balloon device
    creation used to have to manipulate wayland_device_socket and
    balloon_device_socket. Now create_wayland_device and
    create_balloon_device can each deal with just a thing called
    'socket' whose meaning is specific to the appropriate device.

TEST=cargo check
TEST=cargo check --all-features

Change-Id: I50dc53051598668b4d3cabbae588add783b1fb79
Reviewed-on: https://chromium-review.googlesource.com/1501652
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: David Tolnay <dtolnay@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2019-03-06 23:25:27 -08:00
Dylan Reid
4a63b68761 PCI: Return results from pci setup functions
Enough failure cases have been added to `add_pci_bar` and
`add_pci_capabilities` that they should return unique errors instead of
an `Option`.

BUG=none
TEST=cargo test in devices

Signed-off-by: Dylan Reid <dgreid@chromium.org>
Change-Id: Ice2a06d2944011f95707f113f9d709da15c90cfe
Reviewed-on: https://chromium-review.googlesource.com/1497740
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2019-03-06 15:33:43 -08:00
Jorge E. Moreira
52c48ae543 Don't grab input devices created from sockets.
The grab ioctl only makes sense for event devices.

Bug=chromium:938760

Change-Id: I6b0c170185c40de37451a5f3efd2071491eb49a6
Reviewed-on: https://chromium-review.googlesource.com/1504777
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2019-03-06 15:33:42 -08:00
Lepton Wu
0cf2838c53 kokoro: Add librendernodehost library.
This is needed for merging http://crosreview.com/1347330

BUG=None
TEST=Build kokoro image and run tests
Change-Id: I9a77964ab89ed5d5e9e1b6032ada562aed7278bb
Reviewed-on: https://chromium-review.googlesource.com/1503679
Commit-Ready: Lepton Wu <lepton@chromium.org>
Tested-by: Lepton Wu <lepton@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-03-06 06:51:44 -08:00
Gurchetan Singh
e95f4d75c0 virtio-gpu: add a BAR for device
BUG=chromium:924405
TEST=compile

Change-Id: I8a583df2a9db4ea7e066eb284eac54fc62580350
Reviewed-on: https://chromium-review.googlesource.com/1480744
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-03-05 12:58:51 -08:00
David Tolnay
09358ef076 setup: Suppress warning on fields that are only used by TPM
Warnings when building without `--features tpm` previously:

    warning: field is never used: `uid`
       --> src/linux.rs:696:5
        |
    696 |     uid: uid_t,
        |     ^^^^^^^^^^
        |

    warning: field is never used: `gid`
       --> src/linux.rs:697:5
        |
    697 |     gid: gid_t,
        |     ^^^^^^^^^^

TEST=cargo check
TEST=cargo check --features tpm

Change-Id: Id6beee4237e70d9107b36601583f599f85e5c74d
Reviewed-on: https://chromium-review.googlesource.com/1500874
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: David Tolnay <dtolnay@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2019-03-05 12:58:50 -08:00
Zach Reizner
083cc4a286 crosvm: remove LTO from release profile
Builders of crosvm, such as the crosvm ebuild, should determine if they
want LTO enabled. By having lto removed from the release profile,
builders using `--release` will not be forced to use LTO.

BUG=None
TEST=cargo build --release should be heckin' fast

Change-Id: I4e231b6dac7670ab146d36c1c1660ab67935285a
Reviewed-on: https://chromium-review.googlesource.com/1497734
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2019-03-05 12:58:42 -08:00
Daniel Verkamp
b852264e21 linux: use panic=-1 to reboot immediately on panic
This changes the default Linux kernel command line from panic=1 (reboot
one second after panic) to panic=-1 (reboot immediately on panic).  The
kernel should not normally panic; this is just to improve quality of
life for developer workflows, such as running bash as init and exiting
the shell to shut down the VM.

BUG=None
TEST=crosvm run -r vm_rootfs.img -p init=/bin/bash vm_kernel; exit shell

Change-Id: I7c9084ccf1786cd4455fd748512078e02fdb17fa
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1500872
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Tolnay <dtolnay@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2019-03-05 12:58:31 -08:00
paulhsia
4547e30366 sys_util: remove deprecated functions
Remove `write` and `read` after the only user in CL:1488597 change its
usage.

TEST=cargo test -p sys_util
BUG=chromium:848187
CQ-DEPEND=CL:1488597

Change-Id: I15e03077f8970ea8350c7f64de9b64b16a08bfc1
Reviewed-on: https://chromium-review.googlesource.com/1488553
Commit-Ready: Chih-Yang Hsia <paulhsia@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-03-05 09:43:53 -08:00
Jianxun Zhang
56497d23ad main: return error on invalid length of arguments
For the commands that verify the length of arguments, returning
Ok on an invalid length will confuse any external programs that
launch crosvm because they still get exit code of success from
crosvm even when the command failed.

Also add a missed return of 'create_qcow2' sub-command.

BUG=None
TEST=some basic tests:
() cargo check
() verify the return value from changed sub-commands is not 0 with
an invalid argument length.
() launch a VM with concierge_client from a root shell

Change-Id: I8278107a4d2fcf3cb6fafb65f30f431f97f7deb1
Signed-off-by: Jianxun Zhang <jianxun.zhang@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/1501552
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-03-05 05:53:36 -08:00
Dylan Reid
e4ece32798 ac97: Add top level unit test
Check that the device can be created. This test would have caught the
bug with adding pci bars.

Change-Id: Ib0cc2edf0d8d1b2d95d9c3588ac325b5da886603
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1497738
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2019-03-04 17:44:58 -08:00
Jingkui Wang
2de0088c9e make aarch64 pci dma-coherent
On arm, if the device is not coherent, guest kernel will allocate dma memory as
no-cacheable. Crosvm on the host user space thinks the memory is
cacheable. Thus when guest kernel write to dma memory, it will bypass
the cache, crosvm won't see the change.

BUG=None
TEST=local build and test

Change-Id: If6cf2d28afec61d5beb136628116ff9e7e0483f4
Reviewed-on: https://chromium-review.googlesource.com/1497739
Commit-Ready: Jingkui Wang <jkwang@google.com>
Tested-by: Jingkui Wang <jkwang@google.com>
Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2019-03-03 06:01:39 -08:00
David Tolnay
c69f97542a error: Consistently use Display instead of error description()
The description method is deprecated and its signature forces less
helpful error messages than what Display can provide.

BUG=none
TEST=cargo check --all-features
TEST=cargo check --target aarch64-unknown-linux-gnu

Change-Id: I27fc99d59d0ef457c5273dc53e4c563ef439c2c0
Reviewed-on: https://chromium-review.googlesource.com/1497735
Commit-Ready: David Tolnay <dtolnay@chromium.org>
Tested-by: David Tolnay <dtolnay@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2019-03-02 17:41:31 -08:00