Commit graph

3510 commits

Author SHA1 Message Date
Dennis Kempin
e40b5b8f4b build-chromeos.sh: Install python 3.9 for depot_tools
Kokoro uses python2 by default, which breaks repo

BUG=b:226975041
TEST=./ci/kokoro/simulate.py ./ci/kokoro/build-chromeos.sh

Change-Id: I2424107c76d52c4bc76cd640114c21fca00f3c44
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3606968
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-04-25 23:01:50 +00:00
Vikram Auradkar
0c0ba1c158 base: fix Event import in clock
The unix clock uses crate::Event. Using crate::Event makes it
consistent and downstream compiler happy.

BUG=b:213153157
TEST=presubmit

Change-Id: Ia03f0eb787eb8eaf344fe4fa25b5a78f705f43c2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3606372
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-04-25 22:57:06 +00:00
ZhaoLiu
0c2ce08ca1 x86_64: Preparation for ITMT scheduling in Guest
With Intel Turbo Boost Max Technology 3.0, (ITMT),  the maximum turbo
frequencies of some cores in a CPU package may be higher than for the
other cores in the same package. In that case, make the scheduler prefer
to run tasks on the CPUs with higher max turbo frequencies, to achieve
better performance.

When vCPUs 1:1 map to pCPUs, ITMT scheduling feature can benefit
performance of Guest. So when user sets `--itmt`, crosvm will check if
`--host-cpu-topology` is set or if `--cpu-affinity` is set for 1:1
mapping.

In kernel, ITMT scheduling feature depends on intel_pstate driver and
ACPI CPPC support.

To setup intel_pstate driver and pass CPPC capability check, we need
emulate related MSRs in userspace:

- MSR_HWP_CAPABILITIES and MSR_TURBO_RATIO_LIMIT: intel_pstate driver
  only needs to read. So we passthrough them to Guest. But please note,
  to be compatible with the configuration in initramfs, use `FromCPU0`
  Temporarily.

- MSR_PM_ENABLE and MSR_HWP_REQUEST: they are MSRs to control HWP.
  When intel_pstate driver is initializing, the driver will close/open
  HWP by writing into MSR_PM_ENABLE, and the driver also needs to set
  performance policy by writing some hints into MSR_HWP_REQUEST.
  Note that we don't want Guest's behavior to affect the performance
  control of the host, so use 'emulate' handler for them.

- MSR_PLATFORM_INFO: this MSR is emulated in kernel with a fault value
  by default. intel_pstate doesn't want this fault value, so we ask
  this MSR to exit to userspace and give it a real value.

- MSR_IA32_PERF_CTL: intel_pstate driver use this MSR to set the min
  pstate in the initialization. So use 'emulate' handler for this MSR.

Since of `FromCPU0` setting of MSR_HWP_CAPABILITIES, ITMT scheduling
will set the same priority for each core so optimization will not work.

BUG=b:225375705
TEST=Set `--itmt` and check /proc/sys/kernel/sched_itmt_enabled

Change-Id: Icfa85ffa15c3b977c3b62a1f8a379c4c2f5fc49d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3575511
Commit-Queue: Zhao Liu <zhao1.liu@intel.corp-partner.google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-04-25 08:21:16 +00:00
ZhaoLiu
202d5a549b x86_64: Add kvm MSR_PLATFORM_INFO read control
Add a kvm capability config helper. This helper controls wheter
MSR_PLATFORM_INFO can be read in kernel space.

With this helper, we can ask RDMSR of MSR_PLATFORM_INFO traps to
userspace and emulate this RDMSR in crosvm.

BUG=b:225375705
TEST=Cargo build

Change-Id: Ic3444e678b124c19b600d8b31062a2cbe3a65156
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3575510
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Mattias Nissler <mnissler@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: Zhao Liu <zhao1.liu@intel.corp-partner.google.com>
2022-04-25 08:02:09 +00:00
ZhaoLiu
b969ded8a5 crosvm: Support MSR emulation
At present, crosvm can support handle RDMSR in userspace by read MSR of
Host directly. This is the RDMSR passthrough in userpace.

This patch adds more MSR handler support, including:
- WRMSR passthrough: write the corresponding MSR of Host directly in
  userspace; The control of MSR will work on host;
- RDMSR emulation: crosvm uses a dummy MSR value to let Guest reads on.
  This value can be different with real MSR of Host;
- WRMSR emulation: crosvm uses a dummy MSR value to let Guest writes
  into. This means the control of MSR won't really work (on Host).

BUG=b:225375705
TEST=Set `--userspace-msr=0x1a2,type=r,action=pass,from=cpu0`

Change-Id: I3276dd651464ef7b695e2ddd433793d59128af9b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3575508
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-04-25 07:50:55 +00:00
Xiong Zhang
e93b16cefc x86_64: Redesign MTRR setting
Currently MTRR setting is: the default cache type is write back and the
pci low mmio range is uncache, then guest memory is WB by default, but
pci high mmio and the gap between ram end and pci start below 4G are WB
also, this part is wrong. In order to fix it, var mtrr should be used to
set pci high mmio as uncache, but pci high mmio is too large to have
enough var mtrrs.

This commit change MTRR setting as: the default cache type is uncache,
and the guest memory is WB. So memory range below 4G and above 4G are
passed into setup_msrs(). And the variable MTRR registers are limited
and have base and length requirement, so guest memory size is aligned
to 256MB to avoid MTRR failure.

BUG=None
TEST=check guest mtrr setting with different guest memory size

Change-Id: I4c18e83ce5e7fac9ac1bf6e174116a69924184ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3578015
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-04-25 06:11:45 +00:00
Alexandre Courbot
f82754c78c virtio: console: inline write_output function
These two lines are called from one place and do not justify having a
dedicated function.

BUG=b:228912920
TEST=cargo build

Change-Id: Ia57b8f74bb6fa9c7b78e7caa56ea3f7c3ce259db
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600163
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-04-23 03:51:53 +00:00
Richard
6601d6cf36 vhost-user handler: Upstream Windows handler.rs vmm implementation
System specific code refactored into "sys" module

Bug: b:228081882
Test: built and presubmits
Change-Id: Id9caacb23cc7fcd8ca8640ce7292562809f0f71e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3601236
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Richard Zhang <rizhang@google.com>
2022-04-22 18:27:10 +00:00
Pierre-Clément Tosi
5edab50b7c virtio: Add default VirtioDevice::supports_iommu()
Introduce a way for virtio devices to broadcast their need for a
virtio-iommu without relying on parsing their feature bits, as
VIRTIO_F_ACCESS_PLATFORM may be set for other reasons than needing an
IOMMU.

Bridge the gap between PciDevice::supports_iommu() and that new method
in VirtioPciDevice.

Use the new method to enable virtio-iommu support in VirtioVHostUser.

BUG=b:223546213
BUG=b:226644087
TEST=tools/dev_container tools/run_tests --target=vm:aarch64

Change-Id: I5c20def2b96ee971f3d56776095635a984feccfe
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3571561
Reviewed-by: Andrew Walbran <qwandor@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-04-22 10:07:35 +00:00
Dennis Kempin
0a581d64ef Kokoro: Add ChromeOS post-submit builder
This adds an experimental build script that will build crosvm for
ChromeOS. This will allow us to catch issues on the ChromeOS build of
crosvm earlier in the process.

BUG=b:226975041
TEST=./ci/kokoro/simulate.py ./ci/kokoro/build-chromeos.sh

Change-Id: I4a1d906a44191e78f4e656fe76c989bd7e1b6977
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600764
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-04-22 04:41:03 +00:00
Dennis Kempin
ba8f18e671 Adding Noah to crosvm OWNERS
Insert famous spiderman quote here.

BUG=None
TEST=None

Change-Id: I5dca10144b0270c414242ef6533950b3449b2069
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600799
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-04-22 04:40:32 +00:00
Vikram Auradkar
273a9b16b3 base: move timerfd to timer
A series of patches move unix specific code into src/sys/unix/timer.rs,
retain platform independent code in src/timer.rs and then introduces
windows timer.rs.

BUG=b:213153157
TEST=presubmit

Change-Id: I1dad42b112305e70582f0ec8a0e38b7e305783fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600758
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-04-22 02:13:13 +00:00
Vikram Auradkar
5bafb3a3c7 base: Fix doc tests
Some of the fixes are already available for unix code. This change will
make future cls pass doc tests on windows.

BUG=b:213153157
TEST=presubmit

Change-Id: Ie172c1cb253f633628ae9db016fcd259b39b0bfe
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600757
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-04-22 02:13:12 +00:00
Noah Gold
486fa03648 net_util: refactor unix for cross platforming.
BUG=b:213151463

TEST=bots

Change-Id: I67d43171df084392175261de98c8dc0404a933d6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3598233
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-04-22 01:37:58 +00:00
Vikram Auradkar
d367eff0db Prefer descriptor variants over fd
These are selected few instances where we can use platform independent
raw_descriptor variants over platform specific raw_fd

BUG=b:213153157
TEST=presubmit

Change-Id: Id9e80fb4e9bf6ef9fa059f0324821b82dfd45292
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600756
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-04-22 01:13:52 +00:00
Anton Romanov
3d1c3018d4 crosvm: static INFO as lowest log level for release builds
We do not intend for release builds to be able to log debug/trace
statements

BUG=none
TEST=cq

Change-Id: I963c055de8ac14f5928ef5037caba4ef456f3887
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3598245
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
2022-04-21 22:02:01 +00:00
Anton Romanov
fd71fa1bd4 crosvm: refactor base::syslog and integrate with log facade
Motivation behind this is to greatly reduce code duplication and more
streamlined syslog experience.
Integration with log facade allows us to have logs from 3rd party crates
and better integration into rust ecosystem. As well as getting rid of
our log/warn/etc macros.

Notable changes:
    * Moving to log's levels: info/trace/debug/error/warn. Note that
      none of our code utilizes alert/critical/etc so this is benign
    * Moving windows' syslog implementation filtering into
      cross-platform scope;

BUG=none
TEST=kokoro

Change-Id: I28b3a34a3ddca21af9cc6d191061681a02314f7b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3588248
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Auto-Submit: Anton Romanov <romanton@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
2022-04-21 21:56:09 +00:00
yuankaichen
708161aad7 add release / debug modes to build_test script for building windows
binaries

Test: build locally
Change-Id: I4a9b96a0387c3c26ff2975680851943c2252946b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3598240
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Yuankai Chen <yuankaichen@google.com>
2022-04-21 17:09:29 +00:00
Noah Gold
ab263d1010 disk: fix punch_hole using wrong AllocateMode.
9da4030ab0 migrated consumers to use
AllocateMode, but this method got the wrong mode. This CL fixes that.

Thanks to idanr@ for spotting this during downstream merging.

BUG=NONE
TEST=bots + inspection.

Change-Id: I10792d4f293d7f672d3474288a7f706a5c0fd835
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3597038
Auto-Submit: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-04-21 02:19:31 +00:00
Keiichi Watanabe
94e753c41e crosvm_control: Skip build.rs when cargo-doc is called
This will fix GitHub Action's failure.
This couldn't be caught in kokoro because kokoro sets correct
environment variables for testing.

BUG=none
TEST=./tools/cargo-doc

Change-Id: I1db2e459422e755f6231cb0a6e5e082ffa0727ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3581449
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Kameron Lutes <kalutes@chromium.org>
2022-04-21 00:17:25 +00:00
Keiichi Watanabe
b24aa4cb84 crosvm_control: Use anyhow in build.rs
This provides clearer error message.

BUG=none
TEST=cargo check

Change-Id: I954be94b2961383f2c23da104e695321e49e497e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3581448
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Kameron Lutes <kalutes@chromium.org>
2022-04-20 23:53:07 +00:00
Anton Romanov
13c21bdd12 crosvm: tools: Skip non-scripts in tools/
Otherwise tools/[fmt, health-check] crash and burn trying to decode
vim's swap/undo files as utf8 text

BUG=none
TEST=kokoro

Change-Id: I4ebd3fe33484353bddb0ae12054c47ca3ecd6b89
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3598242
Auto-Submit: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-04-20 23:50:38 +00:00
Anton Romanov
c79d5f838c crosvm: crosvm_control: use OUT_DIR instead of CARGO_TARGET_DIR in build script
CARGO_TARGET_DIR is not meant to be used in build scripts as that is an
optional variable that *may* be passed to cargo. The one that is set by
cargo itself is OUT_DIR and is always present to specify where build
scripts are expected to place output

BUG=none
TEST=cq

Change-Id: I118eebf914dbefd93f2cafb6950c7a6b4c01c574
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3598239
Auto-Submit: Anton Romanov <romanton@google.com>
Reviewed-by: Kameron Lutes <kalutes@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
2022-04-20 23:05:48 +00:00
Dennis Kempin
a62858f89d Ensure python doc tests failures will fail health-check.
And fix a nit in the existing tests to make it pass.

BUG=b:219965702
TEST=presubmit

Change-Id: I65fb98b04d7042755930dd34913f679fa129c88c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3594248
Reviewed-by: Maciek Swiech <drmasquatch@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-04-20 19:47:49 +00:00
Keiichi Watanabe
25d7911e8d crosvm_control: Minor style fix
BUG=none
TEST=cargo chekc

Change-Id: I24fa7eced9053eee535778153390f4039044e47f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3581447
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Kameron Lutes <kalutes@chromium.org>
2022-04-20 19:33:30 +00:00
Noah Gold
35290a48c0 cros_async: enable tests on Windows.
BUG=b:213147081
TEST=bots

Change-Id: I88ac2eb0c4c9b4f3f77e2b3c0cc994979a14d14c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3585009
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-04-20 18:56:54 +00:00
Kameron Lutes
1904e141b7 Reland "crosvm_control: Generate C header during build"
This is a reland of commit 06fca32aff

Original change's description:
> crosvm_control: Generate C header during build
>
> Generates a C header for the crosvm_control library during crosvm build.
>
> BUG=b:188858559
> TEST=cq
>
> Cq-Depend: chromium:3553666
> Change-Id: Ic6d57d654f546a4ddf9facad16d29a03c103ebbe
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3553761
> Reviewed-by: Dennis Kempin <denniskempin@google.com>
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Kameron Lutes <kalutes@chromium.org>

Bug: b:188858559
Change-Id: I041cf6452ecec2d3ef9581b07ee0c457ba81cf98
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3593855
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Kameron Lutes <kalutes@chromium.org>
2022-04-20 18:29:20 +00:00
Richard
2aa0a385f0 tube_transporter: Upstream this Window's specific crate
This IPC crate is used to send boot data across the different CrosVm
processes on Windows.

Test: built presubmit
Bug: b:213154641
Change-Id: I9e8d220e64823fed7c6f887a06ce30795c2bdae5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3584244
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-04-20 01:24:35 +00:00
Noah Gold
a81eebfe8e cros_async: move IntoAsync to use AsRawDescriptor
Originally cros_async was not permitted to depend on base, and as such
was precluded from using RawDescriptor/AsRawDescriptor. Now that we can
use base, we are switching over to those types/traits as they allow for
much cleaner cross platform code.

BUG=b:228904576
TEST=builds (also tested applying downstream).

Change-Id: Id5da60b127656568069795707a48beca1a015151
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3584139
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-04-19 22:19:06 +00:00
Noah Gold
68bbe92339 cros_async: upstream Windows support.
Major changes:
* Adds Windows implementations
* Refactors cros_async to use the styleguide for cross platform code.
* Adds platform specific Descriptor impls to Timer & Event (short term;
  this will go away in the next CL in the series).

Minor adjustments:
* The doctests for the Executor were passing the wrong type of seek
  parameter to write_from_vec. It was disabling seeking (None) when it
  should have been  seeking to zero (Some(0)).

BUG=b:213147081
TEST=tested by Windows & Linux bots.

Change-Id: Id7e025ceb9f1be4a165de1e9ba824cf60dd076ff
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3579735
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-04-19 22:19:05 +00:00
Dennis Kempin
1def2e61d9 reland: Remove temporarily duplicated code from codebase
This removes sys_util(_core), which moved into base::unix/common, as
well as common/(cros_async,io_uring), which moved into the root
directory.

The only reason the code was still around is that they were still
used in the ChromeOS codebase.
ChromeOS has pinned the version of crosvm it uses for these libraries
so we can go ahead and remove the code.

A few remaining references to sys_util have been updated to base.

BUG=b:227226222,b:229016539
TEST=presubmit

Change-Id: I7a711044de7e067b217287f2bac822d6ac7d3964
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3593852
Reviewed-by: Allen Webb <allenwebb@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-04-19 21:48:29 +00:00
Dennis Kempin
809b42db2d audio_streams: Remove dependencies on sync and sys_util
sys_util is only used to have a SharedMemory instance to run test.
This commit replaces that with a mock implementation.

BUG=b:229114164
TEST=presubmit

Change-Id: I6268f36dd3d986422090b1d2506ba55896cbca62
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3593851
Reviewed-by: Allen Webb <allenwebb@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-04-19 21:39:52 +00:00
Dennis Kempin
66be807115 Revert "Remove temporarily duplicated code from codebase"
This reverts commit aac461e25e.

Reason for revert: Breaks audio_streams portage build

Original change's description:
> Remove temporarily duplicated code from codebase
>
> This removes sys_util(_core), which moved into base::unix/common, as
> well as common/(cros_async,io_uring), which moved into the root
> directory.
>
> The only reason the code was still around is that they were still
> used in the ChromeOS codebase.
> ChromeOS has pinned the version of crosvm it uses for these libraries
> so we can go ahead and remove the code.
>
> A few remaining references to sys_util have been updated to base.
>
> BUG=b:227226222,b:229016539
> TEST=presubmit
>
> Change-Id: I35a3d1f0ea28182b77abf9b423fcab4cad525981
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3580118
> Reviewed-by: Allen Webb <allenwebb@google.com>
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Dennis Kempin <denniskempin@google.com>

Bug: b:227226222,b:229016539
Change-Id: I907279ab47718355cd57915830580929dc157f84
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3593846
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Maciek Swiech <drmasquatch@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-04-19 18:24:13 +00:00
Noah Gold
9da4030ab0 cros_async: use portable enum for fallocate modes
fallocate modes were previously unix specific constants, which won't work after
we add support for Winodws. Here, we've put a generic abstraction in place so
that each platform can implement the details as appropriate.

Thanks to acourbot@ for suggesting the splits in this series.

BUG=b:213147081
TEST=see final CL in series.

Change-Id: I822ad6c4a26eea716482029e8a6c0489aa72c595
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3583613
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-04-19 05:37:42 +00:00
Noah Gold
78ef113617 cros_async: make AsyncTimer use base::Timer
TimerFd is the sys_util era Unix-specific timer, which doesn't support Windows.
This CL moves us to base::Timer, which is the cross platform equivalent.

Thanks to acourbot@ for suggesting the splits in this series.

BUG=b:213147081
TEST=see final CL in series.

Change-Id: I41c8ad88da77c48397ed466ff11aecd703c470a8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3583612
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-04-19 05:37:41 +00:00
Noah Gold
084aa95af1 cros_async: make AsyncEvent use base::Event
EventFd is the original sys_util era Unix-specific Event. We need to use
base::Event, which is the cross platform event that works on Windows.

Thanks to acourbot@ for suggesting the splits in this series.

BUG=b:213147081
TEST=see final CL in series.

Change-Id: I174313cb544c5fc3768810365a42e6eaac1ca91a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3583611
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-04-19 05:37:40 +00:00
Risan
ab11843e86 fs: Support setting project inheritance flag
This CL allows passthrough to set project inheritance flag through
cryptohome since setting project inheritance flag cannot be done in
user namespace.

BUG=b:226908517
TEST=atest android.appsecurity.cts.StorageHostTest

Change-Id: Icdde5164e2e6f8655fff28748f6bc18449ad36c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3585215
Reviewed-by: Ryo Hashimoto <hashimoto@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Risan <risan@chromium.org>
2022-04-19 00:18:41 +00:00
Vikram Auradkar
29818542a4 move unix/win under sys/
This brings the dir structure *somewhat* similar to that the style
guide recommends.

BUG=b:213153157
TEST=presubmit

Change-Id: Iff7c7af1cfb64be45b07e57a9929d9f2fd1fa47e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3585020
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-04-19 00:17:04 +00:00
Dennis Kempin
970b00fa4d Add documentation for ChromeOS workflows
This change consolidates some of the spread out information about
what ChromeOS developers need to know about crosvms differences to
other ChromeOS projects.

I created a new directory since I would expect a similar guide for
AOSP eventually.

This also adds more documentation on some of the process changes
suggested in go/crosvm-merge-improvements to improve the
stability of the merge process.

BUG=b:227475914
TEST=None

Change-Id: I08111ecd5a937fde22c7d97f342c1cf02f49b02e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3561886
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-04-18 19:05:49 +00:00
Dennis Kempin
aac461e25e Remove temporarily duplicated code from codebase
This removes sys_util(_core), which moved into base::unix/common, as
well as common/(cros_async,io_uring), which moved into the root
directory.

The only reason the code was still around is that they were still
used in the ChromeOS codebase.
ChromeOS has pinned the version of crosvm it uses for these libraries
so we can go ahead and remove the code.

A few remaining references to sys_util have been updated to base.

BUG=b:227226222,b:229016539
TEST=presubmit

Change-Id: I35a3d1f0ea28182b77abf9b423fcab4cad525981
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3580118
Reviewed-by: Allen Webb <allenwebb@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-04-18 18:35:07 +00:00
Elliot Berman
c903a58f86 aarch64: Abstract KVM register read/writes
Remove KVM-specific code from the generic aarch64 module by providing a
generic enum for hypervisor-specific vCpus to use instead:
VCpuRegAArch64.

Change-Id: Idd7379ad35943622c534b5e0d954ec15f9d15b41
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3586723
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Steven Moreland <smoreland@google.com>
2022-04-18 17:58:06 +00:00
Elliot Berman
d28ce639c6 linux: Prepare to run with multiple hypervisors
Move KVM-specific code to "run_kvm" function in preparation for
supporting different hypervisors.

Change-Id: I02b81478ded893a0ee67e132f12d637912491fea
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3586011
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Steven Moreland <smoreland@google.com>
2022-04-15 22:23:33 +00:00
Elliot Berman
53d9530f36 linux: Drop kvm_ prefix from vcpu_ids
Simple rename to emphasize that vcpu_ids are not KVM-specific.

Change-Id: Icaf8a5f15a83021cf48467b0b8d0042ab0ab4a92
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3586010
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Steven Moreland <smoreland@google.com>
2022-04-15 22:23:32 +00:00
Dennis Kempin
af594fe6a6 Merge bot: A few minor tweaks
- Don't try to download gcompute tools multiple times
- Fix off-by-one error in merge log calculation.
- Fail if gerrit upload fails repeatedly

BUG=None
TEST=./tools/chromeos/merge-bot update-dry-runs

Change-Id: I9e845455f8c5209c38aee1bcd6bb1b2b81a3d99a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3585019
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-04-15 20:40:00 +00:00
Dennis Kempin
77569908de Merge bot: Always set up username on gce
Sligthly changes the logic. If we are on GCE, always use the authdaemon
and set up the git user info for the service account.

Outside of GCE just check if a cookie is available.

BUG=None
TEST=Faked out is_gce_instance and ran locally

Change-Id: Icf4c521b650b5d47f395a59695d1f1470621f661
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3585016
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-04-15 19:59:57 +00:00
Dennis Kempin
fe433eb18f Add version pin warning to common/
Could be added to README.md, but who reads those...

BUG=b:229016539
TEST=None

Change-Id: I3cc0f3672999926018fae572d8966dd971dcf80f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3586142
Reviewed-by: Allen Webb <allenwebb@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-04-15 19:51:35 +00:00
Dennis Kempin
a3249a7fef Merge bot: Actually execute clone of gcompute-tools
BUG=None
TEST=Ran locally, but cannot test actually running the tool outside of
GCE.

Change-Id: I4483d8ea75fceb3d289a38d2aa3b8c6f85985dfa
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3588403
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-04-15 19:31:18 +00:00
Dennis Kempin
ba4adc0efb Add python presubmit checks
This change adds python type and formatting checks and
consolidates code health checks in ./tools/health-check.

Dealing with relative imports in python is tricky, so
we are making ./tools/impl a proper package with no
directly executable files.

Some of the bash shorthands in ./tools had to be converted
to python for this.

To make the new checks pass, we run the formatter and fix
some mypy type checks.

TEST=./tools/health-check
BUG=b:218559722,b:219965702

Change-Id: Ie18d3d6dd2f5a033141e167a6e1aa762791941d6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3558592
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-04-15 19:22:53 +00:00
Dennis Kempin
335aaf6ad2 common.py allow absolute paths to programs
This would previously trigger a program not found error.

BUG=None
TEST=Added doctest

Change-Id: I357c44d2b9ce7b2a3240958c5c88008a29164baa
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3587885
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-04-15 18:42:27 +00:00
Dennis Kempin
0506ac6549 Curl with headers to get GCE metadata
Metadata-Flavor is a header and not part of the body.

BUG=None
TEST=Has to be tested in GCE.

Change-Id: I92711a86502d19601a5f2d63e6a653743b5b2614
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3579815
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-04-14 23:33:54 +00:00