Commit graph

2380 commits

Author SHA1 Message Date
Dennis Kempin
62770b484a Remove trunks proto from crosvm build
The feature was never finished (crbug.com/911799), but adds a
build-time dependency on the trunks proto in platform2.

BUG=b:193267897
TEST=cargo build with and without tpm feature

Change-Id: I7299ba0779bb04ebca6284cfd11873e99500c993
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3043491
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-07-31 03:01:21 +00:00
Jooyung Han
2e14c730b8 Add create_zero_filler for composite disk images
Previously, gaps(or holes) between component disk images were filled
with "GPT header". Rather than relying on arbitrary filler, it'd be nice
those gaps are filled with zeros.

BUG=b:190503456
TEST=cargo test

Change-Id: Ie7bcec5049ddc6c2e852bac6cd9bffc61f9d79d9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3058836
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Andrew Walbran <qwandor@google.com>
Commit-Queue: Jooyung Han <jooyung@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Jooyung Han <jooyung@google.com>
2021-07-31 02:26:57 +00:00
Jooyung Han
d7e56bab2e composite disk: no support for multi-file partition
We don't need to support multi-file partition for composite disk images.
This will make the code simpler.

BUG=b:190503456
TEST=cargo test

Change-Id: I9e115ec73ad451ea46fe91c0d0a3c2e85aa1f010
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3058835
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Andrew Walbran <qwandor@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jooyung Han <jooyung@google.com>
Auto-Submit: Jooyung Han <jooyung@google.com>
2021-07-31 02:26:57 +00:00
Junichi Uekawa
7bea39fef5 crosvm: O_DIRECT for opening disk image.
Introduce a new disk flag o_direct=true, which uses O_DIRECT for open.
Block access and memory buffer needs to be aligned to 512 bytes.

BUG=b:190435784
BUG=b:184204645
TEST=boot tests (boot_test_suspend_resume, boot_test_vm) keep running with o_direct=true.

Change-Id: I17888f8a6ef2a38baba2c17dbb0d7aa18b70dbfd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2821112
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-07-30 06:34:11 +00:00
Federico 'Morg' Pareschi
9d1d7d9d48 devices: virtio: Update fs code to use sync::Mutex
fs/worker.rs and fs/mod.rs were still using the old std::sync::Mutex
version instead of the crosvm-specific wrapper sync::Mutex

BUG=b:179636297
TEST=build crosvm and run shared-dir with virtio-fs

Change-Id: I773a885fd0ef35e25bc7a090f067d8a6f60636da
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3058837
Auto-Submit: Morg <morg@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Morg <morg@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-07-30 06:06:40 +00:00
Vikram Auradkar
ed4bd118bc cros_async: name threads + doc fix
BUG=b:191488633
TEST=cargo test && cargo doc && cargo clippy

Change-Id: I61cfb4b547e7ca280ad1726300fd145617a27d69
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3059870
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-07-30 04:41:36 +00:00
David Staessens
a27e035aa2 virtio: video: Add support for configuring the peak bitrate to encoder.
This CL adds support for the VIRTIO_VIDEO_CONTROL_BITRATE_PEAK control
to the crosvm encoder. This control allows configuring the peak bitrate
used when encoding a video. The peak bitrate is only used when the
bitrate mode is set to VBR (variable bitrate), and is ignored for CBR
(constant bitrate).

BUG=b:190336806,b:181514834
TEST=tast run DUT arc.VideoEncodeAccel.h264_192p_i420

Cq-Depend: chromium:2946469
Change-Id: Ie513b474f48f09a710a68c9f06111e0fc6627aa6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2944321
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Staessens <dstaessens@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2021-07-30 02:10:14 +00:00
Jorge E. Moreira
9e7cd5bbd3 vios_backend: Reduce lock contention in the IO buffer queue
... by not holding locks while data is being copied around, but only
when the buffers are being allocated.

BUG=b:174713663

Change-Id: I558e14422eeff690c09f031f6c5564ee7de21e39
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2994806
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Jorge Moreira Broche <jemoreira@google.com>
Commit-Queue: Jorge Moreira Broche <jemoreira@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-07-29 19:13:41 +00:00
Jorge E. Moreira
40c695521d vios_backend: Lock once and receive a single packet per command
BUG=b:174713663

Change-Id: I7bae76f01464492fb43540f7d322ce58304d44c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2993287
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Jorge Moreira Broche <jemoreira@google.com>
Commit-Queue: Jorge Moreira Broche <jemoreira@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-07-29 19:13:40 +00:00
Jorge E. Moreira
10d205cb24 Remove unnecessary mutexes from VioSClient
BUG=b:174713663

Change-Id: Icb51e804d10b5b7fb5e019c8c3a4585743cf3570
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2986409
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Jorge Moreira Broche <jemoreira@google.com>
Commit-Queue: Jorge Moreira Broche <jemoreira@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-07-29 19:13:39 +00:00
Chia-I Wu
aed8fb2dad devices: gpu: remove VIRTIO_GPU_MAX_IOVEC_ENTRIES
When VIRTIO_GPU_BLOB_FLAG_CREATE_GUEST_HANDLE is not set, the check
should not be applied.  This is also more consistent with
GpuCommand::ResourceAttachBacking.

When VIRTIO_GPU_BLOB_FLAG_CREATE_GUEST_HANDLE is set, the check may not
be correct because upstream kernel made the limit configurable recently

  https://patchwork.freedesktop.org/patch/438905/

It should be better to just remove the check and let the kernel does the
validation.

BUG=b:194314538
TEST=huge allocations

Change-Id: I536f44b257a96f7a52a0bc88fc2b63e0e2a701f5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3059400
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Chia-I Wu <olv@google.com>
2021-07-29 18:46:47 +00:00
Chih-Yu Huang
d23252e1d6 virtio: video: handle FlushComplete and PictureReady response together
At crrev.com/c/2719245, we postpone sending the decoded frames until
receiving the buffer. However, we should also keep the order between
decoded frames and the flush complete event. This CL handles both
event response together to preserve the order.

BUG=b:168750131
BUG=b:192523692
TEST=android.mediav2.cts.CodecDecoderSurfaceTest#testFlushNative
TEST=android.media.cts.AdaptivePlaybackTest

Change-Id: I9184790c855c7d60455d1f71daad768200adc468
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3005181
Auto-Submit: Chih-Yu Huang <akahuang@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chih-Yu Huang <akahuang@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-07-29 08:58:08 +00:00
Richard
5afeafa6a5 crosvm: Refactor Error out of linux.rs
This will prevent future auto merging conflicts related to the Error
struct being update.

BUG=b:194718591
TEST=cargo build

Change-Id: I6ccf1934103cfd6258beecc3ea8aad6ede4f94ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3053108
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Richard Zhang <rizhang@google.com>
2021-07-29 07:33:36 +00:00
Domen Su
c25cb1441e crosvm: Rename trunks interface.proto
`trunks/interface.proto` was renamed to `trunks/trunks_interface.proto`.

Rename `interface.proto` in crosvm accordingly.

BUG=b:193096536
TEST=./build_packages --board=amd64-generic crosvm

Cq-Depend: chromium:3013439
Change-Id: I9c2d1d70e81e60a73daa26fded92746591210ae7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3016218
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Yi Chou <yich@google.com>
Reviewed-by: John L Chen <zuan@chromium.org>
Reviewed-by: Leo Lai <cylai@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Domen Su <domen@google.com>
2021-07-29 07:24:56 +00:00
Dennis Kempin
50a58f9372 Integrate audio_streams into crosvm, add stub libcras implementation
The `# ignored by ebuild` tag will remove the path to libcras_stub and
allows crosvm to be built with the actual libcras implementation.

This allows all other platforms to build without depending on
`third_party/adhd/cras/client/libcras`, which is a prerequisite for
externalizing crosvm.

An empty libcras_stub crate is provided to keep cargo happy in external
builds.

To build with cargo against libcras, the setup_cros_cargo.sh script
can be used.

BUG=b:191511078
TEST=Tests in crosvm and cros_sdk both pass:
  $ ./test_all
  $ cros_run_unit_tests --package=crosvm

Cq-Depend: chromium:2993483
Change-Id: I86aad23a86c78e580c1724fb311f870b25d6b09e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2988154
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
2021-07-29 05:59:42 +00:00
David Staessens
f1dd5afb9a virtio: video: Add support for configuring the bitrate mode to encoder.
This CL adds support for the VIRTIO_VIDEO_CONTROL_BITRATE_MODE control
to the crosvm encoder. This control allows configuring the bitrate
mode used to encode a video.

Possible values are:
- VIRTIO_VIDEO_BITRATE_MODE_VBR (Variable bitrate)
- VIRTIO_VIDEO_BITRATE_MODE_CBR (Constant bitrate)

BUG=b:190336806,b:181514834
TEST=tast run DUT arc.VideoEncodeAccel.h264_192p_i420_vm

Cq-Depend: chromium:2946469
Change-Id: Ic8461e746884620cd426c1b562724e4120fe2129
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2944317
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Staessens <dstaessens@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2021-07-29 03:52:27 +00:00
Jorge E. Moreira
cc0f7b2750 Move stream state to StreamSource
The VioSClient object has no reason to keep track of stream states,
except maybe to validate operations, but for that it can simply rely on
the sound server to do it for it.

BUG=b:174713663

Change-Id: Ia0bb1675f4cbfb2714feebe63aec8d75e54c1588
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2986401
Auto-Submit: Jorge Moreira Broche <jemoreira@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jorge Moreira Broche <jemoreira@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-07-28 21:57:00 +00:00
Junichi Uekawa
fc325cdd23 integration_tests: Show error message passed down instead.
Might help a bit more when things stop working.

BUG=None
TEST=./integration_tests/run  # and observe the error message.

thread 'boot_test_suspend_resume' panicked at 'called `Result::unwrap()`
on an `Err` value: InvalidFd', integration_tests/tests/fixture.rs:176:24

becomes

thread 'boot_test_suspend_resume' panicked at 'failed to initiailize
syslog: guess of fd for syslog connection was invalid',
integration_tests/tests/fixture.rs:177:13

Change-Id: Ife82b9e430d416a40cefced258e7f9bdc589bf73
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3055551
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2021-07-28 07:23:57 +00:00
Chih-Yang Hsia
222a901240 audio_streams: Copy dir from adhd with commit history
In adhd repository:
git log --pretty=email --patch-with-stat --reverse -- \
  audio_streams/ | \
  sed '/Change-Id/d' | sed 's/Reviewed-on/> Reviewed-on/g' | \
  sed '/Tested-by/d' | sed '/Commit-Queue/d' | sed '/Signed-off-by/d' | \
  sed '/Commit-Read/d' | sed '/Cq-Depend/d' | sed '/Auto-Submit/d' | \
  sed 's/BUG/> BUG/g' | \
  sed 's/TEST/> TEST/g' | \
  sed 's/Reviewed-by/> Reviewed-by/g' > ~/cras-to-crosvm.patch

In crosvm repository:
- apply patch by
  git am --committer-date-is-author-date < ~/cras-to-crosvm.patch
- squash and amend commits by
  git rebase --interactive

Add the `audio_streams` crate

The `audio_streams` crate provides a basic interface for playing audio.
This will be used to enable playback to various audio subsystems such as
Alsa and cras. To start, an empty playback example `DummyStreamSource`
is provided.

> BUG=781398
> TEST=Included Dummy Stream tests and boot crosvm with ac97 using the
DummyStream for output.

> Reviewed-on: https://chromium-review.googlesource.com/1402264
> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>

audio_streams: Servers can return a list of open FDs

To allow implementers of the StreamSource trait to be put in Linux
jails, add an optional function that returns a list of file descriptors
that need to be kept open when entering a jail.

> Reviewed-on: https://chromium-review.googlesource.com/1416052
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>

audio_streams: Add audio capture interface

Add `CaptureBufferStream` which provides interface for audio capture.
This will be used to enable capture to various audio subsystems such as
Alsa and cras.
A null capture example `DummyCaptureStream` is provided.

> BUG=chromium:932268
> TEST=Unit tests
> TEST=Apply full patch set and run
     $ cras_test capture -f /tmp/res.raw
     to test capture functionality

> Reviewed-on: https://chromium-review.googlesource.com/1530354
> Reviewed-by: Dylan Reid <dgreid@chromium.org>

audio_streams: add direct read and write functions for audio buffers

These functions are needed so that clients of audio_streams can make use
of the buffer's internal slices directly. Before, the only way to access
internal buffers was indirectly via the client passing in a slice of its
own, which would require an extra copy when the client is using volatile
memory sources which can not be safely turned into slices.

> BUG=chromium:938767
> TEST=build crosvm with "eliminate mut from non-mut references"

> Reviewed-on: https://chromium-review.googlesource.com/1639621
> Reviewed-by: Dylan Reid <dgreid@chromium.org>

audio_streams: Updated trait object syntax

Trait objects without `dyn` generate warnings with newer compiler
versions.

> Reviewed-on: https://chromium-review.googlesource.com/1714273
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>

Add blueprint files for crosvm dependencies.

Test: m libaudio_streams
Test: m libcras_sys
Test: m liblibcras
Bug: 140201589
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/1789920
> Reviewed-by: Dylan Reid <dgreid@chromium.org>
> Reviewed-by: Ivan Lozano <ivanlozano@google.com>

CRAS: libcras: Support more output formats

Add support for U8, S24_LE, and S32_LE audio to libcras and cras_tests.
24bit samples are stored in 4 bytes of space, not 3.

> BUG=chromium:1010667
> TEST=sox -n -r 48000 -c 2 -b 8 -e unsigned-integer output.raw synth 3 sine 100 &&
     cras_tests playback -f U8 output.raw
> TEST=sox -n -r 48000 -c 2 -b 32 output.raw synth 3 sine 100 &&
     cras_tests playback -f S32_LE output.raw
> TEST=sox -n -r 48000 -c 2 -b 24 output.raw synth 3 sine 100 &&
     sox -t s24 -r 48000 -c 2 output.raw -t s32 output_24.raw vol 0.00390625 &&
     cras_tests playback -f S24_LE output_24.raw

> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/1856646
> Reviewed-by: Fletcher Woodruff <fletcherw@chromium.org>

CRAS: cras_tests: Restructure arguments

In preparation for adding control functionality to cras_tests,
restructure Command by making AudioOptions a parameter of the Command
enum, e.g Command::Capture(AudioOptions).  This way, a control command
can be later added as Command::Control(ControlOptions).

> BUG=chromium:1008990
> TEST=cargo test

> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/1865832
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>

CRAS: audio_streams: Limits length in copy_cb

Limits the size of index for accessing internal buffer in PlaybackBuffer
and CaptureBuffer to prevent index-out-of-range panic.

> BUG=b:146471328
> TEST=Build and test audio capture with stresstestapp

> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/1980593
> Reviewed-by: Yu-Hsuan Hsu <yuhsuan@chromium.org>

CRAS: cras_tests: add WAVE playback and capture

Create structs WavSource and WavSink which adapt hound::WavReader and
hound::WavWriter to implement the Read and Write traits, and use these
to implement WAVE playback and capture.

Dynamically select which source type to use based on the input/output
file name.

The audio is limited to integer sample formats, but supports all bit
depths that CRAS supports. S24_LE samples are upsampled to S32_LE due
to a quirk of the encoder used.

> BUG=chromium:1008990
> TEST="sox -n -r 48000 -b 16 output.wav synth 5 sine 330 &&
     cras_tests playback output.wav", check that sine wave is played
     accurately.
> TEST="cras_tests capture output.wav && aplay output.wav",
     check that data is recorded properly.

> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/1832584
> Reviewed-by: Dylan Reid <dgreid@chromium.org>

CRAS: move shm_streams into audio_streams

Move the shm_streams trait into the audio_streams crate so that systems
that do not use CRAS can create audio backends implementing the shm_streams
interface.

Remove cras_types as all code in it has moved to cras-sys or
audio_streams.

Add a StreamEffect struct to audio_streams containing one effect, echo
cancellation, as well as a conversion to CRAS_STREAM_EFFECT in cras-sys.

> BUG=chromium:968724
> TEST=cargo test

> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2040904
> Reviewed-by: Dylan Reid <dgreid@chromium.org>
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>

CRAS: Add .gitignore

Add .gitignore for audio_streams, cras-sys and libcras to ignore Cargo.lock as
these are rust libraries not end products.

Doc: https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html

> BUG=None
> TEST=cargo build

> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2100454
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
> Reviewed-by: Dylan Reid <dgreid@chromium.org>

CRAS: Implement FromStr and Default for StreamEffect

1. Implement FromStr and Default traits for StreamEffect.

> BUG=b:149174845
> TEST=cargo test

> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2053654
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>

CRAS: Change new_stream trait of ShmStreamSource

1. Allow users to create streams with multiple effects by a slice of
StreamEffect in ShmStreamSource::new_stream.
2. Implement FromIterator<&StreamEffect> for CRAS_STREAM_EFFECT.
3. Update CrasClient new_stream API.

> BUG=b:149174845
> TEST=cargo build

> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2095644
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>

Allows audio_streams errors to be passed across threads

Instead of returning Box<dyn Error>, we returns Error that impls Send +
Sync, so that these errors can be passed across threads. It's needed for
collecting the errors when we create streams in child threads.

> BUG=b:149437381
> TEST=emerge-{BOARD} cras_tests
> TEST=cargo test in audio_streams
> TEST=cargo test in libcras

> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2215772
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>

Remove explicit lifetimes that can be elided

Fixes crosvm `cargo clippy` errors:

  error: explicit lifetimes given in parameter types where they could
  be elided (or replaced with `'_` if needed by type declaration)

> BUG=None
> TEST=crosvm bin/clippy

> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2225151
> Reviewed-by: Dylan Reid <dgreid@chromium.org>

audio_streams: add num_channels in ShmStream trait

Add num_channels() to allow to get the channel count of a stream.

> BUG=b:157433024
> TEST=cargo build

> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2259312
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>

audio_streams: Change timer start time in null_consumption_rate

```
let start = Instant::now();
```

should be moved to earlier than

```
let mut stream_source = NullShmStreamSource::new();
```

> BUG=chromium:1106557
> TEST=cargo test

> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2303415
> Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>

audio_stream: Suppress cargo clippy warnings

Suppress `cargo::type_complexity` and `clippy::too_many_arguments` warnings
which are acceptable.
Also, fixed a trivial clippy warnings.

> BUG=chromium:1112251
> TEST=`cargo clippy` passes

> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2331964
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>

audio_streams: change frame_rate to u32 in ShmStream and ShmStreamSource

1. Change frame_rate from usize to u32 for
     * StreamSource::new_playback_stream
     * StreamSource::new_capture_stream
     * ShmStreamSource::new_stream
     * DummyStream::new
     * DummyCaptureStream::new
     * NullShmStream::new
     * MockShmStream::new
     * CrasClient::create_stream
     * CrasClient::new_pinned_playback_stream
     * CrasClient::new_pinned_capture_stream
     * CrasStream::try_new
     * cras_audio_format_packed::new
     * WavSource
     * WavSink::try_new
   The frame_rate may supports up to 96000 khz
   and therefore the correct data type should be u32.
2. Add frame_rate() to ShmStream trait allow to get the sample rate of a stream.
3. Add sample_rate to
     * CrasShmStream
     * CrasShmStream::try_new
4. Fix some clippy issues in cras_tests

> BUG=b:168082107
> TEST=cargo build && cargo test

> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2434114
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>

CRAS: fix clippy lint in audio_streams

Pass SampleFormat by value to sample_bytes() function, since it
implements Copy and is small.

> BUG=None
> TEST=None

> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2541844
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>

audio_stream: Replace the use of Dummy* to Noop*

Ableist language like dummy should be removed.
Adding a NoopStreamControl that is a duplication of DummyStreamControl
for future migration so we don't break crosvm's dependency.
Will have a follow-up CL to remove DummyStreamControl once all existing
dependencies are removed.

> BUG=b:167649426
> TEST=./build_packages --autosetgov --board=hatch adhd audio_streams \
libcras crosvm

> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2547616
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>

audio_streams: Cache elapsed Duration in unit tests

Cache start_time.elapsed() with `elapsed` to prevent

"overflow when subtracting duration" error.

> BUG=chromium:1161663
> TEST=`cargo test`

> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2612305
> Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>

cras: Remove Dummy* for inclusive language

Ableist language like dummy should be removed.
NoopStreamControl has been added to replace and deprecate DummyStreamControl.
Remove DummyStreamControl as all existing dependencies are removed.

> BUG=b:167649426
> TEST=./build_packages --autosetgov --board=hatch adhd audio_streams \
libcras crosvm && src/platform/dev/contrib/search_blocked_words.sh

> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2739020
> Reviewed-by: Yu-Hsuan Hsu <yuhsuan@chromium.org>

resolve rust clippy 1.50 issues

The issue was with unnecessary lifetimes and nested match statements
that resolved quite cleanly in this change.

> BUG=b:179277332
> TEST=cargo clippy with rustc 1.50+

> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2757729
> Reviewed-by: Dylan Reid <dgreid@chromium.org>

audio_streams: Add next_[playback/capture]_buffer_async

with async sleep.

> BUG=b:179757101
> TEST=cargo test

> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2960197
> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>

audio_streams: Add executor arg to next_[playback/capture]_buffer_async

cras stream will need an executor to initialize its AsyncAudioSocket

> BUG=b:179757101
> TEST=cargo test

> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/3005176
> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>

BUG=b:191511078
TEST=cargo build

Change-Id: I2832583b29722deee2ece210b2e7e821768c3fd0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3045578
Auto-Submit: Chih-Yang Hsia <paulhsia@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-07-28 03:56:06 +00:00
Junichi Uekawa
aab74e4fcb crosvm: make help indent consistent.
Should probably be handled by the argument help utility level but at
least make existing help message indented consistently.

BUG=None
TEST=crosvm run --help

Change-Id: I14d39a1f69a28910111a73a0401fbe07e211f6d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3038007
Auto-Submit: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-07-27 09:31:56 +00:00
David Staessens
06d7c9edb9 virtio: video: Recreate encoder on framerate changes.
CL crrev.com/c/3005194 introduced changes to the encoder to allow
dynamic framerate changes even when there are already resources queued
in the input or output queue. As a side effect the encoder is only
recreated if any parameters besides the framerate change.

Unfortunately the above checks assumes that changing the framerate will
never influence any of the other parameters, which isn't always
correct. The requested H.264 level is adjusted to conform to the
minimum requirements for the selected bitrate and framerate. We can't
dynamically adjust the H.264 level during encoding, but as long as we
don't have any resources queued yet we can recreate the encoder to make
sure the H.264 level is properly adjusted if required.

BUG=b:192623395,b:192419592,b:193947502
TEST=android.media.cts.MediaRecorderTest#testProfileAvcBaselineLevel1

Change-Id: Ie02e30a5b6fb82b9b62e88ae3ab75c8ef42f3844
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3037296
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: David Staessens <dstaessens@chromium.org>
Commit-Queue: David Staessens <dstaessens@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2021-07-27 08:33:16 +00:00
Chih-Yang Hsia
b0423fd529 Revert "virtqueue: Try to further reduce unnecessary interrupts"
This reverts commit c6554e9c7e.

Reason for revert:

`time tast run mycros arc.Boot.vm` will always halt at

```
  Waiting for Android boot
  Waiting for initial ARC process
```
till timeout.

Original change's description:
> virtqueue: Try to further reduce unnecessary interrupts
>
> Try to reduce unnecessary interrupts by updating `signalled_used` every
> time we check `used_event` rather than only when we actually write to
> the eventfd.
>
> This technique is lifted out of the vhost_add_used_n and vhost_notify
> methods in drivers/vhost/vhost.c in the kernel and the variable names
> are changed to more easily compare the two implmentations.
>
> This combined with the other notification suppression changes give a
> performance improvement of ~10% across all storage devices in the
> blogbench benchmark.
>
> BUG=none
> TEST=vm.Blogbench.{p9,block,virtiofs}
>
> Change-Id: I618767e4c36ecae607b7641e54a029c25583844d
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3026691
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>

BUG=b:194452080
TEST=time tast run mycros arc.Boot.vm

Change-Id: Ib7511dec3e0df26be54616f20226ded598fc8a37
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3051292
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Chih-Yang Hsia <paulhsia@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-07-26 07:00:57 +00:00
Chih-Yang Hsia
4dd683a354 ac97: Add timerfd operations to accepted list
Since CL:2999451, libcras is using timerfd features from `cros_async`,
we need to add timerfd operations to the accepted list of
`cras_audio_device`'s seccomp policy files.

BUG=b:179757101
BUG=b:194452080
TEST=tast run ${DUT_IP} arc.Notification.vm

Change-Id: I74b33fa1e304fccc95b7326e04bedc32feff85f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3047951
Auto-Submit: Chih-Yang Hsia <paulhsia@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-07-23 18:43:21 +00:00
Chirantan Ekbote
c6554e9c7e virtqueue: Try to further reduce unnecessary interrupts
Try to reduce unnecessary interrupts by updating `signalled_used` every
time we check `used_event` rather than only when we actually write to
the eventfd.

This technique is lifted out of the vhost_add_used_n and vhost_notify
methods in drivers/vhost/vhost.c in the kernel and the variable names
are changed to more easily compare the two implmentations.

This combined with the other notification suppression changes give a
performance improvement of ~10% across all storage devices in the
blogbench benchmark.

BUG=none
TEST=vm.Blogbench.{p9,block,virtiofs}

Change-Id: I618767e4c36ecae607b7641e54a029c25583844d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3026691
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-07-23 13:00:07 +00:00
Chirantan Ekbote
1ac296b8d9 virtqueue: Re-enable notification suppression
Now that the get and set methods have the proper memory barriers it
should be safe to re-enable this.

BUG=none
TEST=crostini.Basic.buster_stable; reboot arcvm in a loop for 75
     iterations without observing a hang

Change-Id: I03271d838e31ad091536163359836bead7e00178
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3026690
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-07-23 13:00:05 +00:00
Leo Lai
558460fe59 Revert "devices: irqchip: add need_halted function"
This reverts commit e470ef9933.

Reason for revert: possibly breaks critical test, in turn CQ.

Original change's description:
> devices: irqchip: add need_halted function
>
> This allows irqchip implementations to specify whether they need to be
> notified via the halted() function when the vCPU encounters a HLT
> instruction.
>
> All of the current in-tree irqchip implementations do nothing on
> halted(), so this will always return false for now, but a fully
> userspace irqchip would need these notifications.
>
> Querying this function will allow the hypervisor code to determine
> whether disabling VM exits on HLT instructions is allowed.
>
> BUG=b:181106085
> TEST=test_all
>
> Change-Id: I433fe208d125dcd14e7100ce5aff37474b423a83
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2937304
> Reviewed-by: Colin Downs-Razouk <colindr@google.com>
> Reviewed-by: Zach Reizner <zachr@chromium.org>
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>

Bug: b:181106085
BUG=b:194452080

Change-Id: I755fc732e79a56f0306819e23ba9bd6c840dc927
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3045583
Commit-Queue: Leo Lai <cylai@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Owners-Override: Leo Lai <cylai@google.com>
Auto-Submit: Leo Lai <cylai@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2021-07-23 06:41:40 +00:00
Jordan R Abrahams
e3c53096d7 seccomp: Update seccomp filters for glibc
At present, libraries which use glibc to dynamically load
shared libraries do not have fstafs in their seccomp policies.
A change in glibc will force all systems which load shared
libraries to call the fstatfs or fstatfs64 syscall.

Without the call, crosvm will not start when running
crostini/android tests.

BUG=chromium:1182687
TEST=CQ of https://crrev.com/c/2910526

Change-Id: I10abb8866474c2fe0398a17a80069cf2b0629493
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3011355
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Jordan R Abrahams <ajordanr@google.com>
2021-07-22 17:08:20 +00:00
Daniel Verkamp
da4e8a9fcd arch: move resume_notify_devices out of Bus
The devices to be notified on resume are unrelated to the functionality
of Bus, which is looking up devices in an address space. Additionally,
each Bus instance had its own list of devices to notify, although in
practice, only the one in the I/O bus was used.

Move the resume_notify_devices list into RunnableLinuxVm instead.

BUG=None
TEST=Boot Crostini on x86 and arm

Change-Id: I72c629c6d6589c4a9350831c8a076c5c0c9f9aeb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3043489
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
2021-07-22 02:59:34 +00:00
Daniel Verkamp
ba4cf4d985 rand_ish: remove unused crate
BUG=None
TEST=./test_all

Change-Id: Iee374cac5da7e6f4e91b4d0b704c6f4c209bc2f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3017609
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-07-21 23:28:28 +00:00
Daniel Verkamp
5cf2691610 tests/plugins: replace rand_ish use with a counter
Rather than generating a random temporary file name for each plugin
generated by the test, just use a counter to ensure uniqueness.

This was the only remaining rand_ish user, so this change will allow the
removal of rand_ish.

BUG=None
TEST=cargo test --features=plugin

Change-Id: I8d42da97870db54a850f686826ca107255b8c3ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3017608
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-07-21 23:28:27 +00:00
Jorge E. Moreira
771a03b12f Add jack support in virtio-snd
BUG=b:174713663

Change-Id: I8b80edd33279ff5443895fa6ad4572d454d3fcec
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2983392
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Jorge Moreira Broche <jemoreira@google.com>
Commit-Queue: Jorge Moreira Broche <jemoreira@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-07-21 23:04:06 +00:00
Daniel Verkamp
e470ef9933 devices: irqchip: add need_halted function
This allows irqchip implementations to specify whether they need to be
notified via the halted() function when the vCPU encounters a HLT
instruction.

All of the current in-tree irqchip implementations do nothing on
halted(), so this will always return false for now, but a fully
userspace irqchip would need these notifications.

Querying this function will allow the hypervisor code to determine
whether disabling VM exits on HLT instructions is allowed.

BUG=b:181106085
TEST=test_all

Change-Id: I433fe208d125dcd14e7100ce5aff37474b423a83
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2937304
Reviewed-by: Colin Downs-Razouk <colindr@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-07-21 21:47:30 +00:00
Chirantan Ekbote
e63a531356 Enable VIRTIO_RING_F_EVENT_IDX in base_features
This should reduce the number of interrupts generated by the device as
well as the number of vm exits triggered by the guest for notifying the
device.

BUG=none
TEST=crostini.*; reboot arcvm in a loop for 30 iterations without
     observing a hang

Change-Id: Iea4a59092ba6306de9eecbb7722d0ae356183272
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3026689
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-07-21 07:59:39 +00:00
Jorge E. Moreira
e75114e978 Add support for events in virtio-snd
BUG=b:174713663

Change-Id: I6b3044d95c4e6b74565c5adf3a00066b6c437be7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2983391
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jorge Moreira Broche <jemoreira@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-07-21 01:25:14 +00:00
Junichi Uekawa
2a33360586 crosvm: Add a note on cros_workon_make.
It took me a while to realize the side effects making cargo fail.

BUG=None
TEST=read it.

Change-Id: I55db0e267452f865985d36d75c91a2314d117b06
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3026652
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-07-21 00:26:07 +00:00
Keiichi Watanabe
5a01341edb Disable pre-upload hook
Stop running pre-upload hook because we have kokoro which runs clippy.

BUG=none
TEST=none

Change-Id: Iaa29a1785fdedca929c7c42f41c165066585c5ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3033234
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
2021-07-20 18:31:30 +00:00
Chirantan Ekbote
1eb7712652 vhost-user-devices: Drop optional dependencies
Compiling different binaries with different sets of features means that
we also end up recompiling a bunch of dependencies every time.  Instead
just make the dependencies a superset of all crates/features needed by
all devices.

BUG=b:179755651
TEST=cargo test

Cq-Depend: chromium:3009693
Change-Id: Ic8faf2cbabd7b55b87d501639aee56ba5063de06
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2987592
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-07-20 04:54:50 +00:00
Chirantan Ekbote
c950eb92c5 cros_async: Make file offsets optional
p{read,write} cannot be used on sockets even if the file offset is 0.
Make the file offset optional and fall back to regular read/write when
it is not set.

BUG=none
TEST=cargo test

Change-Id: Iff938aabe613b6164782714cfac94743d64f551a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3033233
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Woody Chow <woodychow@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-07-20 02:38:48 +00:00
Chirantan Ekbote
52c97d41bd tpm: Process all descriptors when notified
In order to enable the VIRTIO_RING_F_EVENT_IDX feature, devices need to
keep processing the queue until it is empty as the guest may not send
any more notifications until the device has processed all pending
messages.

Change the process_queue method to process all messages in the queue.

BUG=none
TEST=????

Change-Id: I7df56111ad99bc7511c685ecafc051aef077b34e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3026688
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-07-20 02:28:41 +00:00
Chirantan Ekbote
378e338f12 virtqueue: Remove update_int_required
When the VIRTIO_RING_F_EVENT_IDX feature is enabled we will
automatically update avail_event when a descriptor from the queue is
popped.  Having update_int_required set this to a different value means
that it would keep going back and forth.

BUG=none
TEST=crostini.Basic.buster_stable

Change-Id: I9098259c306cf19c034656169ee0e70ad69d1c64
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3026687
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-07-20 02:28:40 +00:00
Chirantan Ekbote
c013a658e2 devices: Trigger interrupts via the Queue
Have all devices trigger interrupts via the Queue rather than directly.
This way we can skip sending the interrupt entirely when notification
suppression features have been negotiated with the guest kernel.

BUG=none
TEST=crostini.Basic.buster_stable

Change-Id: Ica6f978127aa648fd983f641518940d7a857916f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3026686
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-07-20 02:28:39 +00:00
Junichi Uekawa
f8fff1c5bf qcow_img: Fix warning message.
warning: panic message is not a string literal
  --> qcow_utils/src/qcow_img.rs:52:26
   |
52 |         Err(f) => panic!(f.to_string()),
   |                          ^^^^^^^^^^^^^
   |
   = note: `#[warn(non_fmt_panic)]` on by default
   = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
   |
52 |         Err(f) => panic!("{}", f.to_string()),
   |                          ^^^^^
help: or use std::panic::panic_any instead
   |
52 |         Err(f) => std::panic::panic_any(f.to_string()),
   |                   ^^^^^^^^^^^^^^^^^^^^^^

warning: 1 warning emitted

BUG=None
TEST=build

Change-Id: I06a18610b455e57c9c9813513963385749fad17c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3026651
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-07-20 01:33:20 +00:00
Jorge E. Moreira
227beb25c9 virtio-snd: Add support for channel maps
BUG=b:174713663

Change-Id: If04128763823ed82a6267a8a50c25c9f3d8df6f3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2983390
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jorge Moreira Broche <jemoreira@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-07-19 23:00:23 +00:00
Jorge E. Moreira
d4562d0ab5 Partial implementation of the virtio-snd device
Supports everything related to pcm streams, but not jacks or channel
maps.

BUG=b:174713663

Change-Id: I16f44d66fc7580a94eda91383d46cb52f9513eee
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2983389
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jorge Moreira Broche <jemoreira@google.com>
Auto-Submit: Jorge Moreira Broche <jemoreira@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-07-19 17:38:51 +00:00
Peter Fang
e42a43d880 acpi: add _SB.PCI0 to DSDT
Supply the OS with basic PCI hostbridge information (PIO region, MMIO
region, etc) using Device (_SB.PCI0) in DSDT. Without this info the
Linux kernel behaves erroneously in iova_reserve_pci_windows().

Output from the Linux kernel, w/o _SB.PCI0:

    pci_bus 0000:00: root bus resource [mem 0x00000000-0x7fffffffff]

Since DSDT contains PCI hostbridge information, ACPI is always required.

Use "acpi=noirq" in cmdline when DSDT/MADT is not provided by the user.
The Linux kernel refers to PCI configuration space for interrupt
routing.

BUG=b:181736020
TEST=boot Linux kernel and check dmesg

Change-Id: Id328a958fb770e087788e71fe480839eab4f40c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2846422
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-07-19 06:29:46 +00:00
Zide Chen
4638906314 devices: allow vfio_dma_map() to map read only guest memory
This is needed because virtio IOMMU may not allow writes to mapped
memory if VIRTIO_IOMMU_MAP_F_WRITE flag is not set in driver MAP
request.

BUG=b:181736020
TEST=--vfio=/sys/bus/pci/devices/0000:00:14.0,iommu=on

Change-Id: I2c101410594782f1b66b3f6ae527d4a7621b7496
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2757279
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-07-19 06:29:46 +00:00
Zide Chen
71435c1aea devices: virtio: iommu: implement VIRTIO_IOMMU_F_INPUT_RANGE feature
In VT-d, the IOMMU hardware can translate guest physical address that
is no more than MGAW (Maximum Guest Address Width) which is reported
from the VT-d Capability register.

We pass this information to the guest IOMMU front driver so that it
can allocate appropriate IOVA.

VT-d indicates that "implementations must support MGAW at least equal
to the physical addressability (host address width) of the platform".
Thus we take the Physical Address Bits that is reported by
CPUID.80000008H as the minimum MGAW.

BUG=b:181736020
TEST=--vfio=/sys/bus/pci/devices/0000:00:14.0,iommu=on

Change-Id: I26a421ea2e7dd893d413d63ab313721cfdf0b5c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2757278
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2021-07-19 06:29:44 +00:00
Federico 'Morg' Pareschi
762d609366 vhost_user_devices: Add in/out files for console
This change allows us to redirect in/out streams for a vhost user
console device to any file. This means we can assign individual PTYs for
input/output redirection to the host VM.

Example command:

vhost-user-console-device --socket $SOCKET --output-file $OUT_FILE \
                          --input-file /dev/pts/$NUM

You can `echo <message> > /dev/pts/$NUM` to send input signals to the
VM, and `tail -f $OUT_FILE` to monitor the output in real time as it is
written to a file.

BUG=b:192517623
TEST=run vhost-user-console-device with --output-file and --input-file

Change-Id: Iee0929d63d39848f2626c17e440d6d9368ae2d0f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3026359
Auto-Submit: Morg <morg@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Morg <morg@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-07-16 10:20:52 +00:00
Louis-Francis Ratté-Boulianne
775aa4f594 virtio: gpu: add support for non-blocking fence synchronization
A completed fence callback is set in Rutabaga. When the callback
is executed, the descriptor associated with the fence is immediately
marked as used and the control queue is signalled.

As of now, the callback is still called in the main worker thread
when poll_fence() is executed, but once we enable the async callback
feature in virglrenderer, the callback might be called from another
thread. This is the reason everything is protected with mutexes.

The completed_fences hash map keeps track of the latest completed
fence for each context to avoid any race condition.

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Change-Id: I6f3f55d21b7f4722721bdc2b16da1b39bae4ff7e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2845984
Reviewed-by: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2021-07-16 02:22:53 +00:00
Chirantan Ekbote
2f879fb2be cros_async: Add spawn_blocking()
Add a spawn_blocking() method to the Executor so that users don't need
to manually create a BlockingPool every time they need to do some
blocking work.

BUG=b:179755651
TEST=cargo test

Change-Id: I70d111d98a4c51af4bc8ed8181a4b102bf3c2ffa
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2987586
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-07-15 23:18:23 +00:00