Commit graph

3294 commits

Author SHA1 Message Date
Keiichi Watanabe
f46226d65a tools: dev_container: Install mdbook-linkcheck
Install https://github.com/Michael-F-Bryan/mdbook-linkcheck and bump up
the container version.

BUG=none
TEST=make -C tools/impl/dev_container crosvm_dev

Change-Id: I6ce95ddb66f93e23b5abac5ee1350ff8e3106073
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3428603
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-02-02 02:52:53 +00:00
Vikram Auradkar
f7da4929c1 Rename files to match job config files
TEST=none

Change-Id: I6c1c54ab2960c09a02c10a02359fbdd176423319
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3429623
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-02-02 00:00:38 +00:00
Chia-I Wu
3d27a4b747 rutabaga_gfx: enable debug callback on arm
v2: add va_list and share code between x86/arm debug_callback.

BUG=b:209647747
TEST=cargo fmt
TEST=tail -f /var/log/messages

Change-Id: I0a8ac703aacb95ac0b4df069aa6e2b48401d8c3f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3320959
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Chia-I Wu <olv@google.com>
2022-02-01 22:17:27 +00:00
Chia-I Wu
bdd15ba5e7 rutabaga_gfx: fix virgl_renderer_bindings generator
There are three fixes

 - rustfmt the generated code
 - define VIRGL_RENDERER_UNSTABLE_APIS
 - use ${sysroot}/usr/include/virglrenderer.h by default, and use the
   checked out repo only when --virglrenderer is specified

BUG=b:209647747
TEST=tail -f /var/log/messages

Change-Id: Iabd337be140b8b82ffc9e3488b812ed30ef28027
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3429700
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Chia-I Wu <olv@google.com>
2022-02-01 22:17:26 +00:00
Chia-I Wu
198320c1c5 rutabaga_gfx: simplify debug_callback
The va_list can be consumed.  There is no need to simulate a va_copy
before calling vsnprintf.

BUG=b:209647747
TEST=tail -f /var/log/messages

Change-Id: Ib61f22bd55b013d2ebdb7e2c983f530b86ea1ab3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3429699
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Phillip Pearson <philpearson@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Chia-I Wu <olv@google.com>
2022-02-01 22:17:25 +00:00
Keiichi Watanabe
72982f57e2 CONTRIBUTING: Add links to mdbook
BUG=none
TEST=none

Change-Id: I4191ed589d9f3887a0d84ed8d70ad135c0b89507
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3255196
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-02-01 10:39:32 +00:00
Keiichi Watanabe
292b50cd64 docs: Cosmetic changes for code blocks
* Remove leading `$`s so that readers can copy and pastes commands more
easily.
* Use `sh` instead of `bash` because `bash` is for scripts rather than
command line interfaces.

These rules are ones used in mdBook's instruction.
https://github.com/rust-lang/mdBook/tree/master/guide/src/guide

BUG=none
TEST=mdbook build

Change-Id: I3b35fa2c7b20ef10e3da78a47f41a1603744daf0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3423292
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
2022-02-01 10:39:31 +00:00
Vikram Auradkar
71e74b0a64 Add kokoro build config file and helper script
Build config sets timeout to 40 minutes.
helper script relies on choco to install rustup, which is used
to install rust toolchain.

Bug: 213603713
Test: Tested the toolchain setup part of the script in a
      codelab repo.
Change-Id: Ibf139bbc4ff6fe6c811652767dd885584414dda6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3421515
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Brandon Amiosci <brandonamiosci@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-02-01 07:56:02 +00:00
Woody Chow
8b2c7b995b virtqueue: DescriptorChain::checked_new returns anyhow::Error
checked_new fails when guest gives invalid descriptor entries.
The error makes debugging easier.

BUG=None
TEST=cargo test

Change-Id: I6c6f5b04e7f39a685d95ca738b9cb01be643fa21
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3418620
Reviewed-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Woody Chow <woodychow@google.com>
2022-02-01 05:53:07 +00:00
Anton Romanov
d43ae3c13c Fix building without gpu feature.
Guard gpu-related imports

BUG=None
TEST=cargo check --no-default-features; cargo check

Change-Id: Iaec2d7a6896a55e9450dd29c9168a27059684491
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3426379
Reviewed-by: Anton Romanov <romanton@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
Auto-Submit: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-01-31 19:08:16 +00:00
Junichi Uekawa
d7cbca27e3 system_allocator: Fix comments.
While reading code, some of the comments need fixing.

BUG=None
TEST=None

Change-Id: Iff9cd639f5e14512680475bcf9240c07551690a5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3418634
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-01-31 06:41:58 +00:00
Dennis Kempin
0520a95161 ci/kokoro: Pythonify the simulate script
Does the same thing, but in python. This should allow us to make
this work on windows as well.

BUG=b:216833094
TEST=./simulate.py build-x86_64.sh

Change-Id: If6eb214c2a3185fbb60a636b89cd03ecf28b42e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3425651
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-01-29 16:49:32 +00:00
Keiichi Watanabe
6b7a9923ae docs: Fix broken links
BUG=none
TEST=mdbook build

Change-Id: I77bde44d5614ecab28c0b3c23e1c5f67c52235f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3423290
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-01-29 03:48:23 +00:00
Anton Romanov
195724b002 async: remove misplaced must_use attribute
must_use attribute clearly was meant to be set on future struct type
since futures need to be polled to do anything. It was never meant to
apply to invocation of paste macro
Also, today any implementor of `Future` trait gets that attribute by
default anyway

BUG=n/a
TEST=cargo check

Change-Id: I60db1aa2bc7c8d6130cc1579641ae815c9cb738e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3425184
Reviewed-by: Anton Romanov <romanton@google.com>
Auto-Submit: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-01-29 03:26:09 +00:00
Long Cheng
7ea795dc56 Apply usb configuration even configuration is not changed.
Apply usb configuration even when configuration is not changed. When
Android sets usb configuration, it expects the device connection gets reset.
This change will pass CTS verifer  USB devices tests which try to
observe device connection and reconnection after set unchanged usb
configuration.

BUG=b:123374026
TEST= Run cts verifer USB device tests in ARCVM.
TEST=lsusb in crostini. device shows.

Change-Id: I5856d1173a3ea1a65c6fa205cb9facd407706a6c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3413815
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Long Cheng <lgcheng@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Long Cheng <lgcheng@google.com>
2022-01-29 01:11:41 +00:00
Anton Romanov
5acc0f52f5 linux: split out linux mod into multiple
At nearly 4k loc its harder to maintain. This change only moves some
things around without changing any code. Input on symbol visibility is
welcome - in reality it doesn't really matter if symb is
pub/pub(super)/pub(crate) as mods themselves are private to linux mod.
I plan to invest more into splitting things apart if possible
(especially the main loop) but its a start

TEST=./tools/presubmit
BUG=n/a

Change-Id: I2792dd0acdb5627f1c9b5d0fb998c976c6fe5e15
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3422266
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Anton Romanov <romanton@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
Auto-Submit: Anton Romanov <romanton@google.com>
2022-01-28 23:07:01 +00:00
Anton Romanov
6afc5a7f10 Rename linux.rs into linux/mod.rs to preserve at least some history after refactoring
BUG=n/a
TEST=cargo check

Change-Id: Id2de1980b4e63f7f50e72223f4240fb079c14570
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3425697
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Anton Romanov <romanton@google.com>
Auto-Submit: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
2022-01-28 23:06:38 +00:00
Allen Webb
da4bad999f sys_util: Add support for F_SEAL_FUTURE_WRITE.
BUG=b:210847494
TEST=cargo build

Change-Id: I8bb714cafba994afed42cbf0c9e6d9adee799dd9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3408094
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Allen Webb <allenwebb@google.com>
Auto-Submit: Allen Webb <allenwebb@google.com>
2022-01-28 18:45:49 +00:00
Andrew Walbran
e79aba1026 Check KVM_CAP_ARM_PROTECTED_VM after creating a protected VM.
This should have been updated with the pKVM ABI change in
https://crrev.com/c/3330204, as protected mode is now selected when
creating the VM, and pVM firmmware is optional.

BUG=b:209794844

Change-Id: I2850b4c2ef523a15b8215df070eb9da066a67cb5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3420330
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Andrew Walbran <qwandor@google.com>
2022-01-28 16:16:26 +00:00
Andrew Walbran
1a19c67e22 Handle errors and crashes in VM differently to clean shutdown.
BUG=b:211704107
TEST=tools/dev_container tools/run_tests
TEST=tools/dev_container tools/run_tests --target=vm:aarch64

Change-Id: I383be89becefe300d9dc94b7d67d35269c628a39
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3412772
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Auto-Submit: Andrew Walbran <qwandor@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Andrew Walbran <qwandor@google.com>
2022-01-28 15:30:39 +00:00
Andrew Walbran
b28ae8e70f Distinguish reboot from shutdown on aarch64 too.
BUG=b:211704107
TEST=Ran VMs with Android vm tool on Oriole

Change-Id: I3525cb03ab325ac35aea8f318faa4ebab8250b83
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3395416
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Andrew Walbran <qwandor@google.com>
2022-01-28 14:11:51 +00:00
Andrew Walbran
985491ae73 Pass HypervisorCap by value rather than reference.
It's a simple enum, so it should be Copy.

TEST=tools/dev_container tools/run_tests
TEST=tools/dev_container tools/run_tests --target=vm:aarch64

Change-Id: Ieeacedb10fa6a93d6cdd9878097c66aa936f8e30
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3420329
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Andrew Walbran <qwandor@google.com>
2022-01-28 11:02:45 +00:00
David Stevens
8be9ef0a20 crosvm: add external balloon socket
Add socket to allow external process to directly control the balloon
device via the balloon_control API. When the option is used, the vm
control socket cannot control the balloon.

BUG=b:213962590
TEST=manual testing with crrev.com/c/3394436

Change-Id: I3feea811e39a5b09afcc44420fc644935fdc6ebf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3394441
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-01-28 05:17:19 +00:00
David Stevens
0f924dd693 balloon_control: expose rust API for balloon
Add a crate containing an API for controlling the balloon. This is done
by reusing the API between the control socket and the balloon device.

BUG=b:213962590
TEST=compiles

Change-Id: I5d89d5ebee55162d28ba45ca2c49b7083561b916
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3394440
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-01-28 03:52:35 +00:00
Alexandre Courbot
c61125c154 devices: fix compile warnings in tests
Fix a few compilation warnings in our tests:

* The PCI device had an unused argument without a leading underscore in
  the name ;
* The virtio queue is dereferencing null pointers, which is UB albeit
  technically ok in this case (bindgen generates similar tests too [1]).

[1] https://github.com/rust-lang/rust-bindgen/issues/1651

BUG=None
TEST=cargo test in devices/ does not show these warnings anymore.

Change-Id: Id272b5381f80bb72d96839a5a6da8bb0c644502d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3418623
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-01-28 02:51:14 +00:00
Dennis Kempin
145f452cf5 merge-into-chromeos: Exclude dry runs from previous merge commits
Otherwise we end up with this: https://crrev.com/c/3422185

BUG=None
TEST=None

Change-Id: I8abd0e3f4465e9ae2ae34630dde5a3b15e190b09
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3421734
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-01-28 01:32:07 +00:00
Colin Downs-Razouk
2802e828fb x86_64: mptables bad irq0 entry
crosvm seems to be adding an extra mptable entry for irq0 that points to
a non-existent ioapic (with apic_id=0 where the ioapic's id is not 0).
The bad irq0 and valid irq0 entries are the first two listed when using
apic=debug and show_lapic=all kernel params:

```
[    0.756044] Int: type 0, pol 0, trig 0, bus 01, IRQ 00, APIC ID 0, APIC INT 00
[    0.764474] Int: type 0, pol 0, trig 0, bus 01, IRQ 00, APIC ID 5, APIC INT 00
```

If the bad irq0 entry exists, and if check_timer is called in io_apic.c
in the kernel, it can cause an invalid opcode exception in some kernels,
seemingly because it ends up calling find_irq_entry(-1, -1, 0) which
does a -1 index on the static "ioapics" struct in io_apic.c. It seems
like a kernel bug that such an index could happen, but this also seems
like a bad entry in mptables.

A similar irq entry exists in kvmtool, but it it's a local interrupt. If
this entry is adjusted to match then the invalid opcode kernel panic
stops.

BUG=b:211912415
TEST=ran linux image, booted fine

Change-Id: I125dd2458f86de65553577b8d1c4d1366d778de9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3405332
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Colin Downs-Razouk <colindr@google.com>
2022-01-28 01:21:22 +00:00
Vikram Auradkar
0108238474 Upstream windows build/test script
The patch also adds files to skip building and testing crates on
windows. When we run
```
tools/windows/build_test.py --skip_file_name .windows_build_test_skip
```

the build/test succeeds without actually doing anything as build/test
for all crates is skipped by creating '.windows_build_test_skip'.

Bug: 213170957
Test: Ran script on downstream repo
Change-Id: Iebd2cea463ee722be4feaed88229e1fb5e9fd6c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3417918
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-01-28 00:55:08 +00:00
Dennis Kempin
722dcd4afd OWNERS: Add crosvm-bot
This should allow the bot to submit dry-runs to the CQ.

BUG=chromium:1290646
TEST=None

Change-Id: I44fc74c94129e7d136a161c1ba11445d7bf675c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3421730
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-01-27 23:41:23 +00:00
Dennis Kempin
6b06f405ff docs: Use mdformat to format markdown files
The tool is added to ./tools/fmt which will be called during
./tools/presubmit as well as by Kokoro during testing.

This requires a new dev container version to bundle the mdformat
tool in the container.

Note: mdformat does not have any IDE integrations, but the prettier
plugin with prose-wrap enabled and a line length of 100 provides
almost identical results.

BUG=None
TEST=./tools/fmt --check

Change-Id: I0ae5659eff8555df7c85c70e62095a1e116b98da
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3416098
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-01-27 21:29:11 +00:00
Dennis Kempin
cde666cd54 Reorganize usage doc and add example usage
BUG=b:214104901
TEST=mdbook serve

Change-Id: I7039493212912cb698f74967abef228df278f4c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3399872
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-01-27 21:29:10 +00:00
Vineeth Pillai
2b6855e725 crosvm: Add support to pass vcpu-cgroup-path to crosvm
The latency reduces to 50-100ms max from over 1 second, when we overload
the system.

BUG=b:208138181
TEST=run stress-ng inside and outside VM.

Change-Id: I10a22807b47a1ed2dd181c2ddcc995eebef7f652
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3383936
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vineeth Pillai <vineethrp@google.com>
2022-01-27 21:19:21 +00:00
Daniel Verkamp
33f982e179 crosvm: allow --stub-pci-device multifunction again
The previous multifunction change removed this option entirely, but that
makes the transition difficult, since the caller and crosvm need to be
updated simultaneously. To make the changeover simpler, allow the
multifunction option but make it do nothing, since the PCI root code
will already do the right thing.

BUG=b:210795995
TEST=Run crosvm with --stub-pci-device with multifunction enabled

Change-Id: I5d378001d495ec54bd4c1869de796ba6a418f43a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3421006
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-01-27 20:39:52 +00:00
Dennis Kempin
32c3f30e05 merge-into-chromeos: Set Bot-Commit+1 as well
This is an experiment to figure out the permissions needed by
crosvm-bot.
See https://crbug.com/1289780 for details.

BUG=chromium:1289780
TEST=None

Change-Id: Ic202532ceaa2b0d86f51c8670137bde2d8f16868
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3419296
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-01-27 20:08:51 +00:00
David Stevens
06d157a7b6 crosvm: add param to limit initial memory
Add an init-mem parameter that limits how much memory the VM can use on
startup. If set, the balloon is inflated on startup to (mem - init-mem).

BUG=b:213962590
TEST=set param and verify balloon inflates on startup

Change-Id: I920bf9cfa26081ee544219406f8cf9827ff84bfa
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3394439
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-01-27 15:11:30 +00:00
Andrew Walbran
3cd9360fac Disable virtio balloon device for protected VMs.
It is not compatible with pKVM and leads to RCU stalls on the host due
to the virtio_balloon thread getting stuck.

BUG=b:215517095

Change-Id: Ibd1c9db53bfa001e07ba6399ff50e9073476017d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3412776
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Andrew Walbran <qwandor@google.com>
2022-01-27 11:23:47 +00:00
Junichi Uekawa
8764deb8dd crosvm: Minimal change for manatee memory mapping.
Do not map RAM to where the coreboot regions are.

Shift boot time GDT and IDT a bit to make way for coreboot region at
0..fff.

BUG=b:188011323
TEST=boot volteer-manatee
TEST=tast run rammus-arc-r arc.Boot.vm  # ARCVM still boots.
TEST=tast run rammus-arc-r crostini.Basic.bullseye_stable

volteer-manatee memory map:

after:

localhost ~ # dmesg | grep e820
[    0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable
[    0.000000] BIOS-e820: [mem 0x0000000000200000-0x00000000cfffffff] usable
[    0.000000] BIOS-e820: [mem 0x00000000f4000000-0x00000000f7ffffff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000100000000-0x00000003f05fffff] usable

before:

localhost ~ # dmesg | grep e820
[    0.000000] BIOS-e820: [mem 0x0000000000001000-0x000000000009fbff] usable
[    0.000000] BIOS-e820: [mem 0x0000000000200000-0x000000005fffffff] usable
[    0.000000] BIOS-e820: [mem 0x00000000f4000000-0x00000000f7ffffff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000100000000-0x0000000460600fff] usable

Change-Id: Ifa19988c444d79dc81eb77c59e5b5434abf883fb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3405402
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-01-27 02:29:32 +00:00
Junichi Uekawa
57d7eba097 crosvm: Use MB and GB across the file.
BUG=None
TEST=build

Change-Id: Ibd101c10ccc9425c389bbf3d43a1d44e3ebea7f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3405401
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-01-27 00:27:14 +00:00
Dmitry Torokhov
9cbe543e6a devices: gpu: control lifetime of render server jail
Rearrange the code that creates devices and starts the VM so that the
jail object is not destroyed while VM is running and also make sure we
kill the process when vm stops.

BUG=b:177267762
TEST=./tools/presubmit

Change-Id: Id35791e7264a52e34d2ddfac86425ad4b3c2d059
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3416101
Reviewed-by: Chia-I Wu <olv@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-01-27 00:06:10 +00:00
Dmitry Torokhov
cbfef3b3e3 plugin: switch to using resize_with() when initializing per-VCPU states
Now that resize_with() has stabilized and is available in version of
Rust we are using we can switch to it instead of implementing the same
by hand.

BUG=None
TEST=./tools/presubmit

Change-Id: I08b418ad898ecbc52c63bd7a47f6470af30c8a66
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3417961
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-01-26 23:08:50 +00:00
Dennis Kempin
d6c3154b13 merge-into-chromeos: Create a dry run merge as well
The dry run merge is re-created every day and automatically
set to CQ+1. This allows us to check for bad crosvm changes
while we submit parts of the merge chain.

BUG=b:215741244
TEST=./tools/ci/simulate merge-into-chromeos.sh

Change-Id: I0773a99f9858962e9f25bebff1b233d455d33cdd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3417508
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-01-26 20:47:46 +00:00
David Stevens
4700aa062f sys_util: add more features to UnixSeqpacket
Add an accept_with_timeout method to UnixSeqpacket and implement a few
basic traits for UnixSeqpacket.

BUG=b:213962590
TEST=cargo test

Change-Id: I1b8461e54aac2be31604213b252c15ce2195e33a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3394438
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-01-26 13:42:19 +00:00
Mattias Nissler
bbd91d088d Add generalized file-backed mapping functionality
This is a generalization of the existing --direct-mmio option with the
following improvements:

 * Memory is mapped directly into the guest namespace rather than
   handled via MMIO exits.
 * The --file-backed-mapping option can be specified multiple times to
   set up mappings backed by different files.
 * Command line option format is extensible, allowing to add further
   parameters in the future as needed.
 * O_SYNC mapping is configurable from the command line, making this
   useful for mapping both MMIO regions and regular system memory into
   the VM.

One limitation that this new implementation brings is that mappings
need to be page-aligned (which isn't the case for --direct-mmio). I'm
not aware of existing users that require fine-granular file-backed
MMIO mappings though, so this is hopefully OK.

The existing --direct-mmio option code is left untouched, but will be
removed later after converting over existing usage.

BUG=b:184815519, b:188011323
TEST=unit tests for command line parsing, manual test to specify --file-backed-mapping and observe that the backing file content is accessible from the guest.

Change-Id: I86aee74d2032caaf9130569203d5749994a4413d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3328602
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Mattias Nissler <mnissler@chromium.org>
2022-01-26 10:03:19 +00:00
Alexandre Courbot
f70a014c32 virtio: video: decoder: fix computed picture plane size
The picture buffer size was computed from the size of the visible
rectangle, which is potentially incorrect: if the origin of the visible
rectangle is not (0, 0) then the buffer is going to be larger.

Fix this by using the provided coded width and height, which correspond
to the actual size of the buffer and not just its visible area.

BUG=b:161774071
TEST=Android Youtube decodes properly on zork-arc-r.

Change-Id: I80e15248f41d6202190456d2ab61f8f50d3b6ebb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3412457
Reviewed-by: Chih-Yu Huang <akahuang@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: David Staessens <dstaessens@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-01-26 03:54:45 +00:00
Junichi Uekawa
63d127f45c crosvm: Merge README.chromeos to CONTRIBUTING.
Docs are scattered around, and README.chromeos isn't markdown.  Merge to
CONTRIBUTING doc and update the relevant parts.  Rename to
README.chromeos.md and make it point to the other doc.

BUG=None
TEST=read it.

Change-Id: Ib1df58e1a7c48d6faad71faffc9527da5f3218be
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3405403
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-01-26 01:33:23 +00:00
Dmitry Torokhov
fbc43370b8 plugin: switch to using anyhow for error reporting
Switching to anyhow allows us to get rid of the unwieldy error enum in
places where we do not care about error codes.

BUG=None
TEST=./tools/presubmit and run Parallels VM on CrOS

Change-Id: I4b9636801a7daa1d1289ce1bc4f9a92d47efaeb0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3416093
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-01-26 00:10:32 +00:00
Dmitry Torokhov
2e6e61d1b7 Teach create_base_minijail() to set up remount mode
Instead of having to adjust this after the fact, let's teach
create_base_minijail() handle this request.

BUG=None
TEST=./tools/presubmit

Change-Id: Iabfd583f1d198c243d7d073785066a343ceac94e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3416094
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-01-26 00:06:00 +00:00
Dennis Kempin
151ae7eed4 Docs: remove --global from git config
This causes problems with repo and should only be set on the crosvm
repo.

BUG=None
TEST=None

Change-Id: Id63a60f9ccebf3f7785a1473d15d6a9f88f8cdd0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3414497
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-01-25 23:03:00 +00:00
Dennis Kempin
53c216fd07 Make vscode devcontainer usable
The container was pretty much untested. Now that vscode supports dev
containers via SSH I got to test this properly.

This provides a workable dev environment out of the box.
./tools/presubmit passes and
common extensions for rust, python and bash are added.

BUG=None
TEST=Open in vscode, re-open in dev container. Run ./tools/presubmit

Change-Id: I542f3d26c29c4051000e6ec8b81d77d297bcad7d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3402447
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-01-25 21:30:49 +00:00
Dmitry Torokhov
507536ddd8 x86: pass host's processor brand string to guests
Let's pass host's processor brand string to guests, so that lscpu and
/proc/cpuinfo do not fall back to printing numeric model numbers
but rather print vendor string, such as:

	Intel(R) Core(TM) i3-10110U CPU @ 2.10GHz
or
	AMD Ryzen 3 3250C 15W with Radeon Graphics

BUG=None
TEST=boot zork and hatch, examine lscpu in crostini

Change-Id: I7cd3ccd4a6328695cc180ee4c13d19d2e48f3def
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3410647
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-01-25 01:56:29 +00:00