This test is unrelated to vm_control; it is testing base::Event and
base::Tube functionality, so move it next to the existing Tube tests.
The test module was also in the middle of the file for some reason,
which caused clippy warnings in Rust 1.71.
Change-Id: I52858e71df8aa3e092b3b7d12e1232454b61c4d4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4684827
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Write the whole virtq_used_elem with one write_obj call instead of
writing id and len separately.
This reduces the number of GuestMemory lookups (and IOMMU translations
if IOMMU is in use).
BUG=None
TEST=
Change-Id: I7f9520b0057ffcaa9fa1c00f40c848e9d5423451
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4679852
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zihan Chen <zihanchen@google.com>
This is a partial revert of c244741015
data_init in ChromeOS is pinned to an old revision and p9 is not.
This makes is hard to make cross-crate changes between the two.
BUG=None
TEST=CQ
Change-Id: I5f7618e468ebe9655ccb432516e4166c2a11e61b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4684826
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Since the caller must pass a DescriptorChain now (rather than a raw
descriptor index), and DescriptorChain can only be constructed inside
the Queue implementation, it is not necessary to validate the queue
index in add_used(). Leave a debug-only check so that programming
mistakes can be caught in unit tests/fuzzers/... without negatively
impacting release build performance.
BUG=None
TEST=cargo build --release; observe SplitQueue::add_used asm
Change-Id: I69672758f63304c3ea59c0fc1c0780ef36fa4cdd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4679851
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
We know that self.size is >= 1, so subtracting 1 will never overflow.
Use wrapping_sub() to convince the compiler not to emit an overflow
check.
BUG=None
TEST=cargo build --release, check add_used() assembly
Change-Id: Ia7c933f5edf2a136dcd324ff8c9fca5c4f14ce8a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4679850
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zihan Chen <zihanchen@google.com>
GuestAddress::unchecked_add() previously used a normal + operator to add
the two values, which got converted into a checked addition even in
release mode due to our use of `overflow-checks = true`. Explicitly call
the wrapping_add() function instead to ensure we get the natural binary
integer behavior, which can be compiled into a simple add instruction
without any extra checks.
Additionally, mark the function as #[inline] - even though the function
body is quite small, in practice, I observed the compiler emitting a
call instead of simply inlining the single instruction (at least in
non-LTO release builds).
This probably has very little impact in practice, but it should slightly
improve codegen in some critical paths for virtio descriptor processing.
BUG=None
TEST=tools/dev_container tools/presubmit
TEST=cargo build --release and observe no call in SplitQueue::add_used
Change-Id: Idad5acccf56b4428f8db890576e37e470e61584d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4679849
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
The Le16/Le32/Le64 <-> u16/u32/u64 conversions should be no-ops on
little endian platforms, and even the big-endian conversions can be
efficiently implemented with a single byte-swap or MOVBE instruction in
most cases, so it should almost always be beneficial to inline the
conversion functions.
BUG=None
TEST=cargo build --release; view SplitQueue::add_used assembly
Change-Id: Ia028670e99f93754e729b3ff1fbdae2bcef74917
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4679848
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This is mainly for qcow2, which doesn't immediately write all mutations
to file. It is important that all writes be sent to the OS so that
snapshots taken while asleep do not lose information.
BUG=b:266514327
TEST=patched into AOSP and manually ran snapshot-restore flow
Change-Id: I2a9f24120d51fd053ff1440d0e1750e9bbebf379
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4679843
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Elie Kheirallah <khei@google.com>
This change fixes compiler errors that occur when building crosvm test
targets for riscv64 Android.
BUG=b:286142463
TEST=Copied patch to Android, built crosvm_test_src_main
Change-Id: I9729b084a0784c23133248752fdf41f8b8b3cee4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4682168
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Based on https://docs.kernel.org/arch/x86/boot.html#id1, this patch
adds a null GDT entry to match the Linux 64-bit Boot Protocol. With
this patch, CS is 0x10, DS, ES, and SS are 0x18.
Booted a bzImage and an ELF kernel, no issues observed.
TEST=cargo test -p x86_64
BUG=None
Change-Id: I234e9c43598fd5edb9d4e1b0fed1ba67f06a1845
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4680287
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Changyuan Lyu <changyuanl@google.com>
- The remaning DataInit are all left due to limitations of the
current stable version of zerocopy
- Only 5 files still use DataInit
- DataInit is marked as deprecated to prevent future introduction
- Other mentions of DataInit across the repository are cleaned up
TEST=CQ
BUG=b:204409584
FIXED=b:204409584
Change-Id: Id7126e58cff63eaa67138de429375382a3ffbc55
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4680289
Auto-Submit: Zihan Chen <zihanchen@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
VhostUserMsgHeader is a generic type and requires updated zerocopy
to be able to derive AsBytes. Everything else in this folder is
cleaned up.
TEST=CQ
BUG=b:204409584
Change-Id: Ic86dd577969cb79648898fa3071a262824faeef7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4679845
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Zihan Chen <zihanchen@google.com>
This change creates a new type (QueueConfig) that represents a queue
configuration before it has been activated. The QueueConfig::activate
function serves the same purpose as the previous Queue::activate, but
now it also returns the Queue type, which now always represents an
actively running queue.
BUG=b:290268617
TEST=tools/dev_container tools/presubmit
Change-Id: I502ac6b29bf9f0cfc33ef15f6fb7fe482214eafd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4111872
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Yuan Yao <yuanyaogoog@chromium.org>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
Devicetree bindings for restricted-dma-pool say that *either* "size" or
"reg" property should be used (but do not allow for both).
Each child node may either use a 'reg' property ... or a 'size'
property ...
Presently, "size" property is added even when fixed swiotlb region is
used. Apply the "size" property only when using dynamically allocated
swiotlb.
BUG=b:244630071
Fixes: 653f62a4a3 ("aarch64: static swiotlb allocation")
Change-Id: I1c88c9be043133e698e1da9072e5353ad7419e27
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4680283
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
Fixing small typo in command to install multiple packages. A comma is
required, and not a space.
BUG=N/A
TEST=mdbook build
Change-Id: I8a7032b3e767d1dc072cf593131f5cbddaf57ff8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4680286
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Elie Kheirallah <khei@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Elie Kheirallah <khei@google.com>
Previously this effort is blocked by VhostUserInflight having
different type layout (padding) on different bit length archs.
However, unlike i686, armv7 have same data layout and padding
as aarch64 and x86_64, so it's not an issue for our supported
architectures.
bitflags crate is upreved to 2.3.2. New version is already
vendored in cros cargo vet.
TEST=CQ
BUG=b:204409584
Change-Id: I51701550a4cf297dc739344d2895972a9c6f6cc6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4679841
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Zihan Chen <zihanchen@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Add snapshot restore to vsock device.
BUG=b:267691230
TEST=presubmit, e2e_tests
TEST=boot VM with vsock, snapshot, boot restored VM with vsock.
Change-Id: I3ae0c5e5099645f9a4ded6a751bb2df063c0b8e9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4610692
Commit-Queue: Elie Kheirallah <khei@google.com>
Reviewed-by: Richard Zhang <rizhang@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Use the concrete Interrupt type in its place, since Interrupt now works
for all virtio and vhost transports.
No functional change intended.
BUG=b:244204463
TEST=tools/dev_container tools/presubmit
Change-Id: Ie08c396b7eee997dfde7ae46a5ab7c728ba3584c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4639203
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
For a stable rutabaga API, we should do this.
BUG=b:273555494
TEST=./rutabaga_test
Change-Id: I4cbb35324cff6dd5c1fafc06d91a3826d659cff8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4673245
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Certain wayland protocols require clients to mmap shmem as PROT_READ
(such as zwp_linux_dmabuf_feedback_v1:event:format_table), but crosvm's
virtio-wl device always assumes PROT_READ | PROT_WRITE. Just mirror the
host fd's access mode to always get it right.
BUG=b:290125852
TEST=glxgears, vkcube, steam in VM
Change-Id: Iffbde2559a796098fa0655aeb1593f36588838cc
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4669514
Reviewed-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Ryan Neph <ryanneph@google.com>
This allows the tests to run on all executor kinds supported by the
generic io_source test harness (io_uring, epoll, and Windows handle).
readmulti is modified to write different data to each region so the test
can verify the correct part of the file is actually read.
fsync is removed since it is already covered by io_source's fsync test.
readwrite_current_file_position is split into two tests that validate
the async io_source behavior using normal non-async File operations
(read_current_file_position and write_current_file_position).
BUG=b:288967124
TEST=tools/dev_container tools/presubmit
Change-Id: I59ce8dd3934135499062fed4cb7e0f54bf446d09
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4655444
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Some examples in the book assume that packages are installed. One
example as such is `Vsock`, where there's an assumption that `ncat` is
installed.
Some examples provide a hint at how packages are installed, but it's not
explicitely formulated. And if you skip the examples page and go
directly to Vsock, you lack the information on how to install `ncat`.
Added more information in the Example Usage on how to install packages,
and added the virt-builder command in vsock.
BUG=N/A
TEST=mdbook build
Change-Id: Id5a07287458ce55538ccb8a9b387dfb4b512042f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4675702
Commit-Queue: Elie Kheirallah <khei@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
A forward declaration should be enough and not clash with other
self-defintions. Similiar to what gfxstream does.
BUG=b:273555494
TEST=compile
Change-Id: Ib5dae74f0590337977466f8e5921111db713517f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4673244
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Recent capset name changes have caused test to
fail. Fix this.
BUG=b:273555494
TEST=./rutabaga_test
Change-Id: I875f8a6350970f90ae127eaeb527f3264db54236
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4673243
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
We should do this.
BUG=b:273555494
TEST=./rutabaga_test
Change-Id: I8fc3a7d0bd3802df8c57e3b15eb0bb3fd1371366
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4673241
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Update crosvm_client_swap_disable_vm to the new argument format. The
temporary crosvm_client_swap_disable_vm2 function will be removed in a
followup change, after downstream clients stop using it.
BUG=None
TEST=None
Change-Id: Ice624eaaacec7910a00e09a4b6e94a0635ecf7dd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4664189
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>