Commit graph

123 commits

Author SHA1 Message Date
Frederick Mayle
d13a8cf231 gpu_display: delete unused field and method GpuDisplay::is_x
Change-Id: I5a1e4aa28100bf9d935902bf5040b4e4f6744927
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4777341
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-08-18 18:23:25 +00:00
Frederick Mayle
6a4aea4445 gpu_display: simplify GpuDisplay::open_x signature
Change-Id: I334004ac47466de2f8cd800e680a14cb7f75ef3c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4775759
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-08-18 18:23:25 +00:00
Vikram Auradkar
0e1c85f293 clippy: Disallow new_without_default
BUG=b:283512997
TEST=none

Change-Id: If10b73f0cd686ff1a1a17e4aa3260f01e1ee8db5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4546662
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2023-05-22 21:14:06 +00:00
Ryan Neph
99ca07bd39 gpu_display: pass error logging callback and remove syslog()
syslog() is used on the error path for wayland display management. On
32-bit arm, the glibc implementation of syslog() uses send(), which
causes a seccomp violation. This was regressed a long time ago and never
found until now.

Fixing syslog() on 32-bit arm requires changes to gpu_device.policy on
32-bit arm (to add send() and socket()), but we'd prefer to call
crosvm's configured logger and drop syslog() anyways, so let's just do
that.

TEST=Run crosvm + glxgears/vkcube
BUG=b:281165392

Change-Id: I69bcf8cf3617d117360c4a255b1cc1234493eccc
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4517955
Commit-Queue: Ryan Neph <ryanneph@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-05-10 19:56:16 +00:00
Daniel Verkamp
b080f54729 gpu_display: allow xlib::Window to u64 casts
The code should not depend on xlib::Window being u64 internally (it
could differ on 32-bit platforms), so allow the clippy warning rather
than removing the casts.

BUG=b:276487055
TEST=tools/clippy # with rust 1.68

Change-Id: Iba59c2d4fb940837783679fce81c2b35ed64142b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4390738
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-10 19:55:20 +00:00
Daniel Verkamp
083dcf75f4 tree-wide: apply nightly rustfmt
BUG=None
TEST=tools/fmt --nightly

Change-Id: Ifb08dd55ccf2a74ef739d7517a64970d24a82405
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4375640
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-03-27 21:30:45 +00:00
Zihan Chen
bbc4f68ebb crosvm: Convert DataInit to zerocopy 10/n
We are down to only 30 `unsafe impl DataInit` across our repo now!

TEST=CQ

BUG=b:204409584

Change-Id: I1b6cf95b2a15eac194f3b464330009fd898a0bfa
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4356907
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-03-24 18:12:38 +00:00
Zihan Chen
c30a6ac4ea gpu_display: Read only 8 bytes from socket for virtio_input_event
Previously this function will consume 24 bytes from event socket
and try to convert the bytes into virtio_input_event (8 bytes)
using DataInit::from_slice(). from_slice() guards size mismatched
conversion and will always return None and fall into Err branch.

Seems related to crrev/c/2034046

TEST=CQ, input still work running a debian desktop vm

Change-Id: Ib82095fed6ec4591ba170a6a52fe47a61d33e013
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4357923
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2023-03-22 01:30:34 +00:00
Daniel Verkamp
732b422bdc gpu_display: find wayland-scanner with which in build.rs
This allows us to print a more useful error message if the
wayland-scanner tool is not present.

BUG=None
TEST=cargo build # with and without wayland-scanner present

Change-Id: I8909e064621cb4d71bc8ec96d76df8a2b4c4fc88
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4294676
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-02-27 21:18:21 +00:00
Zihan Chen
30f58a81aa crosvm: Partially convert DataInit to zerocopy (6/n)
This CL removed many uses of DataInit in devices. Some paddings
are manually added/fixed to allow AsBytes to derive without ABI
changes.

TESTED=CQ

BUG=b:204409584

Change-Id: I1f8c2d5304fc8e685cc3e5166c73481f6a3f78f7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4235224
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-02-10 01:52:24 +00:00
Zihan Chen
28ce4e5423 crosvm: Uprev rust toolchain and dev container
- Rust toolchain is updated to 1.65.0
- Catapult dashboard upload tool is added to dev_container
- Bindgen is updated to latest version to support custom derive
- Derive Eq when PartialEq is derived as required by new Clippy

TEST=CQ, bindgen-all-the-things

FIXED=b:260784028
BUG=b:257303497

Change-Id: I2034cd09e0aed84d4e9b30f2e85d84d94a442ea4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4228427
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2023-02-08 20:26:30 +00:00
Dennis Kempin
acc162000f Add conditional compilation for unix-only crates
Instead of configuring which crates to --exclude in
test_config.py, we can use conditional compilation to
exclude code that is not supported on windows.

This allows more fine-grained control and also allows
us to use plain cargo for building without complicated
configuration and exclusions.

BUG=b:265829867
TEST=cargo test --lib --bins --workspace
	--target=x86_64-pc-windows-gnu
	--features=all-mingw64

Change-Id: I8422c3f08053bc27d9896b220876a56bd25543d6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4165868
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-01-19 21:21:59 +00:00
Daniel Verkamp
ac0fc378a3 Fix remaining Chrome/Chromium OS instances
These should be written as ChromeOS and ChromiumOS (without the space)
to match the updated branding. The copyright headers were already
migrated to the new style (https://crrev.com/c/3894243), but there were
some more instances left over.

BUG=None
TEST=tools/cargo-doc

Change-Id: I8c76aea2eb33b2e370ab71ee9b5cc0a4cfd00585
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4129934
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-01-03 22:14:30 +00:00
Daniel Verkamp
7519b10342 gpu_display: require x feature for simple_open example
The simple_open example doesn't work without --features=x, so mark it as
a required feature.

BUG=None
TEST=cargo build -p gpu_display --example simple_open # fails
TEST=cargo build -p gpu_display --features x --example simple_open

Change-Id: Id780d6e56bb8aebd4abfc42f58ab0b49fb524f02
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4068551
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-12-01 06:11:48 +00:00
Daniel Verkamp
54cc0eb450 gpu_display: make simple and simple_open example targets
Fixes cargo warning:
  [...]/gpu_display/Cargo.toml: file found to be present in multiple build targets:
  [...]/gpu_display/examples/simple.rs

https://doc.rust-lang.org/cargo/reference/cargo-targets.html#examples

BUG=None
TEST=cargo build -p gpu_display --example simple --example simple_open

Change-Id: I76d0c5729caf2926c9d7fe54170b10c15267fe6f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4068547
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-12-01 06:11:03 +00:00
Daniel Verkamp
10990c89af Rust 1.65: Fix clippy derive_partial_eq_without_eq lints
BUG=b:260784028
TEST=tools/clippy

Change-Id: Ib2b595385ed04b9480b22549334ce798d980d347
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4064717
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-12-01 01:32:30 +00:00
Idan Raiter
7b846137b6 devices: gpu: Remove kiwi tubes
Let's remove the tubes:

1) gpu_device_service_tube - We diverge downstream nearly everywhere due
   to other tubes passed just like it. Reducing merge conflicts should
   happen maybe via structs, but we are already paying the cost anyway
   when code changes next to this tube (due to the other differing args)
2) gpu_main_display_tube - We will be moving this to the wndproc thread
   when upstreaming further work on it, so there is no need to keep the
   old version around.

BUG=b:243061269
TEST=presubmit, cargo build

Change-Id: I241922952d34a212dcb412bc1f0391f8473d8a61
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4033254
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Pujun Lun <lunpujun@google.com>
Commit-Queue: Idan Raiter <idanr@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-11-21 19:51:34 +00:00
Daniel Verkamp
87fd7a8d40 gpu_display: add basic error handling to examples
This helps diagnose problems if the examples don't work (for example,
simple_open requires the `x` feature to be enabled).

BUG=None
TEST=run simple and simple_open examples

Change-Id: Ic115d48d93531bf2313948597a49a003538949cd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4029530
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-11-16 19:33:35 +00:00
Vikram Auradkar
afcaa35ab8 crosvm: Fix windows clippy warnings
BUG=b:257249038
TEST=CQ

Change-Id: Iffb53295fbe64b31b4f68e217f6b522e4231e61c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3993933
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-11-03 18:36:29 +00:00
Dennis Kempin
6289de1d36 gpu_display: Add build targets for example binaries
This will allow them to be build via

cargo build --bin simple
cargo build --bin simple_open

It will also include them in CI builds to ensure the
code will not rot.

BUG=None
TEST=CQ

Change-Id: Id6e73f3d5535141f5b1df0edc07c0f84cd03305b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3997601
Reviewed-by: Luigi Semenzato <semenzato@chromium.org>
Commit-Queue: Luigi Semenzato <semenzato@chromium.org>
2022-11-01 21:51:07 +00:00
Daniel Verkamp
74db80eb13 gpu_display: fix allow(unsed) typo
BUG=None
TEST=tools/run_tests --platform=mingw64 --verbose

Change-Id: I33096ea9ab48c06a02207ab04d87257970265d20
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3993686
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Pujun Lun <lunpujun@google.com>
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
2022-10-31 19:59:34 +00:00
Idan Raiter
3c21f8e313 device: vhost-user: Cross-platform GPU base
Makes the async vhost-user backend cross-platform. The next change will
add the plumbing to turn it on. The plan is to create GpuBackendConfig
and GpuVmmConfig in the broker and pass to the relevant processes.
This way, we can also pass GpuBackendConfig to the main process if we
want to use the original non-vhost-user worker. The config changes will
be included with the plumbing CL that follows.

- Split into a sys module.

- Introduce 'platform_workers' that tracks platform-dependent futures.
  Reasoning: Windows will need to be able to launch more futures at
  runtime due to our input handling, it's useful to have a vector of
  workers to append to. This way the specific worker function doesn't
  need to leak into the shared file. We can also put the resource
  bridge workers here following the same logic.

- Introduce backend and VMM config structures to pass around.

BUG=b:243061269
TEST=downstream / presubmit

Change-Id: I53458c4dd2cf74b9e6bf5d10819533206e47a683
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3963645
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Commit-Queue: Idan Raiter <idanr@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-10-31 18:26:02 +00:00
Vikram Auradkar
8044443135 gpu_display: Fix warnings
BUG=none
TEST=presubmit

Change-Id: I6f9d5ac3161f02b20d4b042e39bbcafc7dab8e43
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3988325
Reviewed-by: Pujun Lun <lunpujun@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-10-28 22:40:23 +00:00
Ryan Neph
3d0ece792c gpu: handle unexpected compositor disconnections
If crosvm's connection to the host compositor is suddenly broken
(e.g. from a compositor crash), a single POLLHUP is sent on the listened
file descriptor, but it is ignored. Then the VirtioGpu backend is
repeatedly awoken to handle display events, although there are none.

Since the compositor is lost and there is currently no path for
recovery, we can at least prevent runaway CPU usage by removing the
display from VirtioGpu's WaitContext. For VMs that can continue to
function without a guest display (headless crostini), this is
non-lethal. For VMs that require a display (ARCVM), other mechanisms
already exist for shutting down the VM under such unrecoverable
conditions.

BUG=b:250923109
TEST=Run Crostini and trigger a chrome crash; inspect virtio_gpu CPU
usage

Change-Id: I8b2261a093191dfe142697c4c4adc4e9ffab751a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3975942
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Ryan Neph <ryanneph@google.com>
2022-10-25 21:39:45 +00:00
Pujun Lun
eb3b49f185 gpu_display: better detection for window sizing/moving modal loop.
We do receive WM_ENTERSIZEMOVE when the window is about to be resized or
moved, but it doesn't tell us whether resizing or moving should be
expected. We won't know that until later we receive WM_SIZING or
WM_MOVING. There are also corner cases where we don't receive either
WM_SIZING or WM_MOVING in the modal loop, or receive both of them.

This CL adds an enum SizeMoveLoopState to track this state, so that we
can know whether the window is resizing or moving.

One alternative is to use WM_NCHITTEST to test whether the cursor is on
the window title bar (which implies moving the window) or window
borders/corners (which implies resizing) when WM_ENTERSIZEMOVE is
received. However, the user may also trigger resizing/moving from the
system menu (e.g. by right-clicking on the title bar and selecting it
from the drop down list), so this is not always reliable.

BUG=b:254702853
TEST=Tested in the Windows downstream

Change-Id: I8c8d97a7542b291c57dbddb75d785b324ff2776e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3975933
Commit-Queue: Pujun Lun <lunpujun@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-10-24 20:21:57 +00:00
Pujun Lun
f8a6c29e60 gpu_display: use the unicode version of WinAPI everywhere.
The Windows official doc suggests that, "New Windows applications
should use Unicode to avoid the inconsistencies of varied code
pages and for ease of localization".

BUG=b:254702853
TEST=Tested in the Windows downstream

Change-Id: I159263d21ff5e9900c4bb79fe17bd0aa3aedae0d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3971022
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Pujun Lun <lunpujun@google.com>
2022-10-21 18:01:48 +00:00
Pujun Lun
4331e432c5 gpu_display: add F1-F12 and numpad equal key to keycode translator.
BUG=b:254702853
TEST=Tested in the Windows downstream

Change-Id: I932bac772acee48179b3d793be0f129c9bfed79e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3969223
Commit-Queue: Pujun Lun <lunpujun@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-10-20 21:25:37 +00:00
Frederick Mayle
3d4b4809ba base: cross platform Event API
Trying to reconcile the difference between the linux and windows
implementations.

Code relying on the eventfd count must now use the linux specific
`EventExt` interface.

BUG=b:231344063
TEST=presubmits

Change-Id: I14eb50f7a02d766a00f27aca388823309633e193
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3864030
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
2022-10-19 20:17:42 +00:00
Pujun Lun
b849ebd0e1 crosvm: GPU and display arg parsing for Windows.
This replaces the handwritten arg parser with the serde_keyvalue
based parser. Eventually we will unify the arg parsing with Unix.

BUG=b:233676779
TEST=cargo b --features all-msvc64,gpu --no-default-features
TEST=cargo t -p vm_control --features all-msvc64,gpu
     --no-default-features
TEST=cargo t -p crosvm sys::windows::config::
     --features all-msvc64,gpu --no-default-features

Change-Id: I36a563be9767c7e5cbd3ab44f6a9ba23cd64cdb6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3939033
Commit-Queue: Pujun Lun <lunpujun@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-10-18 05:17:53 +00:00
Pujun Lun
3b2ecd9570 gpu: a few fixes for Windows build.
1. gpu_control_tube is not used on Windows yet. We will make use of
   it and test it in the downstream first before removing the Unix
   feature flag.
2. In Gpu::keep_rds(), skip appending descriptors of stdout and
   stderr since it is hard to find such descriptors on Windows, and
   this function won't be called on Windows anyways.
3. Some functions in gpu_display should be guarded with gfxstream
   feature flag, since we don't need to link against gfxstream
   binary when we are building/tesing without gfxstream.

BUG=b:213149288
TEST=presubmit

Change-Id: I28c3d16d82916e6d4a542aa008dd09015141716c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3947825
Commit-Queue: Pujun Lun <lunpujun@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-10-12 18:09:48 +00:00
Daniel Verkamp
b60140b37e tree-wide: use "crosvm" capitalization everywhere
Fix a few stray references to "CrosVM" and "CrosVm" so that we refer to
the crosvm project with consistent capitalization.

BUG=None
TEST=None

Change-Id: If5c3c131774d6e5da1d27466810642aec3cb42ac
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3938640
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-10-07 01:10:12 +00:00
Pujun Lun
90a22c35bb gpu_display: remove release_event_device().
This function has no call site so we might remove it to simplify
the code.

BUG=b:213150276
TEST=presubmit

Change-Id: I7c74c91de224cbccecd307c7774a15145d12433e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3930937
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Pujun Lun <lunpujun@google.com>
2022-10-04 22:01:28 +00:00
Pujun Lun
97a6a5fb31 gpu_display: use mpsc channels to avoid busy-waiting (2).
We were busy-waiting on atomic variables for the message loop
state of the WndProc thread. That is to make sure other threads
don't start posting messages to the WndProc thread until the
latter has created the message queue and is about to enter the
message loop. We can use mpsc channels instead. The WndProc
thread notifies other threads that it is ready by sending out its
thread ID.

BUG=b:243184256
TEST=tested in downstream

Change-Id: Ia2a675c083bb6aa9046dd9eab932a95fa06b8709
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3928133
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Pujun Lun <lunpujun@google.com>
2022-10-04 01:11:37 +00:00
Pujun Lun
203cef4216 gpu_display: use mpsc channels to avoid busy-waiting.
We were busy-waiting on atomic variables for surface creation
results. We can use mpsc channels to avoid that, which also
eliminates the need for enum CreateSurfaceResult since we just need
to send booleans.

BUG=b:243184256
TEST=tested in downstream

Change-Id: If4c39c797f9ca9edf3695e44689904066546759f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3928131
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Pujun Lun <lunpujun@google.com>
2022-10-04 01:10:19 +00:00
Pujun Lun
26d9803ccb gpu_display: sync with downstream code.
Notable changes:

1. Use "W" methods during window creation and message dispatching
   to ensure unicode characters are sent to the window.
2. In DisplayEventDispatcher::dispatch(), filter() and map() will
   be ignored if we don't call collect(). We replace map() with a
   for loop to make this clearer.

Other changes are due to linter/formatter warnings, etc.

Bug=b:213150276
TEST=cargo b -p gpu_display --features win64 --no-default-features

Change-Id: I767aec208d8afd7d7cb86039d08ba8ec8369da81
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3913991
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Pujun Lun <lunpujun@google.com>
2022-09-27 20:12:29 +00:00
Pujun Lun
b97f10ef0f gpu_display: upstream Windows implementation
On Windows, we have to create a GUI thread that creates the window and
retrieves window messages from the thread-specific message queue created
by the system. All host events, such as window resizing and mouse and
keyboard events, are sent in the form of window messages. Hence, we
created these structs/traits to model it:

- `Window`: Owns the handle of one window, and provides helper functions
  for operating on this window.
- `HandleWindowMessage`: A trait implemented by the struct that
  processes host events. In our case, that is the surface.
- `WindowMessageProcessor`: Holds one `Window` object and one
  `HandleWindowMessage` trait object. We only support one window for
  now. Once we support multi-windowing, there will be multiple
  processors.
- `WindowMessageDispatcher`: A singleton, responsible for dispatching
  messages retrieved from the message queue to the targeted processor.
- `WindowProcedureThread`: Wraps the GUI thread, retrieves messages from
  the message queue and forwards them to the dispatcher. It also
  provides helper functions for other threads to talk to the GUI thread.
- `MessageRelayThread`: Relays service messages to the GUI thread.

Main difference from other platforms: event devices are imported to the
GUI thread, since all host events are processed there.

BUG=b:213150276
TEST=presubmit

Change-Id: I0aabf6adf8a9ff4b24375e9c7df7625b6f761c7a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3834009
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Pujun Lun <lunpujun@google.com>
2022-09-16 17:36:57 +00:00
Daniel Verkamp
7c6d8bec3f health-check: enforce blank line after copyright
While we are tweaking all of the copyright headers, let's take the
opportunity to ensure there is always a blank line after the copyright
header for consistency. (Almost all files already follow this style.)

This includes a slightly ugly regex to allow the end of a C-style
comment block after the end of the copyright:

/*
 * Example comment block
 */   <-- this line

Change-Id: Idfd0855861e5ecb3d33afae942fdba908af0dcff
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3892521
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-09-13 22:24:35 +00:00
Dennis Kempin
1dab58a2cf Update all copyright headers to match new style
This search/replace updates all copyright notices to drop the
"All rights reserved", Use "ChromiumOS" instead of "Chromium OS"
and drops the trailing dots.

This fulfills the request from legal and unifies our notices.

./tools/health-check has been updated to only accept this style.

BUG=b:246579983
TEST=./tools/health-check

Change-Id: I87a80701dc651f1baf4820e5cc42469d7c5f5bf7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3894243
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-09-13 18:41:29 +00:00
Dennis Kempin
78f62a44e7 Update copyright header check to cover all files
generated files and a list of excluded files are skipped.
Others are fixed to include the missing header.

BUG=b:246579983
TEST=./tools/health-check --all copyright_header

Change-Id: I13e9bf79df18789f1ed4b83fc47c0c2e080d70a8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3894240
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-09-13 18:41:29 +00:00
Pujun Lun
e4d8e6685b gpu_display: fix Linux keycode for '`'.
BUG=b:213150276
TEST=presubmit

Change-Id: I92fad55467b1f740ec94cf1575573d47141b7c76
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3871958
Commit-Queue: Pujun Lun <lunpujun@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Pujun Lun <lunpujun@google.com>
2022-09-02 18:44:41 +00:00
Daniel Verkamp
583a2963d3 gpu_display: rework build.rs for cross compilation
The #[cfg(unix)] and #[cfg(windows)] checks in build.rs are testing
properties of the build system, not the target system, which is
inappropriate for cross compilation scenarios. This will matter when
cross compiling from Linux for Windows, as an example.

Use the appropriate Cargo environment variables to test target
properties instead:
https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts

BUG=None
TEST=cargo build
TEST=tools/run_tests --target=host --build-target=mingw64 --build-only

Change-Id: If1ac479ae519fe69168cead68b9ee44bac56f851
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3840955
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-08-19 22:43:07 +00:00
Dennis Kempin
7a4d4d6b2a health-check: Add check for newline at ends of files
Fixes a couple of files that were missing them.

BUG=b:242605601
TEST=./tools/health-check --fix

Change-Id: I620d6a939cb824e014002152584aacfc5dfdf7e8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3835648
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-08-18 00:17:04 +00:00
Pujun Lun
64880d13dc gpu_display: switch from UnixStream to StreamChannel.
Prefer the platform agnostic interface StreamChannel.

BUG=b:213150276
TEST=presubmit

Change-Id: I68e9b943cd18ec07ee06876c6f07a00e67b1ec9b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3829714
Tested-by: Pujun Lun <lunpujun@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Pujun Lun <lunpujun@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-08-12 20:55:34 +00:00
Noah Gold
256ac75f1f Revert "x display: ST event emulation for MT events"
This reverts commit d98f01af14.

NOTE: we are intentionally keeping the changes to use new tracking IDs
per contact, and the conversion of wayland to send MT events, as those
are not really part of the simulation change, and should be fine to keep.

Following discussion w/ drmasquatch@ offline re comments on the OCL, it
seems like there are other ways we could solve for the original
problem without introducing a simulation layer. Given the complexity
introduced and the fact that not all consumers necessarily want this
compat layer, a revert seems like the best step. Some options for fixing
the original problem in the future:

* Modify gpu_display_wl to produce ST events based on a CLI flag.
  This is pretty easy, and involves enhancing
  `--display-window-mouse` to take whether the events should be ST
  or MT, and then generating the ST events in the display backends
  as specified. The same flag also needs to create a ST device
  rather than a MT device so that the ST events will be accepted
  by the guest kernel.
* Modify the virtio-input kernel driver. This might be the right
  place to add a compat layer, if one is needed more broadly. It
  will also fix the problem everywhere.

Original CL: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3330723
TEST=builds
BUG=b:191173095

Change-Id: Iad07b6b5a06a3884dc352c49847b2b3c268ee5bd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3814100
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Noah Gold <nkgold@google.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-08-09 00:11:50 +00:00
Daniel Verkamp
600ad38ff8 Remove redundant {self} imports
- Remove trailing ::{self} on all use statements
- Remove any resulting single-level use statements (e.g. use libc;)
- Reformat with `tools/fmt --nightly`

BUG=b:239937122
TEST=tools/dev_container tools/presubmit --all

Change-Id: I8afd1b0458ca6d08d9b41a24583f7d4148597ccb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3798973
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-08-01 21:27:54 +00:00
Dennis Kempin
4fea399df9 Reformat imports
crosvm is switching the import style to use one import per line.
While more verbose, this will greatly reduce the occurence of merge
conflicts going forward.

Note: This is using a nightly feature of rustfmt. So it's a one-off
re-format only. We are considering adding a nightly toolchain to
enable the feature permanently.

BUG=b:239937122
TEST=CQ

Change-Id: Id2dd4dbdc0adfc4f8f3dd1d09da1daafa2a39992
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3784345
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-07-28 00:15:50 +00:00
Noah Gold
fdfc96bde6 gpu_display: clean up EventDevice buffer mgt.
The code to manage the EventDevice buffers was a little tricky to
follow. This CL refactors it.

BUG=b:239699447
TEST=builds. Tested downstream.

Change-Id: I979643ed82dc69544d2073d09f55a52a4cc3bb39
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3782777
Tested-by: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-07-22 20:58:23 +00:00
Noah Gold
5cbe496fde gpu_display: fix overflow in EventDevice
send_report used to panic if we tried to send more events than would fit
in the buffer. Now overflow is handled gracefully. We've also increased the
buffer size, which was previously quite tiny, so that we're less likely to drop
events if there is a flood of them.

BUG=b:239699447
TEST=builds. tested downstream.

Change-Id: Ie4b9d927bb75c6a3126de17e781d4a3e18551f7c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3780879
Commit-Queue: Noah Gold <nkgold@google.com>
Tested-by: Noah Gold <nkgold@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
2022-07-22 04:48:28 +00:00
Zihan Chen
e2f7c0c24b crosvm: Fix cross-compile in dev container
- Fix devcontainer.json to be used by vscode correctly
- Fix wayland-protocols path finding
- Add missing SYSROOT env for pkg_config
- Add missing linker settings

TEST=native/armv7/aarch64 targets compile in dev container

Change-Id: Id6fc43b2fd63d09bc46169d996387d5417ada93e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3766822
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-07-19 17:07:49 +00:00
Vikram Auradkar
32cabe0cd4 devices: enable tests
BUG=b:213149155
TEST=presubmit

Change-Id: Iff1a721dddfaed3e2728222a75348745be9ef05a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3710851
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-23 00:26:06 +00:00