Commit graph

2482 commits

Author SHA1 Message Date
Daniel Verkamp
a5884b5a6e kernel_cmdline: convert to ThisError and sort
BUG=b:197143586
TEST=cargo check

Change-Id: Ic86f0d08b36e5f1b30ea35def38e3875c972c938
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105081
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-09-02 21:00:23 +00:00
Daniel Verkamp
793b4703cf io_uring: convert to ThisError and sort
BUG=b:197143586
TEST=cargo check

Cq-Depend: chromium:3105310
Change-Id: I661c65e095d0a8274a68ff44d70a65bce21970f5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105080
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-09-02 21:00:22 +00:00
Daniel Verkamp
c3f546906b gpu_display: convert to ThisError and sort
BUG=b:197143586
TEST=cargo check

Change-Id: I461144d021314984e9ec2c738144b8e3065efcf4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105079
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-09-02 21:00:22 +00:00
Daniel Verkamp
620b0f033e fuse: convert to ThisError and sort
BUG=b:197143586
TEST=cargo check

Change-Id: Ie16063534c5c912a429863427dcb20c08b67c784
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105078
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-09-02 21:00:21 +00:00
Daniel Verkamp
e6ff5376e1 disk: convert to ThisError and sort
BUG=b:197143586
TEST=cargo check --features=composite-disk

Change-Id: Ibd06b85b959d28f6cc5948be30220fa268034dcb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105077
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-09-02 21:00:21 +00:00
Daniel Verkamp
5225377caf devices: convert to ThisError and sort
BUG=b:197143586
TEST=cargo check
TEST=./test_all

Change-Id: I9583dc47ad4c88984a7111667d1ffbdac04ae786
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105076
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-09-02 21:00:20 +00:00
Daniel Verkamp
19141aa529 data_model: convert to ThisError and sort
BUG=b:197143586
TEST=cargo check

Cq-Depend: chromium:3105309
Change-Id: Iba6951588038bfb2cc7d1f8eca68183d7b75fc54
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105075
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-09-02 20:59:14 +00:00
Tomasz Jeznach
7ab02aa85b crosvm/pci: update to PCI/INTx allocation
For VFIO devices, allow host interrupt allocation
numbering to match ACPI _CRS.

BUG=b:179648314
TEST=./test_all, boot on sytem with vfio devices connected.

Change-Id: Ied1153f3fc72876d8f3df8822ff6d4e869c40f62
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2893367
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-09-02 10:00:47 +00:00
Woody Chow
737ff125ca Add virtio-snd device with CRAS backend
Enable with `--cras-snd`.

Verified:
Basic playback and capture

Missing features:
* Getting chmap/jack/stream info from CRAS. They are hardcoded for now.
* Jack connect/disconnect notifications from CRAS
* Reporting latency bytes to the driver. It is currently hardcoded to 0.

BUG=b:179757101
TEST=`aplay` and `arecord` inside a debian img with a 5.10 kernel built
     with virtio snd support. Launched with crosvm on rammus/kukui/hatch

Change-Id: I240000a92418b75b3eb8dcd241ff320214b68739
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2777991
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Woody Chow <woodychow@google.com>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
2021-09-02 04:29:55 +00:00
Ryo Hashimoto
bf0294eb7f power_monitor: Upgrade dbus to 0.9
BUG=b:197638022, b:190791826
TEST=`cat $(find /sys -name voltage_now 2>/dev/null)` in adb shell

Change-Id: Ie195abeee7aa601d6b42b900d2197f30a128e8e8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3135100
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Ryo Hashimoto <hashimoto@chromium.org>
2021-09-01 18:21:42 +00:00
Dennis Kempin
00bfcab3e8 Update tpm2-sys build.rs to support cross-compilation
Also removes the use of the hermetic flag in favor of not failing the
build if the submodule is not checked out.
This allows us to remove the tpm2 build from the build_environment
Makefile.

BUG=b:198293072
TEST=./test_all

Change-Id: Ide81e78efe0da3a1b64d4b8ef094a2e901f99ccf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3133623
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-09-01 01:59:09 +00:00
Jason Macnak
1cb7028070 rutabaga_gfx: gfxstream: Save iovecs in gfxstream
The virtio gpu resource used as a ring buffer for sending
CROSS_DOMAIN_CMD_GET_IMAGE_REQUIREMENTS responses back to the
guest is created with VIRTGPU_BLOB_MEM_GUEST. Because of this, it
is initially created with via a resource_create_blob() without a
ctx_id. The rutabaga backend routes resource_create_blob() requests
without a ctx_id to the default component which is Gfxstream on
Cuttlefish. The Gfxstream component needs to attach the backing
iovecs to the RutabagaResource in order for CrossDomainContext to
eventually take ownership of them.

BUG=b:189133053
TEST=launch Cuttlefish w/ cross domain

Change-Id: I1779fcae2c612dae55ca66fe61a5d2f966cedc1d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3131442
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Jason Macnak <natsu@google.com>
2021-08-31 21:55:53 +00:00
Daniel Verkamp
dcfb7de431 ci: prevent creation of virglrenderer __pycache__
Prevent the dependency build process from leaving untracked files in the
working copy when running test_all.

BUG=None
TEST=./test_all

Change-Id: Ia9dca114ffe98e73f9858795657a3864deab9d3b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3119699
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-08-31 20:12:29 +00:00
Jason Macnak
c90545d6e6 rutabaga_gfx: rutabaga_gralloc: Handle vulkano release 0.25.0
- Use new VulkanImageAspect
- Use new vulkano::device::physical namespace
- Replace 'loaded_extensions' with 'enabled_extensions'
- Handle 'device_type' change
- Remove u64 to usize casts for DeviceMemoryBuilder
- Extension name update

BUG=b:189133053
TEST=build

Change-Id: I99d319b3eff534d1c4b93db9d7d64d2a95074d19
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3131446
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Auto-Submit: Jason Macnak <natsu@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
2021-08-31 17:17:10 +00:00
Daniel Verkamp
28359e141f sys_util: remove unsafe struct_util functions
Replace the uses of read_struct() and read_struct_slice() with the
safe DataInit::from_reader() implementation.

BUG=b:197263364
TEST=./test_all
TEST=Boot bzImage kernel
TEST=Boot raw ELF kernel extracted with extract_vmlinux

Change-Id: I80f98243bfb58a7ae93e1686bc4d92b0cd485cda
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3108249
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-08-27 23:48:24 +00:00
Fergus Dall
51200519a2 Don't rely on being able to look up users/groups
Some devices need to have their current uid mapped in their sandbox
for bind mounts to work as expected. Currently crosvm looks up the
uid/gid for "crosvm" and maps that.

This logic is dubious anyway, since crosvm should be using whatever
user/group it was started under rather then trying to switch (which is
a priviliged operation), but putting concierge in a user namespace
breaks it entierly because the crosvm user gets remapped to a
different numeric value.

Replace the current approach with mapping the current euid/egid,
whatever it may be.

BUG=chromium:1240116
TEST=Manually tested

Change-Id: I0e9b95ed04834da1adedb72bee52ac4359f06041
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105907
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Allen Webb <allenwebb@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-08-27 17:57:57 +00:00
Daniel Verkamp
ddcf7bd2ab cros_async: convert to ThisError and sort
BUG=b:197143586
TEST=cargo check

Cq-Depend: chromium:3105313
Change-Id: Ic9757b7e1947970910245fe954e47e4a2b7aa28e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105074
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-08-26 22:29:41 +00:00
Daniel Verkamp
9aeb925b30 base: convert to ThisError and sort
BUG=b:197143586
TEST=cargo check

Change-Id: Ief0c14b39889993b704d3c5ef39cff66177db272
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105073
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-08-26 22:28:32 +00:00
Daniel Verkamp
b09646303e audio_streams: convert to ThisError and sort
BUG=b:197143586
TEST=cargo check

Cq-Depend: chromium:3105308
Change-Id: Id48674c3fb0536a72a14a945a9f76bc58649fb46
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105072
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
2021-08-26 22:28:32 +00:00
Daniel Verkamp
e8e871b085 arch: convert to ThisError and sort
BUG=b:197143586
TEST=cargo check

Change-Id: Id02ed4873158e20664b45bf651ba68e0eb715b1c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105071
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-08-26 22:28:31 +00:00
Daniel Verkamp
114361eb26 aarch64: convert to ThisError
BUG=b:197143586
TEST=cargo check

Change-Id: I21428922fce8f7a25d288c88813d43b10ee47fae
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105070
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-08-26 22:28:29 +00:00
Daniel Verkamp
1349c1314c Cargo.toml: make thiserror a required dependency
BUG=b:197143586
TEST=cargo check

Change-Id: Iabb7dfa9ec20774b7c15297b9ef86a9009fb11e2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105069
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-08-26 22:28:28 +00:00
Adrian Ratiu
b08a9e2953 seccomp: allow fstatat64/statx syscalls on arm
On 32bit arm systems, starting with glibc 2.33, the fstatat64
syscall is used to fix a y2038 bug and statx is also called
for 64bit->32bit datastructure conversion.

See this upstream glibc 2.33 commit range for more details:
d892723830..aa03f722f3.

Example failures (only on 32bit arm):
type=SECCOMP comm="mtpd" exe="/usr/sbin/mtpd" sig=0
arch=40000028 syscall=327 code=0x7ffc0000
type=SECCOMP comm="mtpd" exe="/usr/sbin/mtpd" sig=0
arch=40000028 syscall=397 code=0x7ffc0000

BUG=b:187795855
TEST=Local builds; CQ.

Change-Id: I003feeaa75552770920cdf9969a393940c5e997b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3113972
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-08-26 20:59:21 +00:00
Daniel Verkamp
5e9b5dfe58 virtio: video: use iter .any() to check presence
Rather than using .find().is_none(), use !.any() to fix a new clippy
warning.

BUG=b:197251702
TEST=bin/clippy # with rust-toolchain = 1.54.0

Change-Id: I7e3de6b8e864f74300956c43dffaa033c58b7eb0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3108617
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Allen Webb <allenwebb@google.com>
2021-08-25 23:02:29 +00:00
Daniel Verkamp
7cca590593 devices: use mem::take to replace with default
mem::take() can be used in place of mem::replace() when replacing with
the default value, fixing a new clippy warning.

BUG=b:197251702
TEST=bin/clippy # with rust-toolchain = 1.54.0

Change-Id: I7289515eece30b9e294046930aa863a1ceab4de4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3108616
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Allen Webb <allenwebb@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-08-25 23:02:29 +00:00
Daniel Verkamp
e73249af06 devices/register_space: use Copy rather than Clone
Fixes a new clippy warning with Rust 1.54.0.

BUG=b:197251702
TEST=bin/clippy # with rust-toolchain = 1.54.0

Change-Id: I42cf6e380900ea4bb245629b56b0be5c75e2099d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3108615
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Allen Webb <allenwebb@google.com>
2021-08-25 23:02:28 +00:00
Daniel Verkamp
63db2893e2 devices/irqchip: deduplicate statements inside if
Pull the duplicated first statement out of the IRQ triggering sequences
to placate clippy's new warning.

BUG=b:197251702
TEST=bin/clippy # with rust-toolchain = 1.54.0

Change-Id: I8cd8577af35990522e198f97f3a666ad6730e31b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3108614
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Allen Webb <allenwebb@google.com>
Reviewed-by: Colin Downs-Razouk <colindr@google.com>
2021-08-25 23:02:27 +00:00
Daniel Verkamp
35712b20d8 devices, gpu_display: use Iterator flatten()
Instead of checking each item for Some/Ok-ness, filter down to just the
desired items using flatten() on the iterator.

BUG=b:197251702
TEST=bin/clippy # with rust-toolchain = 1.54.0

Change-Id: I80db12c36f41e76f5dff6c30299a3f5d3745f578
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3108613
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Allen Webb <allenwebb@google.com>
2021-08-25 23:02:26 +00:00
Daniel Verkamp
cfe494661d linux.rs: add clippy allow for manual_map
This only triggers when the powerd support is compiled out, so just
ignore it.

While we're here, fix the name of the power-monitor-powerd feature in
the line just below (drop the extra "d"); it would always apply, since
the feature name was misspelled.

BUG=b:197251702
TEST=bin/clippy # with rust-toolchain = 1.54.0

Change-Id: I1b8ef3732c3d5968a9e230216f8f727bd1445609
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3108612
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Allen Webb <allenwebb@google.com>
2021-08-25 23:02:26 +00:00
Daniel Verkamp
5e9959e8f5 main: replace assert_eq!(..., true/false) with assert!()
BUG=b:197251702
TEST=bin/clippy # with rust-toolchain = 1.54.0

Change-Id: I80b8a5e4a90f2d6aefafd3d0d4b64b6751163b25
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3108611
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Allen Webb <allenwebb@google.com>
2021-08-25 23:02:25 +00:00
Daniel Verkamp
166d1ddfbe crosvm: fix needless_borrow clippy warning
Tree-wide cleanup of new clippy warning in Rust 1.54 that warns about
needless borrows:

  error: this expression borrows a reference (`&...`) that is
  immediately dereferenced by the compiler

https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

BUG=b:197251702
TEST=bin/clippy # with rust-toolchain = 1.54.0

Change-Id: Ib702ec524d4623d264a00ec11dbc2150c411a67b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3108321
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Allen Webb <allenwebb@google.com>
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-08-25 23:02:23 +00:00
Woody Chow
e0f96c5930 Add cros_async to patches.crates-io
to avoid version conflict

BUG=None
TEST=CQ

Change-Id: If640e6288430213c104d95eb00cf0cb01c64b6d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3113245
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Woody Chow <woodychow@google.com>
2021-08-25 07:58:15 +00:00
Adrian Ratiu
48486f9248 seccomp: make consistent use of faccessat/2
In some places the faccessat and faccessat2 syscalls were
added only for arm64 but starting with glibc 2.33 they are
required on all architectures, so add them to arm and amd64.

BUG=b:187795855
TEST=Local builds; CQ.

Change-Id: Ica4755844fbbd29d31df2967724abe735ab59f7e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3111369
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Manoj Gupta <manojgupta@chromium.org>
2021-08-24 23:12:34 +00:00
Junichi Uekawa
25724e2ccc integration_test: Check file system before running test.
We need a file system that supports O_DIRECT. We know ext4 to work and
tmpfs not to work. Try out O_DIRECT before running the individual tests.

Follow up to changing the configuration so that the next time I can notice the
failure reason faster.

BUG=b:190435784
TEST=integration_tests/run

Change-Id: I7f8a97005dd959a5d0af4d1a91459b7bffc0fa9b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3096427
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-08-24 21:56:52 +00:00
Victor Hsieh
5c4e0347e1 Drain the read buffer of DevFuseReader
In some circumstances, it's possible that the buffered data isn't fully
consumed by the filesystem. Before handling the next request, we need to
drain the residual.

This change also moves the reader/writer/mapper out of the loop, since
we intend to not duplicate the FDs for each interation, and prefer to
reuse the buffer / avoid re-allocation anyway. This allows us to
implement `drain` in DevFuseReader.

BUG=b:196264590
TEST=fsverity measure a filesystem without ioctl impl, the filesystem
     does not crash any more

Cq-Depend: chromium:3105916
Change-Id: Ib758c98e6d7b4ce1391c51db19c120a4cec09dff
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3092409
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Victor Hsieh <victorhsieh@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-08-24 18:41:30 +00:00
Ryo Hashimoto
8f9dc1d55e aarch64: Support pstore
Add necessary kernel cmdlines for aarch64.
Adjust PCI address to make room for ramoops on aarch64.
Move the code from x86_64 to common places.

BUG=b:153934386
TEST=vm_pstore_dump

Change-Id: I8f92a7fd04a49afd7e8be9e7cf1901ef70b88d65
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3103131
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Kansho Nishida <kansho@chromium.org>
Commit-Queue: Ryo Hashimoto <hashimoto@chromium.org>
2021-08-24 14:31:44 +00:00
Xiong Zhang
e19ab750bc devices:vfio-pci: Assign vfio-pci device pci address
For vfio-pci devices created during vm setup period, they have the same pci
address as host.

For hotplug in vfio-pci device, caller should assigh the bus number,
so it could be associated with a pcie root port or pcie downstream port, but
devfn should be 0, as pcie root port driver scan it children device at devfn=0.

BUG=b:185084350
TEST=Boot a vm with passthrough device and check its function

Change-Id: Ia314cb74b15de374de540e440a91374a6538af54
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2955568
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-08-24 00:56:32 +00:00
Xiong Zhang
544fb027c7 devices:pci: Pass pci bus number into allocate_pci()
Pci BusNumber is allocated by guest kernel, the BusNumber should be 0
for all the integrated pci devices and vfio-pci device, but pci bridge
and vfio-pcie device may have BusNumber > 0, so caller should know its
device BusNumber and pass it into allocate_pci() and get the desired
PciAddress.

BUG=b:185084350
TEST=None

Change-Id: I3cb18212e6c168c047f655a5f425abdeccbaae55
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2954678
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-08-24 00:56:31 +00:00
Xiong Zhang
2ec87968d5 devices:pcie: Implement HotPlugBus trait on PcieRootPort
PcieRootPort is used to notify hotplug event into guest,
so implement HotPlugBus trait on it.

BUG=b:185084350
TEST=Boot a guest with pcie root port and check its status

Change-Id: Ide110d107422fa784bd8de0aaa87b319c786ef28
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2954677
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-08-24 00:56:31 +00:00
Xiong Zhang
262e618b04 devices:pcie: Add and emulate pcie root port
Pcie root port implements pcie cap register, but it is wrapped as a pci
bridge to VM, the pci bridge implements PciDevice trait.

BUG=b:185084350
TEST=Boot a guest with pcie root port and check its status

Change-Id: I739e878846f4b35d58e4d213caafe30196a27ccb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2954676
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-08-24 00:56:30 +00:00
Xiong Zhang
9fadc3fda0 devices🚌 Add HotPlugBus Trait
Device implement HotPlugBus trait could notify hotplug event into
guest, and such device should be added into RunnableLinuxVm, so it
could be used at device plug in and plug out.

BUG=b:185084350
TEST=Boot a guest with and without passthrough device

Change-Id: I9497f61312582483090ff708d0f37b97d7303811
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2954673
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-08-24 00:56:29 +00:00
Xiong Zhang
8c9fe3ef34 Arch: Vfio device could be created and configured at runtime
When a vfio pci device is added through hotplug in, it should be configured
at runtime and added into pci_root->devices tree, so pci_root is added
into linux.

BUG=b:185084350
TEST=Boot a guest with and without passthrough device

Change-Id: Ibcb5f4a849134f64fbceeac645bebd80d6ca72d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2954672
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-08-24 00:56:28 +00:00
Chirantan Ekbote
b56de80b07 fs: Support fs-verity
Needed by arcvm.

BUG=b:141632062
TEST=Run `fsverity enable $FILE` and `fsverity measure $FILE` inside a
     VM on a virtio-fs mountpoint

Change-Id: Ifb9e7e9c8b924a835971bf298256495d8dc81733
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2387820
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-08-23 16:15:03 +00:00
Chirantan Ekbote
f4d6014c41 data_model: Don't heap allocate in DataInit::from_reader
We can use MaybeUninit instead of heap allocation to ensure that our
buffer has the proper size and alignment. `from_reader` is used for
every message in the fs device and this saves us some unnecessary small
heap allocations.

Switch Reader::read_obj to use this method so that we don't have
multiple implementations of the same thing. This also fixes some
unsoundness in read_obj where we were creating a `&mut [u8]` out of
uninitialized data.

BUG=none
TEST=unit tests

Change-Id: I1fa66de11974e2fe3a8dfb4b7ab4b210ecf395d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3109088
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-08-23 11:59:16 +00:00
Chirantan Ekbote
98aeeff782 fuse: Implement Reader and Writer for mutable references
This way we're not required to transfer ownership every time we call
`handle_message`.

BUG=none
TEST=unit tests

Change-Id: Ia0cc10c7b5431e8bb90afbc0b658efac33eef6c9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105916
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-08-23 09:20:11 +00:00
Keiichi Watanabe
48473283aa README: Add TOC
BUG=none
TEST=none

Change-Id: Id2a6af763bb891e95001a40b435f029f85eb7df9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3109172
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-08-20 07:57:34 +00:00
Adrian Ratiu
a0320d286d crosvm: seccomp: allow faccessat2 syscall if it exists
Starting with glibc 2.33 the faccessat2 syscall is used and
only if it doesn't exist (eg kernel older than 5.8) glibc will
default to the older faccessat syscall, so we need to allow it.

Previously this syscall has been enabled on a per-component
basis after testing, but this one does a bulk enable when
faccessat is used on all architectures.

See glibc commit 3d3ab573a5 ("Linux: Use faccessat2 to implement
faccessat (bug 18683")

BUG=b:187795855
TEST=Local builds; CQ.

Change-Id: I1f17e82e8c416b0fa2c43342731e9ea8394c47fa
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3097212
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Manoj Gupta <manojgupta@chromium.org>
2021-08-19 19:07:35 +00:00
Keiichi Watanabe
ee4b58ef42 main: Add 'device' subcommand for vhost-user devices
BUG=b:195495971
TEST=Run `crosvm device block <options>`

Change-Id: I93c9a4f9bef895edecc850e59cda155e10b6a444
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3070724
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-08-18 16:44:28 +00:00
Keiichi Watanabe
f1d5a76b77 devices: vhost: user: device: Return failures instead of printing
Make run_*_device() return an error instead of printing error messages
so that the caller of the functions can handle errors from each device
in the same manner.

BUG=b:195495971
TEST=cargo build

Change-Id: I1b464b8bedbe6d4e640084a2ad3b2565d11b9e07
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3099429
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-08-18 16:44:27 +00:00
Keiichi Watanabe
024784d5c0 devices: Merge vhost_user_devices library to devices crate
We originally created `vhost_user_devices` crate so that we'll be able
to have device executables there.
However, we decided to have vhost-user device as crosvm's subcommand.
So, we have no longer a reason to have vhost-user devices as the
separate crate. As the first step to remove the vhost_user_devices
crate, this CL move its main logic to the devices crate.

Note that we add `vhost_user_devices/src/*_device.rs` in this CL as we
need to keep the device executables for a while.

BUG=b:195495971
TEST=cargo build

Change-Id: I355b9cd35214ac0c3d8ffd6fbebc29dd7548fd61
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3070723
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-08-18 16:44:26 +00:00