These macros are no longer necessary, as we can replace them with const
fn implementations instead.
BUG=None
TEST=tools/dev_container tools/presubmit
Change-Id: If64cfa8fe08f113ead7236d11bb5a8b0fd51c290
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4484512
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
system_api bindings have been regenerated with protobuf 3.2; this should
be okay to land before the full ChromeOS system_api migration, since
crosvm always uses its own copy of the bindings rather than the ones
provided by the dev-rust/system_api package.
The protoc-rust crate is replaced with protobuf_codegen in 3.x.
BUG=b:277243607
BUG=b:279834784
TEST=tools/dev_container tools/presubmit
Change-Id: I6aad45ded2639d7506a7238800584bebab196455
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4405309
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Some type parameters in <> were being mis-parsed as HTML tags.
BUG=b:276487055
TEST=tools/cargo-doc # with rust 1.68.2
Change-Id: Iaa9ec6cf94a6084cfdf323bb04c643396a320889
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4485758
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Add cast to support Android. Libc Android has different types for some
variables than Libc Linux. This leads to casts required. Added skips on
clippy for these casts as they would be redundant on a platform while
required on another.
The same change is also applied to fuse:.
BUG=N/A
Test=presubmit
Change-Id: I994af922cf3ccc56438f2642fef9af91f6af5118
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4485518
Commit-Queue: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Both single and multi process did not have realtime priority, due to us
dropping the multimedia trick handle in set_audio_thread_priority where
we should be holding it until the thread is finished.
BUG=b:276698085
TEST=Process explorer -> properties -> threads -> base priority
increases from 8 to 24
Change-Id: Ia9199f4816e087046b8718e85c60abc9479ec0f3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4416757
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Idan Raiter <idanr@google.com>
Some `as usize` casts are necessary on non-glibc C libraries, since the
type of `cmsg_len` and `msg_controllen` may not be usize in the libc
bindings, so these warnings are suppressed instead of removing the
casts.
BUG=b:276487055
TEST=tools/clippy # with Rust 1.68
Change-Id: I30d9a16d37710b1356cffc183a03f8c8f6f35680
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4391102
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Add method to deserialize sequences to arrays in custom serde.
This allows for a simpler conversation, avoiding more code for each
conversation, while bypassing the serde limitation on array deserialization
of sizes larger than 32.
BUG=N/A
TEST=tools/presubmit
Change-Id: I89e4d7599cdde2c9781117f2a8e53fc9c50aa909
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4385874
Reviewed-by: Frederick Mayle <fmayle@google.com>
Auto-Submit: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Elie Kheirallah <khei@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Uprev to version available in Debian.
This seem to end up doing uprev to 1.3 now.
BUG=b:265082456
BUG=b:229895468
TEST=build
Change-Id: I550778acb675c9034b9cfcea77f4ae847e2d2ea1
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4364559
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
The volatile_impl! and volatile_at_impl! macros were only used to
implement the traits for the File type, and they don't make sense for
any other type on Win32 anyway, so it is simpler to replace the macro
invocations with the actual implementation.
BUG=b:263815124
TEST=tools/run_tests --platform=mingw64
Change-Id: I695fdfdefa87fe267927ae15dc914a55b779021f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4126569
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
"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>
Add snapshot to vCPU for x86 and x86_64 arch.
BUG=b:266515147
BUG=b:232437513
Test=crosvm run && crosvm snapshot take img_name socket
Change-Id: I65d059a7537c713e9ef6c1456a7aeae2b6bc4728
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4237759
Auto-Submit: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Elie Kheirallah <khei@google.com>
Pre-populating page cache improves the latency of swap-in which I/O wait
mostly have taken up. This was because page cache populations were
triggered on page fault basis. Since swap-in operation moves pages
sequentially, pre-populating has a benefit on the latency.
MADV_WILLNEED causes the kernel to asynchronously start populating the
pages, and MLOCK_ONFAULT ensures that the data remains in the page cache
until it is UFFD_COPYed. mlock(2) without MLOCK_ONFAULT is not
applicable because it blocks the calling thread until populated.
MADV_DONTNEED is also important in terms of the swap-in latency. It
frees the page cache which is already UFFD_COPYed to be reused for later
readaheading swap file. Otherwise the memory pressure from the swap file
page cache population triggers system-wide page frame collection which
is heavy.
Pre-populating page cache alone is actually not enough to improve the
swap-in latency without swapping in on a background thread
(https://crrev.com/c/4317028).
BUG=b:265606668
TEST=cargo test -p swap
Change-Id: I2069c1260d0cf45499298999a71621e563f28f30
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4314186
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This CL introduced a negligible amount of overhead as some read
operations on some tiny data strucutres (acpi netlink events) are
converted from zerocopy to single copy.
Also fixed a naming mistake around PCI MSI and manually added
padding to allow AsBytes to be derived.
TEST=CQ
BUG=b:204409584
Change-Id: Ibafe4c413fbed50e61c54433d495ff024fe60da4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4348712
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Zihan Chen <zihanchen@google.com>
Avoid the possibility of tests reusing the same socket path by using a
known unique directory from tempfile::tempdir().
BUG=b:274145919
TEST=tools/dev_container tools/presubmit
Change-Id: I883e223617fb465cdfbff5a45509098487b62b3b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4348699
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
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>
Move generic implementation of BlockedSignal to base sys.
Change-Id: I459ca424a633dc3fc2a5dec625dde8e5878132c0
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
(cherry picked from commit 5f51fa4ae3b979972d273dff4c224c1999b6e641)
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4346950
Reviewed-by: Dennis Kempin <denniskempin@google.com>
If the input to ioctl_expr is a u8, it cannot be implicitly upcast to
u32. Cast the inputs, not the output, to IoctlNr.
Change-Id: I2bce639bd13f49c92fadedb146ef09171b7128ef
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
(cherry picked from commit 585dbff782e96d0531734d37ec2dae958f6ff6c1)
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4346949
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Adds command line options to move the vGPU threads housed within crosvm
and the vGPUserver threads housed externally into separate cgroups.
This will give us the ability to perform some tweaks/experiments
with the affinity masks of these threads as a group.
BUG=b:269139377
TEST=Launch Borealis VM, ensure command line options work as expected.
Change-Id: I558673e616e0344bae2407db1ff693902816daac
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4304743
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Isaac Bosompem <mrisaacb@google.com>
Nothing calls this code, so it should be okay to remove it.
BUG=None
TEST=tools/dev_container tools/presubmit
Change-Id: I5f079dc9e6e15178506b801b7266d8bd0351ddbb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4321329
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
The overlapped wrappers on PipeConnection are unsafe, but they were
marked as safe. There are no actual unsafe production uses of them
because the conventions for overlapped IO generally make that hard to
do. That being said, these wrappers MUST be marked unsafe. This CL does
so and updates the callers with safety statements.
BUG=b:272812234
TEST=presubmit
Change-Id: I0def7056431d5b3b70eb4ce7c6ac8b44aef0a4cc
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4330490
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Noah Gold <nkgold@google.com>
In the future we'll be using read/write wrappers in multiple places,
but the wrapping code currently lives in the named pipe implementation.
This CL pulls it out to its own module. It also brings in some other
code in win_util that wasn't upstreamed.
BUG=b:272614458
TEST=presubmit
Change-Id: I6871f3db6991336f42706652b69935755bf2fbc3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4326942
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Upstreams blocking overlapped read/write commmands to base.
These funtions will be used by the broker to forward messages exchanged
between main and service.
Bug: 269191436
Test: none
Change-Id: I029e8c440bb6b8234fe2d1ca3b1dd5ddb408d814
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4329913
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
crrev.com/v/4237140 was reverted in crrev.com/c/4310064 due to the
generated header file not defining the RegisteredEvent type. along with
re-reverting the original cl (and corresponding bugfix cl) this patch
introduces a RegisteredEventFfi type which mirrors the original
RegisteredEvent type but should be exposed in the generated header file.
BUG=b:269609274
TEST=sidecar process (patch: crrev.com/c/4276642)
TEST=cargo build, header file inspection
Change-Id: I4a17163e36eb466a540a72d2bb4356419739c974
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4311831
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Maciek Swiech <drmasquatch@google.com>
This reverts commit 2404c5ed44.
Reason for revert: This fails to build crosvm C interface and blocking ChromeOS CQ.
Original change's description:
> balloon: add event registration mechanism for sidecar processes.
>
> this patch introduces a mechanism for so-called 'sidecar processes' to
> register as event listeners, consuming events that are generated in
> various parts of crosvm. in this patch we focus on events that enable
> roziere cooperative ballooning, but lay the groundwork for a more
> general framework.
>
> the general idea is that a sidecar process would open a listening socket
> and register the path with crosvm for a specific event. crosvm will pass
> along a handle to a registered event tube to the appropriate device (or
> other internal component) which would then be responsible for passing
> along events. once events arrive back in the crosvm control loop, an
> attempt is made to dispatch the events to any registered sockets.
>
> BUG=b:269609274
> TEST=sidecar program that performs registration and receives events
>
> Change-Id: Iaff41aad8f862ed99a104c75623caaabc53e9e88
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4237140
> Commit-Queue: Maciek Swiech <drmasquatch@google.com>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Bug: b:269609274
Change-Id: I135e0d55bb296cf591548b7bd4feffc7ff9f3447
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4310064
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
this patch introduces a mechanism for so-called 'sidecar processes' to
register as event listeners, consuming events that are generated in
various parts of crosvm. in this patch we focus on events that enable
roziere cooperative ballooning, but lay the groundwork for a more
general framework.
the general idea is that a sidecar process would open a listening socket
and register the path with crosvm for a specific event. crosvm will pass
along a handle to a registered event tube to the appropriate device (or
other internal component) which would then be responsible for passing
along events. once events arrive back in the crosvm control loop, an
attempt is made to dispatch the events to any registered sockets.
BUG=b:269609274
TEST=sidecar program that performs registration and receives events
Change-Id: Iaff41aad8f862ed99a104c75623caaabc53e9e88
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4237140
Commit-Queue: Maciek Swiech <drmasquatch@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
The device process sandbox does not allow connect(), so if the syslog
connection is closed for any reason and then a device tries to log
something, calling connect() in the retry loop would kill the process
since connect is not allowed in the seccomp policy.
BUG=b:259860758
TEST=kill -9 $(pgrep rsyslogd); resize disk to get a log
Change-Id: Ic3d44543edbc6ab63e41f4589f77630620b4eca5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4245440
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Nicholas Verne <nverne@chromium.org>
forking a process with multiple threads will lead to
undefined behavior. Unfortunately, newer versions of
libtest will spawn multiple threads even when running
a with --test-threads=1.
This change implements a custom, test harness using
libtest-mimic. It mimics the libtest CLI but enforces
a single threaded test process.
BUG=b:270167741
BUG=b:268496046
TEST=tools/run_tests --dut=host
Change-Id: Icef6a1b65bab7f5cd5021c01fbd94487fa0ca5fb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4295157
Reviewed-by: George Burgess <gbiv@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Add a minijail's mode of operation where an always-allow seccomp
filter is attached to forked device processes. This facilitates
capturing seccomp filters used by each device process separately.
TESTED=./tools/build_release -- --features seccomp_trace && strace -ff crosvm --log-level debug run <args>
BUG=b:258316090
Change-Id: Ic4d3f5178e6a2dcbd748d101db43574f3224ff78
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4289510
Commit-Queue: Zihan Chen <zihanchen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
This is a refactoring of ProxyDevice and fork_process().
ProxyDevice did not have `ExitGuard`, but it should have it.
BUG=none
TEST=manual test
Change-Id: I19020b7ce1704638b16e544f0c4863a35c652d47
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4230551
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
PunchHole should be originally immutable method since the
file_punch_hole() for both unix and windows are immutable function which
do not change the underlining file offset.
QcowFile is the only object which requires mutability to punch a hole to
its file.
This commit introduce a new PunchHoleMut and the existing PunchHole
traits and make PunchHole trait immutable. This unblocks b/269981962
which tries to punch a hole to non-mut reference File.
This also remove useless top level defined functions in base crate.
BUG=b:269981962
TEST=cargo build --feature=qcow
TEST=./tools/run_test2
Change-Id: I8333d13f4adc6dff319c0ddababe400d5e995141
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4269718
Reviewed-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Shin Kawamura <kawasin@google.com>
WorkerThread provides a mechanism to start a thread that can be stopped
by sending an event from another thread. It also handles automatically
stopping the thread if the WorkerThread object is dropped.
BUG=b:269187468
TEST=tools/presubmit --all
Change-Id: Ifeef3f34f75fcd0496e87e038b60fa9e5e60a681
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4237530
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
This is admittedly an odd feature with a narrow use case. It will lower
the risk of crash analysis tools accidentally trying to read guest
memory that has been unshared from the host (i.e. in a protected VM).
Hoperfully we'll eventually have a better solution, where we only mmap
the memory regions that are shared with the host. There is no hypervisor
support for that yet.
BUG=b:238324526
Change-Id: Iac7ed38aa52778a43ac5ba22bab5a3df7a554ee6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4251719
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This roughly matches the unix::terminal interface and can be used
to configure the terminal for use with a serial console (no line
buffering, interpret ANSI escapes, and so on).
BUG=b:264428954
TEST=tools/presubmit --all
Change-Id: I7efa8c405b44dadec55e08993b5f7a4c0236cf69
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4200971
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Prior to this CL, the doctest for write_obj_volatile() was failing on
a Windows device, and the doctest for read_obj_volatile() called
read_obj() rather than read_obj_volatile(), not testing the correct
function. After this CL, both tests pass on Linux and Windows, and the
doctest for read_obj_volatile() correctly tests the volatile version of
the function.
TEST=cargo test --doc in base/src, CQ
Change-Id: I4d3fd77a7ededed12231c980899187d747b61234
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4247139
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Clarissa Garvey <clarissagarvey@chromium.org>
With the previous CLs migrating many functions and types to use
zerocopy, finally we can do a big clean up of`unsafe impl DataInit`.
We are down to 93 instances now from 230 at 5th CL in this series.
Also fixes a bug introduced previously in this series where I set
the trait bound of a few write_at_addr unsafe functions to
`FromBytes` when `AsBytes` should also be required.
TEST=CQ
BUG=b:204409584
Change-Id: I6658dd246a8932493ef6a652054a23ecfde76198
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4237765
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Zihan Chen <zihanchen@google.com>
The Rust uprev breaks some assumptions these make. Sounds best from
discussion on the CL to temporarily disable them.
BUG=b:266817148, b:268496046
TEST=emerge-nocturne crosvm-base
Change-Id: If86eb23200b5af4be8221bacc42954b3dfc25aeb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4218895
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: George Burgess <gbiv@chromium.org>
We will enable clippy checks on those platforms in CI soon.
BUG=b:268356784
TEST=tools/clippy --platform=aarch64/armhf
Change-Id: Icfefdbce7498731d78448b00c7c21a0f86639dff
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4233580
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
- Rust toolchain is updated to 1.65.0
- Catapult dashboard upload tool is added to dev_container
- Bindgen is updated to latest version to support custom derive
- Derive Eq when PartialEq is derived as required by new Clippy
TEST=CQ, bindgen-all-the-things
FIXED=b:260784028
BUG=b:257303497
Change-Id: I2034cd09e0aed84d4e9b30f2e85d84d94a442ea4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4228427
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Zihan Chen <zihanchen@google.com>
userfaultfd(2) syscall requires CAP_SYS_PTRACE of root user namespace.
For better permission control /dev/userfaultfd was introduced from Linux
6.1. Since ARCVM runs inside a sandbox user namespace and enabling
/proc/sys/vm/unprivileged_userfaultfd opens up userfaultfd to the entire
system, crosvm for ARCVM has to use /dev/userfaultfd to create a
userfaultfd.
For systems which do not have /dev/userfaultfd, the Factory falls back
to userfaultfd(2).
BUG=b:268145007
BUG=b:266642532
TEST=manual test
Change-Id: I44b657877093d2a75627432619c1233b7ac2464e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4196763
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
MemoryMappingBuilder on Windows has to be built from SharedMemory. On
Linux we can build without one. We should fix this API discrepency at
some point, but for the moment let's get the test working again.
BUG=b:267219257
TEST=the fixed test passes downstream.
Change-Id: If9728f2b73465a30aa324549fbc10e189737b420
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4220528
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
Add custom_serde to base
Move serialize_* functions from devices/lib to base/custom_serde
Made serialize_arr accept generic sized types and different sizes
BUG=b:232437513
TEST=./tools/presubmit --all
Change-Id: I5c686f4ff4235141e48764001aedc7a18d9dbbf9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4210069
Commit-Queue: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
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>
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>
The default behavior when handling a panic in a multi-threaded Rust
program is to terminate only the thread that panicked; other threads
continue running.
In order to get a crash dump (and to prevent the program from continuing
to run in an inconsistent state), add a call to abort the whole program
at the end of the panic hook installed by install_memfd_handler().
The crosvm panic hook configured by set_panic_hook() already behaves
this way, but adding this behavior to install_memfd_handler() will cause
it to be used in all ChromeOS Rust programs that use the hook from
libchromeos.
Test program:
```
fn main() {
println!("hello world");
install_memfd_handler();
thread::Builder::new()
.name("crashtest".into())
.spawn(|| {
println!("about to panic");
panic!("test panic");
})
.unwrap();
}
println!("continuing to run main");
thread::sleep(Duration::from_secs(1));
}
```
BUG=b:234093439
TEST=panic in multithreaded test program; observe core
Change-Id: I2340b2f54607651fe577ebf44a0ecb12e409cef4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4190031
Reviewed-by: Allen Webb <allenwebb@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>