Commit graph

4592 commits

Author SHA1 Message Date
Tomasz Nowicki
37cab1bf82 devices: virtio: Add transport type distinction
Since PCI is not the only transport that Virtio can operate on,
implement function to expose transport type - PCI by default for crosvm.

BUG=b:189182339
TEST=boot manatee and verify that Virtio PCI devices work properly

Change-Id: Ida66a45648ee2396e7df4903750b1c4f85d6e4f9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3855005
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Tomasz Nowicki <tnowicki@google.com>
Commit-Queue: Tomasz Nowicki <tnowicki@google.com>
2022-08-26 12:21:37 +00:00
Tomasz Nowicki
09e9f1a24a devices: virtio: Support interrupt configuration for MMIO transport type
Virtio over MMIO is using single edge-triggered IRQ which is used
to deliver notification for all vrings assigned to the MMIO device.
Introduce new MMIO interrupt type abstraction and allow to configure
corresponding edge-triggered IRQ.

BUG=b:189182339
TEST=boot manatee and verify that Virtio PCI IRQ works properly

Change-Id: I24be2fdb9ca6eae065d127cfbf160b2783b5e0cb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3855004
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Tomasz Nowicki <tnowicki@google.com>
Commit-Queue: Tomasz Nowicki <tnowicki@google.com>
2022-08-26 11:51:17 +00:00
Tomasz Nowicki
6fc73a23b1 devices: virtio: Introduce Virtio transport medium type for interrupt abstraction
Virtio, by spec definition, can operate using multiple transport medium
e.g. PCI, MMIO etc. In preparation for adding another transport medium
introduce Virtio transport type abstraction to do proper distinction
while setting up interrupts.

BUG=b:189182339
TEST=boot manatee and verify that Virtio PCI IRQ works properly

Change-Id: I6b8993e10f0a8edd3d3776322939f3dca70048c4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3855003
Tested-by: Tomasz Nowicki <tnowicki@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Tomasz Nowicki <tnowicki@google.com>
2022-08-26 11:51:17 +00:00
Dmytro Maluka
d98e20b908 crosvm: Preserve platform devices in RunnableLinuxVm
If a vfio-platform device has no mmio regions, it is unexpectedly
destroyed at startup (in particular, its vfio device fd is unexpectedly
closed, so its interrupt forwarding stops working, etc) since in
generate_platform_bus() arced_dev is not added to mmio_bus so there are
no more references to the device. To fix this issue, preserve references
to platform devices also in platform_devices field of RunnableLinuxVm.

BUG=b:197169350
TEST=Use vfio-platform for passthrough of a device with interrupts but
without mmio regions, e.g. touchpad on Brya, and check if it works in
the VM (i.e. its interrupts are successfully delivered).

Change-Id: I4042c5508ef6b69649c7d20962edf61b735abc03
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3820043
Commit-Queue: Dmytro Maluka <dmaluka@google.com>
Tested-by: Dmytro Maluka <dmy@semihalf.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-08-26 08:41:37 +00:00
Junichi Uekawa
9ac7ca65fd crosvm: unix: Do not keep around a reference to minijail.
minijail object destructor only frees memory regions, we don't need to
keep it around.

BUG=b:238646369
TEST=build.

Change-Id: Ia736d4b6e1ccc4bb476e8fda18981259d271a36f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3850109
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Tested-by: Junichi Uekawa <uekawa@chromium.org>
2022-08-26 07:57:07 +00:00
recipe-roller
576d5c5311 Roll recipe dependencies (trivial).
This is an automated CL created by the recipe roller. This CL rolls
recipe changes from upstream projects (recipe_engine) into this repository.

The build that created this CL was
https://ci.chromium.org/b/8804788818609863569

recipe_engine:
d9f13ea569
  d9f13ea (tikuta@chromium.org)
      internal: show more information in exception steps

Please check the following references for more information:
- autoroller, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#autoroller
- rollback, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#rollback
- cross-repo dependencies, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/cross_repo.md

Use https://goo.gl/noib3a to file a bug.

R=denniskempin@google.com

Recipe-Tryjob-Bypass-Reason: Autoroller
Ignore-Freeze: Autoroller
Bugdroid-Send-Email: False
Change-Id: I2272a31f1d9e060aa7f8a8286e680c7db473f480
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3857706
Commit-Queue: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
Bot-Commit: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
2022-08-26 06:56:47 +00:00
Alexandre Courbot
66bc11234a virtio: video: decoder: group input resource maps together
Our input resource struct now consists of two maps which are using the
same key and are being used at the same place. Group that information
into a single map which can now become our full input resource type.

BUG=b:161774071
TEST=tast arc.VideoDecodeAccel*_vm passes on hatch.

Change-Id: Iae4567ba6cac0ef11ef7471b780e432150b01e63
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3849208
Reviewed-by: Tatsuyuki Ishi <ishitatsuyuki@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-08-26 02:42:19 +00:00
Daniel Verkamp
2506a65325 devices: virtio-iommu: do not hold RefCell across await
Previously, the `state` RefCell reference would live past the `.await`
on the send at the bottom of the loop. Avoid this by retrieving the
mapper inside an `if let` instead.

Fixes a Rust 1.62 clippy lint:

  error: this `RefCell` reference is held across an `await` point

<https://rust-lang.github.io/rust-clippy/master/index.html#await_holding_refcell_ref>

BUG=b:243677117
TEST=tools/clippy # with Rust 1.62

Change-Id: Ia531180fe6ea7e6805dc0a174dae516c1c357a0f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3854966
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-08-25 21:38:21 +00:00
Vikram Auradkar
5d264785c8 crosvm: resync with downstream after running clippy
BUG=b:243099012
TEST=presubmit

Change-Id: Ia910932344c58979c6735776797139e3a1ee9428
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3846056
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Richard Zhang <rizhang@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Tested-by: Vikram Auradkar <auradkar@google.com>
2022-08-25 20:45:12 +00:00
Vikram Auradkar
9ce0b67d80 crosvm: Fix Windows arg parsing
RunCommand and RunMPCommand take same set of arguments so use RunCommand
within RunMPCommand.
- Remove catch all. This will help print better arg parsing error msg
- Use code that splits --key=value into "--key" "value"

BUG=b:239579779
BUG=b:240717724
BUG=b:238361778
Test: presubmit && ran downstream integration tests

Change-Id: I1c3847891dbfe499b34c240656baf0e81bdf1438
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3846055
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Richard Zhang <rizhang@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Vikram Auradkar <auradkar@google.com>
2022-08-25 20:31:25 +00:00
Zihan Chen
9c3270b08c dev_container: Fix /scratch permission
Correct permission of /scratch to allow crosvmdev to modify its
content after UID & GID changed to match host after container first
start.

TEST=tools/dev_container --stop ; tools/dev_container tools/run_tests
--target=vm:aarch64 --build-only

Change-Id: I8872c433ae903536750a4623f0d149b2875deba2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3855471
Commit-Queue: Zihan Chen <zihanchen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Zihan Chen <zihanchen@google.com>
2022-08-25 18:34:56 +00:00
Daniel Verkamp
ac9a459761 disk: make AsyncDisk take a dynamic BackingMemory
Rather than tying AsyncDisk::read_to_mem/write_from_mem to the
GuestMemory type specifically, use dyn BackingMemory like the underlying
read_to_mem/write_from_mem calls in cros_async. This will allow an async
version of QcowFile to use these functions to read/write temporary
buffers as part of its internal bookkeeping.

BUG=b:219595052
TEST=tools/presubmit

Change-Id: I4ca3c976bf5dca68e3bbe0e3f163023b47034254
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3824065
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
2022-08-24 20:03:09 +00:00
Daniel Verkamp
03dd11a0d4 disk: do not require DiskFile in ToAsyncDisk
This would complicate the implementation of ToAsyncDisk for qcow and
other formats. Change the trait bounds so that only the minimal set of
traits used in the asynchronous block device is required.

BUG=b:219595052
TEST=cargo build

Change-Id: Id5ece59596b0a0989f953854a9cf4c30d32f7e34
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3824064
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
2022-08-24 20:00:49 +00:00
Victor Ding
8050152448 x86_64: Generate ACPI device for each static PCI device
The generated ACPI devices are given deterministic names from PCI
addresses and topology. ACPI requires a device defined before any
reference or usage. For example, PCI switch must occur before its
downstream devices, and "Device" must occur before any "Scope"
extending it. By providing skeleton device definitions in DSDT, it
dramatically eases the composition of SSDT, especially when a device
is referenced in multiple SSDTs or "Scopes".

BUG=b:194390621
TEST=Dump DSDT and verify

Change-Id: Id9f74130b2c1f250374a3103db952ee10fa1b5ee
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3844817
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Victor Ding <victording@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-08-24 19:48:54 +00:00
Victor Ding
f39758b695 devices: Use BFS to get downstream devices from PciBus
It guarantees that a PCI switch always occurs before its downstream
devices.

BUG=b:194390621
TEST=tools/presubmit

Change-Id: I41f76ca2f99c2cf9b26c49081e580f75689b0c1d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3844814
Auto-Submit: Victor Ding <victording@chromium.org>
Reviewed-by: Tinghao Zhang <tinghao.zhang@intel.corp-partner.google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Victor Ding <victording@chromium.org>
2022-08-24 19:48:54 +00:00
Daniel Verkamp
8f094a2713 config: remove redundant file exists checks
The uses of these options already have good error messages, so we can
drop the extra checks in validate_config().

Change-Id: If4a3dc8c35819e41596b57aaf6d1fe4d644a4883
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3807100
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
2022-08-24 19:37:40 +00:00
Daniel Verkamp
e74cd052ac crosvm: unix: improve balloon-control error message
If connecting to the balloon control socket fails, include the path in
the error message.

Change-Id: Idb28c0e8871c2a9038618f40767aabe423a3bc10
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3807099
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
2022-08-24 19:36:29 +00:00
Daniel Verkamp
5648ac6888 crosvm: unix: improve vcpu-cgroup-path error message
If creating the cgroup file fails, include the path in the error
message.

Change-Id: If30ab8c90db97636bf957d546121a05f736f85c4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3806078
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
2022-08-24 19:36:29 +00:00
Daniel Verkamp
07f769528d devices: vhost-vsock: improve open error message
Include the vhost vsock device path in the error message if opening it
fails, and remove the now-redundant file exists check.

BUG=None
TEST=crosvm run --vhost-vsock-device /does/not/exist ...

Change-Id: I1f66c03df8b7b7ad68339b1c151b19ce8fa37a5e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3806077
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-08-24 19:36:29 +00:00
Daniel Verkamp
1407290307 devices: snd: improve open error message
Include the path when opening the sound backend device fails.

Change-Id: I37ce06c973588bea4676741f8fab17de11a2a7cb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3806076
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-08-24 19:36:10 +00:00
Daniel Verkamp
956dbba2b5 x86_64: improve smbios open error messages
Include the error code and path to the file that failed to open. Then we
can remove the redundant file existence check in validate_config.

BUG=None
TEST=crosvm run --dmi /does/not/exist vm_kernel

Change-Id: Id857284c521aaa958a8b7967d7c2de81adcb74a5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3806075
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
2022-08-24 19:36:10 +00:00
Victor Ding
f43e359fb2 x86_64: Change PCI root to "PC00"
There could be at most 256 PCI buses. Using "PCxx" naming convention
allows easily naming all possible PCI buses.

BUG=b:194390621
TEST=Dump DSDT and verify

Change-Id: I53c054555460e3a37b57d2ef6c71972949dd1bd3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3844816
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Victor Ding <victording@chromium.org>
Tested-by: Victor Ding <victording@chromium.org>
2022-08-24 19:33:20 +00:00
Takaya Saeki
495e291809 devices: virtio: video: Add doc comments of Worker
Add doc comments for Worker and related definitions to make it easier to
understand what the definitions mean. No function change is intended for
this commit.

BUG=None
TEST=None

Change-Id: Icd0e78ead1163567064e11a2d4c06611a7f5e7c8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3850018
Commit-Queue: Takaya Saeki <takayas@chromium.org>
Tested-by: Takaya Saeki <takayas@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-08-24 07:17:59 +00:00
Victor Ding
06c376eba5 x86_64: Refactor PCI0's ACPI generation
Minor code refactor to improve readability.

BUG=b:194390621
TEST=Dump DSDT with and without this patch; then ensure they are
     identical

Change-Id: Iccc62803788c3e44ce5f0cb8322831c015a95f85
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3844815
Auto-Submit: Victor Ding <victording@chromium.org>
Tested-by: Victor Ding <victording@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Victor Ding <victording@chromium.org>
2022-08-24 06:31:19 +00:00
Daniel Almeida
26f53eb732 media: libva: open DRM fd as O_RDWR
File::open() opens the file as O_RDONLY, which can cause issues with the
VA-API driver.

In particular for Intel hardware this will cause allocations to fail, as can
be seen in issue #1449 for intel-media-driver. These failed allocations may or
may not crash the VA-API driver, as the driver might eventually dereference a
NULL pointer.

Fix it by opening the DRM fd as O_RDWR. This is also in line with the examples
in libva-utils.

BUG=b:214478588
TEST=`cargo test --features "video-decoder,vaapi" -p devices vaapi::tests::test_get_capabilities -- --ignored` passes on AMD hardware.

Change-Id: Ie3cf2a6512157a3f23f943b54249eb2928082af9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3782999
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-08-24 01:15:19 +00:00
Alexandre Courbot
7e0206ee4a serde_keyvalue: use nom crate for parsing
Use the nom crate for parsing. This will arguably be both simpler to
read and more reliable than our current ad-hoc parser.

Add a few extra tests to enforce the new rules that the new parser is
supposed to enforce.

BUG=b:218223240
TEST=cargo test -p serde_keyvalues -p crosvm
TEST=ARCVM starts successfully.

Change-Id: I4ea188ffe8aee872071c900793c50127855403ec
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3822428
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-08-24 00:37:59 +00:00
Alexandre Courbot
bda417d9ff docs: books: update instructions for using ffmpeg in the guest
Ffmpeg can now reliably be used in the guest to decode VP8 or VP9
streams, so update the instructions to showcase this.

BUG=b:235067555
TEST=mdbook build

Change-Id: If3af1797d8bc686167292e3859d6a4f08bfe2b41
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3841483
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Tatsuyuki Ishi <ishitatsuyuki@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Tested-by: Alexandre Courbot <acourbot@chromium.org>
2022-08-24 00:31:39 +00:00
Alexandre Courbot
5cdeb2a8b3 virtio: video: decoder: reset session when input queue is cleared
Clearing the input queue means a reset of all parameters, so reset the
session when it happens. This allows the guest to change input
parameters after a reset.

BUG=b:161774071
TEST=ffmpeg in the guest does not complain that "parameter for input cannot be changed once decoding started" upon exit.
TEST=tast arc.VideoDecodeAccel*_vm passes on hatch.

Change-Id: I2e25ddc01d99cb9ce39f0dbf9bbb9413084dba19
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3841482
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Tested-by: Alexandre Courbot <acourbot@chromium.org>
2022-08-24 00:25:59 +00:00
Alexandre Courbot
ec9a403e4e virtio: video: decoder: allow reset to be performed if the session does not exist
It is valid to perform a reset on a non-started device - it's just a
no-op. Regular V4L2 clients like ffmpeg may do this.

BUG=b:161774071
TEST=ffmpeg in the guest does not complain about "returning error response: invalid operation" upon exit.
TEST=tast arc.VideoDecodeAccel*_vm passes on hatch.

Change-Id: I63eabbf5183ff2d051997af4d16cf5c841313565
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3841481
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-08-24 00:23:49 +00:00
Alexandre Courbot
53ade023da virtio: video: decoder: fix timestamp management
Fix the broken timestamp management in the virtio decoder device.

Timestamps are specified by the guest's user-space as a struct timeval,
which is effectively a (seconds, microseconds) pair. This pair is turned
into a u64 with nanoseconds units by V4L2, and passed to the virtio
device in that form.

This is fine so far, save for the fact that libvda works with 32-bit
timestamps. To accomodate that, we divided the original timestamp by
1_000_000_000, passed that truncated timestamp to the decoder backend as
a u32, and when the backend gives us decoded frames, multiplied their
timestamp by 1_000_000_000 again and passed that value as the frame
timestamp to the guest. For some reason, we also used the timestamp as
the key for the `NotifyEndOfBistreamBuffer` event, which forced us to
have a mapping table between an input buffer timestamp and its
corresponding resource ID. This in turn required that each input buffer
has a unique timestamp, lest they collide in the mapping table.

Anyway, the timestamp division by 1_000_000_000 means that any
sub-second timestamp information was lost during the decoding process.
This is not a problem with the Android V4L2 decoder which increases the
timestamp by one second for each frame and does not use sub-second
information, but clients that use *actual* timestamp information (like
ffmpeg) get pretty confused by that and abandon decoding with an error.

Fix this by passing the original 64-bit timestamp to decoder backends,
along with the 32-bit ID of the input resource. This allows backends to
directly send the NotifyEndOfBitstreamBuffer with the currect resource
ID, removing the need for the mapping table and unique timestamps for
input buffers.

More importantly, backends that can work with 64-bit timestamps (all of
them but libvda) can just pass the original timestamp to their decoder
logic and return it as-is in the PictureReady event. Libvda still
requires 32-bit timestamps, so we reproduce the truncation and mapping
table behavior inside the libvda backend (I also tried sending the
32-bit input resource ID as a timestamp to VDA, but it was not happy
with it). At least now that behavior is local to the VDA backend.

Thanks to this change clients other than the Android C2 decoder can get
proper timestamp information. One can argue that the code is also
simpler (except for libvda which adds a simple mapping table that we
were using before anyway).

BUG=b:161774071
TEST=cargo test --features "video-decoder,ffmpeg" -p devices video
TEST=`ffmpeg -codec:v vp8_v4l2m2m -i test-25fps.vp8 test-25fps-%d.png`
in the guest completes successfully with the ffmpeg backend.
TEST=tast arc.VideoDecodeAccel*_vm passes on hatch.

Change-Id: Idb21b4c536acafbdf5458e88cdbc33c9376a405e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3841480
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Tatsuyuki Ishi <ishitatsuyuki@google.com>
2022-08-24 00:10:50 +00:00
Daniel Verkamp
bf449563d8 tree-wide: reformat with nightly rustfmt
BUG=None
TEST=tools/fmt --nightly

Change-Id: I9e1985546b364835e252df04dab2c9ecb192047c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3852316
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
2022-08-23 23:33:58 +00:00
Elie Kheirallah
b2011fd697 devices: small refactor in serial.rs
removed 2nd impl block, leftover from a previous CL

Bug=N/A
Test=cargo test && ./tools/dev_container ./tools/run_tests
--target=vm:aarch64

Change-Id: I7efa8f0fc3527e7bbc4f5750f80becaa843a4253
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3852318
Commit-Queue: Elie Kheirallah <khei@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: Elie Kheirallah <khei@google.com>
Auto-Submit: Elie Kheirallah <khei@google.com>
2022-08-23 23:31:30 +00:00
Zihan Chen
483345c4c0 dev_container: Use host UID & GID for user in container
Container shell now defaults to user `crosvmdev` which will have
same UID & GID as outside user. VS Code Remote Containers extension
has the same behavior when loading config from devcontainer.json.

TEST=all tests pass in container, new files in container have same
permission as files created outside.
FIXED=b:239476013

Change-Id: Ib3c696509e9ea45edd5f02ff025d9477576ec765
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3814094
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-08-23 23:16:09 +00:00
Victor Ding
53298c039d aml: Update OpRegion to take Aml as offset and length
ACPI Machine Language (AML) Specification defines both RegionOffset and
RegionLen as Term.

BUG=b:194390621
TEST=tools/presubmit

Change-Id: Ib9d09fab3069566e9fc84c823b6d9f644ac975a0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3845277
Tested-by: Victor Ding <victording@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Victor Ding <victording@chromium.org>
Auto-Submit: Victor Ding <victording@chromium.org>
2022-08-23 05:28:38 +00:00
Victor Ding
cb243d3ef0 tools/cl: add 'fetch origin' before 'checkout -B'
'checkout -B' would fail if 'origin' isn't fetched or is too outdated.

BUG=None
TEST=tools/cl # on a repo where 'origin' isn't fetched

Change-Id: I13a5d8a3796c4c9002243902a5f8d145dc9393ef
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3844820
Tested-by: Victor Ding <victording@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Victor Ding <victording@chromium.org>
Auto-Submit: Victor Ding <victording@chromium.org>
2022-08-23 04:40:38 +00:00
Tatsuyuki Ishi
48fbede24a docs: book: Fix dead link
BUG=None
TEST=mdbook build + click the link

Change-Id: I3da84175f4aa8345069cf4e2f64d5e2211b6d872
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3849207
Auto-Submit: Tatsuyuki Ishi <ishitatsuyuki@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: Tatsuyuki Ishi <ishitatsuyuki@google.com>
Commit-Queue: Tatsuyuki Ishi <ishitatsuyuki@google.com>
2022-08-23 02:38:28 +00:00
Alexandre Courbot
aa4c70e3da media: ffmpeg: upgrade to ffmpeg 5.0 libraries
Update the ffmpeg bindings and build script to use 5.0 and update our
code to match the API changes since 4.4.

BUG=None
TEST=cargo test -p ffmpeg
TEST=cargo test --features "video-decoder,ffmpeg" -p devices video
TEST=v4l2r example from the crosvm book passses.

Change-Id: If7820a4dd270d715e89c60d55f89b9730f40e864
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3835501
Reviewed-by: Tatsuyuki Ishi <ishitatsuyuki@google.com>
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-08-23 01:47:48 +00:00
Alexandre Courbot
d19ae375b5 crosvm: disable ffmpeg decoder from default builds
We are about to require ffmpeg >= 5.0 in the ffmpeg decoder backend, but
the version on Debian Bullseye (used in our container and VM images) is
still 4.3. Temporarily disable building the ffmpeg crate and video
decoder by default until we use a system image that includes ffmpeg >=
5.0.

BUG=None
TEST=./tools/dev_container ./tools/run_tests
TEST=./tools/dev_container ./tools/run_tests --target=vm:aarch64
TEST=./tools/dev_container ./tools/run_tests --target=vm:aarch64 --build-target armhf

Change-Id: Idf96862d3ea9bea597701fdee8145e12a0753a3e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3835500
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-08-23 01:47:48 +00:00
Alexandre Courbot
d874d323c9 tools/clippy: exclude crates on all platforms
Make sure that excluded crates are actually not considered on all
platforms, not just Windows.

BUG=None
TEST=./tools/clippy succeeds and does not attempt to build ffmpeg.

Change-Id: If7167bb6b598692847bbab9f069f875a3fb0b581
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3844812
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: Alexandre Courbot <acourbot@chromium.org>
2022-08-23 01:47:39 +00:00
recipe-roller
0cf93bfccd Roll recipe dependencies (trivial).
This is an automated CL created by the recipe roller. This CL rolls
recipe changes from upstream projects (depot_tools) into this repository.

The build that created this CL was
https://ci.chromium.org/b/8805083258749440353

depot_tools:
de38174544~..19b3eb5adbe00e9da40375cb5dc47380a46f3041
  de38174 (vapier@chromium.org)
      CROS_OWNERS: switch to our common shared lists
  19b3eb5 (vapier@chromium.org)
      repo: update to 2.29 launcher

Please check the following references for more information:
- autoroller, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#autoroller
- rollback, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#rollback
- cross-repo dependencies, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/cross_repo.md

Use https://goo.gl/noib3a to file a bug.

R=denniskempin@google.com

Recipe-Tryjob-Bypass-Reason: Autoroller
Ignore-Freeze: Autoroller
Bugdroid-Send-Email: False
Change-Id: Ibe61b2cdf4e21a5b2d3e9e6bcd1b04514d3b0dee
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3846067
Commit-Queue: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
Bot-Commit: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
2022-08-23 00:58:43 +00:00
recipe-roller
ee65e516c1 Roll recipe dependencies (trivial).
This is an automated CL created by the recipe roller. This CL rolls
recipe changes from upstream projects (depot_tools) into this repository.

The build that created this CL was
https://ci.chromium.org/b/8805084517603520337

depot_tools:
baa7be052e
  baa7be0 (tikuta@chromium.org)
      presubmit_support: remove backslash from log

Please check the following references for more information:
- autoroller, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#autoroller
- rollback, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#rollback
- cross-repo dependencies, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/cross_repo.md

Use https://goo.gl/noib3a to file a bug.

R=denniskempin@google.com

Recipe-Tryjob-Bypass-Reason: Autoroller
Ignore-Freeze: Autoroller
Bugdroid-Send-Email: False
Change-Id: Ia73c5e51437c7bbc3e76a058079517fcf65c0791
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3846064
Bot-Commit: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
Commit-Queue: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
2022-08-23 00:38:58 +00:00
recipe-roller
7a1d74c255 Roll recipe dependencies (trivial).
This is an automated CL created by the recipe roller. This CL rolls
recipe changes from upstream projects (depot_tools) into this repository.

The build that created this CL was
https://ci.chromium.org/b/8805085771004012577

depot_tools:
92c463cd65
  92c463c (tikuta@chromium.org)
      autoninja.bat: have space suffix in ninja status

Please check the following references for more information:
- autoroller, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#autoroller
- rollback, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#rollback
- cross-repo dependencies, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/cross_repo.md

Use https://goo.gl/noib3a to file a bug.

R=denniskempin@google.com

Recipe-Tryjob-Bypass-Reason: Autoroller
Ignore-Freeze: Autoroller
Bugdroid-Send-Email: False
Change-Id: Ibffb00a7b09c0ef76850a0ce2fcebeba8f354fd6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3846062
Commit-Queue: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
Bot-Commit: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
2022-08-23 00:19:58 +00:00
Jason Macnak
ea11f76234 gpu: enable EDID for 2D mode
... to ensure consistent phyiscal display ids when
running Android with Cuttlefish across both 2D and 3D
modes.

BUG=b:242931783
TEST=boot Cuttlefish with 2D mode and EDID and interact
     with the displays

Change-Id: Iba0e786464a603c7e1264625ddf619b91b9099bc
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3846059
Reviewed-by: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
2022-08-22 21:45:28 +00:00
Jason Macnak
d7e3f94677 gpu: populate more EDID info
... which is required to pass the Android framework's EDID
validation (frameworks/native/libs/ui/DisplayIdentification.cpp).

Also, remove additional hard-coded extra resolutions which were
unused.

BUG=b:242931783
TEST=boot Cuttlefish with EDID re-enabled
     (aosp/2189577 reverted)

Change-Id: Ib9cda60882fc3921c8424d10fd45d7dceae28a2f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3846058
Tested-by: Jason Macnak <natsu@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Kaiyi Li <kaiyili@google.com>
2022-08-22 21:45:28 +00:00
Daniel Verkamp
4a6942dd33 base: syslog: make platform syslog init non-fatal
If we can't create a PlatformSyslog instance (for example, if /dev/log
is not available on a minimal Linux system without a traditional init),
warn the user and continue executing instead of failing.

BUG=b:242103548
TEST=Run crosvm inside minimal VM with no init

Change-Id: I4d81da396125331ef7ad335e57b37645b6546980
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3842814
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Abhishek Bhardwaj <abhishekbh@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
2022-08-22 21:05:18 +00:00
Xiong Zhang
eac63e6a50 Pcie: Inject pending HP interrupt when guest enable HP interrupt
When pcie port driver put device into suspended state, it will
disable hotplug interrupt. So in order to inject virtual hotplug
interrupt into guest, virtual pcie port injects a virtual PME into
guest to resume pcie port, then pcie port driver enable hotplug
interrupt, finally virtual hotplug interrupt is injected after
PME is handled by guest.

Previously pending HP interrupt is injected at guest clear root
port's PME status, this is work for pcie root port only. Pcie
downstream port doesn't have root port's PME status. This commit
changes the time for injecting pending HP interrupt when guest
enable HP interrupt in PME handler.

BUG=b:199986018
TEST=Check root/downstream port's hotplug function in guest

Change-Id: Iffaa1fc73f13e1b940a45459fbcdc51af11dcca8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3824072
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-08-22 21:01:48 +00:00
Xiong Zhang
dba3d9abc0 Pcie: Set Presence Detect Changed status at virtual hotplug interrupt
Currently PDC(Presence Detect Changed) is set even at virtual PME
injection also, kernel treats it as spurious event in PME handler.
This patch set PDC when virtual HP interrupt is injected, so kernel
won't see it in PME handler.

BUG=b:199986018
TEST=Verify root/downstream port's hotplug function in guest

Change-Id: I9c56216f32da37cb74fe6759ea944dee64642583
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3824071
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-08-22 21:01:48 +00:00
Xiong Zhang
730dd5a250 Pcie: Only root port could generate PME interrupt
According to Pcie spec, Pcie upstream/downstream port send PME message
to pcie root port, then pcie root port remembers request id and trigger
pcie PME to cpu. So when pcie upstream/downstream port need PME, it
should request pcie root port and write its pci address in root port's
root status register.

In order to convenient upstream/downstream port to find out its root port,
a global variable is used to store all the root ports, and each root port
covers a BusRange, so upstream/downstream port's bus number is used to
search its root port from global variable.

BUG=b:199986018
TEST=Check upstream/downstream port's PME function in a VM

Change-Id: If58da2cfbe2d258a665086b30df219161d1a8081
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3824070
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
2022-08-22 20:51:28 +00:00
Xiong Zhang
f1fe59da0e Pcie: Only pcie root port has root cap in pcie cap register
According to Pcie SPEC, only pcie root port has root cap in
pcie cap register, pcie upstream/downstream port doesn't have
root cap, so this commit make root_control and root_status
as option in PciePort.

BUG=b:199986018
TEST=Check pcie root/upstream/downstream ports register in vm

Change-Id: Icffa2c99ee7943d293dbec77d3e9ac03e37401d5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3824069
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-08-22 20:51:28 +00:00
recipe-roller
f2558fe731 Roll recipe dependencies (trivial).
This is an automated CL created by the recipe roller. This CL rolls
recipe changes from upstream projects (depot_tools) into this repository.

The build that created this CL was
https://ci.chromium.org/b/8805116604169744577

depot_tools:
e19b7624ef
  e19b762 (sokcevic@google.com)
      Keep old git alternatives when changing mirrors

Please check the following references for more information:
- autoroller, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#autoroller
- rollback, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#rollback
- cross-repo dependencies, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/cross_repo.md

Use https://goo.gl/noib3a to file a bug.

R=denniskempin@google.com

Recipe-Tryjob-Bypass-Reason: Autoroller
Ignore-Freeze: Autoroller
Bugdroid-Send-Email: False
Change-Id: I7aef33839e646a3cf41b488ae1f605183fb9ed3c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3846050
Bot-Commit: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
Commit-Queue: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
2022-08-22 16:06:57 +00:00