Commit graph

1734 commits

Author SHA1 Message Date
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
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
Chirantan Ekbote
19c0ca7f11 cros_async: Drop Unpin requirement from uring futures
The futures don't require the IoSource to be Unpin if they take a
Pin<&I> where I: IoSource.

BUG=none
TEST=unit tests

Change-Id: I6d8e73d54ac612da58004b5bd732640524aac3b9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2387822
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2020-09-12 09:42:38 +00:00
Chirantan Ekbote
370ee0fb75 io_uring: Pin iovecs in memory
Pointers to the iovec structs are shared with the kernel for the
duration of an I/O operation and so must be pinned in memory.  Use
Pin<Box<[iovec]>> instead of Vec<iovec> to express this and also to
prevent any changes made in the future from accidentally doing something
that causes the memory location of the iovecs to change.

BUG=none
TEST=unit tests

Change-Id: I317f3a6f68d457b0b0a6c86494d506b0e978b5fb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2387823
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2020-09-12 09:42:37 +00:00
Chirantan Ekbote
b6c1eba580 cros_async: Don't implement IoSource for pointer types
We can use Pin::as_ref to go from a Pin<P> to a Pin<&<P as
Deref>::Target>, which doesn't require <P as Deref>::Target to be Unpin.
So let's have callers use that method rather than implementing the
IoSource trait for different pointer types.

BUG=none
TEST=unit tests

Change-Id: I45f54e70fe81bc0ceac3f038db47aef50201daa2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2387821
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2020-09-12 09:42:36 +00:00
Chirantan Ekbote
8ea889fccf cros_async: Refactor executors
This CL includes several smaller changes to how executors work:

  * Replace BTreeMap with Slab, which should give us some small
    performance benefits by giving O(1) lookups and reducing memory
    allocations when adding new I/O operations. It also gives some
    improvements to readability as we no longer have to carry around
    "next_*" variables. Slab has no dependencies and we're already
    pulling it in via the futures crate.
  * WakerToken no longer implements Clone.
  * Merge pending_ops and completed_ops in URingExecutor into a single
    `ops` Slab and introduce an OpStatus enum that indicates whether an
    operation is pending or completed.  This also fixes a resource leak
    where an operation that was canceled before completion would end up
    staying in completed_ops ~forever. Add a test for this leak.
  * Add a generation number to RingWakerState and include it in all
    RegisteredSources. Since a RegisteredSource can outlive the
    RingWakerState that created it, the generation number ensures that
    it will only affect the RingWakerState that created it. Add a test
    for this.
  * Poison RegisteredSource so that it doesn't implement Send or Sync.
    Since it's associated with a thread-local executor, sending it
    across thread boundaries is not ok.

BUG=none
TEST=unit tests

Change-Id: I43dcfbb8166002995ec8773522c22fab8fb2da9e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2374885
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2020-09-12 09:39:26 +00:00
Daniel Verkamp
c677fb49ce crosvm: allow setting VCPU affinity per VCPU
Allow separately specifying each VCPU thread's affinity, extending the
existing --cpu-affinity option so that it can parse a new format:

  <GUEST-CPU>=<HOST-CPU-SET>[:<GUEST-CPU>=<HOST-CPU-SET>[:...]]

This can be used to pin each VCPU thread to a single host core, for
example.

Tested with this command to verify the affinity of the VCPU threads:

  ps -C crosvm -T | grep vcpu | awk '{print $2}' | xargs -n1 taskset -p

BUG=b:167714813
TEST=cargo test
TEST=Run crosvm with new --cpu-affinity option; verify with taskset -p

Change-Id: Ie6c1acf954931c12b9eaa74c6ae3f67c3f062ef6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2399639
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2020-09-11 22:38:03 +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
George Burgess IV
61126c786c fuzz: fix build
A recent API change made `{Reader,Writer}::new` take `GuestMemory` by
value instead of reference. Since `GuestMemory` is just a pair o'
`Arc`s, this appears to be an easy fix.

BUG=chromium:1125394
TEST=`emerge-amd64-generic crosvm` with a `--profile=fuzzer`'ed board

Change-Id: I964f284134241f958456f87912334a387dfcf61e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2394756
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: George Burgess <gbiv@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: George Burgess <gbiv@chromium.org>
2020-09-07 13:15:32 +00:00
Jason Macnak
23400524e9 devices: gpu: Check /dev/dri exists before mount
GPU in 2D mode does not need this and /dev/dri may not
exist (Nvidia startup failure after forced workstation
updates?).

BUG=b:166180769
TEST=boot Cuttlefish

Change-Id: Iaf80fc0f8f031270267df18d61964f8a648920b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2381892
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Jason Macnak <natsu@google.com>
2020-09-03 17:07:44 +00:00
Kansho Nishida
ab205af96c main: Allow some vcpus to be real time
Add an option to set some vcpus as real time. With a cooperative guest,
this allows for getting real time behavior for a subset of guest
threads.  The guest will use cpusets to ensure that only real time tasks
are run on the real-time CPU, and that vcpu thread is real-time on the
host leading to behavior close to host real-time threads.

BUG=b:142777321
TEST=crosvm --rt-cpus 1 [OPTION]...
     ps -AT -eo comm,sched,rtprio | grep crosvm_vcpu
     then check the sched policy of vcpu1 is 2 (SCHED_RR)

Change-Id: Ic8e7a6840bdbce2c90e518458f6d0c50a65ca3f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2152167
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Suleiman Souhlal <suleiman@chromium.org>
Tested-by: Kansho Nishida <kansho@chromium.org>
Commit-Queue: Kansho Nishida <kansho@chromium.org>
2020-09-03 07:20:02 +00:00
Paul Kirth
6e1260face Revert "msg_socket: Fixed bug with all skipped fields in struct"
This reverts commit ca3817bda3.

Reverting prevents these errors when starting the vm:

[ERROR:src/linux.rs:2324] failed to recv VmMemoryControlRequest:
msg buffer size too small
[ERROR:src/linux.rs:2324] failed to recv VmMemoryControlRequest:
msg buffer size too small
[ERROR:src/linux.rs:2350] failed to recv VmIrqRequest:
msg buffer size too small

BUG=b:162032986
TEST=manual

Change-Id: I22a31fa36274d3b6dd4ebc7431ab9ac3878b735b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2380301
Reviewed-by: Richard Zhang <rizhang@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Zach Reizner <zachr@chromium.org>
2020-09-02 23:20:22 +00:00
Daniel Verkamp
8c2f000917 linux: replace sort with sort_by_key and Reverse
Use the _by_key variant of the sort function as recommended by
https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_sort_by
and replace the potentially easy-to-miss swap of the two compared values
with an explicit call to std::cmp::Reverse (also recommended by the same
clippy lint).

Fixes a clippy warning with Rust 1.46.0.

BUG=None
TEST=docker/wrapped_smoke_test.sh (with Rust 1.46.0)

Change-Id: I682652736a27cb09111dbc813e654b17269670da
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2386479
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2020-09-02 18:41:25 +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
Gurchetan Singh
6951fca9fb docker: build against virglrenderer master
Requires Meson, python3-setuptools, epoxy update too.

This, too, should keep kokoro happy.

BUG=chromium:924405
TEST=./wrapped_smoke_test.sh

Change-Id: Ib1ca1bcca7b21f76e74c8e4dca9f96e84154b9e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2379995
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2020-08-28 23:26:34 +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
Daniel Verkamp
62fb00d4bb tempfile: add tempfile() and NamedTempFile
This simplifies the common case of creating a temporary file whose path
does not need to be known, as well as a a temporary file with a known
name.

BUG=None
TEST=cargo test -p tempfile

Change-Id: I664b6097b5ae44ae3f1aa7f6c366271375a8df46
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2360458
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:02 +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
Richard Zhang
ca3817bda3 msg_socket: Fixed bug with all skipped fields in struct
Fixed a bug where RecvZero would be thrown when sending a struct with
all it's fields being skipped. Added a test for this too.

BUG=b:162032986
TEST=cargo test -p msg_socket

Change-Id: I01ba17593df24564786bcbf7b35312d61e3bb3f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2339311
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
2020-08-23 00:24:47 +00:00
Richard Zhang
649f116d9d msg_socket: delete impl for Mutex
The MsgOnSocket impl for Mutex contains a threading bug where it's
possible for the object inside the Mutex to mutate after msg_size()
and/or fd_count() has been called.

Also it's not being used.

BUG=b:162032986
TEST=cargo test -p msg_socket

Change-Id: I41188547152236c8124d9ac9593deea93dc02c73
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2339308
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
2020-08-23 00:24:45 +00:00
Suleiman Souhlal
14fa6bdf5a balloon: Use different method for sizing balloon.
Use free + cached memory in the guest instead of available
reported through the balloon stats, which uses some strange heuristics,
for sizing the balloon. This brings it more in line to what
the ChromeOS available counter does.

Also, change the way the memory is balanced such that the
balloon is sized so that the "available" memory in the guest
would be equal the host's available memory.

BUG=b:160826299
TEST=arc.MemoryChromeOSPerf.vm tast test improves to be closer to
 container ARC: 1900MB -> 2400MB on 4GB machine.
 No difference in arc.MemoryAndroidPerf.vm.

Change-Id: Idddf1e5f5d75ea4d1ebb190b60dd785bbe2327df
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2299279
Auto-Submit: Suleiman Souhlal <suleiman@chromium.org>
Tested-by: Suleiman Souhlal <suleiman@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Suleiman Souhlal <suleiman@chromium.org>
2020-08-22 12:51:37 +00:00
Chirantan Ekbote
f9038f464b cros_async: Delete IoOperation
This seems like an unnecessary extra layer of indirection.

BUG=none
TEST=unit tests

Change-Id: If63bf06fed6a0bc99f075b3b34a5d7998e9865b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2369053
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
2020-08-22 10:39:59 +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