Commit graph

2751 commits

Author SHA1 Message Date
Allen Webb
82316c3b40 sys_util: Add wait_for_pid.
This adds a safe wrapper for libc::waitforpid that converts the *status
field to an enum so the various edgecases can be handled.

BUG=None
TEST=cargo build

Change-Id: Ic518e686b8ea60fa968f849f1cae571ebfe069e8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3199623
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Auto-Submit: Allen Webb <allenwebb@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Allen Webb <allenwebb@google.com>
2021-10-04 13:40:16 +00:00
Chirantan Ekbote
f1cd8d7a66 fs: Make posix acl support optional
Google drive and file systems used for external media (like FAT32) don't
support xattrs, which means they also don't support posix acls.
However, we unconditionally enable FUSE support for posix acls
preventing us from using virtio-fs for those mount points.

Make posix acl support optional so that we can also use virtio-fs for
gdrive and external media.  This feature is on-by-default since we
currently use it for every other virtio-fs mount point.

BUG=b:196946147
TEST=arc.PlayStore.vm

Change-Id: I9139852d6dceb46bef21af43f77fc527f3fa58d9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3168564
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-10-04 03:18:26 +00:00
Abhishek Bhardwaj
909f8cd3e5 crosvm: Add bar index and offset to read_bar and write_bar
This change adds the bar index and offset to the read_bar and write_bar
methods to the VirtioDevice trait. VirtioDevice needs these parameters
to implement the device bars.

BUG=b:194136484
TEST=Compile.

Change-Id: I48cb6e743b29467dc9707e13ce72b6b61951a6db
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3188668
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Abhishek Bhardwaj <abhishekbh@chromium.org>
Auto-Submit: Abhishek Bhardwaj <abhishekbh@chromium.org>
2021-10-01 20:15:34 +00:00
Dennis Kempin
be3443cd10 Revert "Add StreamEffect to new(_async)_capture_stream"
This reverts commit 79d6696394.

Reason for revert: The change made it through to ChromeOS builds
because the audio_streams ebuild is not manually upreved yet. Re-submit after https://crrev.com/c/3192217 is landed.

Original change's description:
> Add StreamEffect to new(_async)_capture_stream
>
> It is needed to support AEC in virtio-snd (cras backend)
>
> BUG=b:201472965
> TEST=cargo test
>
> Change-Id: If79eee8a41d1da7e6d643e8187bbc75768f31ad9
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3193841
> Reviewed-by: Judy Hsiao <judyhsiao@google.com>
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
> Commit-Queue: Dennis Kempin <denniskempin@google.com>
> Tested-by: kokoro <noreply+kokoro@google.com>

Bug: b:201472965
Change-Id: Ib68978ea148ae3598109a779e620377f7f1f9d94
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3200179
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-10-01 19:20:26 +00:00
Tomasz Nowicki
71aca792b3 crosvm: Introduce VfioParam structure to recognize VFIO device type
VFIO-PCI device type is not the only one. To manage VFIO device type:
- add new structure to keep device type, its sysfs path
- refactor VFIO command line parser and let parameter options to be
extensible

BUG=b:185504618
TEST=manatee PCI device passthrough boots/works

Change-Id: I8f3226d388267e1a15dc537e37bb2054e3c6e486
Signed-off-by: Tomasz Nowicki <tn@semihalf.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2961211
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Tomasz Nowicki <tnowicki@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-01 19:02:51 +00:00
Adrian Ratiu
cdedd7000a seccomp: allow newfstatat in more amd64/arm64 policies
newfstatat has been added to a few policies for the
two 64bit architectures, but some more require it to
avoid crashes, so add it to all which contain fstat
or statx.

BUG=b:187795909
TEST=CQ

Change-Id: I3cd0f5379b87102caa256503a888c5a1aa4103b6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3198571
Commit-Queue: Manoj Gupta <manojgupta@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-10-01 17:09:16 +00:00
Woody Chow
79d6696394 Add StreamEffect to new(_async)_capture_stream
It is needed to support AEC in virtio-snd (cras backend)

BUG=b:201472965
TEST=cargo test

Change-Id: If79eee8a41d1da7e6d643e8187bbc75768f31ad9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3193841
Reviewed-by: Judy Hsiao <judyhsiao@google.com>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-10-01 16:33:23 +00:00
Chirantan Ekbote
1b2d8dc856 fs: Make DAX optional
We don't currently have it enabled anywhere but we still always allocate
PCI shared memory regions for it.  Instead make it optional and off by
default.  We can re-enable it on a per-device basis.

BUG=none
TEST=arc.PlayStore.vm

Change-Id: Icf122a561251a3e55757a9ffe4633b96adc4066d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3168563
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-10-01 10:33:18 +00:00
Chirantan Ekbote
b9917a22a3 virtqueue: Use stronger fences
Acquire/Release orderings are not sufficient when accessing memory
that's also touched by the guest kernel.  Use SeqCst ordering, which
also more closely matches what the kernel does.

BUG=b:200637442
TEST=Run vm.Virtiofs 15 times in a row both with and without
     VIRTIO_RING_F_EVENT_IDX enabled and observe that the test does not
     hang

Change-Id: I54f1d7123bdcbbf01f94935193e48a9c2e252bbc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3199301
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-10-01 10:32:59 +00:00
Junichi Uekawa
e7b6f4fe6e crosvm: Try using block size of 4096.
Documentation says 512 but ext4 block size is 4096 and we don't need to
diverge here.


BUG=b:199094605
TEST=arc.Boot.vm

Change-Id: I6f04e652dea6a3cf661d36b943278753340cc665
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3195155
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-10-01 09:45:14 +00:00
Tomasz Nowicki
ab86d52fba arch: Generalize PCI device box for build_vm
Before we call build_vm we are creating devices and there is no reason
to assume those have to be PCI only. In preparation for VFIO platform
device support, add super trait which allows to pass generic device
structure around and still be able get back to our original type.

BUG=b:185504618
TEST=manatee PCI device passthrough boots/works

Change-Id: I500f44af430f5f06299f20fc4ca17ca008a7e0c5
Signed-off-by: Tomasz Nowicki <tn@semihalf.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2961210
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Tomasz Nowicki <tnowicki@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-01 08:46:21 +00:00
Keiichi Watanabe
eaaba5eb54 mdbook: Add more virtio devices in devices.md
BUG=b:195003973
TEST=none

Change-Id: Ie383d75f540ff4fc904d64e130d5c9ddb071a84e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3067484
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-09-30 11:44:33 +00:00
Keiichi Watanabe
48903bc8ee ARCHITECTURE: Update code map
Add explanation on several components I'm a bit familiar with.

BUG=b:195003973
TEST=none

Change-Id: I7c4c6ebc266ae40dadfb984e9dff8016efe6ab73
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3188676
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-09-30 11:44:32 +00:00
Junichi Uekawa
52437db2e9 crosvm: Add more information of adding block device.
Trying to chase down what is failing in the bots that cannot be
reproduced.

BUG=b:199094605
TEST=tast run localhost:2229 arc.Boot.vm
shows:
2021-09-30T00:51:27.843991Z INFO ARCVM(34)[23414]:  [src/linux.rs:228] Trying to attach block device: /opt/google/vms/android/system.raw.img
2021-09-30T00:51:27.844122Z INFO ARCVM(34)[23414]:  [disk/src/disk.rs:283] disk size 648871936,
2021-09-30T00:51:27.844456Z INFO ARCVM(34)[23414]:  [disk/src/disk.rs:283] disk size 648871936,
2021-09-30T00:51:27.844753Z INFO ARCVM(34)[23414]:  [src/linux.rs:228] Trying to attach block device: /opt/google/vms/android/vendor.raw.img
2021-09-30T00:51:27.844785Z INFO ARCVM(34)[23414]:  [disk/src/disk.rs:283] disk size 139890688,
2021-09-30T00:51:27.844998Z INFO ARCVM(34)[23414]:  [disk/src/disk.rs:283] disk size 139890688,

Change-Id: Ief63cf75ba86e5324c6cc65a825c2717d3a0cb18
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3195154
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2021-09-30 07:53:06 +00:00
Keiichi Watanabe
d38a34c038 docs: Move code map to ARCHITECTURE
BUG=b:195003973
TEST=none

Change-Id: Idfe9565354d661361010df91c83a9313d94462b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3188674
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-09-29 16:19:51 +00:00
Keiichi Watanabe
909d7f3c05 docs: Add ARCHITECTURE.md
It's a common idea to have ARCHITECTURE.md next to README.md and
CONTRIBUTING.md [1].
So, let's do so instead of having the doc only under mdbook.

[1] https://matklad.github.io//2021/02/06/ARCHITECTURE.md.html

BUG=b:195003973
TEST=mdbook build

Change-Id: I8d3f479ba65c7f85865c51b5c22fb5b37d6e8f78
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3188675
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-09-29 16:19:50 +00:00
Keiichi Watanabe
b8bfe8dd04 mdbook: miscellaneous cleanup
* Remove an unnecessary index in SUMMARY.md
* Fix section levels in usage.md

BUG=b:195003973
TEST=mdbook build

Change-Id: Icf97038f664d02d169f9db30f4999f053ed2ed81
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3188673
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-09-29 16:19:49 +00:00
Keiichi Watanabe
c912894ae9 docs: Run mdformat
Ran:
$ find ./docs/book/src/ -name "*.md" | xargs mdformat --in_place

BUG=none
TEST=mdbook build

Change-Id: I56c74538a4c2643fa2c6e33fe99660611442b4dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3188672
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-09-29 16:19:48 +00:00
Udam Saini
38fedb73e5 Revert "vm_memory: Add from_desciptor() in MemoryMappingBuilder"
If we need descriptor for things that aren't file or other shared_memory objects, we can create a separate descriptor change, but it shouldn't be the default.

This reverts commit 533c5c8258.

Reason for revert: this causes conflicts with other platforms.

Original change's description:
> vm_memory: Add from_desciptor() in MemoryMappingBuilder
>
> MemoryMappingBuilder had `from_file()` and `from_shared_memory`, which
> are almost the same. So, this commit adds `from_descriptor()` to replace
> both of the two.
>
> BUG=b:194137301
> TEST=build
>
> Change-Id: Ia13f5e8e0f95a5c32e47dc9b3be13b7a7fa510bf
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3159881
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>

Bug: b:194137301
Change-Id: Ie203ee3eb3dcddd41c5e55b6980dc6292eb24f85
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3183183
Auto-Submit: Udam Saini <udam@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Udam Saini <udam@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-09-27 16:36:24 +00:00
Daniel Verkamp
2e7dbd4fa4 rutabaga_gfx: convert to ThisError and sort
BUG=b:197143586
TEST=cargo check

Change-Id: I78d3d70c0a9a328ac04857bb78a9d633b93db6c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105426
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2021-09-24 22:52:30 +00:00
Daniel Verkamp
8d26c71677 resources: convert to ThisError and sort
BUG=b:197143586
TEST=cargo check

Change-Id: Ia9b0fd918d81a00e6a4741355ea07152e1d1559a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105425
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-09-24 21:13:19 +00:00
Daniel Verkamp
22af5965e8 power_monitor: convert to ThisError and sort
BUG=b:197143586
TEST=cargo check

Change-Id: Iab4eaa40f9b642d294fcd3a6b85b8f09954c120a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105084
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-09-24 21:13:19 +00:00
Daniel Verkamp
1a98986d1d net_util: convert to ThisError and sort
BUG=b:197143586
TEST=cargo check

Change-Id: I21a7908fbe885b1cc0b98c9b3b17d3f4ea807bde
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105083
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-09-24 21:13:17 +00:00
Daniel Verkamp
8c2b990e16 kernel_loader: convert to ThisError and sort
BUG=b:197143586
TEST=cargo check

Change-Id: Ic58e295f225a01f5f12889bf1537c899ff2725aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105082
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-09-24 21:13:16 +00:00
Abhishek Bhardwaj
5b36338f9b crosvm: Plumb read_bar and write_bar to VirtioDevice
This change plumbs read_bar and write_bar methods to the VirtioDevice
trait. VirtioDevice exposes PCI bars and the virtio vhost user proxy
device would need these methods.

BUG=b:194136484
TEST=Compile.

Change-Id: Ib65d0fb81feb8af6913a2c2c2bdba80ef6d20d31
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3176396
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Abhishek Bhardwaj <abhishekbh@chromium.org>
Auto-Submit: Abhishek Bhardwaj <abhishekbh@chromium.org>
2021-09-24 07:30:14 +00:00
Dennis Kempin
bfa99f02ba Add testvm.py tool for managing test VMs
The script can be used to run VMs to test crosvm in a controlled
environment, and most importantly, to test crosvm on aarch64.

This will eventually replace the current Docker based VM setup
process and will be integrated into our test runner to allow aarch64
test runs without using Docker.

Run `/tools/aarch64vm` for usage instructions.

Note: I will make a follow-up change to consolidate all of our dev
tools and scripts (e.g. clippy or rustfmt) in the tools directory.

BUG=b:200562467
TEST=
./tools/aarch64vm ssh
./tools/x86vm ssh

Change-Id: Idef8256bf6737b2915912984a44240ba39c6bc2f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3176381
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-09-23 17:47:20 +00:00
Alexandre Courbot
c5dad3fdee virtio: video: remove suspicious code
When outputting a picture there is a bit of code that updates the size
of each output plane to the size of the visible rect. This looks wrong
on several accounts:

1) The plane size should already have been computed when we received the
   buffers,
2) With this code each plane is assigned the same size, which is
   obviously wrong with formats such as NV12,
3) The size in bytes of a plane depends on the coded size, not the
   visible size.

Looking at the git history it appears that this code has been here since
the initial revision of the decoder, and then moved around. Maybe it was
just here to make things work in the beginning and slipped under the
radar. In any case, removing that code does not seem to hurt.

BUG=b:161774071
BUG=b:169295147
TEST=Android Youtube plays properly on Hatch.

Change-Id: I6c8949c49c070daaa3540b757dd35469b571c43c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3026344
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chih-Yu Huang <akahuang@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2021-09-23 10:50:03 +00:00
Dmitry Torokhov
cc03cdbecc plugin: capture stderr when spawning/jailing plugin binary
While minijail uses syslog to log errors during jail setup, ld.so simply
dumps error into stderr. When debugging plugin startup issues it is
beneficial to see what ld.so might be upset about, so let's capture
stderr of the child and log it.

BUG=None
TEST=removed /opt/pita/lib symlink, tried starting Parallels VM,
observed meaningful error message captured from stderr.

Change-Id: I7e57e110a969653e0d27e6e93f4a8104efeca978
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3170589
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2021-09-23 04:57:15 +00:00
Gurchetan Singh
e4d14af544 devices: gpu: update to latest CONTEXT_INIT protocol
Changes __le32 info --> u8 ring_idx + padding u8[3], as per:

https://www.oasis-open.org/committees/ballot.php?id=3645

BUG=b:150239451
TEST=run wayland apps

Change-Id: I6a65ca0deb7b66c50982a70949e75c0241c8300d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3173068
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2021-09-22 22:14:22 +00:00
Gurchetan Singh
686d37a82b rutabaga_gfx: RutabagaFenceData --> RutabagaFence
It's a little bit less wordy.

BUG=b:150239451
TEST=none

Change-Id: Ia25ac6b3db77ce8e9b074273967294909fb56e87
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3173067
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2021-09-22 22:14:21 +00:00
Tomasz Nowicki
bea1935867 vfio: Remove PCI dependency
VFIO-PCI device has its own region naming but eventually it starts from 0
(as well as it suppose for others VFIO device types) so simply use 0
instead of VFIO_PCI_BAR0_REGION_INDEX.
At the same time move PCI-specific checks to helper function for clarity.

BUG=b:185504618
TEST=manatee PCI device passthrough boots/works

Change-Id: I404a9585016d230c48a6db7248172d2381a0a3e1
Signed-off-by: Tomasz Nowicki <tn@semihalf.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2961213
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Tomasz Nowicki <tnowicki@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-09-22 13:57:29 +00:00
Andrew Scull
82f723fede crosvm: arm64: Use helper function for entry address
Rather than duplicate the calculation, resuse the helper function that
calculates the entry address. This means there's just one place to make
changes and everything will be kept in sync.

BUG=none
TEST=presubmit

Change-Id: I2fd31dbaf2479ad0ce9d05c7341323b695268fa4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3111366
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Andrew Scull <ascull@google.com>
2021-09-22 12:21:14 +00:00
Keiichi Watanabe
533c5c8258 vm_memory: Add from_desciptor() in MemoryMappingBuilder
MemoryMappingBuilder had `from_file()` and `from_shared_memory`, which
are almost the same. So, this commit adds `from_descriptor()` to replace
both of the two.

BUG=b:194137301
TEST=build

Change-Id: Ia13f5e8e0f95a5c32e47dc9b3be13b7a7fa510bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3159881
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-09-22 04:37:44 +00:00
Charles William Dick
4745f03ce0 virtio_balloon shared and unevictable stats
This CL adds support for parsing stats introduced by:
https://crrev.com/c/3115084

BUG=b:198468047
TEST=candy crush runs

Change-Id: I8e258ebf7f2b7dd7a3019f40397c59514e7b18bc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3168561
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Charles William Dick <cwd@google.com>
2021-09-22 01:06:43 +00:00
Daniel Verkamp
127a90ff3e linux: disable PCI to PCI bridge
The presence of the PCI bridge introduces a regression when booting
OVMF:

  PciHostBridgeDxe: IntersectMemoryDescriptor: desc [0, A0000) type 2 cap
  800000000002600F conflicts with aperture [0, D0021000) cap 1

The root cause is that the bridge does not correctly populate the memory
base/limit and prefetchable memory base/limit PCI bridge configuration
registers.

For the short term, since this bridge is only needed for the PCI hotplug
feature that is not enabled yet, remove the creation of the bridge from
the startup code.  Fixing the bridge will be done in another commit to
keep this change small and easy to backport.

BUG=b:199442120
BUG=b:185084350
TEST=crosvm run --bios OVMF.fd

Change-Id: I91b2cc6628e320ac2403bd8b74d18ef5a26d7c0f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3158942
Reviewed-by: Xiong  Zhang <xiong.y.zhang@intel.corp-partner.google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-09-22 01:04:31 +00:00
Tomasz Nowicki
70a71f8d89 devices: virtio: vhost: fix device initialization race condition
Complete vhost worker queue init before spawning thread routine.

Enabling a virtio devices requires updating the
VIRTIO_CONFIG_S_DRIVER_OK bit, which signifies that the devices is
ready to process the virtio queue. Do this before spawning the worker
thread in order to avoid the situation where a guest VM starts using the
queues before initialization has been completed.

Also make this fix for vhost net and vsock.

BUG=b:200658613
TEST=boot with vhost-net interface and check that network is working fine

Change-Id: Ibc505ba63d692d9c5380d9ec3b6f80d75ff99181
Signed-off-by: Tomasz Nowicki <tn@semihalf.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3015206
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Tomasz Nowicki <tnowicki@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-09-21 18:44:40 +00:00
Woody Chow
f5183c26be Set rtprio in virtio-snd (cras backend) worker
to 10 (following other cros audio client)

BUG=b:199796992
TEST=Examine output of `ps -AT -eo rtprio,command` when the device
  is running

Change-Id: I1293c693e1bd699788d87d5bc085fd4fd281fff1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3159894
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Woody Chow <woodychow@google.com>
2021-09-21 10:49:57 +00:00
Chirantan Ekbote
44292f58f3 Support out-of-tree vhost-user-gpu
BUG=b:179755651
TEST=`glxinfo -B | grep virgl` inside a crostini vm

Change-Id: I37b98fcccfb8e56af4d07a2afe828ca3b5087b1f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2987595
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-09-21 10:08:51 +00:00
Gurchetan Singh
084c87baad rutabaga_gfx: cross_domain: save iovecs in cross domain context
Essentially, the same issue as crrev.com/c/3131442.  The kernel
driver doesn't pass the ctx_id (even though that information is
available), so need two component.create_blob function.  Long-term
solution might to modify virtio spec.

BUG=b:150239451
TEST=run cross domain context without building any 3D renderers

Change-Id: I8d23eed7fa20de37633a6e915f137c481cb82e47
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3169356
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2021-09-20 19:21:28 +00:00
Keiichi Watanabe
7e68e485ca mdbook: Add "Code Overview" section to CONTRIBUTING.md
Move `Code Overview`  section from README to CONTRIBUTING.md

BUG=b:199874828
TEST=mdbook build

Change-Id: Id3947f958d31816f4fc802a1a35177c0ceafa4dd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3159889
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-09-20 12:45:45 +00:00
Keiichi Watanabe
eced721cc8 mdbook: Add 'Running Crosvm' section
BUG=b:199874828
TEST=mdbook build

Change-Id: I760ce0aa072fcc0194353ceaf2396357005b3aea
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3159888
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-09-20 12:45:44 +00:00
Keiichi Watanabe
db6b0170c8 mdbook: Add "Building Crosvm" section
Duplicate sections from README

BUG=b:199874828
TEST=mdbook build

Change-Id: Id097a4077f5e844bf36528fc49de887df6409c9e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3159887
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-09-20 12:45:43 +00:00
Keiichi Watanabe
9ad1788661 mdbook: Simplify SUMMARY.md
* Remove sections whose contents don't exist.
* Move supplementary or/and out-dated documentations to Appendix.
  - Add notes in example_usage.md

BUG=b:199874828
TEST=run `mdbook build` in /docs/book/

Change-Id: Id9d3e90df40fdd138d6c3a39066c5352ec66c41d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3159886
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-09-20 12:45:42 +00:00
Keiichi Watanabe
8f6e61705c Add GitHub Action for mdbook
BUG=b:199688855
TEST=run at personal account

Change-Id: I7e44424deccf64be5fdf0d14d24109c3245e37c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3159885
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-09-20 12:45:41 +00:00
Abhishek Bhardwaj
7a1a6cd58b crosvm: Implement communication logic in virtio-vhost-user PCI device
This change adds the PCI device that will act as the conduit between
vhost vmm and vhost device in a virtio-vhost-user
specification. It only implements the communication logic i.e. rx / tx
from the vmm socket and virtio queues associated with the device.

BUG=b:194136484
TEST=Compile.

Change-Id: Ib47045b7633b77b73ed7bd428ca981caa6645275
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3146213
Auto-Submit: Abhishek Bhardwaj <abhishekbh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Abhishek Bhardwaj <abhishekbh@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-09-17 22:07:55 +00:00
Chirantan Ekbote
3e8d52b802 vhost: Don't require GuestMemory in ::new()
GuestMemory is only needed for the set_mem_table and set_vring_addr
methods so take it in as a parameter there rather than storing it in the
struct.  Vhost-user devices don't have access to GuestMemory when the
vhost device is first constructed.

BUG=b:179756331
TEST=unit tests

Change-Id: Id446db43777c26b0dfbe8b37366f2da93de53b23
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3153211
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-09-17 12:21:30 +00:00
Daniel Verkamp
eb1640e301 disk: limit maximum nesting depth
Impose a limit on the maximum nesting of file formats that can open more
files. For example, a qcow2 file can have a backing file, which could be
another qcow2 file with a backing file (or even the same file as the
original), potentially causing unbounded recursion.

BUG=b:198326611
TEST=cros_fuzz

Change-Id: I2f8573a7c71c6d8b310f2c2a75a240f2f8f0c9b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3146214
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Cody Schuffelen <schuffelen@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-09-17 02:55:04 +00:00
Dennis Kempin
e9aa5f9598 Fix ./ci/kokoro/simulate
Somehow, after rsyncing the whole directory, git will no longer work in the
copy. So instead, we are now using 'git clone'.
This changes the behavior to not include local workspace modifications in
kokoro simulations. Which is ok, we have test_all for that and the behavior
will more closely match what's happening in kokoro presubmits.

BUG=None
TEST=./ci/simulate_all

Change-Id: I439b9eadcac65d99782e2b0eb869519abb2ada37
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3152425
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-09-15 17:06:48 +00:00
Dennis Kempin
3b3545b2c3 Upgrade ci containers to bullseye and clean up
We no longer need to build dependencies from source and provide them
via pkg-config, this simplifies much of our builder container setup.

As debian bullseye got promoted to stable, we can now also simplify
further by just using bullseye stable instead of mixing stable and
testing packages.

BUG=b:181359683
TEST=./test_all

Change-Id: I2ce61992d5cfe6eb5dc3f0ec61920dcc5455ca40
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3141772
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-09-15 17:06:46 +00:00
Federico 'Morg' Pareschi
a1184822c7 Add vhost-user-fs device
This CL adds a vhost user FS device to crosvm. The implementation
requires the following arguments:

--socket = a path to a unix socket crosvm is going to connect to
--tag = a virtio fs tag to mount within the VM
--shared-dir = path to the shared directory

Optional arguments are:
--uid-map = UID translation from inside the VM to the outside
--gid-map = GID translation from inside the VM to the outside

Example command:
crosvm device fs --socket $HOME/test --tag fs-tag --shared-dir $DIR
crosvm run --vhost-user-fs=$HOME/test:fs-tag ...

BUG=b:179636297
TEST=launch fs device and verified that mounted directory works

Change-Id: Icab9e4be65092ef817006408b50bb3bf35033c62
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3062161
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Morg <morg@chromium.org>
Commit-Queue: Morg <morg@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-09-15 02:06:49 +00:00