Commit graph

20 commits

Author SHA1 Message Date
Daniel Verkamp
45b0920767 doc: add a top-level comment to all crates
This provides at least a minimal one-line description to show what each
crate is about.

BUG=None
TEST=tools/cargo-doc

Change-Id: I26732e8c29062e622d5be09bdc120a49d564b9fd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3630422
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-06 20:46:57 +00:00
Daniel Verkamp
f35f636cc5 Rust 1.60 clippy fixes
BUG=None
TEST=tools/presubmit # with rust-toolchain updated to 1.60.0

Change-Id: I5772e8b0593f8d92003e93aeb2145e87610abe2e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3577332
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-04-11 20:40:36 +00:00
Peter Fang
072c103be6 acpi: support fixed power button in vPM1
- Add a new trait, PmResource, for PM-related public interfaces.
- Use SCI_INT in FADT as vSCI if FADT is forwarded.
- Inject vSCI if ACPI fixed power button is enabled and a power button
  event is received.
- Disable MPTable generation if FADT is forwarded [1].

[1] MPTable generation in mptable.rs makes certain assumptions about
    SCI which is incompatible with FADT forwarding. MADT takes
    precedence over MPTable in the Linux kernel so hopefully things
    should work correctly.

BUG=b:199383670
TEST=boot Linux kernel and shut down

Change-Id: Icc93c3e7492e44b3a5badc5e75373c472c9b9791
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3350491
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Tomasz Nowicki <tnowicki@google.com>
2022-03-10 16:59:19 +00:00
Anton Romanov
bed40ad547 crosvm: migrate to Rust 2021 edition
BUG=none
TEST=cq

Change-Id: I0059c970879b78bfd40b6ce58b10debcf154b50f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3508322
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Anton Romanov <romanton@google.com>
2022-03-09 01:16:03 +00:00
Vikram Auradkar
ae5118f5c7 Enable windows tests for a few crates
Run tests for sys_util_core, poll_token_derive and balloon_control on
windows.

Using dotfiles to disable/serialize test runs of a subset of crates does
not work well with third party crates as it forces us to commit the dot
file to the crate.

The patch modifies and uses the script that runs linux tests.
This patch also allows us to
- build/test child crate even if parent crate has disabled build/test.
- avoid building crosvm if it is not explicitly specified.

RIP short lived .windows_build_test_skip. You allowed us to run noop
kokoro tests.

Test: py .\tools\impl\test_runner.py --arch x86_64
Bug: b:215610772
Change-Id: Icc6d04ffd7c0c33d4f60aeac16fc7d23881c387d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3459809
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-02-18 03:18:58 +00:00
Vikram Auradkar
0108238474 Upstream windows build/test script
The patch also adds files to skip building and testing crates on
windows. When we run
```
tools/windows/build_test.py --skip_file_name .windows_build_test_skip
```

the build/test succeeds without actually doing anything as build/test
for all crates is skipped by creating '.windows_build_test_skip'.

Bug: 213170957
Test: Ran script on downstream repo
Change-Id: Iebd2cea463ee722be4feaed88229e1fb5e9fd6c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3417918
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-01-28 00:55:08 +00:00
Xiong Zhang
b5fa790d53 x86_64: Add _OSC for pcie hotplug
OS call acpi _OSC method to request control for PCIE natvie features like
pcie hotplug, pcie advanced error report, pcie PME. But currently crosvm
lack of _OSC method, so OS couldn't enable these pcie features.

This commit add _OSC method, enable pcie hotplug and pcie cap structure
control, but disable SHPC hotplug, pcie PME and pcie AER.

BUG=b:197877871
TEST=Check pcie hotplug capability in VM

Change-Id: If4b6c8026c312ebfdeb18df7c0673571e3e9b631
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3305945
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-12-09 00:19:42 +00:00
Dennis Kempin
a1e42f07ea Enable clippy on more workspace crates
As before, some are automatically fixed by clippy, some manually
fixed.

BUG=b:192373803
TEST=./tools/presubmit

Change-Id: Ifcab4cf60775ee6bb7d4530af6406a74958432ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3283683
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-11-15 23:55:42 +00:00
Dennis Kempin
8a1c50d5cd Refactoring: Move various general purpose crates to common/
This change contains the results of running

./tools/contib/cargo_refactor.py

This will break the next uprev, and needs to be synchronizized
with the corresponding ebuild changes in https://crrev.com/c/3248925

BUG=b:195126527
TEST=./tools/run_tests

Change-Id: Ied15a1841887bb8f59fba65b912b81acf69beb73
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3248129
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-29 22:31:43 +00:00
Daniel Verkamp
7fd815ed22 crosvm: switch to upstream tempfile crate
Use the crates.io implementation of tempfile instead of our own version.

Our reimplementation is kept in the tree for now in case of dependencies
outside of the crosvm tree; it can be removed later once those are fully
switched over to the crates.io implementation.

BUG=b:199204746
TEST=emerge-hatch crosvm

Change-Id: I07d3404239302ab9a17f4ddc82a9479b256e4eb4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3209839
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-10-11 18:35:55 +00:00
Daniel Verkamp
166d1ddfbe crosvm: fix needless_borrow clippy warning
Tree-wide cleanup of new clippy warning in Rust 1.54 that warns about
needless borrows:

  error: this expression borrows a reference (`&...`) that is
  immediately dereferenced by the compiler

https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

BUG=b:197251702
TEST=bin/clippy # with rust-toolchain = 1.54.0

Change-Id: Ib702ec524d4623d264a00ec11dbc2150c411a67b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3108321
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Allen Webb <allenwebb@google.com>
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-08-25 23:02:23 +00:00
Daniel Verkamp
05485a91ee acpi_tables: use vec![] to initialize vectors
Fix a few instances of a new clippy warning ("calls to `push`
immediately after creation").

https://rust-lang.github.io/rust-clippy/master/index.html#vec_init_then_push

BUG=None
TEST=bin/clippy

Change-Id: I8bf2abbb4dfeac16ddfb64f160f04176d89c4719
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2864367
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-05-06 22:06:55 +00:00
Daniel Verkamp
548754cd2f Specify file paths via Path instead of PathBuf
Many functions took a reference to PathBuf, but then just passed the
parameter to File::open(), so they can be changed to a reference to
Path instead to avoid a potential allocation.

https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg

BUG=None
TEST=bin/clippy

Change-Id: Ife5a52df2ba16da1ce1307efb2fe921cd8b4f956
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2862581
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-05-06 22:06:51 +00:00
Tomasz Jeznach
cf55111b9b acpi: FACS support, minor fixes for acpi forwarding.
User provided DSDT/MADT/FADT tables will have precedence
over crosvm generated data, with crosvm only overriding
critical FADT fields to match ACPI tables placement.
Also, this patch adds mandataory empty FACS structure.

BUG=None
TEST=run guest with set of ACPI tables provided and verify content.

Change-Id: I3f3ff2170c08b3f570ff863ecc45c5bf203eb940
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2841754
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-04-22 07:25:33 +00:00
Dennis Kempin
a5262a177f acpi_tables: Add test case for reading SDT data from files
Seemed like an easy test to add.

BUG=b:171082843
TEST=This is a test

Change-Id: I2a10c0965be2952cd3150965e4127a27a3ec6dff
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2495844
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Dennis Kempin <denniskempin@google.com>
2020-10-27 05:22:34 +00:00
Tomasz Jeznach
4264464153 acpi: support user provided ACPI SDTs.
Enable support for user provided ACPI tables with supplementary system
description. Argument --acpi-table shall point to exsting file or
pseudo-file with valid ACPI table content.

BUG=None
TEST=boot Linux kernel with generated SSDT tables.

Change-Id: I8eac21da070dcc325884ed888cc7bcb01bc086ce
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2212501
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Tomasz Jeznach <tjeznach@chromium.org>
Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
2020-06-01 23:25:39 +00:00
Chuanxiao Dong
6db9f9f58a acpi: refactor the ACPI PM device
Add the AML support to generate the S1 table instead of hard coding.
Also use the IO allocater to allocate the IO resouce for ACPI PM.

BUG=None
TEST=boot crosvm by command "crosvm run -s crosvm.sock -m 4096 --cpus 4
--rwdisk rootfs.img -p "root=/dev/vda rootfstype=ext4" vmlinux".
Check the S1 capability by "#echo standby > /sys/power/state" from guest
side. Linux guest is suspended. And resume linux guest by "#crosvm resume
crosvm.sock" from host side.

Change-Id: I75b484c44db05f98d49557ba694a1531b57871c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2119571
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com>
2020-05-11 13:43:59 +00:00
Chuanxiao Dong
d5f47a9865 acpi: add AML support
This is backported from cloud hypervisor, which can be used to
generate the AML from ASL which is more easily for people to
understand what this AML is doing.

BUG=None
TEST=cargo test -p acpi_tables

Change-Id: Ib7c60caca92fd6ca7ab6800ddf36b2135fbcfc88
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2119570
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com>
2020-04-25 17:59:57 +00:00
Chuanxiao Dong
020fbf04c2 x86_64: generate ACPI tables
Add acpi_rsdp_addr in boot_params to allow crosvm to pass
a physicall address of RSDP to the Linux guest kernel, so
that the linux guest kernel can parse the constructed ACPI
tables and enable the ACPI.

Although there is ACPI tables but as we still have "acpi=off"
in command line parameter, there is still no ACPI in guest kernel.

The ACPI construction refers to the implementation of the
Cloud-hypervisor commit:
- arch: x86_64: Generate basic ACPI tables

BUG=chromium:1018674
TEST=None

Change-Id: Ibcb2ae98c43da8ef8c07a07eda9213f61570d14c
Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2035351
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
2020-02-28 00:11:19 +00:00
Chuanxiao Dong
91e8403ddf acpi_tables: Add initial ACPI tables support
The basic ACPI table support for creating XSDT.

It refers to the implementation of the Cloud-hypervisor's ACPI
commit:
 - Cloud-hypervisor: acpi_tables: Add initial ACPI tables support

BUG=chromium:1018674
TEST=cargo test -p acpi_tables

Change-Id: Ia3b597936fef214fcb92fce28c91152dfa03bec9
Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2035350
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2020-02-27 05:07:01 +00:00