Commit graph

1765 commits

Author SHA1 Message Date
Zach Reizner
ab04758814 build_test: misc options, improvements, amd bug fixes
New option, --size-only, speeds up using build_test for getting release
binary size by skipping everything else. The lto flag is also added for
release builds to get a more realistic comparison.

The list of crates to test is built up automatically instead of
hard coded. To modify what gets included, empty .build_test_* files are
checked for existance. This is better than hard coding the list of
packages because it was frequently out of date.

For certain crate tests, a dynamic library that only exists in a sysroot
is required. This change includes a fix that adds the sysroot's lib
directory to the LD_LIBRARY_PATH env variable, similar to how
PKG_CONFIG_LIBDIR is modified.

TEST=build_test
BUG=None

Change-Id: I626cbcccf40035a0d29001cef7989a091848e4c9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2444273
Tested-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Zach Reizner <zachr@chromium.org>
2020-10-15 13:40:32 +00:00
Victor Hsieh
7ab6aac800 device: fs: replace read_obj with from_reader in server
BUG=b:168305155
TEST=./build_test

Change-Id: I6874c325ef0f614e449fb3177ba5edb8dc0f3364
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2469501
Commit-Queue: Victor Hsieh <victorhsieh@chromium.org>
Tested-by: Victor Hsieh <victorhsieh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Victor Hsieh <victorhsieh@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2020-10-14 23:15:31 +00:00
David Stevens
27fdbba0d2 devices: virtio: video: Ensure failures are logged
BUG=b:170062417
TEST=Compiles

Change-Id: I12236ce7cb5498086f9ede0e3c3de4aff7d4b78e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2461150
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chih-Yu Huang <akahuang@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2020-10-14 16:17:19 +00:00
David Stevens
e341d0ab7b Expand video sandboxing for AMD devices
BUG=b:170062417
TEST=tast run grunt-DUT arc.Boot.vm and no resource bridge logspam

Change-Id: I84e185c4507b8df6b09505a369f09933d3d6143f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2461149
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: David Stevens <stevensd@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2020-10-14 16:17:17 +00:00
Chih-Yu Huang
65687c376b virtio: video: call set_output_buffer_count() just before passing the first buffer
GAVDA checks if the client sends any buffer between 2
AssignPictureBuffers() call. To guarantee crosvm always passes buffers
after AssignPictureBuffers() call, this CL moves the call just before
passing the first buffer to VDA session.

BUG=b:168557465
TEST=run android.media.cts.AdaptivePlaybackTest#testVP8_adaptiveDrcEarlyEos
     and not see GAVDA's error log mentioned at commit message

Change-Id: I777ff914688ea589a4cf8921fc05ad59d3161b5e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2463052
Tested-by: Chih-Yu Huang <akahuang@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Chih-Yu Huang <akahuang@chromium.org>
2020-10-14 05:27:27 +00:00
Chih-Yu Huang
3db25abe21 virtio: video: Check queue type when cancelling Clear tag
AsyncCmdTag::Clear tag contains the queue type information. This CL
checks if the queue type matches the target when cancelling the
command.

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

Change-Id: I8960ebaebc48c4fffbc8aaa326edeab449284c09
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2437685
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Chih-Yu Huang <akahuang@chromium.org>
Commit-Queue: Chih-Yu Huang <akahuang@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2020-10-14 05:27:26 +00:00
Noah Gold
ee71c80b08 Mark MsgSocket as !Sync.
Semantically, MsgSocket is !Sync: multiple threads reading/writing to
the same end of the socket will result in U.B.. This CL brings the
syntactic definition of MsgSocket in line with its semantic meaning by
marking it as !Sync. While earlier work caught one of the other
consumers that was using a socket end in a Sync manner, this CL has
found another: the usb crate.

The fixes proposed for the usb crate are mostly for compilation's sake,
and should have little material effect on the operation of crosvm. Note
that they will assure correctness, since the send/recv for the socket
end involved are in the same critical section.

BUG=None
TEST=builds

Change-Id: I38469d9ed3228a43457b7d43879a6b4fff97b9a4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2466960
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Noah Gold <nkgold@google.com>
2020-10-14 01:36:09 +00:00
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
Daniel Verkamp
1eedd1bfb4 fuzz: replace SharedMemory with tempfile
The block, qcow, and zimage fuzzers all created a SharedMemory and then
converted it into a file; with the new base API changes, this is no
longer supported.  Replace the SharedMemory uses with tempfile to fix
the build (this also simplifies the code).

BUG=chromium:1136895
TEST=`FEATURES=test USE='asan fuzz' emerge-amd64-generic crosvm`

Change-Id: I50d4e8c57ed41419c79a3fac440654224696f80c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2463895
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2020-10-12 09:45:46 +00:00
Suleiman Souhlal
015c3c1eb9 x86_64: Introduce --no-smt flag.
When set, VCPUs aren't presented to the guest as hyperthreads,
on Intel.

Instead, present them as different, non-hyperthreaded cores on
the same package. Presenting them as hyperthreads might make the
guest scheduler migrate tasks between VCPUs more aggressively,
which can be expensive in a VM.

AMD will need a different CL.

BUG=b:169828263
TEST="cat /proc/sys/kernel/sched_domain/cpu0/domain0/name" in
    the guest returns "MC" instead of "SMT" when starting crosvm
    with --no-smt.

Change-Id: Ifdb4d54a3d7d83c5620fa768ce88ba1a0d85ee50
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2460534
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Suleiman Souhlal <suleiman@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Suleiman Souhlal <suleiman@chromium.org>
2020-10-10 12:10:05 +00:00
Daniel Verkamp
253269b836 docker: update adhd commit to fix kokoro build
Fixes compilation errors:

error[E0308]: mismatched types
   --> devices/src/pci/ac97_bus_master.rs:558:17
    |
558 |                 sample_rate,
    |                 ^^^^^^^^^^^ expected `usize`, found `u32`

BUG=None
TEST=docker/build_crosvm_base.sh && docker/wrapped_smoke_test.sh

Change-Id: Idede11303ff7fd4195bc5fab6cdf2303138a4069
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2462940
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2020-10-10 02:08:49 +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
Lepton Wu
2c5dd1b018 readme: add a note about using virtiofs as rootfs.
This is convenient for development.

BUG=None
TEST=None

Change-Id: I2ee06d70a7e47ea1c4de0e9cb54d382cb8b050d8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2460862
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Lepton Wu <lepton@chromium.org>
Tested-by: Lepton Wu <lepton@chromium.org>
Auto-Submit: Lepton Wu <lepton@chromium.org>
2020-10-08 17:43:30 +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
A. Cody Schuffelen
3faab5a16e Allow more than 4 virtio-console serial ports.
As these are PCI devices, the guest can handle and dynamically discover
more of these devices.

Test: create a Cuttlefish device with 18 serial ports, check the device IDs
Bug: b/170149708
Change-Id: Ia2ad73b3a05ee885ce222917c72a53b423fde7c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2450455
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
2020-10-07 06:14:31 +00:00
Andrew Walbran
cf014f3554 Add more build dependencies to README.
BUG=None
TEST=sudo apt install ...

Change-Id: Ic30b659049818c673f69068112350687bdf2666e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2452791
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Andrew Walbran <qwandor@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Andrew Walbran <qwandor@google.com>
2020-10-06 18:39:14 +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
Zach Reizner
2c770e6f79 hypervisor: replace RunnableVcpu with VcpuRunHandle
This removes RunnableVcpu as an associated type on Vcpu traits, instead
using the new VcpuRunHandle type to enforce the same guarantees. This
simplifies implementations of Vcpu becuase only one impl is needed with
all the methods provided.

The other advantage to removing RunnableVcpu was that a Vcpu could be
try_cloned, defeating the purpose of consuming the Vcpu in the first
place with to_runnable. The type system and ownership model gave a false
sense of compile time safety. The usage of VcpuRunHandle is more
consistent with the fact that it is a runtime check that the programmer
is doing the safe thing. It's also consistent with all hypervisor impls.

BUG=None
TEST=./build_test

Change-Id: I14bbc5d939744cb92fb9cb3152edb82603cadd11
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2442096
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Zach Reizner <zachr@chromium.org>
2020-10-03 02:59:54 +00:00
Noah Gold
b0e9842602 Update safety comments for DataInit.
Previously DataInit did not specify that any implementor `T` must not
contain implicit padding, though implementors of DataInit often include
a safety statement mentioning that they have no implicit padding. This
CL updates DataInit to clarify that any implementor must certify it has
no implicit padding to be safe / free of undefined behavior.

BUG=none
TEST=none (comment only change)

Change-Id: Ieddce51949bfa65de65a891deae071a744b0a4ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2439301
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2020-10-02 04:10:12 +00:00
Gurchetan Singh
cf68ea6f3e crosvm: finish up flexible array wrapper
We added the file, but forgot the flexible array. Fix this.

BUG=chromium:892806
TEST=kvm/hypervisor tests pass, atlas tryjobs pass

Change-Id: Ic52d3c9a9e67f1619151a08d3dd0e879de658066
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2347068
Reviewed-by: Daniel Verkamp <dverkamp@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-02 03:28:07 +00:00
Dylan Reid
0cd3606024 docs: Add note about rust-vmm integration
This is mostly a place holder that will be replaced if and when we
determine a complete plan for consuming crates from rust-vmm.

Change-Id: I8eec6313f40822a887b34d51b462268de5d01fd8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2429813
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
2020-10-01 20:43:41 +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
Daniel Verkamp
caf9ced94a linux: set vcpu affinity before retrieving cpuid
This will ensure that pinned VCPU threads get the per-core CPUID
information from the correct host CPU; previously, the host CPUID
instruction was executed on whatever host core the thread happened to be
running on.

BUG=b:167714813
TEST=Boot crosvm with --cpu-affinity and check core id in /proc/cpuinfo

Change-Id: If06155acb86c4b68d7fb1f8190836c5611e4d32f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2436955
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2020-09-30 19:45:59 +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
Daniel Verkamp
1f4d3c7ca3 x86_64: set APIC ID in CPUID EAX=0xB leaf
This leaf is used to identify the APIC ID on Intel systems.

Fixes guest kernel warnings of this type:

  [Firmware Bug]: CPU1: APIC id mismatch. Firmware: 1 APIC: 11

BUG=b:167714813
TEST=Boot Linux guest kernel; check dmesg

Change-Id: Icc3d32f5a382704c28ecc174b98c982c574bd2b0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2402154
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2020-09-30 02:24:11 +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
Daniel Verkamp
76148ae982 x86_64: calculate CMOS memory values from mem map
The existing mem_below_4g/mem_above_4g calculations did not match the
actual layout used when populating guest memory.  Rather than
duplicating the logic in setup_io_bus to calculate the values reported
in CMOS, just reuse the arch_memory_regions function and count the bytes
in the regions below and above the 4G boundary.

BUG=b:168740534
BUG=b:168628037
TEST=Verify u-boot reports 4 GiB with crosvm --mem=4096

Change-Id: I32a70f19848595eaefd2e31c9f31a260d6ce4453
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2422129
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2020-09-29 03:14:49 +00:00
Daniel Verkamp
b3bafe023f x86_64: fix mem size edge case with --mem=3328
When the RAM size is specified to be exactly 3328 MiB (4096 - 768),
there is no memory after the gap; however, the arch_memory_regions code
was adding a zero-sized region to the list of guest memory areas to be
mapped.

This would result in a mmap syscall failure at startup:

  [ERROR:src/main.rs:1590] The architecture failed to build the vm:
  failed to set up guest memory: failed to map guest memory: mmap system
  call failed: Invalid argument (os error 22)

Fix the off-by-one error when checking whether the address of the end of
guest memory is within 4 GB so that the > 4GB branch is not taken with
mem=3328.

BUG=chromium:1129547
TEST=crosvm run --mem=3328 vm_kernel
TEST=cargo test -p x86_64

Change-Id: I66cd66c98d690b42b2e1d97312528bb0d4830e76
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2417004
Reviewed-by: Ram Muthiah <rammuthiah@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2020-09-29 03:14:47 +00:00
Nicholas Hollingum
c76c2dae56 crosvm: Support "=" in --serial args
The --serial option does not support args that have the '=' character
(or the ',' character for that matter, but we dont mind so much there).

This became a problem after crreev.com/c/2386885 made all encoded VM
names include padding, as the padding charcter '=' caused serial paths
like "foo=.log" to be interpreted as "foo".

This was not noticed because:
 - Logging is not covered in automated testing.
 - My vm name was "brl" in manual testing, which does not require
   padding when b64 encoded.

BUG=b:168859379
TEST=vmc start termina; grep maitred /run/daemon.../log/dGVybWluYQ==.log

Change-Id: I07ffd1c76abab1866a8fb54763605c0ef8733776
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2417797
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Nic Hollingum <hollingum@google.com>
Reviewed-by: Nicholas Verne <nverne@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Fergus Dall <sidereal@google.com>
2020-09-25 09:22:21 +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
Jason Macnak
b3c70d2b46 gpu_display: Fix wayland destruction order
The Wayland context was being destroyed before the surfaces
were destroyed.  This is because the drop order for fields
inside a struct is the order in which they are declared
[Rust RFC 1857].

BUG=b:168735942
TEST=boot Cuttlefish and then `adb reboot`

Change-Id: I3581375a0694871ad50945f5c3ce432bb1f65653
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2415511
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
2020-09-19 16:49:57 +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