Commit graph

183 commits

Author SHA1 Message Date
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
Maciek Swiech
eebc110fbf balloon: implement wss reporting virtio-balloon extensions
this patch implements the virtio-balloon extensions proposed in
go/roziere - namely adding the Working Set Size vqueues and listener on
the wss vqueue. in addition we add a crosvm_control command which allows
a user to request that the balloon device send a request to the driver
to produce a WSS report, similar to asking for balloon stats.

BUG=b:271757427,b:273212204
TEST=sidecar process, available at https://x20.corp.google.com/users/dr/drmasquatch/socket-pinger
TEST=deploy to DUT, restart termina and arcvm

Change-Id: I45753f523aae97d14bfc5dcbad5ddfcb70d10beb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4260158
Reviewed-by: T.J. Alumbaugh <talumbau@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Maciek Swiech <drmasquatch@google.com>
2023-04-05 22:23:04 +00:00
Junichi Uekawa
41cecab05d crosvm: Remove cros_asyncv2
We don't have the necessary dependency in Debian.

BUG=b:265082456
TEST=build

Change-Id: Ia6a38b0d9b5ce4e509a88f2b8e0790b605b47175
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4364560
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2023-04-05 02:07:07 +00:00
Daniel Verkamp
75d1fd7a8f audio_streams: remove unnecessary ref with cvars
The compiler already infers the correct types without the extra
&(ref ..., ref ...), so just drop them.

Fixes clippy lints in Rust 1.68.

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

Change-Id: I0947d653c80e7c7a5a561d2970ecae24a3700adf
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4390736
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-04 22:59:36 +00:00
Daniel Verkamp
10a487a725 tree-wide: replace manual enum Defaults with derive
This is supported since Rust 1.62.

Fixes the new derivable_impls clippy lint, added in Rust 1.67.

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

Change-Id: I3696dd3cf4acbf9b5a2cfa8c2046e7656e13dbbd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4390735
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-04 22:12:39 +00:00
Shintaro Kawamura
018e8caf99 swap: add trim command
"crosvm swap trim <socket_path>" command for trimming 2 types of pages
in the staging memory before swapping out to reduce the disk I/O.

* clean pages
* zero pages

The doc comment of TrimContext explains the page types.

BUG=b:265592787
TEST=cargo test -p swap

Change-Id: I5c33149f7d0bfd712f07fd11eb9aa07c1a8b0e7a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4357224
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
2023-03-29 01:22:02 +00:00
Daniel Verkamp
083dcf75f4 tree-wide: apply nightly rustfmt
BUG=None
TEST=tools/fmt --nightly

Change-Id: Ifb08dd55ccf2a74ef739d7517a64970d24a82405
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4375640
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-03-27 21:30:45 +00:00
Daniel Verkamp
cddc85e857 cros_asyncv2: use tempfile::tempdir in tests
Replace use of env::temp_dir() with tempfile::tempdir() to ensure each
test gets a unique temporary directory name. This avoids test failures
when running multiple tests simultaneously.

BUG=b:274145919
TEST=tools/dev_container tools/presubmit

Change-Id: Iac3a248d52830f3efafd8a954d1cc9633f71f301
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4350606
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-03-17 20:02:41 +00:00
Daniel Verkamp
7e803c87ca base: use SafeDescriptor in unix socket wrappers
The SafeDescriptor type manages the lifetime of the file descriptor,
which simplifies the socket wrappers (each wrapper no longer needs to
manually implement Drop to close the descriptor, for example).

Also remove unneeded RawFd-related functions, replacing them with
RawDescriptor and SafeDescriptor equivalents.

BUG=None
TEST=tools/dev_container tools/presubmit

Change-Id: I634a19922ec24d06071b21247c79761cfc21a79a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4322266
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2023-03-17 18:12:49 +00:00
Frederick Mayle
c842b3ee2d cros_async: block_on: simplify errno handling
Change-Id: I9971911239a0c2e1cc0bbebeabc687025d3c2212
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4328233
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-03-14 20:09:58 +00:00
Vaibhav Nagarnaik
fa557032b4 fix future incompatibilities
* upgrade `mio`to 0.8 to remove its dependency `ntapi`. `ntapi` 0.3 has
  future incompatibility warning.

Test: Compiled.
Change-Id: I59e0689ed526c5ea132669de406d7dde6c86c640
Signed-off-by: Vaibhav Nagarnaik <vnagarnaik@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4318426
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-03-08 21:57:36 +00:00
Judy Hsiao
8e1ea42363 audio_streams: Add latency_bytes to AsyncBufferCommit and BufferCommit trait
Add latency_bytes to the AsyncBufferCommit and the BufferCommit trait
to allow virtio sound device to report the audio latency from the
virtio_snd_pcm_status.

BUG=b:269989582
TEST=play Audio Video Sync Test video from the ARCVM youtube app.

Change-Id: I9415933ed1bd8e3b326fe2c5c73a835ed96dff02
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4273577
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
Auto-Submit: Judy Hsiao <judyhsiao@google.com>
2023-03-08 12:15:45 +00:00
Changyuan Lyu
ef810051cf virtio: vhost-user: Add --cfg to device fs command
Add flag `--cfg` to `crosvm device fs` command to change options
such as posix_acl.

Currently `crosvm device fs` uses hard-coded default config, which
enables posix_acl as default. If a host filesystem without POSIX ACL
support is shared to the guest though virtio-fs, `ls` command in the
guest will fail.

TEST=tools/presubmit
BUG=b:259728763

Change-Id: Ie98c097c74336ce4f756b0ee8541eecbd102d272
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3967441
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Changyuan Lyu <changyuanl@google.com>
2023-03-01 16:33:10 +00:00
Pattara Teerapong
77c0787de3 audio_streams: Implement Serialize and Deserialize for StreamEffect
This CL is to prepare for parsing virtio-snd parameters from cmdline
argument to StreamEffect with serde_keyvalue. Deserialize will be used
when parsing from cmdline. Serialize will be used when we store
StreamEffect inside Parameters struct as the whole struct must be
serializable.

BUG=b:269984052
TEST=cargo check

Change-Id: Ica2169f395f53a4884d407c07fedff16d13cbedd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4273570
Commit-Queue: Pattara Teerapong <pteerapong@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
2023-02-23 10:40:12 +00:00
Daniel Verkamp
0e06ebe15b data_model: fix IoBufMut references in comments
The standard library equivalent is called std::io::IoSliceMut, not
IoBufMut.

BUG=None
TEST=read it

Change-Id: I66956f403e762d84bd46b05e986415f319d5bcbf
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4262436
Commit-Queue: Zihan Chen <zihanchen@google.com>
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zihan Chen <zihanchen@google.com>
2023-02-22 19:36:07 +00:00
Zihan Chen
3c7ee29e9e crosvm: Convert DataInit to zerocopy (8/n)
TEST=CQ

BUG=b:204409584

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

TESTED=CQ

BUG=b:204409584

Change-Id: I1f8c2d5304fc8e685cc3e5166c73481f6a3f78f7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4235224
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-02-10 01:52:24 +00:00
Zihan Chen
7cfc97d736 virtio_sys: Update bindgen to derive zerocopy
With uprev-ed bindgen, we can now customize derive directly.

TEST=CQ

BUG=b:204409584

Change-Id: Iba96cdb8329e9254249b247af55e11974620087c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4234067
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2023-02-09 22:59:10 +00:00
Zihan Chen
8a7550c40a crosvm: Partially convert DataInit to zerocopy (1/n)
Thie effort is splitted into multiple CLs, to reduce change size
and also make bisecing breakages easier.

TESTED=CQ only

BUG=b:204409584

Change-Id: Ie90f171bd5f74b732df3129e94733f3b34621092
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4210751
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2023-02-02 19:28:57 +00:00
Daniel Verkamp
924f5a29ef data_model: Deprecate VolatileRef
This is a reland of commit d39e5811df

This change mark VolatileRef as deprecated instead of removing it
completely. This change also removed all related methods and functions
using VolatileRef that libcras don't use.

Original change's description:
> data_model: remove VolatileRef
>
> All uses except in test code have been eliminated, 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=None
> TEST=tools/presubmit --all
>
> Change-Id: I84f1e2487d6211ce24b8fc992fa7675765870132
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3824000
> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
> Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
> Reviewed-by: Alexandre Courbot <acourbot@chromium.org>

TESTED=CQ

BUG=b:204409584
FIXED=b:236759218

Change-Id: I4019870a2321fcd8610669862b5e6ed9bf7c2282
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4215512
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2023-02-01 23:40:54 +00:00
Gurchetan Singh
22a2dce38a crosvm: revbump for rutabaga_gfx
- Revbum to 0.1.1, 0.1.0-{anything} causes data_model
  0.1.0 to be downloaded since it's a higher release number.

- Also, add include LICENSE in the package includes for
  data_model.

- Also, use the correct version when not using path in rutabaga_gfx.

BUG=b:173630595
TEST=compile

Change-Id: I68af3eb1fa4ab89a77968f784e388b10c94d8b97
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4209693
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-02-01 23:22:03 +00:00
Daniel Verkamp
ac9b8d653c p9: handle Tframe body decode failure separately from header
If the header of an incoming message can be decoded, but the body of
that message is invalid in some way (such as a string containing byte
sequences that are not valid UTF-8), the server should respond by
sending the Rerror message rather than closing the whole connection.

If the header cannot be decoded (for example, if the specified size is
too small), it is not possible to resynchronize the byte stream, so the
connection will still be closed in this case.

BUG=b:243123191
TEST=(cd common/p9; cargo test)
TEST=touch /mnt/chromeos/MyFiles/Downloads/$'\351'

Change-Id: I5f10e357a9b1734497bc2d2d8b5de544f86604ae
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4182888
Reviewed-by: David Munro <davidmunro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2023-01-24 18:42:35 +00:00
Dennis Kempin
acc162000f Add conditional compilation for unix-only crates
Instead of configuring which crates to --exclude in
test_config.py, we can use conditional compilation to
exclude code that is not supported on windows.

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

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

Change-Id: I8422c3f08053bc27d9896b220876a56bd25543d6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4165868
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-01-19 21:21:59 +00:00
Dennis Kempin
a6e7d6f139 Enable compilation of fuzzing targets
Adds a fall-back to cros_fuzz when compiled without
fuzzing enabled that will just produce a main fn entrypoint
with the fuzzing code.
This allows the fuzzing code to be compiled, but won't produce
functional fuzzing binaries.

BUG=b:265829867
FIXES=b:244631591
TEST=crosvm CQ
cargo +nightly fuzz run --fuzz-dir crosvm-fuzz --features upstream-fuzz crosvm_block_fuzzer

Change-Id: Ib2602aab5c5373cb2a71dca0d8419640a00c6725
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4167143
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Zihan Chen <zihanchen@google.com>
2023-01-17 23:18:22 +00:00
Gurchetan Singh
a52694d88e crosvm: add licensing/description to alpha crates
crates.io requires:
    - descriptions
    - license or license-file.

in the manifest.  It doesn't seem the SPDX license
list includes the Chromium license, though it could
be added in the future.

https://github.com/spdx/license-list-XML/blob/main/DOCS/license-inclusion-principles.md

Though for now just copy the license to the specific crates.

(context: https://fxbug.dev/114169)

BUG=b:173630595
TEST=compile

Change-Id: I84676d2fe0200b18a23c85dec75c2a934353f507
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4082335
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-01-14 02:05:06 +00:00
Gurchetan Singh
32ec615426 crosvm: pre-release alpha for data_model
data_model is probably going away in the future, but
until we can release it as pre-release alpha for internal
efforts.

(context: https://fxbug.dev/114169)

BUG=b:173630595
TEST=compile

Change-Id: Ie13ec3ab9083d315c78a035b532132296a8fb651
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4082333
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-01-13 17:23:23 +00:00
Gurchetan Singh
a3596b6175 data_model: match Fuchsia releases of various crates
BUG=b:173630595
TEST=compile

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

BUG=None
TEST=tools/cargo-doc

Change-Id: I8c76aea2eb33b2e370ab71ee9b5cc0a4cfd00585
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4129934
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-01-03 22:14:30 +00:00
Pattara Teerapong
8162b4ab9e audio_streams: Add default implementation for wait_fd_readable
Add default implementation for wait_fd_readable to help with uprev
process with older package of cros_async.

BUG=b:258759773
TEST=emerge audio_streams

Change-Id: I494ac8615e4d73a0cceaf4c2e1beb6e04e9eedc6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4086627
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
2022-12-08 15:15:38 +00:00
Pattara Teerapong
a87d48c12f audio_streams,cros_async: Add async create stream methods
Add async_new_async_{playback,capture}_stream to StreamSource trait.
These methods are used to create new async playback or capture stream
asynchronously. Default implementation is to call their sync version.

cros_async: Add wait_fd_readable to AudioStreamsExecutor trait, this
will be used by libcras to implement the new async_new_async_*_stream
method.

BUG=b:258759773
TEST=emerge audio_streams cros_async
TEST=FEATURES=test emerge-amd64-generic audio_streams

Change-Id: I8dfc743eb8fa6552a1a6b2953b79666e2909e417
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4066242
Commit-Queue: Pattara Teerapong <pteerapong@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
2022-12-05 16:46:49 +00:00
Ronald G. Minnich
9b8fe9237a p9: Add readlink support to 9p
readlink support works in 9p. Symlinks will now stat and
read correctly. A unit test is added.

BUG=None
TEST=cargo test -p p9

Change-Id: If37e0e716535d17222fe67c013986720180b5cb2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4072744
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Ron Minnich <rminnich@google.com>
2022-12-01 20:51:00 +00:00
Daniel Verkamp
ef6fdc97f5 p9: use MaybeOwned to avoid extra clone in do_walk
When passing the initial path to the do_walk() function, we previously
always called try_clone(), which duplicates the file handle of the
starting path. However, in most cases, the walk will only use the
starting path to open the next file or directory in the chain, and then
the duplicated file descriptor would be immediately closed again.

To avoid this extra overhead, we can use the MaybeOwned type to pass in
a borrowed reference to the starting path and only clone it in the case
where the starting path is also the final path.

BUG=None
TEST=deploy 9s to device, `ls` shared directory, observe strace output

Change-Id: I15aabc850a3b8b72a9097294a35ab6babfcb0556
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3943529
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-12-01 18:47:48 +00:00
Daniel Verkamp
10990c89af Rust 1.65: Fix clippy derive_partial_eq_without_eq lints
BUG=b:260784028
TEST=tools/clippy

Change-Id: Ib2b595385ed04b9480b22549334ce798d980d347
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4064717
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-12-01 01:32:30 +00:00