Commit graph

2704 commits

Author SHA1 Message Date
Chirantan Ekbote
5590a24b1b cros_async: Add a deadline to BlockingPool::shutdown
Add an optional deadline to BlockingPool::shutdown.  Any worker threads
that have not yet exited once the deadline expires will be detached.
This ensures that we don't end up blocking indefinitely while waiting
for worker threads to exit.

BUG=none
TEST=unit tests

Change-Id: I6d7e73e1c95a934a4fd80825a9d44187532408b5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3058842
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-08-12 04:29:18 +00:00
Xiong Zhang
5a223d1f2f devices:pci: Correct pci bridge config register writable bits
According to pci bridge spec, some registers are writable and should
be marked correctly.

BUG=b:185084350
TEST=Boot a guest with pcie root port

Change-Id: I501fa05cc9ea6b6ea02d5d8bcbb29ba291a4b49e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2954675
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-08-12 01:03:06 +00:00
Xiong Zhang
12274bf287 devices:pci: Add pci capability writable bits
Some pci capability register is writable, and guest could write it
and control it(like msix control and pcie cap control), let each
pci capability returns its writable bits, so guest could write the
value into config register.

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

Change-Id: Ic98a569823c762e7165f83d29ee90d2ba762dead
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2954674
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-08-12 01:03:04 +00:00
Suleiman Souhlal
2ac78b9ea0 Add "make_rt" command.
This is used to finally make a "delay-rt" VM's RT VCPUs RT.

BUG=b:142777321
TEST="grep policy /proc/<pid of rt vcpu>/sched" to make sure RT vcpu
    isn't RT until "make_rt".

Change-Id: I73177f8adadf3d1099c2b09871ee9d5feab82587
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2703225
Auto-Submit: Suleiman Souhlal <suleiman@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Suleiman Souhlal <suleiman@chromium.org>
2021-08-11 11:39:31 +00:00
Suleiman Souhlal
63630e8dce Add --delay-rt flag.
This flag is intended to be used to delay making a VM's RT VCPUs
RT until "make_rt" is called, in order to avoid boot time
regressions with RT.

BUG=b:142777321
TEST="grep policy /proc/<pid of rt vcpu>/sched" to make sure RT vcpu
    isn't RT until "make_rt".

Change-Id: I1b9132e11f0acc626434c60cecc2f4afe350961a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2703224
Auto-Submit: Suleiman Souhlal <suleiman@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Suleiman Souhlal <suleiman@chromium.org>
2021-08-11 11:39:30 +00:00
David Staessens
8fe6d5f963 virtio: video: Remove empty value from ForceKeyFrame.
The ForceKeyFrame control is a button control, which means that it
doesn't have a value. This CL performs some minor cleanup and removes
the empty parentheses after the ForceKeyFrame CtrlVal as these are not
required.

BUG=None
TEST=tast run DUT arc.VideoEncodeAccel.h264_192p_i420_vm

Change-Id: Ic86eb92e097de46ce68ed71bfe24299e07f8b78e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3064155
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Staessens <dstaessens@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-08-11 07:46:12 +00:00
Junichi Uekawa
7cbd02f109 crosvm: Add integration test case for O_DIRECT.
Make sure we keep booting.

BUG=b:190435784
BUG=b:184204645
TEST=boot tests (boot_test_suspend_resume, boot_test_vm) pass.

Change-Id: I586e555ae83759c88759e1aeb96a728785d0cf5f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3055557
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-08-11 02:22:41 +00:00
Junichi Uekawa
74b18b8ccb vm_tools: Use /var/tmp instead of /tmp.
/tmp is mounted as tmpfs, and tmpfs does not provide O_DIRECT capabilities. Try
using a ext4 file system.

BUG=b:190435784
TEST=time ./ci/builder --vm #    boot_test_vm_odirect passes

Change-Id: I3f8245052ed06c703cc3aa320d300d5f21254e90
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3083206
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2021-08-11 02:22:40 +00:00
Jorge E. Moreira
8be8486d05 virtio-snd: Add event_notifier to the list of file descriptors
BUG=b:174713663

Change-Id: I534818cf4cc90bc5957fcc17c1d273e7d4be9846
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3064651
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jorge Moreira Broche <jemoreira@google.com>
2021-08-06 19:38:48 +00:00
Charles William Dick
5404501966 crosvm fix stale balloon stats
Stale balloon stats results can be returned from a stats request for the
following reasons:
* The initial stats buffer from the guest is posted to the
  balloon_host_tube without a request.
* Balloon stats requests can fail because the balloon device isn't
  completely set up yet; writing a stats request to the tube without
  reading the response.
* Balloon stats requests can time out, returning an error. When the
  balloon stats are eventually computed, they will be queued to the tube
  without a read to consume them.

Possibly other reasons too.

This CL fixes this by adding an id to the balloon stats request. The id
is then returned with the computed stats. When consuming stats results
from the balloon_host_tube, we check that the ID is the one we expect,
if not, we keep reading from the tube until we do.

BUG=b:189282316
TEST=tast run dut multivm.Lifecycle.arc_host

Change-Id: I08e50196a45383b30c9e510b3bacbe32888aef80
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3056310
Auto-Submit: Charles William Dick <cwd@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Charles William Dick <cwd@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Hikaru Nishida <hikalium@chromium.org>
2021-08-06 15:39:15 +00:00
Dennis Kempin
42b825f740 Switch to submodules based workflow
Instead of requiring crosvm to be checked out via the chromeos manifest
to access dependencies in the ChromeOS monorepo, this change adds
git submodules to third_party/.

The CI scripts and Cargo.toml are updated to use the new paths.

BUG=b:194336213
TEST=git clone --recursive https://chromium.googlesource.com/chromiumos/platform/crosvm
     cd crosvm
     cargo test
     ./test_all
     ./ci/kokoro/simulate_all

Change-Id: I9859d18176e21909ac3a140976fbd67cc14129bb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3049003
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-08-05 18:32:32 +00:00
Chirantan Ekbote
eaa95e9cad vhost_user_devices: Ack queue features
We need to call Queue::ack_features to actually enable virtqueue specific
features like VIRTIO_RING_F_EVENT_IDX.

BUG=none
TEST=start a vm with a vhost-user block device

Change-Id: I82d04ad940850b53e17cfaf3ee5cdb4318190424
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3070721
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-08-05 17:53:12 +00:00
Peter Fang
60e4515e61 devices: virtio: iommu: remove VIRTIO_IOMMU_F_TOPOLOGY
VIRTIO_IOMMU_F_TOPOLOGY is not needed as DT/VIOT are the preferred
methods for vIOMMU discovery.

BUG=b:181736020
TEST=boot Linux kernel and verify passthru devices work properly with
iommu=on

Change-Id: I07b2924a8a903ccd5def817af6f7e74c8eb91162
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2976056
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-08-04 07:49:18 +00:00
Peter Fang
ad3b24e8eb devices: virtio: iommu: implement VIOT table
Implement VIOT table for vIOMMU discovery. This is a preferred method
over VIRTIO_IOMMU_F_TOPOLOGY on x86. [1][2]

Make sure the vIOMMU device already has a valid PCI address during
generate_acpi().

[1]
https://lore.kernel.org/linux-iommu/20200821131540.2801801-1-jean-philippe@linaro.org/
[2] https://jpbrucker.net/virtio-iommu/viot/viot-v9.pdf

BUG=b:181736020
TEST=boot Linux kernel and verify passthru devices work properly with
iommu=on

Change-Id: I717a6d5ba2836420af9cd54b3459776b57bfb68e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2976055
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-08-04 07:49:17 +00:00
Peter Fang
c2bba08c34 devices: pci: add generate_acpi() to traits
Add generate_acpi() to traits PciDevice and VirtioDevice to allow each
device to generate its ACPI table elements. The default implementation
is to generate nothing.

BUG=b:181736020
TEST=boot Linux kernel

Change-Id: I9d8d2cb81d571e608a45e7fecb82c3f0922d0898
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2846423
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-08-04 07:49:15 +00:00
Allen Webb
87b96033b7 sys_util: Add wrappers for fchmod and fchown.
This wrappers allow for permissions and ownership changes that are less
sensitive to time-of-check-time-of-use vulnerabilities.

BUG=None
TEST=CQ passes

Change-Id: I6d5e4809a0b0113f3a95b0395d3cfb82431a3fd8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3049330
Auto-Submit: Allen Webb <allenwebb@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Allen Webb <allenwebb@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-08-04 05:20:21 +00:00
David Staessens
8bf5dcade3 virtio: video: Add support for prepending SPS/PPS to IDR frames.
This CL adds support for the VIRTIO_VIDEO_CONTROL_PREPEND_SPSPPS_TO_IDR
control to the virtio encoder. When this control is enabled SPS and PPS
NAL units are prepended to IDR frames, to improve the resilience of
encoded video streams.

Note: Currently the libvda backend always prepends SPS and PPS NAL
units to IDR frames. This behavior can not be disabled, so when
querying this control it will always be reported as enabled. Trying to
set the control to disabled will result in an error.

BUG=b:161495502
TEST=tast run DUT arc.VideoEncodeAccel.h264_192p_i420_vm

Cq-Depend: chromium:3058721
Change-Id: I2a53b635553cfbdbc483c4d678f124953721dba0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3060098
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Staessens <dstaessens@chromium.org>
2021-08-04 01:58:10 +00:00
Allen Webb
1919f432c2 sys_util: Add Ord, and PartialOrd so VsockAddr can be used in BTreeMap.
BUG=None
TEST=sirenia builds with the BTreeMap CL.

Change-Id: I8575484574d03e17cd7810f52fef10a31f0bff67
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3068875
Auto-Submit: Allen Webb <allenwebb@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Allen Webb <allenwebb@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-08-03 21:47:14 +00:00
Dmitry Torokhov
a041068353 Log offending port numbers when port IO read or write fails
To assist in analyzing IoIn/IoOut failures let's log offending IO port
numbers in addition to the IO size.

BUG=b:187772788
TEST=Build

Change-Id: I4d254e26d0a227c188a4a2a965e8f7c738f2eafc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3066142
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2021-08-03 21:34:42 +00:00
Woody Chow
5b9d6d02fa audio_streams: Add [async_][write_playback/read_capture]_buffer
and trigger the callback function for the buffer automatically
without relying on Drop. There is no drop guarantee in rust.
Moreover, the callback function is also async in the async code.
We cannot block wait in the callback function.

BUG=b:192912354
TEST=cargo test

Cq-Depend: chromium:3007841
Change-Id: I57902cdb0e083f61349f7124602e957ffa84b3c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3062163
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Woody Chow <woodychow@google.com>
2021-08-03 10:09:58 +00:00
Jordan R Abrahams
b785cf2bae seccomp: Mass fstatfs change for glibc for Arm
On trogdor devices, fstatfs64 is not used. Instead, 32bit
fstatfs is used. We need to add both to all 32bit Arm
policy files which were originally determined to be
problematic.

This adds fstsatfs to all 32bit Arm policy files which
were modified for the original glibc security change.

Additionally, this commit sorts the syscalls lexicographically
if the policy file was already sorted.

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

Change-Id: I42eb12456625d400ee3422af08d56d648e3f9075
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3066144
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Jordan R Abrahams <ajordanr@google.com>
2021-08-03 08:08:58 +00:00
Dennis Kempin
6a584d6f99 Integrate p9 and cros-fuzz into crosvm build
Updates path and includes the libraries in the test runner.

BUG=b:193243281,b:191509642
TEST=./run_tests passes and executes the new tests

Change-Id: If38126fa6bdf2a0a3dca5a79c6e4d76857617fd0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3049671
Tested-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-08-03 02:25:02 +00:00
Dennis Kempin
a5b7caa506 Import cros-fuzz and p9 into crosvm/common
This CL contains a 1:1 copy of the code from the platform2 repo.
The follow-up CL will integrate them with the crosvm build.
History of these files is available at:
267497a7f7/cros-fuzz
267497a7f7/vm_tools/p9

This is a prerequisite for the externalization of crosvm.

BUG=b:191509642,b:193243281
TEST=None. This is dead code.

Change-Id: Ia25d9642f2de1febc83bcd48b4b81fcd805c7c1c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3049670
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-08-03 02:25:01 +00:00
David Staessens
636b0fb468 virtio: video: Add support for dynamically changing the peak bitrate.
This CL adds support for dynamically changing the peak bitrate in
addition to the target bitrate. This is done by adapting the
request_encoding_params_change function to use the new Bitrate data
structure, similar to the changes done in the Chrome
VideoEncodeAccelerator.

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

Cq-Depend: chromium:3032331
Change-Id: Id0fd3fa2b3d818c8880d4a02a96f84b218b19cef
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3033225
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Staessens <dstaessens@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-08-03 00:48:45 +00:00
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