Use zerocopy functions directly instead. This is a step toward replacing
our data_model crate with standard crates.io functionality where
possible.
BUG=b:312312646
TEST=tools/dev_container tools/presubmit
Change-Id: I9717edce6fe2b4ca53ad9043db61de2e9bc55b78
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5046345
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
This is a new display path for creating vulkan-based surfaces.
Test: build
Change-Id: I28e3b455ed265b615c4f8fe7c6ac28e2da81ec2e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5214569
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
The standard library versions of these functions have been const since
Rust 1.63. Make our sync wrappers match.
Change-Id: I63ec097aa9fbb63735528827576f08ced2304a16
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5318701
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
There don't appear to be any new clippy warnings, and this is the
version of Rust that Android is now using: b/303252546. Work for the
next version is tracked in b/310977762.
This doesn't have any particular features I'm looking for (async traits
only come in 1.75.0). I'm not particularly attached to this change. If
it's easy to upgrade the container though, we could ensure no new clippy
warnings appear.
Android rust versions appear here:
https://cs.android.com/android/platform/superproject/main/+/main:prebuilts/rust/linux-x86/
Also not sure what the ChromeOS release schedule is.
Release docs: https://releases.rs/docs/1.73.0/
Test: tools/dev_container --clean bash -c "rustc --version && tools/presubmit clippy"
Change-Id: I2d3010c3032053709f0c0beb7dcbe2b80d782415
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5201659
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Test the alignment and size in a regular unit test to avoid the external
crate dependency.
BUG=b:312312646
TEST=(cd common/data_model; cargo test)
Change-Id: Ieb7da8108b09603f2342e904ede3a41eea5b9860
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5046606
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
IoBuf is defined in a platform-specific way (it is either iovec on unix
or WSABUF for windows), so it fits into the mission statement of the
base crate, which is meant to be *the* platform abstraction layer in
crosvm.
IoBufMut and VolatileMemory/VolatileSlice are defined in terms of IoBuf,
so they are also moved into base for consistency. Every crate that uses
these types already depended on base, so no extra dependencies are
added, and a few can be removed.
BUG=b:312312646
TEST=tools/dev_container tools/presubmit
Change-Id: I4dddc55d46906dfc55b88e8e6a967d7e1c1922dd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5046605
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Use the default AudioStreamsExecutor::wait_fd_readable implementation
instead, which just returns Ok(()).
Fixes a build error when trying to run clippy with Rust 1.72, which
seems to be related to the async_trait usage.
BUG=None
TEST=cd common/audio_streams; cargo test
Change-Id: I415cff6e7dbd2fdfee43693a04f8ce74da3eeb7a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5005516
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Rather than using MaybeUninit to create a zeroed instance of a type and
std::slice::from_raw_parts_mut() to get a mutable &[u8] referring to it,
we can use the zerocopy 0.7 FromZeroes trait new_zeroed() function and
the AsBytes + FromBytes as_bytes_mut() function to read from the reader
into the type as a mutable &[u8].
This removes all of the unsafe code in the zerocopy_from_reader()
function.
BUG=None
TEST=tools/dev_container tools/presubmit
Change-Id: I76b12b69b02e807a3e52ac9b9e7e7165ee1f55f4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4939612
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
The type T is not necessarily Clone, so we can't use a normal
Vec::resize(), but Vec::resize_with() works since it accepts a function
to initialize each element. This is equivalent to the loop we currently
have while being more concise.
Change-Id: I074a98e24e8c619d639fe2ecb7a0eedc3823f8b5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4929754
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Updates are made to source and documentation.
This more accurately represents the currently supported platforms of
Android/Linux and Windows, without unexpectedly including other
unix-like operating systems.
Command to reproduce:
$ find . -type f -not -path '*/\.git/*' | xargs -I {} sed -i 's/cfg(unix)/cfg(any(target_os = "android", target_os = "linux"))/g' {}
$ cargo fmt
md files manually updated to fix line lengths.
Renaming `unix` modules to `linux` will be done in a later CL.
Test: ./tools/dev_container ./tools/presubmit
Bug: b/298269162
Change-Id: I42c1bf0abf80b9a0df25551613910293217c7295
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4909059
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
DataInit type is finally completely eliminated from crosvm. No
traces, not even in comments, were left.
BUG=b:300969352
BUG=b:204409584
Change-Id: I79742f8e06b90afd53fab338d9052b25ae0af84e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4878508
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
zerocopy 0.7.x has finally released as a stable version, uprev it
to allow some remaining structs to be derivable.
TEST=CQ
BUG=b:300969352
FIXED=b:300969352
Change-Id: I90f0dfb09494f875fef1cd11bfcbd48030846092
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4878761
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Zihan Chen <zihanchen@google.com>
Previously all of the zerocopy imports just used "*", but there are
API changes in zerocopy 0.7, so ensure we get a compatible version by
depending on 0.6 everywhere.
This is a no-op since Cargo.lock already specifies a 0.6.x version, but
it will prevent accidentally upgrading to 0.7.x without updating to the
new API.
BUG=b:301283548
TEST=cargo build
Change-Id: Ifd702d982a09b5083dddd666dc6f3052cba22214
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4878502
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This reverts commit 1eb1106537.
Reason for revert: headers generated by cbindgen do not compile as expected downstream
Original change's description:
> balloon: rename WSS to WS
>
> as the working set feature approaches acceptance at the spec-level, we
> are keeping up with nomenclature changes.
>
> BUG=b/288432539
> TEST=cargo build, cargo build --no-default-features, cargo build --features registered_events
>
> Change-Id: I323a2c5402cb8008f8c912b0849e8e3501f9e1f3
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4702340
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Commit-Queue: maciek swiech <drmasquatch@google.com>
BUG=b/288432539
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: I46459b4afd428c67436a754b3e62a104a680c68f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4722468
Commit-Queue: maciek swiech <drmasquatch@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
as the working set feature approaches acceptance at the spec-level, we
are keeping up with nomenclature changes.
BUG=b/288432539
TEST=cargo build, cargo build --no-default-features, cargo build --features registered_events
Change-Id: I323a2c5402cb8008f8c912b0849e8e3501f9e1f3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4702340
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: maciek swiech <drmasquatch@google.com>
Instead of synchronously waiting for balloon stat responses in the
control loop, add the balloon tube to the wait context and handle the
responses asynchronously. This allows us to get rid of the 100ms timeout
on stat requests, which in turn means we can get rid of the id field in
stat/wss messages because there are no longer "stale" requests.
The fact that balloon stat requests will no longer timeout may require
that clients handle timeouts themselves, instead of relying on a
hardcoded timeout in the crosvm implementation. This adds a new function
to crosvm_control to allow getting the balloon stats with a timeout.
BUG=b:259503518
TEST=test run DUT multivm.*
TEST=cargo test -p vm_control
Change-Id: I89c72d13e28527e432041de53cf8eda25f630bea
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4651166
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
For bazel migration we will require lib entry points to be in their
standard location at src/lib.rs
BUG=b:289258700
TEST=CQ
Change-Id: Iab3f934ee61c8fbbd346525628c22106a0a88b7e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4691362
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@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>
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>
- 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>
the BalloonWssConfigFfi struct was missing a #[repr(C)]
annotation, causing the generated header file to not include the struct
definition. this patch also removes a couple unneeded constants.
BUG=None
TEST=built crosvm_control, checked generated header
Change-Id: Ic02c2145d16143257f5096d4811a4012bb827d69
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4607224
Reviewed-by: T.J. Alumbaugh <talumbau@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: maciek swiech <drmasquatch@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
for ease of initial implementation the number of WSS bins was hard-coded
to 4, however the WSS spec and kernel driver permit any number of bins
between 2-16. this patchset introduces a crosvm run flag which allows to
override the default 4 bins.
the protobuf-encoded WSS report will scale the number of bins correctly
in the return value, however the C crosvm_control_* API will always use
an array of 16 buckets, with a `num_bins` parameter that indicates how
many of them are actually valid. this has been done to preserve safety
across the ffi boundary.
this patchset also removes the sending of an initial WSS config. the
coordinating program (e.g. concierge et al.) is responsible for sending
the config to the guest after boot via the crosvm_control_* API. this is
largely due to the fact there may be various desirable configs for
varying scenarios and it does not make sense to have a baked-in default
config anymore.
BUG=b/278118696
TEST=https://x20.corp.google.com/users/dr/drmasquatch/socket-pinger-variable-bins
Change-Id: Ifaef2933a13a59d8d2580b5a9e283568fe6e86cf
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4577421
Commit-Queue: maciek swiech <drmasquatch@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reland CL:3824000 since libcras removed its usage in CL:4574167.
All test uses have been eliminated in CL:4215512, so we can remove it now.
This was an unsafe abstraction, and we have better alternatives (such as
the read_obj()/write_obj() functions) that do not create a long-lived
mutable reference that could easily alias other slices.
BUG=b:284938484
TEST=cargo test common/data_model/Cargo.toml
Change-Id: I552f22895ae651d6f8ce55d00f20e2950d050db9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4569901
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
The Windows version of IoBuf uses the WSABUF structure, which represents
len as a 32-bit value. Previously, larger len values would be silently
truncated; this change makes those conversions using try_into() instead.
We have no easy way to report failure of this usize -> u32 conversion,
so for now, just unwrap() to cause a panic if the length ever overflows
so it will at least produce a crash report and be noticed.
A possible future enhancement could be to make all relevant IoBuf and
IoBufMut functions return Result<...> so the error could be propagated
back to the caller.
BUG=None
TEST=tools/dev_container tools/presubmit
Change-Id: I79270a7e8af01827ef0d1bafaa98c5d7f4b53b73
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4567110
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Most of the IoBufMut code is generic and doesn't need to be implemented
for each platform. Factor out the sys-specific parts into a new trait,
PlatformIoBuf, that contains the minimal accessor functions for getting
and setting address and length.
BUG=None
TEST=tools/dev_container tools/presubmit
Change-Id: If647dd268f8ccdb8ecba2dcf5b12711363a32c69
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4559526
Reviewed-by: Zihan Chen <zihanchen@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
We no longer need to share cros-fuzz with ChromeOS. So we can
consolidate our fuzzing code and reorganize it to work well
with `cargo fuzz`.
BUG=b:279217867
TEST=cargo +nightly fuzz build --fuzz-dir=crosvm-fuzz -O
Change-Id: I75653961c6cbf251af9e54f894d6f20ea1218b53
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4539922
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This allows it to run on oss-fuzz as well.
BUG=b:279217867
TEST=cargo +nightly fuzz run --fuzz-dir=crosvm-fuzz -O
--features upstream-fuzz crosvm_p9_tframe_fuzzer
Change-Id: Id0d24901d454967a94c4b7487916cb805e205450
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4539920
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
The previous maximum size was 64K minus 1 byte; this also did not leave
room for the request/response header, so the actual maximum transfer
size in a single request was slightly smaller.
Use 64K + 24 bytes, since this matches the P9_IOHDRSZ subtraction used
by the Linux 9p client to calculate the maximum I/O size.
BUG=b:265610073
TEST=strace 9s on host and verify larger read()/write() syscalls
Change-Id: Ia606222d3c52a7a6e3f6cfca1a9fcbd78e223855
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4455812
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
The iounit value is meant to be an upper limit on the size of each I/O
sent by the client: <https://9p.io/magic/man2html/2/iounit>
Previously, we used the stat() st_blksize value for iounit; this caused
the Linux 9p client to split up every read/write request into 4096-byte
chunks in the usual case of an ext4 host filesystem, which causes very
low performance.
Report iounit=0 instead, which will allow the client to send Tread and
Twrite requests up to the negotiated msize (maximum message size).
BUG=b:265610073
TEST=strace 9s on host and verify larger read()/write() syscalls
Change-Id: I86341998f440ac1c567da7d8fc6e740189ccb44a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4455811
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
balloon size is useful for balloon policies using working set size, so
we return the balloon-device cached balloon size. unless there is some
error in adjustement of the balloon, this should reflect that real
balloon size and saves having to query the guest an additional time.
BUG=b/278119213
TEST=run bzImage
Change-Id: I7c6b558358b8db099a737430e8431997bb110b2b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4428532
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: T.J. Alumbaugh <talumbau@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Maciek Swiech <drmasquatch@google.com>
this patch adds the crosvm_control command (and internal implementation)
to send a new WSS config command to a guest balloon driver. included is
a refactor of how wss op notifications are dispatched in the balloon
device.
BUG=b/271891148
TEST=run bzImage
TEST=socket-pinger program available at https://x20.corp.google.com/users/dr/drmasquatch/socket-pinger
Change-Id: Id9696b0e82b3ba54d87cd0928070c55da9a77d1f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4415596
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Maciek Swiech <drmasquatch@google.com>
for wss, s/intervals/config, add new field to track bytes for ANON and
PAGE memory.
BUG=b:271757427, b:273212204
TEST=crosvm run bzImage
Cq-Depend: 4404310
Change-Id: I62696135d1e3af9219ba819f112a1ed128e39600
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4405307
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Maciek Swiech <drmasquatch@google.com>