* Splits platform specific bits of test_integration into a sys module.
* Cleans up Cargo.toml & platform specific imports.
BUG=b:213152505
TEST=builds
Change-Id: I95eff1f240e98b09a600239a77fc54e5222edebf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3701040
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Richard Zhang <rizhang@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
This makes it easier to integrate crosvm into Android (which doesn't
have the kernel headers available for all the build targets crosvm is
needed in).
The BTN_LEFT constant is already hardcoded in virtio/input/constants.rs,
so the additional tech debt seems acceptable.
BUG=b:228881829
TEST=cargo build && cargo test
Change-Id: Ia25586e855a29fc5f475904cad028eef30d3f016
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3717525
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
Allow the device_helpers code to evaluate base_features() with the value
of protected_vm from the configuration to match the pattern used with
other devices.
BUG=b:227283268
TEST=emerge-hatch crosvm # board with chromeos and tpm features enabled
Change-Id: I15b73bbb32d684c1f29130929ec25c4dc9644967
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3717184
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Yi Chou <yich@google.com>
We depend on both lazy_static and once_cell, which do basically the same
thing.
The once_cell crate has a few advantages:
- once_cell is on track to be included into libstd.
(https://github.com/rust-lang/rust/issues/74465)
- once_cell doesn't require macro magic.
Replace the uses of lazy_static with their once_cell equivalents so we
don't need to pull in both crates.
BUG=b:236191006
TEST=tools/presubmit --all
TEST=tools/run_tests --target=host --arch=win64 --build-only
TEST=cargo test --features=plugin
Change-Id: I7cabcd837ef4878e8e8ae635bb4f235a58e4cae3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3707624
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
cvt isn't used anywhere else in the base crate, and it isn't included in
the ChromeOS crosvm ebuild, so this breaks the CrOS build. Just check
the result and return an error the same way we do elsewhere in base.
BUG=b:231641496
TEST=cargo build
TEST=emerge-hatch crosvm
Fixes: 21445b1b83 ("base: Upstream unix net set_nonblocking fn")
Change-Id: Iba8beee21810210e50e0c715a1b84de29278625a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3716851
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Implement `WhpxSplitIrqChip` for `whpx` (Hyper-V) which has a split IRQ
chip architecture. Add dependencies for the root `whpx` feature on the
`devices/whpx` feature set.
BUG=b:213149158
TEST=Compiled on windows.
Change-Id: I3b0aec441b5abdff3f0266a9467380b0cdc4fdee
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3717187
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vaibhav Nagarnaik <vnagarnaik@google.com>
Rather than having a global CPUIDS variable that is used by all tests
for the TSC CPUID code, we can pass a function pointer to the
tsc_frequency_cpuid() function to retrieve a specified CPUID value. For
normal use, we provide a host_cpuid_count function that uses the normal
__cpuid_count intrinsic as before. For the tests, we provide a fake
CPUID function that returns the desired test values.
This removes the potential for problems when running multiple tests in
parallel (which was hypothetical, since we only had one test so far, but
worth fixing).
BUG=b:234508273
TEST=cargo test -p devices tsc
Change-Id: Ic963b21f09f8e8d7665386ad134ae5e242b3051d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3707623
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Vaibhav Nagarnaik <vnagarnaik@google.com>
Don't log the TSC calibration results for every core at the default info
log level, since that can be quite noisy on machines with many CPUs.
The logs can be re-enabled using the `--log-level` option:
crosvm --log-level=devices::tsc=debug run ...
BUG=b:234508273
TEST=crosvm run doesn't print tsc logs by default
Change-Id: I5051e22740b6b2136d35936c60dee776abd1d00d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3707388
Reviewed-by: Colin Downs-Razouk <colindr@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
The new LoadedKernel structure also splits out the size and end address,
which are both used in different places (x86_64 wants end, aarch64 wants
both).
BUG=b:234155022
TEST=tools/presubmit
TEST=cargo test -p kernel_loader
Change-Id: I86a7e412c983f29a2c614cc9e6896aa11db6ba94
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3673611
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Avoid a collision with sync 0.1.0 on crates.io so patches.crates-io can
be used to override cargo.
BUG=None
TEST=CQ passes
Change-Id: I3f5eb33f20fa5ffab2675ad1a156eefdf687e5b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3707378
Commit-Queue: Allen Webb <allenwebb@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Allen Webb <allenwebb@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This is a reland of commit 7110d673f2
Replace --no-legacy flag, which implied the removal of both i8042 and
rtc devices, with separate --no-i8042 and --no-rtc flags. The old
flag is still supported and implies the other two.
Because the original landing of this flag didn't protect it as an x86
specific option, this change just leaves that alone. But the new flags
are added as x86-only, because they are very x86 specific.
BUG=b:223443221
TEST=crosvm run --bios u-boot.rom --disk kernel
TEST=boot volteer-manatee
Change-Id: I57f9328483f24da29db663e261b3ccc2a97c3239
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3715083
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
In preparation for the upcoming VAAPI backend, derive Clone for Capability.
This is so a Decoder can own a Capability and merely clone it in the
DecoderBackend::get_capabilities call, reducing the number of calls into
the libva driver.
BUG=b:214478588
TEST=None
Change-Id: Ide3d410e0e0a89e774400ea466cac5875ebc8dc3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3422777
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
This will give coverage to the video decoder code in the CQ.
We don't enable it for armhf as the `device` crate is not tested anyway.
BUG=b:169295147
TEST=./tools/run_tests
TEST=./tools/run_tests --target=vm:aarch64
TEST=FEATURES=test emerge-amd64-generic chromeos-base/crosvm
TEST=FEATURES=test USE=crosvm-video-ffmpeg emerge-amd64-generic chromeos-base/crosvm
Change-Id: I6fd6061c50225e83af5d25c72d7e3bf1baa2447b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3688028
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
When resources are overlapping we probably want to know what is
overlapping.
BUG=b:236574949
TEST=boot
Change-Id: I4f99f742bda91945f7fe6e94d60bc8adbfe4326f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3715074
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Now that the ffmpeg decoder backend has been merged, anyone can try the
virtio-video device. Add a page on the book explaining how to do so.
BUG=b:235067555
TEST=mdbook build
Change-Id: I984b4953580274015900a80a378cab9c3eb7b2ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3708389
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
This reverts commit 7110d673f2.
Reason for revert: Needs to preserve --no-legacy flag for a while though deprecated
Original change's description:
> crosvm: split up --no-legacy flag
>
> Replace --no-legacy flag, which implied the removal of both i8042 and
> rtc devices, with separate --no-i8042 and --no-rtc flags. The old
> flag is still supported and implies the other two.
>
> Because the original landing of this flag didn't protect it as an x86
> specific option, this change just leaves that alone. But the new flags
> are added as x86-only, because they are very x86 specific.
>
> BUG=b:223443221
> TEST=crosvm run --bios u-boot.rom --disk kernel
>
> Change-Id: I4bbea2d0a38fdd3a5d69d12ca79fa360f0460358
> Signed-off-by: Alistair Delva <adelva@google.com>
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3510982
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
> Tested-by: kokoro <noreply+kokoro@google.com>
Bug: b:223443221
Change-Id: I022cff96f4508713c15973ee37a57e7fdc8c14e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3715073
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Create an `IrqEventSource` for each instance of IRQ registration with
the `direct` feature.
This fixes a compilation issue with the `direct` feature.
TEST=Compiled with `cargo build --features=direct`
Change-Id: I691b156f84bc6795c887d5203aad7d15aaad22e7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3715270
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
We need base features to prevent the "virtio: device uses modern
interface but does not have VIRTIO_F_VERSION_1" error in the kernel
driver.
BUG=b:227283268
TEST=Build OK.
TEST=vmc start --software-tpm termina
TEST=ls /dev/tpm0
Change-Id: Icf3c288f2acc39ec1e8e23250a9d0cd6b8f84eb9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3696295
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Leo Lai <cylai@google.com>
Commit-Queue: Yi Chou <yich@google.com>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
This CL will add "vtpm_proxy" option into the crosvm.
BUG=b:227283268
TEST=Build OK.
TEST=vmc start --vtpm-proxy termina # With crrev.com/c/3697690
Change-Id: I44c81abc1e2f41a80276f4de70e269c07eff901f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3696293
Commit-Queue: Leo Lai <cylai@google.com>
Commit-Queue: Yi Chou <yich@google.com>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
This CL will introduce a new TpmBackend called VTpmProxy.
This proxy will bridge the VM tpm device and the vtpm daemon on
ChromeOS.
BUG=b:227283268
TEST=Build OK.
Change-Id: Ibfbfdddbaca2af1d066920bb62918d88b0943d59
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3696292
Commit-Queue: Yi Chou <yich@google.com>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Leo Lai <cylai@google.com>
Pass the correct type to the function instead of a boolean that we will
convert.
BUG=None
TEST=cargo build
Change-Id: Ic825e9444847cb38318bd854bcbdf9aefbe83c4c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3708384
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
The bus/address and vendor/product IDs are unused internally; only the
usbdevfs device path matters. Update the internal API parameters and
documentation to match.
The crosvm_control `crosvm_client_usb_attach()` function must keep the
extra parameters to maintain API compatibility, but its documentation is
updated to note that they are unused.
BUG=None
TEST=Attach USB device to Crostini on trogdor
Change-Id: I7086f61a420be1dbf3dd1877fa86a5e82c0c5c77
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3708640
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Arc::as_ptr() is only available as an associated function.
Fixes compile error:
error[E0599]: no method named `as_ptr` found for struct
`Arc<bindings::WHV_RUN_VP_EXIT_CONTEXT>` in the current scope
BUG=b:213151419
TEST=tools/run_tests --target=host --arch=win64 --build-only
Change-Id: Icc6753e4109b54ca507bb91bc89abd80fae098b7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3707626
Reviewed-by: Vaibhav Nagarnaik <vnagarnaik@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
These are currently guarded by a feature flag check that was only
enabled for haxm.
BUG=b:213151419
TEST=tools/run_tests --target=host --arch=win64 --build-only
Change-Id: Id40a29ffd63e378ce1583e56ca0f23914705b6fb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3707625
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Vaibhav Nagarnaik <vnagarnaik@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This will be used to pass the initial register values for each vcpu.
Each architecture can define its own variant of the initial vcpu state.
BUG=b:234155022
TEST=tools/presubmit --all
Change-Id: I696a5ecda202c1ff0681f0b89b89b9eec11e27e7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3673615
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Check in the source to generate the test binary, and make it a minimal
x86-64 ELF binary that can actually work inside crosvm. The new version
uses the COM1 serial port to print a hello message.
This provides a proper test for the ELF loader, including a binary that
is linked with the appropriate physical address fields in its program
headers.
The resulting binary is checked in rather than generated by tbe build
system since we want a consistent file that can be verified against
known good constants in the tests.
BUG=b:234155022
TEST=cargo test -p kernel_loader
Change-Id: I772b4d7e1fcb2b420acd454dc40764943bf975b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3673610
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This irqchip is currently used with Haxm which doesn't implement a local
APIC.
BUG=b:213149158
TEST=Compiled.
Change-Id: I3088ea5cad68451230dc3d5f8b649d54e83b938b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3701442
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vaibhav Nagarnaik <vnagarnaik@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This allows irq processing thread to log statistics and metrics and
track them using the source of the device. To be upstreamed later.
Introduce `PCI_VENDOR_ID_CROSVM` which identifies devices created by
crosvm. And introduce `CrosvmDeviceId` which adds a unique device ID for
each type of crosvm device.
BUG=b:213149158
BUG=b:213152505
TEST=Compiled.
Change-Id: Ica1374d8a2d8fd627c9397553bb7fb62baeaff7d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3687418
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vaibhav Nagarnaik <vnagarnaik@google.com>
rwroot automatically adds root=/dev/vd[a-z], but the example image
actually uses /dev/vda5. This leads to confusion when two root= kernel
command line arguments are passed in and only one of them works.
Therefore we use rwdisk instead which doesn't add the kernel argument.
BUG=b:236198584
TEST=mdbook builds, examples build and run
Change-Id: I9bfc05445b1e2aef197a43ee647d7c784d50dad7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3708365
Commit-Queue: Yuanchu Xie <yuanchu@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Exclude pci mmio region below 4gb from the e820 table. This is a
followup to CL:3696671.
BUG=None
TEST=arc.Boot.vm
Change-Id: I07c2b9a9e2e4e27682c4b60406625b019eea195f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3708390
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
Make `cargo test --feauture=direct` pass by fixing build dependencies
and skipping a broken test case.
BUG=b:220292205
TEST=cargo build --features=direct in x86_64
Change-Id: I599ad5bc7ebb2fa91f6ff64291fb15ea129f8d05
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3708381
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
We are going to use separate policy files per device for the following scenarios:
1) Regular in-VMM virtio device,
2) Virtio device over vhost-user,
3) Virtio device over Vvu.
Each of these scenarios require slightly different policies as a jailed
device process needs to allow not only the system calls necessary for
the device to function, but also those required by the virtio transport
in use.
This CL adds a README.md file to the seccomp directory that details the
naming and policy inclusion rules, and updates the serial, xhci and
coiommu policies to follow the naming scheme.
Vhost-user and VVU policy files will be added along with support for
jailing devices when they are in use.
BUG=b:217480043
TEST=serial device works with `crosvm run`.
Change-Id: I6d454aa6e05d00691fe3346e822ed1fc7b24aed8
Signed-off-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3706490
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
The device and jail creation helpers should be reusable in other
contexts than `crosvm run` - e.g. they would be helpful to run a list of
sandboxed vhost-user devices without a VMM. However the `Config`
structure currently represents an entire VM config, which makes these
helpers unusable outside of `crosvm run`, and also expose individual
devices to much more configuration data than they need.
Fix this by only passing the needed configuration data from the `Config`
struct, which for most devices consists of the protection type and jail
configuration.
BUG=b:217480043
TEST=cargo build
Change-Id: If1f6dcb0d6d82a4e73d25a45b367da2364642e6f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3546582
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Pcie upstream/downstream port will also have their related host port,
and their functionality should be similar with pcie host root port.
So I refactored PcieHostRootPort to PcieHostPort here, so that
pcie upstream/downstream port could use them later.
BUG=b:199986018
TEST=./tools/presubmit
Change-Id: I34d46f82c3b3adcfd7b5eb178cda29e902b3eb1f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3692430
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>