Commit graph

81 commits

Author SHA1 Message Date
Daniel Verkamp
7cf3dcacbf Fix clippy::suspicious_open_options warnings
Use .create_new() rather than .create() for cases where we always want
to ensure that the file does not already exist, and add .truncate(false)
for a case where we do want to open an existing file and don't want to
overwrite it.

BUG=b:344974550
TEST=tools/clippy

Change-Id: Ie82a6db306532c600c140efab3d310b6c7cf25a7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5604660
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2024-06-10 19:39:47 +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
58a06581bc base: linux: remove pipe() close_on_exec argument
Every caller passes `true`. If a hypothetical future caller wants pipe
descriptors that are not O_CLOEXEC, then they can use `pipe()` plus
`clear_descriptor_cloexec()`.

BUG=None
TEST=tools/dev_container tools/presubmit

Change-Id: If9aa62653e00a163824157819ddd2fce849fe348
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5251099
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2024-02-01 19:33:27 +00:00
Daniel Verkamp
c970dd44f4 bindgen: update to Linux 6.6 headers
The obsolete KVM_SET_MEMORY_ALIAS ioctl was removed from the kernel; it
was already unused in crosvm, so remove the corresponding ioctl macro.

Change-Id: I1ecfce4b8df886680154c567f82ab7f006fbfd1f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5178535
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2024-01-09 00:37:43 +00:00
Daniel Verkamp
ae33ac2934 bindgen: regenerate all bindings with bindgen 0.68.1
This removes some auto-generated safety comments, but should otherwise
be a no-op.

Change-Id: Ibfcf75c6e296367fe1a6114ce2047fb79e34041b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5178534
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2024-01-09 00:37:43 +00:00
Daniel Verkamp
5d343a3613 io_uring: update io_uring_buf flex array bindings
The kernel UAPI changed from a zero-length array to a flexible array in
<https://lore.kernel.org/r/20230105190507.gonna.131-kees@kernel.org>

Change-Id: Ib84ca00597e10a7a4e8b1ee15b518a835d84cdb9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5178533
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2024-01-09 00:37:43 +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
d362e2ea56 Fix new clippy 1.72 unnecessary_cast warnings
Remove pointer casts where the target type is the same as the original.

Change-Id: Ibb7bda2e4afcb5df2cd7c0bd9a075d0288b69f67
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5005512
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-11-06 19:16:18 +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
Daniel Verkamp
931fcafe0b bindgen: regenerate bindings with bindgen 0.68.1
In particular, this fixes the Clone impl for __BindgenUnionField, which
triggers clippy's incorrect_clone_impl_on_copy_type in Rust 1.73.

Additionally, --size_t-is-usize became the default and the option was
removed in bindgen 0.65.0, so the flag is dropped from our bindgen
command line.

BUG=None
TEST=tools/bindgen-all-the-things

Change-Id: I40a26cd4a9e2897af8a354f454f4909429d2feda
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4927831
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-10-10 22:54:22 +00:00
David Stevens
31bdcfbe7a io_uring: update submission metadata after EINTR
When io_uring_enter returns EINTR, the operations were properly
submitted to the kernel, so we need to properly update crosvm's data
structures to reflect this fact.

BUG=None
TEST=repeatedly strace crosvm doing heavy block IO w/iouring

Change-Id: I0984713fd6be41a460ce6e2e9bf92e736e53c2e3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4532325
Auto-Submit: David Stevens <stevensd@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2023-06-08 05:42:59 +00:00
Takaya Saeki
6bf5d2b6b4 io_uring: refactor prep_next_sqe to remove an argument no longer used
uring::SubmitQueue has pre-allocated io_vecs field inside it, and
prep_next_sqe provides a caller with an io_vec so that the caller
doesn't have to allocate an io_vec by itself. This used to be used by
add_rw_op before. However, no caller uses this given io_vec, but they
allocate io_vec by themselves.

This change removes io_vecs from the arguments of prep_next_sqe, and
refactor SubmitQueue structure to make it simpler.

BUG=None
TEST=cargo test -p io_uring. A vm launches by crosvm run
--async-executor uring...

Change-Id: I07bb2f496d3a2e4ca038a4dd861dd80b87ba41ef
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4546822
Commit-Queue: Takaya Saeki <takayas@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-05-19 01:34:54 +00:00
Takaya Saeki
fb6487f90f io_uring: make tests more DAMP
Refactor some tests so that they become more DAMP style by expanding
unnecessary extra utiltiy function.

BUG=None
TEST=cargo test -p io_uring

Change-Id: I9c0850ac8cf0e5cd4b11c94048c5c5be3a7085ee
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4546821
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Takaya Saeki <takayas@chromium.org>
2023-05-19 01:28:35 +00:00
Takaya Saeki
e8766a6f60 io_uring: test only methods that are actually used and remove add_rw_op
Currently, a lot of io_uring tests are tesing `add_read`, `add_write`,
and `add_rw_op`, but these methods are actually never used except by
those tests themselves. So, these methods and their tests are no longer
necessary.

This change removes these methods and tests only for them, turning
`add_read` and `add_write` intto utility functions for testing.

BUG=None
TEST=cargo test -p io_uring

Change-Id: I2d58afa826d5f09d7b3b5cdbcab798f26d617c23
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4546820
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Takaya Saeki <takayas@chromium.org>
2023-05-19 01:26:09 +00:00
Daniel Verkamp
88d5f4fee7 io_uring: remove stats, in_flight, and completed info
These statistics are updated but never read. Remove them to avoid some
extra atomic operations in the critical path.

BUG=None
TEST=tools/dev_container tools/presubmit
TEST=cargo test -p io_uring -- --include-ignored

Change-Id: Iad28e28b8d617862c4d5a089aba30dde773d6c31
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4541760
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2023-05-18 20:02:42 +00:00
Dennis Kempin
bbb6a24d51 tools/presubmit: Add doctests
Adds an invocation to run doctests to the health_checks builder.

To make this not run by default on every `tools/presubmit`
invocation, this CL splits default_health_checks out of the
health_checks group.

BUG=b:242635135
TEST=tools/presubmit health_checks

Change-Id: Ic850c461eb79e81c4b8118fc3182614fac907569
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4476090
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2023-04-26 00:09:33 +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
Daniel Verkamp
2712fc59b1 bindgen: update kernel bindings to Linux 6.1
Switch to the ChromeOS v6.1 branch and regenerate all affected bindings
in the crosvm tree.

Some minor fixes were required in users of the bindings:
- KVM_SYSTEM_EVENT_RESET_FLAG_PSCI_RESET2 is available in the kernel now
  and was removed from the manually-added section of kvm_sys.
- The KVM system_event now contains an anonymous union, requiring a few
  renames.
- IORING_OP_* were moved into an enum, which required the enum name to
  be prefixed to the uses of those values.

BUG=None
TEST=tools/presubmit --all

Change-Id: I84568fb76658832130e2e9a631495ba82fd4c3ed
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4285742
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-02-23 21:31:44 +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
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
Daniel Verkamp
a506de7ee6 Reformat with nightly rustfmt
BUG=None
TEST=tools/fmt --nightly

Change-Id: I7c74b9190bf28e3d7e3ac4401a2b79800a9e4b76
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4087003
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-12-07 19:33:09 +00:00
Takaya Saeki
266724ea60 io_uring: restrict io_uring operations that can be sumitted
io_uring allows you to submit a lot of file operations. Those operations
have corresponding syscalls, but bypass the seccomp filter since they
are submitted by single syscall. To address this security hole, the
IORING_REGISTER_RESTRICTIONS can be used to apply an allow-list of
operations to a given io_uring queue.

This commit introduces `IORING_REGISTER_RESTRICTIONS` support for
`URingContext`, and has URingExecutor apply a basic allow-list to the
UringContexts that it creates. This basic allow-list is limited to
operations allowed by common_device.policy plus fsync and fallocate.

However, note that this commit is only one step for the effective jail
of io_uring. Since `IORING_REGISTER_RESTRICTIONS` is applicable only
per-queue, a compromised device process can still easily bypass this
restriction just by creating another io_uring queue. The effective jail
is completed with coming changes that allow executor creation only
before jailing.

This commit also updates the policy file with `io_uring_register`.

BUG=b:251039942
TEST=`cargo test -p io_uring` passed
TEST=`crosvm run --disable-sandbox --async-executor uring ...` booted
TEST=`crosvm run --async-executor uring ...` with the jail booted on x86
TEST=`cargo build` succeded on aarch64.
TEST=`cargo check` succeded on armv7.

Change-Id: I6e024f240eaf9fb6ce16f1a3d46b7f923a5f5169
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4071824
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Takaya Saeki <takayas@chromium.org>
2022-12-07 02:02:16 +00:00
Daniel Verkamp
11a94b98a8 crosvm bindgen: regenerate with missing_safety_doc
Regenerate all of the automated bindgen bindings by running
tools/bindgen-all-the-things after commit 54311a8da9 ("crosvm bindgen:
Allow missing_safety_doc").

BUG=b:157245930
BUG=chromium:908640
TEST=tools/presubmit --all

Change-Id: I334f2ddc071acbf634f0d771d88650ee348cd5a0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4025271
Reviewed-by: Zihan Chen <zihanchen@google.com>
Reviewed-by: Clarissa Garvey <clarissagarvey@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-11-15 20:43:50 +00:00
Dennis Kempin
a59403eb93 io_uring: Move tests into integration test
These tests make use of the io_uring features of the linux kernel,
which may not be available in all test environments.

This passes locally, but won't be run in CI due to the lack of
io_uring support on our builders.

BUG=b:244623067
TEST=tools/run_tests

Change-Id: Iff017dc24708c7f607f3d4e05d019701e5672b97
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4018112
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-11-09 20:45:59 +00:00
Frederick Mayle
ef70f71256 cros_async: fix io at current file pos for io_uring
The `ReadAsync` and `WriteAsync` traits accept file offsets as an
`Option<u64>`. The epoll executor interprets `None` as "current file
position" and the io_uring executor interprets `None` as position zero.
This change updates the io_uring executor in favor of the epoll executor
behavior.

It is important to differentiate between position zero and "current file
position" when you don't know whether a file is seekable. For example,
console and serial devices should support both types of files as input.

BUG=b:243198718
TEST=presubmit --all

Change-Id: I01634e6bbdff352c0a6055419d0fafd10c0c40a6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3841945
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Steven Moreland <smoreland@google.com>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
2022-09-30 20:32:02 +00:00
Daniel Verkamp
74f1ca4e78 bindgen: update bindings to Linux 5.15
This requires a few tweaks to non-generated code:
- VIRTIO_ID_VIDEO_ENC/DEC -> ENCODER/DECODER
- io_uring unnamed union layout change

Change-Id: I58e118efa5c6bf28ff56d211fec5603651cb60bc
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3893753
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-09-14 22:09:30 +00:00
Daniel Verkamp
7c6d8bec3f health-check: enforce blank line after copyright
While we are tweaking all of the copyright headers, let's take the
opportunity to ensure there is always a blank line after the copyright
header for consistency. (Almost all files already follow this style.)

This includes a slightly ugly regex to allow the end of a C-style
comment block after the end of the copyright:

/*
 * Example comment block
 */   <-- this line

Change-Id: Idfd0855861e5ecb3d33afae942fdba908af0dcff
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3892521
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-09-13 22:24:35 +00:00
Dennis Kempin
1dab58a2cf Update all copyright headers to match new style
This search/replace updates all copyright notices to drop the
"All rights reserved", Use "ChromiumOS" instead of "Chromium OS"
and drops the trailing dots.

This fulfills the request from legal and unifies our notices.

./tools/health-check has been updated to only accept this style.

BUG=b:246579983
TEST=./tools/health-check

Change-Id: I87a80701dc651f1baf4820e5cc42469d7c5f5bf7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3894243
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-09-13 18:41:29 +00:00
David Stevens
b2b11c32e5 io_uring: handle EINTR
Handle EINTR returned from io_uring_enter. This fixes an issue where
trying to strace an io_uring enabled device would cause the device to
exit.

BUG=None
TEST=attach strace to io_uring enabled crosvm

Change-Id: I2e808a51c3274b98f1caa18dbedd3164f2bd6aef
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3881686
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
2022-09-09 00:47:56 +00:00
Daniel Verkamp
b74d8df552 io_uring: use unsigned_abs() for isize -> usize
Fixes a new clippy lint:
<https://rust-lang.github.io/rust-clippy/master/index.html#cast_abs_to_unsigned>

We still need the cast to u32, since the other parts of the expression are
u32.

BUG=b:243677117
TEST=tools/clippy # with Rust 1.62

Change-Id: Ifb6176f310f3cc7377410c251142a0f062a1ddd4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3854969
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-09-01 18:46:40 +00:00
Dennis Kempin
4fea399df9 Reformat imports
crosvm is switching the import style to use one import per line.
While more verbose, this will greatly reduce the occurence of merge
conflicts going forward.

Note: This is using a nightly feature of rustfmt. So it's a one-off
re-format only. We are considering adding a nightly toolchain to
enable the feature permanently.

BUG=b:239937122
TEST=CQ

Change-Id: Id2dd4dbdc0adfc4f8f3dd1d09da1daafa2a39992
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3784345
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-07-28 00:15:50 +00:00
Daniel Verkamp
f0f10c4209 base: remove WatchingEvents in favor of EventType
Migrate the last few users of WatchingEvents to the equivalent EventType
values so we can remove the unix-specific WatchingEvents type.

BUG=b:213153157
TEST=cargo build

Change-Id: I215127309591125c4c64ff2963e7d2b8e1914cf3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3687057
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
2022-06-06 17:07:33 +00:00
Daniel Verkamp
e3d9206dc9 io_uring: expand poll_events to 32 bits
The original poll_events field in io_uring_sqe was 16 bits wide, but it
was later extended to 32 bits to allow the use of all epoll flags.

Technically, we should check for the IORING_FEAT_POLL_32BITS feature,
but the new poll32_events union member was added in Linux commit
5769a351b89c ("io_uring: change the poll type to be 32-bits"), which was
included in Linux 5.9, so we can assume this is available for all
io_uring-enabled kernels due to our baseline version of 5.10.

BUG=None
TEST=cargo test -p io_uring

Change-Id: I5a6266f24ba53a1826b40c91c281527481e99c8a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3687056
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-06 17:07:32 +00:00
Daniel Verkamp
45b0920767 doc: add a top-level comment to all crates
This provides at least a minimal one-line description to show what each
crate is about.

BUG=None
TEST=tools/cargo-doc

Change-Id: I26732e8c29062e622d5be09bdc120a49d564b9fd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3630422
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-06 20:46:57 +00:00
Anton Romanov
f94281434b crosvm:cros_async:uring: Implement async operation cancellation
BUG=None
TEST=presubmit

Change-Id: I8d0bd6109e8230f953ee736a805677609f5c434d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3628241
Auto-Submit: Anton Romanov <romanton@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-06 00:13:38 +00:00
Vikram Auradkar
95707cfa9c io_uring: use WaitContext
BUG=b:213153157
TEST=presubmit

Change-Id: I5875151109f391fbd217269c864abe7d32b7b92e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3626209
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-05 16:59:04 +00:00
Vikram Auradkar
d0e5b6ae83 base: export PollContext as EventContext
EventContext is a platform independent name.

BUG=b:213153157
TEST=presubmit

Change-Id: Ib0f51fabb622a4ff0b0678768cee8f0e1ab9bba0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3625896
Commit-Queue: Noah Gold <nkgold@google.com>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
2022-05-03 21:23:12 +00:00
Dennis Kempin
1def2e61d9 reland: Remove temporarily duplicated code from codebase
This removes sys_util(_core), which moved into base::unix/common, as
well as common/(cros_async,io_uring), which moved into the root
directory.

The only reason the code was still around is that they were still
used in the ChromeOS codebase.
ChromeOS has pinned the version of crosvm it uses for these libraries
so we can go ahead and remove the code.

A few remaining references to sys_util have been updated to base.

BUG=b:227226222,b:229016539
TEST=presubmit

Change-Id: I7a711044de7e067b217287f2bac822d6ac7d3964
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3593852
Reviewed-by: Allen Webb <allenwebb@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-04-19 21:48:29 +00:00
Dennis Kempin
66be807115 Revert "Remove temporarily duplicated code from codebase"
This reverts commit aac461e25e.

Reason for revert: Breaks audio_streams portage build

Original change's description:
> Remove temporarily duplicated code from codebase
>
> This removes sys_util(_core), which moved into base::unix/common, as
> well as common/(cros_async,io_uring), which moved into the root
> directory.
>
> The only reason the code was still around is that they were still
> used in the ChromeOS codebase.
> ChromeOS has pinned the version of crosvm it uses for these libraries
> so we can go ahead and remove the code.
>
> A few remaining references to sys_util have been updated to base.
>
> BUG=b:227226222,b:229016539
> TEST=presubmit
>
> Change-Id: I35a3d1f0ea28182b77abf9b423fcab4cad525981
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3580118
> Reviewed-by: Allen Webb <allenwebb@google.com>
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Dennis Kempin <denniskempin@google.com>

Bug: b:227226222,b:229016539
Change-Id: I907279ab47718355cd57915830580929dc157f84
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3593846
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Maciek Swiech <drmasquatch@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-04-19 18:24:13 +00:00
Dennis Kempin
aac461e25e Remove temporarily duplicated code from codebase
This removes sys_util(_core), which moved into base::unix/common, as
well as common/(cros_async,io_uring), which moved into the root
directory.

The only reason the code was still around is that they were still
used in the ChromeOS codebase.
ChromeOS has pinned the version of crosvm it uses for these libraries
so we can go ahead and remove the code.

A few remaining references to sys_util have been updated to base.

BUG=b:227226222,b:229016539
TEST=presubmit

Change-Id: I35a3d1f0ea28182b77abf9b423fcab4cad525981
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3580118
Reviewed-by: Allen Webb <allenwebb@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-04-18 18:35:07 +00:00
Daniel Verkamp
fa0ffe7e81 base: accept AsRawDescriptor in PollContext/EpollContext/mmap
This lets us remove the wrap_descriptor() calls.

A few other places around the tree need to be updated to use Descriptor
instead of RawFd to match the new API.

BUG=None
TEST=tools/presubmit

Change-Id: Ie290f082b50bcf6ae8f77ce6a8b7615fad1be480
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3572770
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-04-11 20:27:06 +00:00
Junichi Uekawa
33af75be29 crosvm: Bump version number.
There are two copies of io_uring and cros_async that are slightly
different. Bump the version number of new one.

BUG=None
TEST=cargo build

Change-Id: I7f82d3c5f01633bef7d0ce14ab777bbb50d4fbd5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3565625
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-04-08 01:04:50 +00:00
Daniel Verkamp
7df6c2ee05 io_uring: fix bindgen path after crate move
The io_uring crate is now at the top level instead of inside common, so
fix the path to bindgen-common.sh.

BUG=None
TEST=tools/bindgen-all-the-things

Fixes: 0928f91f98 ("Refactoring: Copy common/io_uring to io_uring")
Change-Id: I788f46ff64372cf615c8a0c59bb493eff7dc7967
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3570176
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-04-06 17:37:53 +00:00
Dennis Kempin
4fa9b5147c Refactoring script: Copy sys_util(_core) to base
This will allow us to merge sys_util and win_sys_util.
The original source locations will remain until they
are moved into the ChromeOS source base.

See go/future-of-sys-util for details

BUG=b:22320646
TEST=run it

Change-Id: Ie1adcadba9d35f18cc7472dc78f05262114a726f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3536890
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-03-21 19:52:56 +00:00
Dennis Kempin
4d53d5683d Refactoring: Make io_uring use base instead of sys_util
sys_util will go away in the crosvm world, but base exports
the same symboles.

BUG=b:22320646
TEST=presubmit

Change-Id: Ibacba5821f7e9b734e58b21ffa376ee23db36d59
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3534503
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-03-21 19:52:56 +00:00
Dennis Kempin
0928f91f98 Refactoring: Copy common/io_uring to io_uring
This applies the script from https://crrev.com/c/3534501

BUG=b:22320646
TEST=presubmit

Change-Id: Ib0c5bdb55df2098930fb1c65e9bd59288c44f357
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3534502
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-03-21 19:52:56 +00:00
Dennis Kempin
8a1c50d5cd Refactoring: Move various general purpose crates to common/
This change contains the results of running

./tools/contib/cargo_refactor.py

This will break the next uprev, and needs to be synchronizized
with the corresponding ebuild changes in https://crrev.com/c/3248925

BUG=b:195126527
TEST=./tools/run_tests

Change-Id: Ied15a1841887bb8f59fba65b912b81acf69beb73
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3248129
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-29 22:31:43 +00:00
Daniel Verkamp
7fd815ed22 crosvm: switch to upstream tempfile crate
Use the crates.io implementation of tempfile instead of our own version.

Our reimplementation is kept in the tree for now in case of dependencies
outside of the crosvm tree; it can be removed later once those are fully
switched over to the crates.io implementation.

BUG=b:199204746
TEST=emerge-hatch crosvm

Change-Id: I07d3404239302ab9a17f4ddc82a9479b256e4eb4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3209839
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-10-11 18:35:55 +00:00
Daniel Verkamp
793b4703cf io_uring: convert to ThisError and sort
BUG=b:197143586
TEST=cargo check

Cq-Depend: chromium:3105310
Change-Id: I661c65e095d0a8274a68ff44d70a65bce21970f5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105080
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-09-02 21:00:22 +00:00