Commit graph

215 commits

Author SHA1 Message Date
Daniel Verkamp
742791deef tree-wide: replace data_model::zerocopy_from_*()
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>
2024-03-13 18:03:24 +00:00
Kaiyi Li
7fbd71e5bf gpu_display: new vulkan display
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>
2024-03-04 23:14:40 +00:00
Daniel Verkamp
7b3f8df17e sync: Mutex and Condvar new() are const now
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>
2024-02-23 19:38:57 +00:00
A. Cody Schuffelen
ecc0206af8 Upgrade rust to 1.73.0
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>
2024-02-20 19:11:51 +00:00
Kaiyi Li
c28067d1d9 Reformat comments
Test: presubmit
Change-Id: I39c261d9985989873b698213c5d8b653fc13757b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5299850
Auto-Submit: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2024-02-15 23:30:13 +00:00
Daniel Verkamp
c1342035e9 data_model: remove static_assertions dependency
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>
2024-01-03 00:54:44 +00:00
Vikram Auradkar
2768f223ee clippy: enforce safety block comments
BUG=b:316174930
TEST=none

Change-Id: I5c7811b2c548155aa003e4b71a54bbc16e2f2588
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5120567
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-12-14 18:21:54 +00:00
Daniel Verkamp
fcc28f5573 data_model: move IoBuf and VolatileMemory to base
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>
2023-11-27 21:42:49 +00:00
Daniel Verkamp
c54a59e75b data_model: use vec! to initialize zero-filled vector
<https://rust-lang.github.io/rust-clippy/master/index.html#slow_vector_initialization>

Change-Id: I525a01d49420ddbb1707bc33e27d2c50bee94fa2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5005520
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-11-06 22:42:31 +00:00
Daniel Verkamp
2ca1a16b3f audio_streams: drop wait_fd_readable in test executor
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>
2023-11-06 21:31:40 +00:00
A. Cody Schuffelen
a97ada3cdd Restore unix on audio_streams
Test: cargo build -p audio_streams --target=aarch64-apple-darwin
Change-Id: I50666bedc333d6ed0906da629b80b559e49584c9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4997934
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
2023-11-02 20:08:01 +00:00
A. Cody Schuffelen
8db9bdc247 Restore data_model's linux to unix.
Test: cargo build -p data_model --target aarch64-apple-darwin
Change-Id: Ifeca4b24cbca549c8033d9c4768fb63a79b1ef57
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4997933
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
2023-11-02 19:51:40 +00:00
Daniel Verkamp
13505b2b9e data_model: eliminate unsafe code in zerocopy_from_reader()
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>
2023-10-16 17:49:03 +00:00
Daniel Verkamp
18bdbdf574 data_model: replace loop with Vec::resize_with()
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>
2023-10-11 20:54:27 +00:00
A. Cody Schuffelen
4748c54b95 Rename "unix" to "linux" in code and docs
$ for DIR in $(find . -name "unix"); do mv $DIR $(echo $DIR | sed "s/unix/linux/"); done
$ for FILE in $(find . -name "unix.rs"); do mv $FILE $(echo $FILE | sed "s/unix/linux/"); done
$ find . -type f -not -path '*/\.git/*' | xargs -I {} sed -E -i "s/mod unix/mod linux/g" {}
$ find . -type f -not -path '*/\.git/*' -not -path '*/third_party/perfetto/*' | xargs -I {} sed -E -i "s/([^o][^s])::unix/\1::linux/g" {}
$ find . -type f -not -path '*/\.git/*' | xargs -I {} sed -E -i "s/use unix::/use linux::/g" {}
$ find . -type f -not -path '*/\.git/*' -not -path '*/third_party/perfetto/*' | xargs -I {} sed -E -i "s/sys::unix/sys::linux/g" {}
$ find . -type f -not -path '*/\.git/*' | xargs -I {} sed -E -i "s/use unix as platform/use linux as platform/g" {}

Test: ./tools/dev_container ./tools/presubmit
Bug: b/298269162
Change-Id: I2c8acb14d77a5588dab4eae124f4a9afbb9025f5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4909060
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2023-10-11 01:15:07 +00:00
A. Cody Schuffelen
97dff044f8 Replace #[cfg(unix)] with #[cfg(any(target_os = "android", target_os = "linux"))]
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>
2023-10-11 00:43:29 +00:00
Zihan Chen
a5e63d4474 crosvm: Remove DataInit
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>
2023-10-10 19:40:48 +00:00
Zihan Chen
cbba480ebe crosvm: Uprev zerocopy to 0.7.x
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>
2023-10-10 17:34:32 +00:00
Daniel Verkamp
03dd1feab7 Cargo.toml: depend on zerocopy 0.6 explicitly
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>
2023-09-20 21:28:58 +00:00
Elie Kheirallah
3b9d6cd83c devices: virtio-snd: add snapshot/restore to common_backend
Add snapshot/restore to common backend.
Restore streams and acked features.
Check avail_features and queue_sizes match.

BUG=b:297770176
TEST=presubmit

Change-Id: I91b10fc7742d9c71ddceeef6247c1b54cab0ca23
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4814940
Reviewed-by: Richard Zhang <rizhang@google.com>
Commit-Queue: Elie Kheirallah <khei@google.com>
2023-08-30 21:01:47 +00:00
Dennis Kempin
accbf3b693 Replace internal p9 with crates.io versio
The code is being moved to https://github.com/google/rust-p9 and published via crates.io

BUG=b:293164618
TEST=presubmit

Change-Id: Iee96cdff8bae6f9ae4faa59dfc80d2132ed31822
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4735191
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-08-14 18:34:51 +00:00
Judy Hsiao
72b1801216 devices: pci: remove AC97 codes
Remove the AC97 codes on crosvm as it's replaced by virtio-snd

BUG=b:281092802
BUG=b:237681055
TEST=./tools/run_tests

Change-Id: Id7390930c355f7bcfe19f5e62bd678c31f79551e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4747399
Reviewed-by: Richard Zhang <rizhang@google.com>
Reviewed-by: Jorge Moreira Broche <jemoreira@google.com>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Judy Hsiao <judyhsiao@google.com>
Auto-Submit: Judy Hsiao <judyhsiao@google.com>
2023-08-11 03:29:31 +00:00
maciek swiech
98ad43515a balloon: change intervals and thresholds to u32
kernel stores these values as u32 isntead of u64, so to prevent needless
casting change to use the same type in crosvm's balloon device.

BUG=b/285581266
TEST=cargo build && cargo build --no-default-features && cargo build --features registered_events
TEST=cargo build -p crosvm_control --features registered_events
TEST=cros_sdk emerge-volteer crosvm && cros_sdk emerge-volteer vm_host_tools

Change-Id: I7672063851f5044b1adf39042ee3b98b478829ed
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4724907
Commit-Queue: maciek swiech <drmasquatch@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-08-09 19:31:25 +00:00
maciek swiech
32f8711cf7 Reland "Reland "balloon: rename WSS to WS""
This reverts commit 2aea504a65.

Reason for revert: missed run-time flag migration, fixed this time around and tested more thoroughly

BUG=b/288432539
TEST=cargo build, cargo build --no-default-features, cargo build --features registered_events
TEST=patch in to chromeos; emerge-volteer crosvm && emerge-volteer vm_host_tools
TEST=cros deploy && restart vm_concierge on DUT
TEST=cros deploy && vmc start borealis && (borealis) DISPLAY=:0 steam

Original change's description:
> Revert "Reland "balloon: rename WSS to WS""
>
> This reverts commit cf1c3cd755.
>
> Reason for revert: The command line change will break existing
> usage of the CLI flag
>
> Original change's description:
> > Reland "balloon: rename WSS to WS"
> >
> > This reverts commit 94dc10b57c.
> >
> > Reason for revert: relanding changes with fully implemented types
> >
> > BUG=b/288432539
> > TEST=cargo build, cargo build --no-default-features, cargo build --features registered_events
> > TEST=patch in to chromeos; emerge-volteer crosvm && emerge-volteer vm_host_tools
> >
> > Original change's description:
> > > Revert "balloon: rename WSS to WS"
> > >
> > > 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>
> >
> > BUG=b/288432539
> >
> > Change-Id: Ifb78acf2914b96306a2d1104e21eff6e67ed45df
> > Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4722288
> > Commit-Queue: maciek swiech <drmasquatch@google.com>
> > Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
>
> BUG=b/288432539
>
> Change-Id: I3bcb26699fd1d15eab594143490f863941d3eceb
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4730438
> Commit-Queue: Dennis Kempin <denniskempin@google.com>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>

BUG=b/288432539

Change-Id: I657f648aec0fc4f4551cf3c109c5ecedcdddbcb2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4733877
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: maciek swiech <drmasquatch@google.com>
2023-08-01 20:26:39 +00:00
Dennis Kempin
2aea504a65 Revert "Reland "balloon: rename WSS to WS""
This reverts commit cf1c3cd755.

Reason for revert: The command line change will break existing
usage of the CLI flag

Original change's description:
> Reland "balloon: rename WSS to WS"
>
> This reverts commit 94dc10b57c.
>
> Reason for revert: relanding changes with fully implemented types
>
> BUG=b/288432539
> TEST=cargo build, cargo build --no-default-features, cargo build --features registered_events
> TEST=patch in to chromeos; emerge-volteer crosvm && emerge-volteer vm_host_tools
>
> Original change's description:
> > Revert "balloon: rename WSS to WS"
> >
> > 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>
>
> BUG=b/288432539
>
> Change-Id: Ifb78acf2914b96306a2d1104e21eff6e67ed45df
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4722288
> Commit-Queue: maciek swiech <drmasquatch@google.com>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>

BUG=b/288432539

Change-Id: I3bcb26699fd1d15eab594143490f863941d3eceb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4730438
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-07-28 22:34:54 +00:00
maciek swiech
cf1c3cd755 Reland "balloon: rename WSS to WS"
This reverts commit 94dc10b57c.

Reason for revert: relanding changes with fully implemented types

BUG=b/288432539
TEST=cargo build, cargo build --no-default-features, cargo build --features registered_events
TEST=patch in to chromeos; emerge-volteer crosvm && emerge-volteer vm_host_tools

Original change's description:
> Revert "balloon: rename WSS to WS"
>
> 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>

BUG=b/288432539

Change-Id: Ifb78acf2914b96306a2d1104e21eff6e67ed45df
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4722288
Commit-Queue: maciek swiech <drmasquatch@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-07-26 21:48:44 +00:00
maciek swiech
94dc10b57c Revert "balloon: rename WSS to WS"
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>
2023-07-26 19:55:38 +00:00
maciek swiech
1eb1106537 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>
2023-07-25 21:27:03 +00:00
David Stevens
326afd881e balloon: don't wait for replies in the control loop
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>
2023-07-21 08:03:38 +00:00
Dennis Kempin
b2bc9e866a wire_format_derive: Move entry point to standard location
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>
2023-07-17 18:47:33 +00:00
Daniel Verkamp
ce5a78e83b clippy fixes for Rust 1.70 and 1.71
Change-Id: If86c6cd531b854293a93208de5254664f5ee6bec
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4637612
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-07-13 20:29:05 +00:00
Dennis Kempin
d9fa331cea Partial revert: crosvm: Deprecate DataInit
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>
2023-07-13 19:07:08 +00:00
Daniel Verkamp
800f2bec5f data_model: inline endian conversions
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>
2023-07-12 23:10:51 +00:00
Zihan Chen
c244741015 crosvm: Deprecate DataInit
- 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>
2023-07-12 21:34:20 +00:00
maciek swiech
5fea452007 balloon: missing #[repr(C)]
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>
2023-06-13 18:05:33 +00:00
maciek swiech
d1612ed53c balloon: permit variable number of WSS bins
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>
2023-06-05 19:47:09 +00:00
Chih-Yang Hsia
0087934ac7 data_model: Reland remove VolatileRef
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>
2023-05-30 18:00:51 +00:00
Daniel Verkamp
d3c28cc3c1 data_model: windows: panic if IoBuf len is too large
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>
2023-05-25 23:26:57 +00:00
Daniel Verkamp
dbf07144e2 data_model: deduplicate IoBufMut sys code
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>
2023-05-25 21:09:58 +00:00
Vikram Auradkar
f054575a8b clippy: Disallow len_without_is_empty and len_zero
BUG=b:283512997
TEST=none

Change-Id: I0477583b3f8c8eefeb1d79f11302b1b28a8bd770
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4549999
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2023-05-22 21:27:21 +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
Dennis Kempin
92dfea4131 fuzz: Move cros-fuzz into crosvm-fuzz
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>
2023-05-16 20:43:37 +00:00
Dennis Kempin
a72f3c4dd2 fuzz: Move p9/fuzz into crosvm-fuzz
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>
2023-05-16 20:43:37 +00:00
Junichi Uekawa
5e6d272282 crosvm: Remove unneeded cros_asyncv2 directory.
For some reason Cargo.lock remained.

BUG=b:265082456
TEST=build

Change-Id: I06605907ff220b5e4aac3d88151a99a4defb6fe8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4505421
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2023-05-08 07:22:23 +00:00
Daniel Verkamp
e7c26c37ed p9: account for header in maximum message size
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>
2023-04-24 19:25:36 +00:00
Daniel Verkamp
de92350a06 p9: report iounit as 0 in create/open
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>
2023-04-24 19:22:05 +00:00
Daniel Verkamp
2c1d17fe41 tree-wide: remove unnecessary casts
Fixes clippy lint in Rust 1.68

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

Change-Id: Ib9d83b8dc15a93e815600391e93b8bb1788f7dc4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4391107
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-17 23:43:59 +00:00
Maciek Swiech
f4c5cd8e42 balloon: return balloon_actual with wss
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>
2023-04-17 21:32:23 +00:00
Maciek Swiech
86df65f6d2 balloon: working set size config command
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>
2023-04-11 19:36:14 +00:00
Maciek Swiech
61bf707120 balloon: bring into WSS spec compliance
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>
2023-04-07 20:39:08 +00:00