Commit graph

3996 commits

Author SHA1 Message Date
Lepton Wu
1973802bea crosvm: Add a flag to disable INTx for virtio devices.
Sometimes we got buggy interrupt entries in ACPI table which
could confuse linux kernel. Add a new flag to disable it so
virtio devices can skip this part of initialization since they
should all support MSI-X.

BUG=b:236206320
TEST=manual - Run crostini on volteer-manatee

Change-Id: I98764b7cd31a2e68ddcd78d8175442f90ad8b164
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3719139
Commit-Queue: Lepton Wu <lepton@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-06-23 00:59:52 +00:00
Vikram Auradkar
32cabe0cd4 devices: enable tests
BUG=b:213149155
TEST=presubmit

Change-Id: Iff1a721dddfaed3e2728222a75348745be9ef05a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3710851
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-23 00:26:06 +00:00
Noah Gold
dd40d069b2 x86_64: cross platform cleanup
* 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>
2022-06-22 23:34:17 +00:00
Keiichi Watanabe
d001987d6b ci: kokoro: Add continuous-x86_64-direct
Add postsubmit test config for crosvm-direct binary on x86_64.

BUG=b:220292205
TEST=./ci/kokoro/simulate.py ./ci/kokoro/build-x86_64-direct.sh

Change-Id: I326c52924cc154485c5941cec82be56547d7d862
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3715071
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-06-22 23:18:35 +00:00
Peter Collingbourne
2f74118ecf Remove madvise from *_audio_device.policy.
It was already present in common_device.policy, causing
errors such as:

crosvm[1384]: libminijail[1384]: compile_file: crosvm/seccomp/aarch64/null_audio_device.policy(8): syscall madvise redefined here
crosvm[1384]: libminijail[1384]: compile_file: /home/pcc/crosvm/seccomp/aarch64/common_device.policy(25): previous definition here
crosvm[1384]: libminijail[1384]: compile_filter: compile_file() failed

Change-Id: I857cefd3075dbda001b07217ae7f20c85b3ef908
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3703886
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Peter Collingbourne <pcc@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-06-22 23:08:02 +00:00
Keiichi Watanabe
eb8cfb4b18 tools: Add crosvm-direct support for run_tests
BUG=b:220292205
TEST=./tools/run_tests --target=host --crosvm-direct

Change-Id: Ife25129d405cd1e514bf812cc31621313f2007b5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3708759
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
2022-06-22 21:51:53 +00:00
Frederick Mayle
7bba2599cf gpu_display: Don't include linux kernel headers
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>
2022-06-22 15:52:39 +00:00
Daniel Verkamp
959a05e7cc devices: virtio-tpm: pass base_features to constructor
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>
2022-06-22 15:20:13 +00:00
Keiichi Watanabe
0974be8042 integration_tests: Define Config struct
Define `struct Config` to specify crosvm arguments so it'll make it
easier to add more complicated arguments in future CLs.

BUG=b:220292205
TEST=./integration_tests/run

Change-Id: I89921e171a81071dbfc58d22b233e9c71abcdf54
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3686717
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-22 01:46:18 +00:00
Noah Gold
f54f7ed040 devices: fix double init of logging on blk for Windows.
BUG=235867298
TEST=tested downstream

Change-Id: I81ff30c9c953b8f2674e1fd8f258a90aad92282a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3712543
Commit-Queue: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-06-22 01:05:50 +00:00
Vikram Auradkar
731c22bbe2 crosvm: build/test few more crates on windows
BUG=213146128
TEST=presubmit

Change-Id: I7fcb5f4d61ee677595df32edbba7f50383ab0731
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3707422
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-06-22 00:48:23 +00:00
Daniel Verkamp
19fc097eb8 crosvm: replace lazy_static with once_cell
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>
2022-06-21 23:40:55 +00:00
Kameron Lutes
6e0ac7de54 crosvm_control: Add cbindgen configuration options
Adds necessary configuration to cbindgen to correctly format the
generated crosvm_control.h header.

BUG=b:188858559
TEST=cq

Change-Id: I7abab7a5f9d260451540c5938719ec51cad56457
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3713865
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Kameron Lutes <kalutes@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-06-21 23:25:39 +00:00
Daniel Verkamp
b33353cc46 base: remove use of cvt crate
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>
2022-06-21 22:04:32 +00:00
Vaibhav Nagarnaik
24b9db5095 irqchip: Add WhpxSplitIrqChip implementation
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>
2022-06-21 21:31:21 +00:00
Daniel Verkamp
927488df91 devices: tsc: pass cpuid as a function pointer
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>
2022-06-21 21:25:28 +00:00
Daniel Verkamp
d42d2004a1 devices: tsc: move logs to debug level
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>
2022-06-21 21:24:57 +00:00
Daniel Verkamp
8cac16bf75 kernel_loader: return a struct for better naming
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>
2022-06-21 19:39:40 +00:00
Clarissa Garvey
21445b1b83 base: Upstream unix net set_nonblocking fn
Bug: b:231641496
Upstream-Crate: base/src/sys/unix
Change-Id: I62b07f2fc3f7a02c1b72da735ac41d6dc73416f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3708762
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Clarissa Garvey <clarissagarvey@chromium.org>
2022-06-21 18:58:53 +00:00
Allen Webb
ac1b5734be common/sync: Bump the version to 0.1.99.
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>
2022-06-21 18:02:52 +00:00
Junichi Uekawa
3d6c9542a7 crosvm: Reland "crosvm: split up --no-legacy flag"
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>
2022-06-21 17:59:38 +00:00
Alexandre Courbot
f9b74bfa18 crosvm: fix build with --no-default-feature
Fix a warning that would prevent `presubmit --all` to pass.

BUG=None
TEST=cargo build --verbose --no-default-features

Change-Id: Iff80e5dd49b284cf20c2dd119d0b985317962a54
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3715086
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-06-21 16:10:29 +00:00
Daniel Almeida
8062587362 devices: video: decoder: Derive Clone for Capability
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>
2022-06-21 16:10:18 +00:00
Alexandre Courbot
08ceb73974 crosvm: enable ffmpeg decoder for 64-bit Linux builds
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>
2022-06-21 16:08:59 +00:00
Junichi Uekawa
ff246f4317 crosvm: Add a better error message.
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>
2022-06-21 05:33:52 +00:00
Alexandre Courbot
2e735a48cf docs: book: add documentation for the video device
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>
2022-06-21 05:18:01 +00:00
Junichi Uekawa
7e7412a86f Revert "crosvm: split up --no-legacy flag"
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>
2022-06-21 01:46:58 +00:00
Vaibhav Nagarnaik
0aa44acd7d direct: Fix irq registration for "direct" feature
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>
2022-06-20 21:21:45 +00:00
Yi Chou
6126fe901b Stop using Config for vtpm_proxy in device_helpers
Resolve the merge conflicts between crrev.com/c/3546582 &
crrev.com/c/3696293

BUG=b:227283268
TEST=Build OK in ChromeOS.

Change-Id: Ie776163428486dbc013667efb5ddf9cb82d39ada
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3715070
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-20 16:42:29 +00:00
Yi Chou
3f532cd2f6 Remove the useless Mutex in virtio-tpm
BUG=b:227283268
TEST=Build OK.

Change-Id: Ic0f82c3bd09614db569e7bed529e8f41b64e1717
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3708380
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Leo Lai <cylai@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Yi Chou <yich@google.com>
2022-06-20 03:41:36 +00:00
Yi Chou
f8dd84e080 Add base_features into virtio tpm device
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>
2022-06-20 03:41:35 +00:00
Yi Chou
46fbd26e02 Add vtpm_proxy into crosvm
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>
2022-06-20 03:41:33 +00:00
Yi Chou
12ce514c0f Add VtpmProxy as a new TpmBackend
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>
2022-06-20 03:41:31 +00:00
Alexandre Courbot
4a2f1c8cb9 crosvm: linux: device_helpers: pass balloon mode in device creation function
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>
2022-06-18 01:00:26 +00:00
Daniel Verkamp
1dbe52fac4 vm_control: clarify that USB attach only uses dev_path
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>
2022-06-17 23:18:24 +00:00
Daniel Verkamp
7afb3be9ca hypervisor: whpx: fix Arc::as_ptr usage
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>
2022-06-17 22:41:32 +00:00
Daniel Verkamp
bc3204c738 hypervisor: enable x86_64 functions for whpx
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>
2022-06-17 22:41:31 +00:00
Daniel Verkamp
77abcb0d0a arch: add VcpuInit data to provide initial values
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>
2022-06-17 20:50:51 +00:00
Daniel Verkamp
299675d957 kernel_loader: replace test_elf.bin
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>
2022-06-17 19:55:58 +00:00
Vaibhav Nagarnaik
0207256ccc irqchip: Add userspace irqchip support
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>
2022-06-17 18:44:21 +00:00
Vaibhav Nagarnaik
b8bfdb496f irqchip: Add IrqEventSource for each event
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>
2022-06-17 18:44:20 +00:00
Anton Romanov
cde05ba3a1 Fix deprecation warning
Change-Id: I614deae1149a8193a4a0121042d1c8c14abaeaed
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3711611
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Anton Romanov <romanton@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-06-17 18:02:52 +00:00
Yuanchu Xie
4071d1ef5e examples: use rwdisk instead of rwroot
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>
2022-06-17 17:43:41 +00:00
David Stevens
a4a46df15e x86_64: fix e820 computation
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>
2022-06-17 09:15:19 +00:00
David Stevens
89479b41db crosvm/linux: fix direct compilation error
Fix a compilation error in the --features=direct build caused by
CL:3696671.

BUG=None
TEST=cargo build --no-default-features --features=direct

Change-Id: Idb90d4712064b007672589db65d93b0168508a8f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3708388
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-06-17 06:55:00 +00:00
Keiichi Watanabe
2dcbb98677 x86_64: Fix build errors with direct feature
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>
2022-06-17 06:21:18 +00:00
Alexandre Courbot
c553d1c283 seccomp: define naming rules for policy files
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>
2022-06-17 04:35:09 +00:00
Alexandre Courbot
172dfd31aa crosvm/linux: stop using Config in device_helpers
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>
2022-06-17 04:35:08 +00:00
Vikram Auradkar
db6ea0adaf devices: cleanup
- a few symbols renamed from fd to descriptor
- comment updates

BUG=b:213149155
TEST=presubmit

Change-Id: I1721c451e3695c50faa5fa416846ca7c317c08e8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3707620
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-06-16 23:59:31 +00:00
Frederick Mayle
e0b3fe3845 base: Delete unused rand crate
BUG=b:228881485
TEST=cargo build && cargo check --tests

Change-Id: I492d564872873953fa30b1b15ccc8e62f3c5bc23
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3710853
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-16 23:46:15 +00:00