Add skeleton for allowing virtcpufreq to communicate
via sockets to make syscalls using privileged proxy
services. This acts a fallback mechanism for systems
that do not grant CAP_SYS_NICE for crosvm.
Bug: 322197421
Test: ./tools/presubmit
Change-Id: I2ca4e01c477d3867a052bcf709bdeddf32e5ded1
Signed-off-by: David Dai <davidai@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5258454
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Drop the hack hard-coding cachability based on driver name, and replace
with querying from minigbm. This allows other drivers to use cached
minigbm/gralloc allocated buffers in cases where it is beneficial (such
as with sw encoders)
BUG=b:239718180, b:306548532
TEST=cts-tradefed run cts -m CtsVideoTestCases -t android.video.cts.VideoEncoderDecoderTest#testAvcGoog0Perf0320x0240
no artifact in Camera FOV Calibration of CtsVerifier on rex
Change-Id: I854e2f00b993310716f64a3c568ed8c6f2665469
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3780218
Reviewed-by: Dawn Han <dawnhan@google.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Chia-I Wu <olv@google.com>
We can't use pipe2() since that is a Linux-only API, so O_CLOEXEC must
be applied as a separate step. This should not be a problem in practice
for crosvm, since we should never be calling pipe() simultaneously with
fork()/exec() in another thread, since fork() in a multithreaded process
is generally unsafe and our fork wrapper disallows it.
Change-Id: I27886b6e50f8b0eb018cf38161530fa7f92f4761
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5251101
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Clean up and refactor the existing clear_*_flags() to allow adding
O_CLOEXEC as well.
Change-Id: Idad76537e3a0d8ed52780bca1723b40c7115a498
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5251100
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
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>
If a device fails to sleep we never handle it and continue snapshotting.
This causes a corrupt snapshot to be made with silent failure on boot.
I noticed this for the vhost-user GPU, whenever there is a failure to
recover the queue, this failure was not preventing the snapshot.
BUG=b:300501737
TEST=snapshotted downstream and checked error prevents snapshot
Change-Id: I7573805c37ba9bb66495ff2f256e706a33907361
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5247322
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Idan Raiter <idanr@google.com>
Improves the queue handling code to fix these two issues:
1) Dangling references to the queue cause queue recovery to fail.
To clean this up we just need to call stop_non_queue_workers as these
workers have a reference to the state.
2) The cursor queue always fails to snapshot since it has no worker and
no state tracking to recover the queue. Clean up this path by
spawning an empty worker instead.
BUG=b:300501737
TEST=snapshotted downstream
Change-Id: Ie8e2eeb0eb71090c873d5fb64f22229f60745f4b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5247321
Commit-Queue: Idan Raiter <idanr@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
The arm64 kernel header contains an 'image_size' field indicating the
minimum size of the reserved memory region into which the kernel is
loaded. This is larger than the size of the Image file, as it also takes
into account NOBITS sections such as the .bss, which will be zeroed
during boot.
Although crosvm parses the kernel header, it fails to take 'image_size'
into account and can end up loading the initrd over the .bss if the
section is large enough to cross the next 16MiB alignment boundary after
the end of the Image.
Size the memory reservation according to the 'image_size' field in the
arm64 kernel Image header, warning if it's zero and falling back to the
current behaviour.
BUG=b:322966413
TEST=tools/dev_container tools/run_tests --platform=aarch64
Change-Id: I23316f201d8a7fd9025762be518aa505e716c642
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5249889
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Will Deacon <willdeacon@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
I don't know if the relaxed ops are wrong, but they aren't clearly
correct.
Change-Id: Ie67b8ea3b4913e91182f6863514a5d47beb1615e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5246698
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Mali driver creates a directory hierarchy when dumping shaders for debug
purposes, necessitating the use of `mkdir` or `mkdirat` syscalls, which
have already been allowed on x86_64 platforms for mesa's shader cache
management and filesystem management by the fs and 9p devices.
BUG=b:322266916
TEST=emerge crosvm
TEST=ARCVM starts successfully
Change-Id: Ib1b838856847edfc2178ab1ae2eb85fdb26a0d2b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5238061
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Ryan Neph <ryanneph@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
When cross-compiling Windows on Linux, multiple features are
reported missing. Also, winapi::ctypes::c_void and
libc::c_void differ.
winbase isn't used yet, but there's a few futre patches that
benefit from it.
BUG=322802940
TEST=cargo build --target x86_64-pc-windows-gnu
Change-Id: I7aee961b1758050e5f93c3619db27d59bf918fe2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5245137
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Add a top level noncoherent-dma feature flag as well as its
counterparts in devices and hypervisor modules.
This flag enables the MemCacheType::CacheNonCoherent handling,
ensuring that behavior introduced in the previous commit can be
selectively enabled.
BUG=b:316337317
TEST=emerge-rex chromeos-base/crosvm
TEST=USE=crosvm-noncoherent-dma emerge-rex chromeos-base/crosvm
Change-Id: I13f50547b21ce804c5fa4b8f6328931f558b717e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5237126
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Zhenyu Z Wang <zhenyuw@linux.intel.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Stanisław Kardach <skardach@google.com>
On Intel, new noncoherent DMA mem flag can be set to allow KVM to
recognize guest cache setting for EPT, which allows WC attribute to be
applied to ensure guest memory access is synchronized in noncoherent DMA.
Unlike previous POC for new device attribute, this uses new added flag
for mem slot.
BUG=b:316337317
TEST=cargo build and run GPU workload
Change-Id: If16d61031bdb2cf0252a57e99d4b6725a89dd38a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5171312
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Stanisław Kardach <skardach@google.com>
Let minigbm decide which randernode to use. In this case, we don't need `rendernode.rs` anymore, and don't have to keep `_fd` in struct `MinigbmDeviceInner`, `fd` can get by calling `gbm_bo_get_fd`
BUG=b:265199561
TEST=./tools/presubmit
TEST=emerge-board crosvm, and deploy to dut
TEST=CQ
Change-Id: I294d6f7f0dcdf075ac85671561dbeeb1eef8edd2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5038006
Commit-Queue: Dawn Han <dawnhan@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Get the directomy from the environement if available.
Test:
mkdir /tmp/out
cd rutabaga_gfx/ffi
CARGO_TARGET_DIR=/tmp/out cargo build
# Also try.
cargo build
Bug: b/317884283
Change-Id: I43fc7d17e4bef50e4afcd45144a2dc9bef273a6b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5237622
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Pierre Labatut <plabatut@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Stub out virtual cpufreq since the current implementation/interface
is unstable so that other users do not rely on this current interface.
Bug=b:284367589
Test=./tools/presubmit
Change-Id: I88d491389293e69dc0cdfb7317708a09a18ef5ff
Signed-off-by: David Dai <davidai@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5237740
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
If OnceCell is used, then rutabaga_init can only be called once per
process.
This commit fixes the ffi tests for me.
Change-Id: If31792d7679292e4bb63d7442a28effafb181b02
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5232199
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Auto-Submit: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Currently, create_composite generates a read-only composite disk by default.
But in embedded system, sometime we need to use a real disk partition as the
backing file. In this case, it is required to create a writable composite disk.
So an optional "writable" argument is added in the command line.
BUG=b:318862474
TEST=cargo test --features composite-disk
TEST=./tools/presubmit
TEST=create a writable composite disk and use it as the backing of virtio-blk,
the writing works well.
Signed-off-by: Junnan Wu <junnan01.wu@samsung.com>
Change-Id: I05033473cf28628887926b18fe17429e267f26f3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5179893
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
This is only used by the e2e_tests, so it should not affect most
downstream projects.
BUG=b:321994092
Change-Id: I42bc550c273d68960174bcf577ea0555cb22ef12
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5232209
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Kernel images are often stored compressed because they can take up a
significant amount of disk space. One of the popular formats for this is
LZ4. Even though it does not offer the best compression ratio, it excels
at decompression speeds.
On arm64, kernels do not come with their own decompressor like they do
on x86. Instead, it is the job of the bootloader to decompress the
kernel before it is executed.
To this end, add crosvm support for LZ4 decompression of kernel images,
via the Rust-safe lz4_flex library. LZ4 file format is detected
automatically via one of its magic numbers. Otherwise crosvm will fall
back to loading the kernel as a raw image.
Some rough numbers using Android's Generic Kernel Image on Pixel 8:
* compresion rate: 49% (33MB -> 16MB)
* decompression time: 20-30ms
Given that the total VM boot takes about 1.5s, the overhead is more than
acceptable.
BUG=b:315141974
TEST=tools/dev_container tools/run_tests --platform=aarch64
Change-Id: I1030abe6fdf7087603cea9ac5273bf9136bad693
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5110323
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: David Brazdil <dbrazdil@google.com>
If running behind proxy, need to pass proxy setting for container as well,
otherwise can't pull crates properly. So this tries to add 'http_proxy'
and 'https_proxy' in environment for container.
Change-Id: I897703f571d9fe5bd03b819fc6b13a9e04384e6f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5232200
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Refresh the bindings with newer bindgen, allowing us to get rid of the
clippy errors.
BUG=b:322056705
TEST=boot emulator on HAXM
Change-Id: I1eb455b8fbb39c89c7d9e60a134a305afaa99499
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5232520
Commit-Queue: Idan Raiter <idanr@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>