This interprets the p_paddr field of ELF program headers as an offset
into physical RAM on aarch64 systems, which is a change in behavior. We
pass an offset of 0 on x86-64, so it makes no difference there.
BUG=b:254601048
BUG=b:255697205
TEST=cargo test -p kernel_loader
Change-Id: I9ebaa285c4cde1f70cb7752e91ff4520e06dc82f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4035738
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Everything has been migrated to argh and serde_keyvalue, so we can
remove the old argument parsing code now.
The parse_hex_or_decimal() function is still used in a few places in
config.rs, so move it there for now.
BUG=b:255223604
TEST=cargo build
Change-Id: Ic2d66a7fac7c3ff00b9521c56a719dd23883284b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4049038
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
This removes the last caller of parse_key_value_options().
BUG=b:255223604
TEST=cargo test
Change-Id: Ia17eb320094ee3d46f0db238f2077163e257b7f8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4049037
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
We need to keep stderr FD when spawning processes. Otherwise, log
messages won't be emitted to stderr.
This affects the cases where we spawn device processes such as:
* "crosvm run" without --disable-sandbox,
* virtiofs device, which create its own jail,
* "crosvm devices", which spawn sub processes
BUG=none
TEST=check log messages in virtio-{block,fs} are shown in stderr
Change-Id: If60845d73290a42c863e6c6f4e75869644f659d0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4054212
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Migrate the --stub-pci-device parameters to serde_keyvalue from
parse_key_value_options().
The deprecated `multifunction` option is dropped, as the only caller was
crosvm-direct.sh and it has since been fixed.
BUG=b:255223604
TEST=cargo test -p devices stub
TEST=Run crosvm with --stub-pci-device options; lspci
Change-Id: I3ed0cf52179020bcd1665540dc9bc9e66e17b85e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4049030
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
BufferMapping could previsouly hold a BufferHandle. Make it more generic
so that it can hold types that can convert themselves to a BufferHandle
instead.
This also simplifies the type considerably, as it only takes a single type
parameter instead of two.
BUG=b:214478588
TEST="cargo build --features=video-decoder,vaapi; Fluster still works"
Change-Id: Idcaf4d0a074609e3155daa596e262810149fe037
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4046944
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Move VaapiDecoderSession closer to its impl for tidiness. Also, if
BufferMapping - which is currently in the middle of them - is extended,
we do not want to widen this gap even further.
BUG=b:214478588
TEST="cargo build --features=video-decoder,vaapi"
Change-Id: I1045e04a313e5d7ee62b313f42923333192ac722
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4046943
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Now that serde_keyvalue is capable of parsing vectors and
sub-structs, we are making the following pattern the official way
of providing display parameters:
--gpu backend=3d,displays=[[mode=windowed[800,600]],\
[mode=borderless_full_screen]]
The reasons for this change are:
(1) We will likely use this syntax for other CLI options as well.
(2) We only support one single virtual GPU as of today, but
technically we could support multiple. When we add that
support, there is no ambiguity as to which display is connected
to which GPU with this syntax.
For backwards compatibility, we will preserve the following ways to
provide display parameters:
(1) --gpu width=800,height=600 (which implies windowed mode)
(2) --gpu-display mode=windowed,width=800,height=600 \
--gpu-display mode=borderless_full_screen
BUG=b:254284360
TEST=presubmit
Change-Id: I7f0078b7cf7554c1e93882afce47a4a2a3170a78
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3984545
Commit-Queue: Pujun Lun <lunpujun@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
The current syntax is:
--gpu-display horizontal-dpi=100,vertical-dpi=200
We would like to change that to:
--gpu-display dpi=[100,200]
We will keep the backward compatibility for now, but the caller
should not use both of syntax at the same time.
FixedGpuDisplayParameters is introduced for backward compatibility
support, and it will be removed once the old syntax is deprecated.
BUG=b:260101753
TEST=presubmit
Change-Id: I66a31c448ecc1eba60f6d1cbcbc753315c6c1df6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4049340
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Commit-Queue: Pujun Lun <lunpujun@google.com>
Recently, common_device.policy added clone3. It is included by most
devices through include, but the video device missed it since it doesn't
include common_device.policy due to some policy override.
This commit adds clone3 to the policy of the video device to fix that
problem. With this fix, the video device successfully runs in the
sandbox on newer kernels.
BUG=None
TEST=a vm with a video device launches with the sandbox enabled
Change-Id: Idc2dee824e863f3ee43cfd6ce76656e36d6200c0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4053447
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Takaya Saeki <takayas@chromium.org>
Document the format and rules for specifying command-line options, and
add a section on how configuration files can also be used.
BUG=b:218223240
TEST=mdbook build
Change-Id: Ieec40315b7ae8212c6a5b60280440abc9a5e92e6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4040820
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
To prepare adding more fixtures such as logic for vhost-user device,
move the existing code to create a VM to a separate module.
Specifically, move the all code in e2e_tests/tests/fixture/mod.rs into
e2e_tests/tests/fixture/vm.rs.
BUG=b:243127910
TEST=./e2e_tests/run
Change-Id: I23e6e5db35ce09b5003f37a9a44f9fda8f502809
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4028760
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
This will allow us to identify virtiofs threads in tracing tools such
as perfetto.
BUG=b:260038313
TEST=run arcvm
Change-Id: I198b599a3f710742fc549ab6ae376ad4cb661fc0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4045667
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Rename each virtio device's worker thread name to the form of
"v_{device type}".
e.g. "v_blk" for virtio-blk
This change allows us to embed more information in the thread names
whose length must not exceed 15. For example, we can embed ID for each
block device thread so we can distinguish threads in `ps` and tracing
tools.
BUG=b:260038313
TEST=CQ
Change-Id: I039421c46e9b28f2cb82f7fc644929ba325e895a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4045666
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
When vhost-user front-end send a vhost-user message via Unix domain
socket, a message header is sent first with optional attached files.
Then, a message body is sent as a separate packet if necessary.
However, the existing implementation blocks only before a
message header coming and assumed that the message body is ready when
the header comes. So, there was a race and `handle_request` could return
`EAGAIN`.
This CL splits SlaveReqHandler::handle_request() into recv_header() and
process_message() so a caller can wait between the header and the
additional payload.
On VVU, we shouldn't wait before receiving the payloads because the
proxy device forwards a header and its message body together. So we
check the protocol in needs_wait_for_payload().
BUG=b:237891754
TEST=Run vhost-user block on Linux
TEST=Run vhost-user block on Windows
TEST=Run VVU block on Linux
Change-Id: I35af3eb0e706cb005bf697397698e01e272b0704
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3863050
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
This is a shorter and more explicit name, and is also what qemu uses for
the same parameter.
Since this is a positional argument, it doesn't affect command-line
argument handling, only the (currently unused) configuration files.
BUG=b:255223604
TEST=None
Change-Id: Ice01335a690550e5afd05b93c6c968b0d0859f32
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4044726
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
The rule for crosvm options is that they should be specified in
kebab-case. Switch the disk options to that format, while also keeping
camel_case aliases for compatibility.
BUG=b:255223604
TEST=--block option works with both block-size and block_size
parameters.
TEST=cargo test -p devices block::tests::params_from_key_values
TEST=cargo test -p e2e_tests boot_test_vm
Change-Id: Ie095565ca4b27d59ed86ddc0613419e45749b3fa
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4040818
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Improve the comment on why a fence is necessary in the middle of
`Queue::peek` so that it gets clearer.
BUG=b:258630435
TEST=`./tools/dev_container ./tools/presubmit` passed
Change-Id: I63f80975e6d04665948a6036998e7ed6e24be64c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4045661
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
The documentation for the --net command-line option was not properly
formatting and had a few trailing words. Also add an OR keyword to
clarify that the keys are mutually exclusive.
BUG=b:255223604
TEST=crosvm run --help
Change-Id: Ib0980c3294828eeccf00e3609b21d829c5da9fb1
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4040819
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Handle the case where VM memory is split up into multiple regions by
taking into account the region end when swapping out memory. Also rename
SwapFile.len to SwapFile.num_pages to make the units clear.
BUG=b:215093219
TEST=cargo test --package base
TEST=enable/disable swap on VM with >4GB of memory
Change-Id: I8dcdadd39c3f7cbd22c1c042498153966a1a0431
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4040653
Commit-Queue: David Stevens <stevensd@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Shin Kawamura <kawasin@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Currently, `Queue::peek` does the following steps for reading and
checking `avail_index`. 1. Reads the current `avail_index` 2. Checks if
`avail_index` meets the condition to go further. 3. If so, read the
current the descriptor index. This works fine on x86. However, on Arm,
which has weak-memory model, the memory read for the third step could
happen before the memory read for the first step since there is no fence
between the first and the third steps. That causes reading a stale value
for the descriptor.
This commit adds a fence between them to fix potential race condition
bugs caused by reading stale descriptor values.
Note it is not fine to move the fence in `Queue::get_avail_index` from
the beginning of it to the end of `get_avail_index`. This is because all
other virtqueue access APIs such as `set_avail_event` also have fences
at the beginning of them. If you move the fence in `get_avail_index` to
the end of `get_avail_index`, the sequence of `set_avail_event` and then
`get_avail_index` loses a fence between them. Because this is a "write
-> read" operations, losing a fence between them causes memory order bug
in both x86 and arm. Thus, we add another fence in this commit instead.
BUG=b:258630435
TEST=`./tools/dev_container ./tools/presubmit` passed
Change-Id: I693f1bc511fcc6fc2f3b0d7739c318483992280f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4041909
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Commit-Queue: Takaya Saeki <takayas@chromium.org>
Brings up the Windows vhost-user GPU, when there is a vhost-user flag.
Otherwise, uses the original worker in the main process.
- Creates backend and VMM configs in broker.
- Always passes the VMM config to the main process.
- Passes backend config either to main or the vhost-user process.
- Create exit read / write event pair in broker, so GPU can request it
from its process (on Windows, when we close the rendering window).
BUG=b:243061269
TEST=downstream / presubmit
Change-Id: I373e59e936bc21580e7962942742750444807093
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3968458
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Idan Raiter <idanr@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
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>
These are not caught during presubmit or when running cargo clippy but
nonetheless exist and should be cleaned up.
BUG=b:157245930, crbug:908640
TEST=cargo build
Change-Id: I8b4d79bf224b800fbdfeaa7729c5f283d42908e9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4039522
Auto-Submit: Clarissa Garvey <clarissagarvey@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Now that the video-related options are stable, we can enable their
creation from the configuration file.
BUG=b:255223604
TEST=video decoders and encoders specified in the configuration file are
properly instantiated.
Change-Id: I57efb7ee984ac92f3a81f742dea814d56cce67c0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3974355
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Add `boot_test_vm_config_file`, which boots a VM similar to
`boot_test_vm`, but using a configuration file instead of command-line
options wherever possible.
BUG=b:218223240
TEST=cargo test -p e2e_tests boot_test_vm
Change-Id: I45f82bfa8201776081e18c50011d928d8c7be0f0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4022749
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
We currently have many different memory-related options. This does not
play well with the idea of having them in a configuration file, where
they would ideally be grouped under a single "mem" section.
Turn the `mem` option into a struct, which currently only has one member
specifying the desired RAM size. This makes the struct compatible with
the existing argument (since the first argument of a struct does not
need to be explicitly mentioned), which allowing us to extend the struct
with more options in the future.
This allows us to enable the `mem` option in configuration files.
BUG=b:255223604
TEST=cargo test parse_mem_opts
Change-Id: I24c324002e4e399e5be492bbc9ddcac7fd2b349e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4033213
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
We currently have many different CPU-related options. This does not play
well with the idea of having them in a configuration file, where they
would ideally be grouped under a single "cpus" section.
Turn the `cpus` option into a struct, which currently only has one
member specifying the number of cores we want. This makes the struct
compatible with the existing argument (since the first argument of a
struct does not need to be explicitly mentioned), which allowing us to
extend the struct with more options in the future.
This allows us to enable the `cpus` option in configuration files.
BUG=b:255223604
TEST=cargo test parse_cpu_opts
Change-Id: I1bc856a935be4774926dcba8b0714f5835feeed9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4033212
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
This is needed to build the `devices` crate only for the windows target.
BUG=none
TEST=cargo test --target=x86_64-pc-windows-gnu --features=slirp in devices
Change-Id: I781def962a716e4ee2ea80f3c6d1a426fc92e2e8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4028759
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
libvda uses libmojo which uses libbase-core.so from libchrome.
After a recent change, libase-core.so's EarlyFeatureAccessTracker tracks
early accesses to features and saves the stacks of the callers using
libunwind. On aarch64, libunwind can use process_vm_readv.
BUG=b:259631550
TEST=autologin.py -a on trogdor
Change-Id: I40b432eea72993a8a000b5aadf856a376f954835
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4034854
Commit-Queue: Chia-I Wu <olv@google.com>
Auto-Submit: Chia-I Wu <olv@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
These tests work correctly on Windows as well, so remove the check that
made them only run on Linux.
BUG=b:238361778
TEST=tools/dev_container tools/run_tests --platform=mingw64
Change-Id: I775cfe66f3324aee3b83c9deeb93a019f4b07296
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4032428
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
When userspace batch frees many buffers, it can end up starving waiting
for virtqueue slots to free up. The reason is this involves sending
many small cmd messages to host (DETACH_RESOURCE, UNMAP_BLOB, and
RESOURCE_UNREF), which despite being small each consume one slot. This
starvation leads to janks / fps-stutters.
(I have some WIP perfetto support to monitor # of free slots in ctrl
queue, and based on that 512 seems to be enough to avoid starvation. We
can always increase it more later if we find a scenario where 512 isn't
enough for everyone.)
BUG=b:230582047
TEST=play grimvalor recording perfetto trace
Change-Id: I5348c619bca7a3b629020e11415a7cac53212cba
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4038124
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Auto-Submit: Rob Clark <robdclark@chromium.org>
Commit-Queue: Rob Clark <robdclark@chromium.org>
Interrupt now supports Clone at crrev.com/c/3858693. Arc is no longer
needed.
BUG=b:244204463
TEST=tools/presubmit --all
Change-Id: Ieacfc0970da5f5727ec9324d6585edbdb785bc98
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4037077
Auto-Submit: Shin Kawamura <kawasin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>