TEST=booted test kernel, ensured uuid is correctly returned at
/sys/class/dmi/id/product_uuid.
BUG=b:249382713
Change-Id: I444adebcea4b374b8c2744afba32cad5ff794ce0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5010881
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Mike Gerow <gerow@google.com>
This change uses the overlay filtering mechanism to only apply nodes
pertaining to the VFIO devices given to crosvm.
For each VFIO device, define its device tree symbol by passing a
`dt-symbol` option in addition to the sysfs path. The DT symbol must
match the label of the device node in the FDT. In addition, specify
which device tree files will be filtered using these symbols by passing
a `filter` option in addition to the device tree overlay path.
As the device nodes are applied to the base FDT, update the `reg` and
`interrupts` properties with correct values for each VFIO device.
Since these values are allocated by crosvm, they are not known ahead of
time and even if written to the overlay file, are unlikely to be
correct. This change will set the correct values for each VFIO device.
Bug: b/296796644
Test: tools/run_tests
Change-Id: I1ca38b5ef223e551b91a831093b9ae790962aa5b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4855969
Commit-Queue: Jakob Vukalović <jakobvukalovic@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
/dev/kvm is not a normal file, so os.path.isfile("/dev/kvm") returns
False. Use pathlib's is_char_device() check instead.
TEST=tools/dev_container --stop; tools/dev_container
Fixes: 0be7e9757e ("dev_container: Only pass /dev/kvm if present")
Change-Id: I150009beb9b0b438013c2dd86fae7f99c959be75
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5021441
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Pierre-Clément Tosi <ptosi@google.com>
This change propagates the overlay files to the `fdt::create_fdt`
function, load the file contents, and applies a series of device tree
overlays to the base device tree after it has been constructed.
Test: tools/run_tests
Bug: b/296796644
Change-Id: I01f4db604fba5b8ecd756f93d092432145357977
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4855968
Commit-Queue: Jakob Vukalović <jakobvukalovic@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This cleans up some extra #[cfg(feature = "plugin")] checks and slightly
reduces the size of the gigantic main config.rs file.
No functional change.
TEST=cargo test --features=plugin
Change-Id: Iaa5a8850adfafbbb6439183fb4e4af2dcd7939d4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5017969
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This makes the generic Protection code more portable and allows removal
of the unix-specific PROT_READ and PROT_WRITE constants from the base
public API.
Users of base should not need to change anything if they were already
using the Protection pub APIs (read(), write(), etc.)
BUG=None
TEST=tools/dev_container tools/presubmit
Change-Id: I4100e333e1a2133d54942780ddd79f722194f487
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5013638
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Convert from the libc PROT_READ and PROT_WRITE flags into the portable
base::Protection type one layer earlier than before. This makes the
`fuse` crate API not depend on the numeric constants for PROT_READ and
PROT_WRITE, which aren't necessarily the same on all platforms.
Currently it still will only work on Linux, but this is a step toward
making it generic.
BUG=None
TEST=tools/dev_container tools/presubmit
Change-Id: I8f036ca9a5d7066aeae5a8578a8cb45c41fa4883
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5014789
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
These duplicate existing VolatileSlice and FileReadWriteAtVolatile
functionality. Removing them means that they don't need to be
reimplemented separately for each platform's MemoryMapping.
BUG=b:309020556
TEST=tools/dev_container tools/presubmit
Change-Id: Ia4332159461efc001b4e980fdb2a9984e852c931
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5019440
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
The Windows and Linux versions were effectively identical, and the same
one should also work for macos.
BUG=b:309020556
TEST=tools/dev_container tools/presubmit
TEST=cargo build --target=aarch64-apple-darwin -p base
Change-Id: Ieaedc256acb80d2b1655cc51ad23899fcc667762
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5018780
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This change adds a '--device-tree-overlay' command line option to pass
device tree overlay files which will be applied to the VM device tree.
The overlay files are opened and propagated to `Arch::build_vm`
function.
Bug: b/296796644
Test: cargo test
Change-Id: I6a1571b2b14cb36cdb9f02e099ef56ee263d6efc
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4855959
Commit-Queue: Jakob Vukalović <jakobvukalovic@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
For large overlay files, sometimes it is not neccessary to apply the
entire overlay, and only a few nodes must be applied instead. For
example, a large overlay file may contain nodes for all devices that can
be assigned to a VM via VFIO. However, in most cases only a small subset
of devices will actually be assigned, so only a small subset of the FDT
overlay must be applied.
This change implements device tree overlay filtering. Ie, it allows the
API user to choose which overlay nodes will be applied to the base.
It is possible to pass a set of symbols (node labels) to `apply_overlay`
function, which act as a filter for the device tree nodes.
This requires defining node labels (symbols) in DT source and compiling
DT overlays (`-@` option in dtc), so that the node symbols are exported
in `__symbols__` node.
Bug: b/296796644
Test: cd cros_fdt && cargo test
Change-Id: I2238cf08b85e1825f668f83d8edadd2446a28869
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4855967
Commit-Queue: Jakob Vukalović <jakobvukalovic@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This is dead code and can be removed.
Change-Id: Ic6bee7b3a6fe59af117f7667ce4ff2a893cf9228
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5018778
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
These are not used anywhere in platform-independent code, so we can
clean them up.
BUG=b:309848917
TEST=tools/dev_container tools/presubmit crosvm_unit_tests_mingw64
Change-Id: Ic5a9ceeee2a41a5a9ff401e0bd59d0921897a0d6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5015650
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested by using a VM with the following option and verified the TTY
works after a susend-resume sequence.
--serial=type=stdout,stdin,hardware=legacy-virtio-console,console
Bug: 309816267
Change-Id: I16e3fdd5bfb2dc6dc8ceffb5e71c8aa4c9ffa7f7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5013636
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
There was some redudant logging and inconsistent error formatting.
Change-Id: I398467957d656316e46c19287d03a1b9484437a9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5013634
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Elie Kheirallah <khei@google.com>
We introduce a new macro to dispatch function calls across different
enum fields to simplify the code. This way we don't have to
re-write multiple match statements for each backend type and
implementation, as most code will be shared (but some may differ).
BUG=b:297957754
TEST=presubmit and tested USB behavior on a DUT
Change-Id: Ib4bc53a9baf3398b66b3e4a4678d3ad4d817ee28
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4943431
Auto-Submit: Morg <morg@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Move the Linux Pid type to unix (it should work for any unix-like
environment) and redefine the Windows Pid as DWORD to match
GetProcessId() and similar APIs (rather than declaring a pid_t type on
Windows).
BUG=b:309848917
BUG=b:309020556
TEST=tools/dev_container tools/presubmit
TEST=cargo build --target=aarch64-apple-darwin -p base
Change-Id: Iaa1cddb84eb16b94fe35c02f2f4988b8d955318a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5014787
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Cody Schuffelen <schuffelen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
These should work for both Linux and macOS.
BUG=b:309848917
BUG=b:309020556
TEST=tools/dev_container tools/presubmit
TEST=cargo build --target=aarch64-apple-darwin -p base
Change-Id: If0353304bf12b1596adb64e412ee8d39c825db38
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5014786
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Cody Schuffelen <schuffelen@google.com>
The WindowMessage enum covers general window messages that multiple
modules may want to process, such as window manager, input manager,
etc.
After this change, it isn't necessary to have the HandleWindowMessage
trait anymore. It will be nuked in the follow-up CL.
BUG=b:244492422
Change-Id: Ib4d8dfd29ff7d7f55aa2d1f759b091aee32c2cdf
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5002765
Commit-Queue: Pujun Lun <lunpujun@google.com>
Reviewed-by: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
- Replace unwrap_or_else(Vec::new) with unwrap_or_default()
- When implementing PartialOrd for a type that has Cmp, use .cmp()
- Create zero-initialized Vec with vec![] macro
- Fix extra slash in doc comment (//// -> ///)
Change-Id: I92a37cdffbe5a297b9f5d08a9264040f7fdac721
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5007730
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This allows the test binary to run without opening any files from the
source directory, fixing the ChromeOS crosvm ebuild tests.
TEST=`FEATURES=test emerge-hatch crosvm`
Change-Id: I3ced2d69f2ffb43305e8e13fc9f8b6a548120b44
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5013626
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Unfortunately, riscv for debian has not been stable enough for us
to reliably build containers for cross-compilation.
Hence the builder is disabled for now.
BUG=b:304875018
TEST=lucicfg validate main.star
Change-Id: Icee9802f8bcb6a9586ff857105b76591e9de1099
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5014784
Auto-Submit: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Running cargo binstall on some packages will install them from source
if no binary release is available.
In that case, the rust-toolchain file of the CWD is used for building,
which may not be the right version required by the binary package
we are trying to install.
The new version of binstall is now also able to pull binaries from
github releases without hitting API quotas.
BUG=b:309563518
TEST=./install-deps
Change-Id: I869002cf766f806f66ba58d5b712b81c0bd30f4f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5014783
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Align with the uAPI documentation, which states that
/**
* VFIO_SET_IOMMU - _IOW(VFIO_TYPE, VFIO_BASE + 2, __s32)
*
* Set the iommu to the given type. The type must be supported by an
* iommu driver as verified by calling CHECK_EXTENSION using the same
* type. [...]
*/
Note that if a kernel supports Type1ChromeOS but doesn't properly
implement CHECK_EXTENSION for it, crosvm will now fall back to TYPE1v2.
TEST=tools/run_tests
BUG=b:306110430
Change-Id: I4480f07a64edd945b83d2b3674334f46ff674066
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5010355
Commit-Queue: Pierre-Clément Tosi <ptosi@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
As VFIO containers are assigned one (and only one) IOMMU type, keep
track of it in VfioContainer and detect IOMMU functions being wrongly
called before the IOMMU has been configured.
Note: no functional change intended.
TEST=tools/run_tests
BUG=b:306110430
Change-Id: Ie91d171de385d673041988b06cbc1ae2c875b8ed
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5009545
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Pierre-Clément Tosi <ptosi@google.com>
Instead of relying on abstractions that aren't fully encaspulated (such
as assuming that !iommu_enabled means vIOMMU or CoIOMMU or the way
IommuTypes are being selected), make the VfioContainer constructor aware
of the IommuDevType in use.
Note: no functional change intended.
TEST=tools/run_tests
BUG=b:306110430
Change-Id: I4d2f6afbc0bc9b8b4fe595550b9e8b5af2d06bda
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5009544
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Remove 2 levels of unnecessary indentation before any actual change.
Note: no functional change intended.
TEST=tools/run_tests
BUG=b:306110430
Change-Id: Ib34405733d0c5734ffbd606b55bc43ada82648d0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5009543
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Even main process shutdown by an error, the vmm-swap monitor process
should be terminated by Command::Exit via the command tube. Dropping
SwapController without explicit SwapController::exit() has caused panic
by tube disconnection in the monitor process when the main process shuts
down by an error.
SwapController will never be dropped in child processes because
ProxyDevice and fork_process() exit with libc::exit() and not drop
objects in the upper stack.
BUG=b:309463106
TEST=manual test
Change-Id: I35386dd1aefe15dafd3e9981a9432c00f8faa3fa
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5009772
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
`fallocate` is Linux-specific. On Linux, `pread*64` and `pwrite*64` are
renamed to `pread*` and `pwrite*` to match the posix definitions.
Bug: b/309020556
Change-Id: Iadeaa843af9380b09a3fa7a7d3ef4ad57c9641dd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5001582
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Every platform was re-exporting the non-platform-specific symbols
defined in descriptor_reflection.rs.
Change-Id: I95d0acdaaf8c157206ca788e4cdf64f15ebd2f84
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5001574
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Cody Schuffelen <schuffelen@google.com>