Previouly some structs are marked as repr(packed) which allow
rustc to reorder them, and is not compliant with ACPI specs.
TEST=CQ
Change-Id: I2b45ee5fc9ccc99cb9355f6d19c14f962c242a54
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4234143
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: 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>
codecov has been very flaky and is undergoing an acquisition
process.
We should probably switch to an in-house tool like the chromium
coverage dashboard.
BUG=None
TEST=None
Change-Id: Ib570224dceb131b55b6ca958b695cc1e97082132
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4228220
Commit-Queue: Zihan Chen <zihanchen@google.com>
Auto-Submit: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Zihan Chen <zihanchen@google.com>
A previous merged infra change didn't update the infra tests'
example result but passed CI (for some unknown reason).
TEST=CQ
Change-Id: I30c8150bbef745fed9301fa1756649e6d3085967
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4228222
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Zihan Chen <zihanchen@google.com>
Commit-Queue: Zihan Chen <zihanchen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
This helps identify a potential deadlock by the NamedLock.
BUG=None
TEST=CQ
Change-Id: I0ef9606b6b5e36a1564ff3fee7720ae013365cc7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4228215
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
`--features` lets us specify any custom features that we would like
to build and test.
BUG=b:267672683
TEST=ran run_tests2 downstream
Change-Id: I47a4a67c261d0ec5281abedbbe6ba46b26b49a62
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4226883
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
This commit introduces ACPI0003 emulated device, which can be enabled by
passing "--ac-adapter" argument.
Emulating ac adapter allows to replicate ac adapter state on the guest side.
The host kernel already propagates ac adapter status to user-space by
generating acpi events: acpi_bus_generate_netlink_event so crosvm upon
receiving "ac_adapter" class acpi event, stores the corresponding data
(ac status) into ac register. Next the previously allocated GPE is
triggered to inform the guest about status change.
Guest upon handling GPE, thanks to generated aml code:
Device (ACDC)
{
Name (_HID, "ACPI0003" /* Power Source Device */) // _HID: Hardware ID
OperationRegion (VREG, SystemMemory, 0x0000000220E00010, 0x10)
Field (VREG, DWordAcc, Lock, Preserve)
{
ACEX, 32
}
Method (_PSR, 0, NotSerialized) // _PSR: Power Source
{
Return (ACEX) /* \ACDC.ACEX */
}
Method (_STA, 0, NotSerialized) // _STA: Status
{
Return (0x0F)
}
}
Scope (_GPE)
{
Method (_E00, 0, NotSerialized) // _Exx: Edge-Triggered GPE, xx=0x00-0xFF
{
Notify (ACDC, 0x80) // Status Change
}
}
triggers Notify on AC adapter and therefore replicates the host
ac_adapter state (accessing ACEX pointed by opregion results with trap
to crosvm, which returns previously stored ac status).
BUG=b:244205651
TEST=Plug/Unplug AC adapter and inside guest run:
1) acpi_listener and confirm that proper acpi events are replicated
2) observe: `cat /sys/class/power_supply/ACDC/online`
Change-Id: I9b1045cfcae1c4de48a0ad50f63148cfe9ff226b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4186657
Auto-Submit: Grzegorz Jaszczyk <jaszczyk@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Grzegorz Jaszczyk <jaszczyk@google.com>
The backends should not be aware of the Parser struct. Removing this
dependency opens the door to further factorization of the VP8 Decoder
struct.
BUG=b:214478588
TEST=cargo test --features vaapi -p cros-codecs
Change-Id: Ie92aa341ed10fccbe328d321469edfc5ae1a334a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4160630
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.corp-partner.google.com>
Sort the members so the common ones appear first and in the same order -
this will help us factorize this part of the code in the future.
BUG=b:214478588
TEST=cargo test --features vaapi -p cros-codecs
Change-Id: I78dedb06fef11fb00cdac88eae7b92d0010e6150
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4160629
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.corp-partner.google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
VP9 segmentation is potentially useful to all backends and not only the
VAAPI one. Since this code is not VAAPI-dependent, move it to the common
decoder.
BUG=b:214478588
TEST=cargo test --features vaapi -p cros-codecs
Change-Id: If1970e9773de97d7923e6e230aa5a320b2d7cdc9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4160628
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.corp-partner.google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
If `ugid_map` is specified but the uid and gid of current user does not
match the map, `setresgid(2)` fails and crosvm fails to boot.
Currently there is not use case when `bind_mounts` is enabled and
`ugid_map` is specified. But this is for the future developers who will
not be bothered by this bug.
BUG=b:266642532
TEST=manual test
Change-Id: I60e1ee18d09ce1ffe05a2a57ea85ba616eb83ccf
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4223603
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
`crosvm snapshot take ...` will write the contents of guest memory to a
file and `crosvm restore apply ...` will read that file to overwrite
guest memory.
To start with, the file is chosen by adding a ".mem" extension to the
snapshot file path. We should consider a better approach in the future,
maybe put them both in a tar file or have the user supply a directory
instead of a file path.
BUG=b:266514791
Change-Id: Ic05f94223fb74674bd57dcd2f848055b31eb5fdc
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4215313
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
In upcoming patches there will be need for allocating unique free GPE,
therefore extend system allocator appropriately.
BUG=None
TEST=Build and run crosvm with WIP patches using GPE allocator.
Additionally trigger simple, introduced test.
Change-Id: I2f175d4da58e4cba8e6a869cee537802ed197e3c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4186656
Auto-Submit: Grzegorz Jaszczyk <jaszczyk@google.com>
Commit-Queue: Grzegorz Jaszczyk <jaszczyk@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dmytro Maluka <dmaluka@google.com>
Instead of using hard-coded value introduce and use ACPIPM_GPE_MAX.
BUG=None
TEST=Build
Change-Id: Iab29705cec74a2fea3f4dad597ee5b72b29dfd97
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4218616
Commit-Queue: Grzegorz Jaszczyk <jaszczyk@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Grzegorz Jaszczyk <jaszczyk@google.com>
Reviewed-by: Dmytro Maluka <dmaluka@google.com>
This makes room for non-device snapshot data, e.g. guest memory metadata.
Included some related cleanup: Made the snapshot and restore code more
symmetric. More abstract interface with the bus library.
BUG=b:266514791
Change-Id: Ia19aa002d4bb7ec6041c1183c6deb422dfbed0c5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4215317
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Re-format the response of `crosvm swap status` command and make it easy
to parse structure as JSON.
BUG=b:265606668
TEST=cargo test -p swap
Change-Id: Ia5216a6ae4b2083bce3829848687cebf932d0933
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4216453
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: David Stevens <stevensd@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>
- makes luci tests conditional
- enables specifying additional cargo features
- downstream uses different features test on different presubmit jobs
like prod vs. non-prod, asan vs. non-asan
BUG=b:267672683
TEST=ran these scripts downstream to an extent possible
Change-Id: Ide6f0e896ecf88ba90a74a3369243595dc199571
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4218894
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Setting up uid_map/gid_map and mount tmpfs to the root path is required
to bind_mount extra files/directories into the jail. Unify the setup
into the `create_sandbox_minijail()` instead of setting it up on each
device.
Set 64MB tmpfs for the root path while snd and tpm devices have used
20KB tmpfs. This does not harm the memory pressure since tmpfs allocates
memory on demand. The tmpfs size should be optimized at b/267581374.
This helps to support injecting /dev/userfautlfd to each device process.
BUG=b:266642532
TEST=ARCVM succeeds to boot and sniper3D app works.
Change-Id: Id9b49860a57ba6518145e7a2a7683896a9d9b2cf
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4211152
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
We should use less Option to keep the api simple. But keep the current
interface of `simple_jail()` as is because it is simple enough and fits
other interface easily (i.e. VirtioDeviceStub and other interface expect
to accept `Option<Minijail>`.)
This is the first step of the refactoring jail_helpers to support
injecting /dev/userfaultfd to each device process.
The new chroot path (`src`) for fs_device is already validated when it
is parsed at `SharedDir::from_str()`. But checking the directory twice
won't add much overhead.
BUG=b:266642532
TEST=cargo build
Change-Id: I55f837b4da3df51f878108b0ed3d3aba1a0dd823
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4211151
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
We greatly improved the test health of crosvm which allows to
make better use of standard cargo tools instead of custom
tailored implementations for running tests.
The new test runner is available at tools/run_tests2 until it
fully replaces tools/run_tests.
The key difference is that tests are packaged into a tarball
to be executed remotely instead of sending and executing every
binary separately via SSH.
Improvements over the old test runner:
- Faster, nextest runs faster and the new model for remote testing
is a lot faster when running tests in a VM.
- Simpler, less custom code to maintain.
- More readable output, uses modern TUI functionality.
- Enables future workflows for testing on cloud devices running
in our luci infrastructure.
How much faster?
- Running all tests on host: 1m -> 9s
- Running all aarch64 tests in vm: 3m20s -> 32s
BUG=b:261600801
TEST=./tools/run_tests2 with args:
-p x86_64
-p x86_64 --dut=host
-p x86_64 --dut=vm
-p aarch64
-p aarch64 --dut=vm
-p armhf
-p mingw64
Change-Id: I842a0ac6f7b288aeccb112b4e2f46a15f3baf54b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4144641
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Dennis Kempin <denniskempin@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>
Activating GPE will be used from different contexts, therefore extract
this common functionality into a separate function.
BUG=None
TEST=Build
Change-Id: Ie6d49d928c8bbb028a33aa8321f580d5abfaee7a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4186655
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Grzegorz Jaszczyk <jaszczyk@google.com>
The decode() method used to take a generic argument that can provide a
reference to the input byte stream. This appears as a convenience but is
really not since it is trivial for the caller to obtain the byte slice
from any type that implements AsRef<[u8]>, and having the generic
parameter uselessly complicates the code and results in large amounts of
monomorphization.
By removing this generic argument, we strip ~30KB on the binary in a
release build while keeping things easier to read overall.
BUG=b:214478588
TEST=cargo test --features vaapi -p cros-codecs
Change-Id: I4a4a09151259a61fa66184dfed09a9bed286de68
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4142081
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.corp-partner.google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
We are now in a state where the shared functions of all backend
implementations are implemented through `VideoDecoderBackend`, while the
codec-specific parts are done through `StatelessDecoderBackend`.
This allows us to extract the common functionality into a shared
`VaapiBackend` structure that provides the implementation of
`VideoDecoderBackend`, that each codec-specific backend will embed.
Doing so dramatically reduces the amount of duplicated code within the
VAAPI backend.
BUG=b:214478588
TEST=cargo test --features vaapi -p cros-codecs
Change-Id: I9498d31cb3da6bfe10542267b4e8fcc075792afc
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4123657
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.corp-partner.google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>