Commit graph

639 commits

Author SHA1 Message Date
David Stevens
0b668f6054 devices: gpu: send resource info response for blobs
BUG=b:169212117
TEST=Play YouTube in ARCVM

Change-Id: Ica6cb900a939a368e3a73d739616d4f55c92c6f3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2430874
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2020-10-12 18:16:39 +00:00
Gurchetan Singh
79bf5c6151 devices: virtio: gpu: rustify error handling
- Reduces lone error! statements
- Reduces the number of match arms

BUG=b:169212117
TEST=compile and run gpu

Change-Id: I8eac2f1dd93e058a50212e33e4379dd96df9f184
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2462552
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2020-10-12 18:16:37 +00:00
Chirantan Ekbote
b696d4feb2 fs: Don't use path-based operations
There are no *at variants for the xattr syscalls so we were using the
path-based variants by reading the /proc/self/fd symlink.  While this
symlink can track renames it cannot track if the user hard links the
file to some other location and then unlinks the original location.  In
this case the symlink simply shows that the path was deleted even though
the fd is still valid.

To deal with this, stop using the path-based method.  For regular files
and directories, we can simply open them and then make the appropriate
f{get,set,list,remove}xattr syscall.  For non-regular files and
directories we can emulate an *at syscall by changing the CWD to /proc
and then making the path-based syscall via the self/fd path.  Even
though the symlink is no longer valid, manipulating the fd via this path
still works.

BUG=b:168689429
TEST=Create a file, set an xattr, hard link it to a new location,
     unlink the original, and then verify that {get,set}fattr still
     works on the new link

Change-Id: Ic291f432b96f18e3e7ccbcf27737d5f8fd240a65
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2437684
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2020-10-12 15:45:19 +00:00
Judy Hsiao
03cd6684c9 ac97: Support multi sample rate for playback
Enables VRA mode to support different sample rates for playback.
With the change, the resampling can be reduced in the GuestOS.

BUG=b:168082107
TEST=`sox -n -t s16 -c2 -r${RATE} synth sine 440 vol 0.1\
      | aplay -D hw:0,0 -r${RATE} -f S16_LE -c2` works
      correctly in the GuestOS.

Cq-Depend: chromium:2434114
Change-Id: I7d254173d41ac6b4688894113808785de9162b50
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2399167
Tested-by: Judy Hsiao <judyhsiao@chromium.org>
Tested-by: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Judy Hsiao <judyhsiao@chromium.org>
Auto-Submit: Judy Hsiao <judyhsiao@chromium.org>
2020-10-09 12:59:33 +00:00
Alex Lau
aba864281b devices: virtio: video: Re-add queue_type to AsyncCmdTag::Clear
The queue_type field was removed in crrev.com/c/2408597 as
decoder is no longer using it, but it will be used by the encoder.

BUG=b:140082257
TEST=USE=test emerge-$BOARD crosvm

Change-Id: Iae552cc05b82eea67a7cff854ba350fb579a8f5c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2456226
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Alex Lau <alexlau@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Chih-Yu Huang <akahuang@chromium.org>
Commit-Queue: Alex Lau <alexlau@chromium.org>
2020-10-08 19:49:00 +00:00
David Stevens
32f4c4cfdd devices: virtio: video: cancel after clearing output queue
A recently introduced workaround for a VDA limitation caused clearing
the output queue to be handled synchronously instead of going through
the Async path used when clearing the input queue. This change makes
sure that we still cancel any pending resources on the output queue.

BUG=b:170053625
TEST=arc.VideoDecodeAccelPerf.vp9_2160p_60fps_vm 20 times w/o warnings

Change-Id: Ib24bdc3053c40ffb6f953021f29ef7a31ea216a3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2452313
Tested-by: David Stevens <stevensd@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2020-10-07 09:59:25 +00:00
Michael Hoyle
685316f0bd base: EventFd -> Event renaming
Note the CL size is large entirely due to the rename,
the changes are mostly negligible.

Also making a few small additional changes in sys_util
areas that don't need much attention in base. This includes
typedefing and adding specific imports for areas that don't
require significant interface changes.

BUG=b:162363783
TEST=./build_test

Change-Id: I4a2c9c4cdce7565806ed338e241c6b8c82c855c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2415180
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Michael Hoyle <mikehoyle@google.com>
2020-10-06 13:50:09 +00:00
Chih-Yu Huang
8683e8e0a9 devices: virtio: video: handle ResourceDestroyAll for in/out queue separately
Originally we clear all the fields about both input and output
resource when either input or output queue gets ResourceDestroyAll
command.

In this CL, we handle this command for the input or output queue
separately.

BUG=b:168557465
TEST=pass android.media.cts.AdaptivePlaybackTest#testVP8_adaptiveDrc

Change-Id: Ib7873a8192e9e0d01d6ea869eb8ea8661b6d1060
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2417793
Tested-by: Chih-Yu Huang <akahuang@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Chih-Yu Huang <akahuang@chromium.org>
2020-10-01 18:53:46 +00:00
Chih-Yu Huang
0ebb18ce3f devices: virtio: video: split InputResources out of Context struct
At crrev.com/c/2416067 we split OutputResources out of Context struct.
Similiarly, this CL splits the fields that related to the input
resource to a dedicated struct `InputResources`.

Note that the field `res_id_to_res_handle` was shared by both input
and output resources. This CL split this field into both InputResources
and OutputResources struct.

BUG=b:168557465
TEST=pass android.media.cts.AdaptivePlaybackTest#testVP8_adaptiveDrc

Change-Id: I664815078e08f1e78ec9de2f6674dbdedd7fd482
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2428486
Tested-by: Chih-Yu Huang <akahuang@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Chih-Yu Huang <akahuang@chromium.org>
2020-10-01 18:53:45 +00:00
Chih-Yu Huang
7f880974e5 devices: virtio: video: re-design the methods of OutputResources
At crrev.com/c/2416067 we split the fields that are related to output
resource from Context struct out to OutputResources struct. Also, we
move the methods that only interact with these fields to the
OutputResources's implementation. However, these methods are designed
from the aspect of Context struct, not OutputResources.

In this CL, we re-design the method of OutputResources to make the
interaction between Context and OutputResources more clear.

BUG=b:168557465
TEST=pass android.media.cts.AdaptivePlaybackTest#testVP8_adaptiveDrc

Change-Id: Ib9a3fad8e0d71159c07ce5345b067a2c9924a119
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2417791
Tested-by: Chih-Yu Huang <akahuang@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Chih-Yu Huang <akahuang@chromium.org>
2020-10-01 18:53:44 +00:00
Chih-Yu Huang
3c77612eb3 devices: virtio: video: split OutputResources out of Context
Some fields of the `Context` struct are related to the output
resources. These fields should be cleared together. This CL
consolidates these fields to another struct to make the code clear.

Note that we add `keep_resources` and `set_output_buffer_count` fields
into OutputResources struct. Originally these two fields are not
cleared with other fields together. So this CL is not just a refactor
CL, it changes the reset logic.

BUG=b:168557465
TEST=pass android.media.cts.AdaptivePlaybackTest#testVP8_adaptiveDrc

Change-Id: I6843e835b6c488e74623704618ee54a5273eb7ff
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2416067
Tested-by: Chih-Yu Huang <akahuang@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Chih-Yu Huang <akahuang@chromium.org>
2020-10-01 18:53:43 +00:00
Daniel Verkamp
10154a9310 devices: vfio: use separate MSI and MSI-X sockets
Previously, the VFIO code was using a single IRQ VM control socket
within an Arc<> container for both MSI and MSI-X; however, MsgSocket is
not technically Sync.  In order to remove the Sync trait from MsgSocket,
split the MSI and MSI-X uses into two separate sockets and remove the
Arc wrapper.

BUG=None
TEST=./build_test

Change-Id: Ib620521be3d02bc9b66c1cc771c34feb8622993c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2436399
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2020-09-30 20:08:13 +00:00
Michael Hoyle
08d86a44a0 base: Add timer package
Very little of substance is added here, just the base boilerplate

BUG=b:162363783
TEST=./build_test

Change-Id: I2e3b3b45cf1d7234784d769b4dced31f10a8774d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2366110
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Michael Hoyle <mikehoyle@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2020-09-30 19:44:42 +00:00
Michael Hoyle
a7e38ab421 base: Add shared memory layer to base.
This is very largely boilerplate, but changes some interfaces
to accept different parameters, esp using Descriptor.

BUG=b:162363783
TEST=./build_test

Change-Id: I81b513c0de9448c2de505fe5d3a61a29f4eccb78
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2342591
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Michael Hoyle <mikehoyle@google.com>
2020-09-30 19:44:40 +00:00
Chirantan Ekbote
48537d43b6 fs: Reduce unnecessary map lookups
Change the inner helper methods to take an &InodeData instead of an
Inode.  This removes the need to fetch the data from the map, which can
reduce unnecessary lookups when the calling method already has the data
on hand.

BUG=none
TEST=cargo test

Change-Id: Ia57a543e68d7aa63544f187bdefefe5a4d20c6a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2437683
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2020-09-30 15:02:29 +00:00
Chirantan Ekbote
e367a1d0a4 fs: Drop unnecessary extra readdir function
Now that readdirplus is handled by the server there's no need to have a
separate do_readdir method. Just merge it into the readdir method.

BUG=none
TEST=cargo test

Change-Id: I77475a64a13316bfbcd97a91610c6aa2ec0a9aae
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2437682
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2020-09-30 15:02:28 +00:00
Chirantan Ekbote
53377a8495 fs: Add helper functions for common operations
Add helper functions for common operations so that we don't have to
copy-paste the same thing everywhere.

BUG=none
TEST=cargo test

Change-Id: Ia9dd132336470cdaa5ecef72945f23f6d1dd4401
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2437681
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2020-09-30 15:02:25 +00:00
Alistair Delva
a5b30b2eea devices: gpu: fix 64/32 compat issue with blob
Bug: b/169430664

Cq-Depend: chromium:2437134
Change-Id: I4b9fa7fe3f985abe803878a4b974e33214ff5fcb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2436998
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alistair Delva <adelva@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2020-09-29 23:12:59 +00:00
John Bates
b220eac0d3 devices: gpu: add support for mesa gpu shader cache
When requested with the --gpu=cache-path=/path arg, crosvm
will pass it to Mesa via env var MESA_GLSL_CACHE_DIR. In
addition, the cache-size will also be passed along if
provided.

BUG=b:168540438
TEST=run with --gpu=cache-path=/tmp,cache-size=50M and
 confirm that files are created in /tmp/mesa_shader_cache.

Change-Id: I2525597749d654a65373a723cefeab6cf2be62d7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2415509
Tested-by: John Bates <jbates@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Riley <davidriley@chromium.org>
2020-09-29 19:02:24 +00:00
Alex Lau
ac010c3a8e devices: virtio: video: Implement Display for Format.
BUG=b:161774071
TEST=USE=test emerge-$BOARD crosvm

Change-Id: I3e6c338d72dadff7b998ba291a8b64741e4ff766
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2435034
Tested-by: Alex Lau <alexlau@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alex Lau <alexlau@chromium.org>
Commit-Queue: Alex Lau <alexlau@chromium.org>
2020-09-29 17:02:47 +00:00
Chih-Yu Huang
2296c987cd devices: virtio: video: Fix QueueClear for output queue.
Originally crosvm calls VDA::reset() when either QueueClear the input
or output queue. However, VDA::reset() only drops input buffers,
not guarantee if drop output buffers.

This CL removes the VDA::reset() call when QueueClear output queue.
Instead, we only clear the records of all the queued output buffers.
Note that it's still a workaround. The correct solution is to expose
VDA::DismissPictureBuffer() to libvda, and then clear the record of
the dismissed output buffer.

BUG=b:168557465
TEST=pass android.media.cts.AdaptivePlaybackTest#testVP8_eosFlushSeek
     with related CLs

Change-Id: Ic88b8b9bb14e4b29f7859bf06bd2231cecc85776
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2408597
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Chih-Yu Huang <akahuang@chromium.org>
2020-09-25 07:21:45 +00:00
Chih-Yu Huang
23885c9f87 devices: virtio: video: Clear output resource in ProvidePictureBuffers()
When ProvidePictureBuffers() is called, it means the VDA already drops
the previous set of output buffers. This CL clears the variables that
are related to the output resource in ProvidePictureBuffers().

BUG=b:168557465
TEST=pass android.media.cts.AdaptivePlaybackTest#testVP8_eosFlushSeek
     with related CLs

Change-Id: I0e562fd216c6f2b91e4cbbe3ad174bca99003a0a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2404511
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chih-Yu Huang <akahuang@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2020-09-25 07:21:44 +00:00
Chih-Yu Huang
d9f640c59d devices: virtio: video: Use the fixed buffer for notifying EOS
When VDA requests crosvm to allocate N output buffers, crosvm will
request the userspace to allocate N+1 output buffers. Then crosvm
keeps one output buffer for notifying EOS.

Originally, after the preserved buffer is dequeued to notify EOS,
crosvm might keep another output buffer for next EOS. If so, then
crosvm will register all the N+1 buffers to VDA.

This CL changes to fix the preserved buffer until VDA requests another
set of output buffers. Also, it introduces another variable to track
the resource ids of queued buffers.

BUG=b:168557465
TEST=pass android.media.cts.AdaptivePlaybackTest#testVP8_eosFlushSeek
     with related CLs

Change-Id: I8a6018f9e889dc6a2b6ef67d4915d6202858a42a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2404512
Tested-by: Chih-Yu Huang <akahuang@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Chih-Yu Huang <akahuang@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Chih-Yu Huang <akahuang@chromium.org>
2020-09-25 07:21:43 +00:00
Judy Hsiao
b4b94c7d64 ac97: Enables AEC when capture with the dedicated MIC
1. Captures with the AC97 dedicated MIC will have the AEC effect enabled.
2. Removes the "capture_effect" option in --ac97.

BUG=b:167946783
TEST=Record in the VM by `arecord -D hw:0,1 -f S16_LE -r 48000 -c 2\
     /tmp/a.out` and verify the opened stream has effect = 0x01 by
     `cras_test_client --dump_a`.
TEST=`cat /proc/asound/I82801AAICH/codec97#0/ac97#0-0 | grep \
     Capabilities` in the VM and verify "dedicated MIC PCM IN
     channel" is supported.
TEST=`amixer controls` and verify that 'Mic Capture Switch'
     and 'Mic Capture Volume' mixer controls show up.
TEST=Unit test.

Cq-Depend: chromium:2395855
Change-Id: I67bff9528175528e284f409fac1f51ecaaa89427
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2394983
Tested-by: Judy Hsiao <judyhsiao@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Auto-Submit: Judy Hsiao <judyhsiao@chromium.org>
2020-09-18 15:37:41 +00:00
Chirantan Ekbote
b52768cfb7 p9: Use crate from platform2
It doesn't make sense to have 2 versions of this crate as we end up
missing bug fixes like chromium:2324089.  Use the version from platform2
as that's updated more regularly.

BUG=b:167166153
TEST=Start a vm with a virtio-9p device and verify that it still works

Cq-Depend: chromium:2404987
Change-Id: I54abd88f64d599b68974c09a393c18ec830ecd76
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2404516
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2020-09-17 08:09:40 +00:00
Alexandre Courbot
ec48dd5304 devices: virtio: video: use filter iterator method
Use the filter iterator method instead of a specific in-block check to
filter out tags we want to keep.

BUG=None
TEST=Video plays in Youtube.

Change-Id: I8c34fadb548c26762e077a3ba6dde822b2fb864a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2409491
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2020-09-17 05:41:54 +00:00
Alexandre Courbot
615de2eb90 devices: virtio: video: move session creation to its own method
This makes the code a bit clearer.

BUG=None
TEST=Video plays in Youtube.

Change-Id: Ia904e693b692d70949afd529218dfc0aed7ec1b0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2409490
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2020-09-17 05:41:54 +00:00
Alexandre Courbot
54dce6fb9c devices: virtio: video: remove redundant clone
We are taking ownership of params here, so no need to clone.

BUG=None
TEST=Video plays in Youtube.

Change-Id: I1013e669cde7e5d0001992d7620643054c03d87d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2409489
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2020-09-17 05:41:53 +00:00
Chirantan Ekbote
09357c8fb8 fs: Add case insensitive lookup
Needed by ArcVm.

BUG=b:162388795
TEST='echo foo > test.txt; stat TEST.TXT` works when ascii_casefold is
     enabled

Change-Id: Id2e720d6e9e9e511ee4ec6bb619a9fdbe2aa5d6d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2403421
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2020-09-17 03:51:51 +00:00
Chirantan Ekbote
bf2c3eb497 fs: Clean up readdir handling
Switch from an FnMut for adding entries to an iterator-like approach.
We can't use the Iterator trait directly because the DirEntry struct has
a generic lifetime parameter and generic associated types are not
currently supported by the language.

Also provide an automatic implementation of readdirplus so that file
systems don't have to deal with some of its fiddly details.

Move the directory entry enumeration code into a separate re-usable
struct as we will need it for the casefold support in the next change.

BUG=b:162388795
TEST=vm.Virtiofs

Change-Id: I40c92468a4852f1e302c2e67877b7189268e9c9b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2403420
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Tested-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2020-09-17 03:51:49 +00:00
Alex Lau
47f24c914e devices: virtio: video: Move response logic to decoder.
This CL moves the remaining response logic from Worker to be done
by the decoder or encoder Device. Currently Worker matches on the
returned responses from Device's process_cmd and process_event_fd,
and adds additional responses when the Device already knows the
responses to send. This allows the encoder and decoder to send
different responses when the same AsyncCmdTag is returned, and to
remove the `take_resource_id_to_notify_eos` Device trait function.

BUG=b:161774071
BUG=b:161782360
TEST=USE=test emerge-$BOARD crosvm
TEST=play multiple YouTube videos to completion

Change-Id: I3b210b59f528df473a03657af76b5b8df488f7f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2352269
Tested-by: Alex Lau <alexlau@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alex Lau <alexlau@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2020-09-10 05:10:30 +00:00
Alex Lau
e37b4d3771 devices: virtio: video: add AsyncCmdDescMap.
This CL is a refactoring that moves out cancel_pending_requests as a
function of the descriptor map so that it can be shared with the
decoder and encoder implementation.

BUG=b:161774071
BUG=b:161782360
TEST=USE=test emerge-$BOARD crosvm
TEST=play YouTube video

Change-Id: I32cd7f5ced855cc42baa2d6d3d1a9db802433412
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2379572
Tested-by: Alex Lau <alexlau@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alex Lau <alexlau@chromium.org>
Commit-Queue: Alex Lau <alexlau@chromium.org>
2020-09-07 14:23:03 +00:00
Dylan Reid
371a021f69 devices: Add ability to consume descriptor offsets
When switching to async usage of descriptor queues, it is more useful to
consume the offsets and lengths of the descriptor buffers instead of the
buffers mapped as `VolatileSlice`s. Having the offset,length pair and
the guest memory it refers to is enough to initiate async ops.

Async versions of non-offset read/write case aren't possible as using
the existing "seek" offset of the file doesn't make sense with async IO.

Adding the new version modifies the existing API. This is necessary as
now `Reader` and `Writer` own `GuestMemory`, which makes async possible.

TEST=unit tests and new test to exercise the async functions.

Change-Id: I0a5e50694f40217e5d6ac40f5fcb82944a4c117e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2306784
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
2020-09-02 10:07:32 +00:00
Xiong Zhang
78782db936 vfio-pci: Add one missed msi cap structure
Msi capability structure for 32-bit message address and per vector
masking is missed, so vfio pci device with such cap couldn't receive
msi interrupt in guest.

BUG=None
TEST=Pass pci device with such msi cap into guest, then check this
device function in guest.

Change-Id: If89c5392af72a5bd1165c53a6857c24fe067e29c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2381399
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Xiong  Zhang <xiong.y.zhang@intel.corp-partner.google.com>
2020-09-02 09:15:22 +00:00
paulhsia
ce17e6e51c ac97: Fallback to null audio if connection refused by CRAS
When getting "connection refused" or other errors in CRAS back-end,
fallback to null-audio-device and keep booting.

- Add `backend` attribute to `Ac97Dev`
- Add function to return minijail policy file path in `Ac97Dev`
- Provide fallback mechanism in `try_new`
- Refactor: change `Ac97Dev` to `Self` in `Ac97Dev`'s `impl` block

BUG=chromium:1116468
TEST=`stop cras` && `vmc start termina`
TEST=`cargo test --workspace devices`

Change-Id: Ic60d993473dab69ec2b8b41ec859fa1c012d8334
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2379586
Tested-by: Chih-Yang Hsia <paulhsia@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
Auto-Submit: Chih-Yang Hsia <paulhsia@chromium.org>
2020-08-29 20:47:27 +00:00
Dylan Reid
7ca98fb599 devices: queue: Keep clone of mem instead of Rc
GuestMemory is just Arcs, cloning it is as cheap as keeping an Rc.

Change-Id: I160585ce0cf70aa0ec33897b550b82fe09bde2a4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2364992
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
2020-08-28 18:22:01 +00:00
Daniel Norman
2e8f355ba0 Adds more keys to the default virtio keyboard.
These keys are frequently found as hardware keys on mobile devices.

BUG=b:163628929
TEST=Use crosvm to launch AOSP Cuttlefish and send volume key events.

Change-Id: I9175d32cfd4060abd74f0fde4100284483f13102
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2369357
Tested-by: Daniel Norman <danielnorman@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Norman <danielnorman@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Jorge Moreira Broche <jemoreira@google.com>
2020-08-28 13:08:54 +00:00
Alex Lau
8db592593b devices: virtio: video: Remove bitrate control query type.
It's not supported by the protocol and unused by the virtio-video
kernel driver.

BUG=b:161774071
TEST=USE=test emerge-$BOARD crosvm

Change-Id: I5d28072618187b90acb29fbb4b4272f644ebf1d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2361543
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alex Lau <alexlau@chromium.org>
2020-08-28 06:59:51 +00:00
Daniel Verkamp
f4a260d3df Simplify tests with tempfile::tempfile()
Where it simplifies the code, use tempfile() rather than TempDir to
create temporary files in tests.

BUG=None
TEST=./build_test

Change-Id: I5caff512a38a3b94556b0c72693e432503d6e679
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2360459
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2020-08-27 00:39:03 +00:00
Gurchetan Singh
fb72b4708b devices: gpu: virgl_renderer_resource_export_blob
With blob resources, there's a new export API.

BUG=chromium:924405
TEST=local testing with blobs

Change-Id: I4a6a48608fd6910b6deea53ef54f94def1799950
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2349395
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2020-08-24 17:46:51 +00:00
Alex Lau
38e8750176 device: virtio: video: Add dead_code attribute to SetControl
BUG=b:161774071
TEST=None

Change-Id: Ia9c9ba1a316a409c17ac601e94bd3f6a75b24af5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2355847
Tested-by: Alex Lau <alexlau@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2020-08-18 11:54:02 +00:00
Gurchetan Singh
3035dd87df devices: gpu: gfxstream: use MemSlot
Not strictly necessary to build gfxstream, but the MemSlot abstraction
was recently introduced and it makes sense to use it everywhere.

BUG=b/153580313
TEST=gfxstream builds

Change-Id: I06c2ca15edd39c553eacf1256dd95c2fc72f67dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2349394
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Lingfeng Yang <lfy@google.com>
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2020-08-18 08:34:27 +00:00
Chirantan Ekbote
be48c252db fs: Fix {GET,SET}FLAGS ioctls on arm
crosvm runs as a 32-bit binary on arm devices but arcvm has a 64-bit
kernel with a 64-bit userspace.  Since the {GET,SET}FLAGS ioctls use a
c_long as part of the encoding, the encoded value changes based on
whether a long is 4 bytes or 8 bytes. This causes a mismatch where the
server expects the 4 byte encoding while the VM sends the 8 byte
encoding.

Check for both encodings when handling ioctls.  The actual flag value
itself is actually just a c_int and not a c_long as you might expect
from the encoding. Since that has the same width on both 32 and 64 bit
systems we don't have to change the actual value that's returned.

BUG=b:163729385
TEST=lsattr and chattr still work inside the VM. Also use a test program
     to check that the 64-bit versions also work inside the VM.

Change-Id: I77e98ea83372306597f7b3eb2bd675035be98d5d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2352281
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2020-08-14 17:41:35 +00:00
Daniel Verkamp
32f423723a gpu_renderer: remove redundant -> () from fns
Fixes clippy "unneeded unit return type" warnings.

Also apply rustfmt.

BUG=None
TEST=bin/clippy
TEST=bin/fmt --check

Change-Id: I139c22e1f867de45cc1a5f4f460f08699d1007a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2349954
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2020-08-13 01:28:52 +00:00
Alex Lau
e0b29ad24d devices: virtio: video: Add SetControl response enum
BUG=b:161774071
BUG=b:140082257
TEST=emerge-$BOARD crosvm

Change-Id: I779074edd33a33b2398bd7f3e70945f78a08085c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2345990
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Alex Lau <alexlau@chromium.org>
Tested-by: Alex Lau <alexlau@chromium.org>
2020-08-12 14:21:12 +00:00
Alex Lau
b35b0ae21d devices: virtio: video: Add missing DataInit for virtio_video_set_control_resp
BUG=b:161774071
BUG=b:140082257
TEST=emerge-$BOARD crosvm

Change-Id: I8833871a7925781f37f8279e29ead8c7be5e2327
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2345989
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Alex Lau <alexlau@chromium.org>
Tested-by: Alex Lau <alexlau@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2020-08-12 14:21:11 +00:00
Alex Lau
2cb3fedbb8 devices: virtio: video: Add missing H264 levels
BUG=b:161774071
BUG=b:140082257
TEST=emerge-$BOARD crosvm

Change-Id: Ia440818360c083611ef9e9c7416999f4cbb367b9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2345988
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Alex Lau <alexlau@chromium.org>
2020-08-12 14:21:09 +00:00
Chirantan Ekbote
ba3269fd39 devices: fs: Initialize security context on creation
Set the security context (via /proc/thread-self/attr/fscreate) before
creating files, directories, nodes, or symlinks.  This ensures that
these entries appear atomically with the correct selinux labels.

BUG=b:155441848,b:158326112
TEST=vm.Virtiofs, arc.PlayStore.vm
TEST=Use strace to verify that selinux contexts are written to the
     fscreate proc file before creation.

Cq-Depend: chromium:2291828
Change-Id: Id960dbc821540373f2df073768e3ebfcb1a1c3f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2239728
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
2020-08-12 04:38:27 +00:00
Alexandre Courbot
927c2e499b Revert "devices: video: dec: Support arbitrary buffers to be mapped as resources"
This reverts commit 4ffb3d06bd.

Since ag/12302792 ARCVM now works with a fixed set of buffers, and will
make sure to submit only one given buffer to a given V4L2 index, so we
can revert this patch in order for the crosvm virtual device to work as
per the expectations of V4L2 decoders.

BUG=b:161323057
TEST=arc.VideoDecodeAccel.h264_vm passes on Kukui.

Change-Id: If822f3d23c3dd37a2107db076c91691a0d1b0a00
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2340727
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2020-08-12 03:13:51 +00:00
Steven Richman
f32d0b48fd Use hypervisor abstraction to run VMs
Calls to the kvm crate have been replaced by calls to hypervisor and
devices::irqchip.  Plugin is unchanged and still KVM-specific.

x86 creates and configures vcpus on the vcpu thread instead of the main
thread.

Code that still depends on kvm or kvm_sys:

  - crosvm_plugin, plugin, and protos use kvm and kvm_sys if built with
    the plugin feature

  - devices::VfioGroup does a kvm_sys ioctl

  - devices::irqchip and hypervisor use kvm_sys.  hypervisor uses
    kvm::Cap and kvm::CpuId internally for now.

BUG=chromium:1077058
TEST=runs es2gears_wayland on kukui
TEST=runs evince on amd64-generic with kernel and split irqchip
TEST=build_test excluding tpm2
TEST=cargo check --features plugin

Change-Id: I0068e34da6a5ff0079b1237be1958933bf12ffe4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2307711
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Steven Richman <srichman@google.com>
2020-08-11 04:51:34 +00:00