Commit graph

2620 commits

Author SHA1 Message Date
ZhaoLiu
2aaf7ad9fc x86: Support Host exposes CPU topology to Guest VM
At present the Guest generates its own CPU topology. To mitigate
cross-hyperthread speculative execution side channel attacks, allow
Guest to use mirror CPU topology of Host is needed for future scheduling
optimization.

Add a config option "--host-cpu-topology" to ask the vCPU number to be
identical to physical CPUs, and make the vCPU has the same APIC ID in
MADT and CPUID as the corresponding physical CPU. The same APIC ID can
ensure the same topology.

"--host-cpu-topology" requires vCPU number must equal to pCPU number,
and it has the default vCPU number setting, which equals to pCPU number.

"--host-cpu-topology" also defaultly sets CPU affinity for each vCPU to
the pCPU which has the same processor ID, like 1=1:2=2:3=3:4=4, so that
the vCPU and its corresponding pCPU will have the same processor ID and
the same APIC ID. User can't set CPU affinity if "--host-cpu-topology"
was set.

BUG=b:197875305
TEST=Set "--host-cpu-topology" option and check Guest's /proc/cpuinfo,
  lscpu, CPUID for different vCPU

Change-Id: Ibc4eb10649e89f43b81bde6d46d6e0e6c7234324
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3217035
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-10-25 04:19:45 +00:00
ZhaoLiu
4e9b1444a4 x86: Support vCPU CPUID keep same topology as pCPU
At present the Guest use the cpu id (enum number) as the APIC ID in vCPU
CPUID and set the different topology with pCPU.

To support the feature vCPU has the same topology as pCPU, vCPU need the
same APIC ID as pCPU. So let vCPU can use the APIC ID from pCPU in
vCPU's CPUID and keep pCPU's topology related information (include CPU
count and topology mask) unchanged.

Now this change is a preliminary preparation and doesn't work.
Additional feature options and corresponding CPU number and CPU affinity
settings are still required.

BUG=b:197875305
TEST=cargo build
TEST=./test_all

Change-Id: I04150ac6c35534d0ff56667b01f448da2ca9f9fc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3217034
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: David Stevens <stevensd@chromium.org>
2021-10-25 04:19:44 +00:00
ZhaoLiu
535271094f x86: Support Guest MADT can use APIC ID of pCPU
At present the Guest use the cpu id (enum number) as the APIC ID in
Guest MADT.

To support the feature vCPU has the same topology as pCPU, vCPU need
the same APIC ID as pCPU. So let Guest MADT can use the APIC ID from
Host is needed.

Now this change is a preliminary preparation and doesn't work. The APIC
ID related changes for vCPU CPUID are still required.

BUG=b:197875305
TEST=cargo build
TEST=./test_all

Change-Id: I0e7dfba8cd57fefd85b7d7e37de3bb9935ff19ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3217033
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: David Stevens <stevensd@chromium.org>
2021-10-25 04:19:43 +00:00
ZhaoLiu
952feb761d sys_util: Add the interface to get CPU affinity
At present we only have a interface to set the CPU affinity and don't
implement the 'get_cpu_affinity' interface.

With a 'get_cpu_affinity' interface, after the thread iterates through
all physical CPUs by setting CPU affinity, it can reset its original CPU
affinity that was obtained and stored through 'get_cpu_affinity' in
advance.

BUG=None
TEST=cargo build
TEST=./test_all
TEST=set the CPU affinity and check the return value of
  'get_cpu_affinity'

Change-Id: I169fbbbb141ca80c980900ed16e4bceed1ba6432
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3217032
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-10-25 04:19:42 +00:00
Daniel Verkamp
81d454515f tempfile: remove from crosvm
All users of the in-tree implementation of tempfile have been moved to
the crates.io tempfile version.

BUG=b:199204746
TEST=emerge-hatch crosvm

Change-Id: Ie94d8cf87141f6d01d928f269e880c5493fc17a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3209840
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-10-21 22:04:50 +00:00
Gurchetan Singh
9aa5b0b4b4 rutabaga_gfx: make certain types usable across FFI boundaries
This is useful for the upcoming C/C++ interface to Rutabaga.

BUG=b:173630595
TEST=compile

Change-Id: Id543edb8c3fd3a0475b832a3c17e15e89b766e4d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3230330
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-10-21 22:04:41 +00:00
Dennis Kempin
66431d7f45 Add onboarding resources to mdbook
This is converted from our onboarding doc with internal references
removed.

BUG=b:199926026
TEST=None

Change-Id: Ibb94e194583b12c1ec7fe3d80306156e34e50000
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3229948
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-10-21 19:32:14 +00:00
Keiichi Watanabe
26b03d02bd mdbook: Fix typos in proper names and script paths
Apply changes of crrev.com/c/3236708 to mdbook

BUG=none
TEST=none

Change-Id: Ida84a9157197a435156957a7eccce07de16b9cec
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3237466
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-21 17:10:59 +00:00
Christian Blichmann
10bc771df8 README: Fix typos in proper names and script paths
TEST=Documentation only change

Change-Id: I0f03f3c58f8f1dea26814b5079e1e55b57c246f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3236708
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Christian Blichmann <cblichmann@google.com>
2021-10-21 15:26:45 +00:00
Xiong Zhang
3022a234b0 devices: Use Mutex to protect bus->devices
With vfio pci device hotplug, bus->devices will be inserted and removed at
runtime in different vcpu threads, so mutex should be used to protect it.

Both each vcpu thread and pci_root share mmio_bus and io_bus, so use Arc
for mmio_bus and io_bus. But pci_root is inserted into io_bus for pci cfg io,
in order to resolve reference loop and memory leak, weak is used for
pci_root.mmio_bus and pci_root.io_bus.

BUG=b:174705596
TEST=boot a vm and check its function

Change-Id: I7b3e63db76a90bc3873619b4d80a66db741ce78f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3184724
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-21 05:42:49 +00:00
A. Cody Schuffelen
bc50b0420a Use a shared buffer for virtio-console data
The strategy of passing Vec<u8> types introduced in crrev.com/c/2470376
can cause panics when the receiving side doesn't have the capacity to
receive the full buffers produced by crosvm. For example, a
virtio-console implementation with only one-byte buffers
(https://android-review.googlesource.com/c/1853082) almost always won't
have the capacity to receive the full buffers.

Using a VecDeque ring buffer allows continually appending data from the
input in the read thread and pulling off as much as the guest can handle
in the guest communication thread, without sacrificing performance when
the guest can handle higher volumes.

Bug: b/182849835
Bug: b/203138623
Test: Pass some input with an unbuffered single-character console driver
Test: Run CtsKeystoreTestCases against cuttlefish (high volume transfers)
Change-Id: I6b52a729d5af82f4626a9b1f29176116299b9297
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3227733
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-20 22:17:21 +00:00
Keiichi Watanabe
610158aa55 ci: kokoro: push-to-github: Use git push --all instead of --mirror
Unlike git push --mirror, git push --all won't delete remote branch so
that gh-pages branch won't be removed by kokoro, I think.

BUG=b:199692764
TEST=none

Change-Id: I2a5ce2f59e966775d24c25b996a1091af1d6efc9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3234557
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-10-20 16:06:04 +00:00
Keiichi Watanabe
8e4f87b44c devices: vfio: Use Result<> alias
BUG=none
TEST=build

Change-Id: Ia2be89464073f6e210bd64639929c8c1418c0388
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3149871
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-20 12:04:59 +00:00
Keiichi Watanabe
7db73604ea devices: vfio: Move VfioPciConfig to vfio.rs
Move the definition of VfioPciConfig, which is currently used by VFIO
passthrough, to vfio.rs so that we can use them when implementing VFIO
driver.

BUG=b:194137301
TEST=cargo build

Change-Id: Ia35d04d1871f5d4917dba81c1b4cc49bfbc3bf4b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3149870
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-20 12:04:58 +00:00
Keiichi Watanabe
226dae5c20 devices: vhost: user: device: Add Doorbell type in VhostUserBackend trait
Add Doorbell type in VhostUserBackend trait.
While it's CallEvent type having an underlying callfd for vhost-user, it'll be a doorbell struct for virtio-vhost-user.

BUG=b:194137301
TEST=cargo test

Change-Id: I569870b8285c6e82423e0d478f83dce7e08d386b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3205229
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-10-20 12:04:57 +00:00
Yiwei Zhang
95ac52a975 seccomp: gpu: allow vulkan loader/layer and virglrenderer
This is the arm equivalent for the below x86_64 CLs
- crrev/c/2634993
- crrev/c/2728307
- crrev/c/2959464

BUG=b:203588512
TEST=vkjson

Change-Id: I0f421d88a9abd9568923573d3135c24c513ed7eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3232961
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chia-I Wu <olv@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Lepton Wu <lepton@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-10-20 07:20:27 +00:00
Tomasz Jeznach
9e6c633ada crosvm: MMIO forwarding.
BUG=b:188011323
TEST=None

Change-Id: I93b722893c29add6e5de173d40ff1523d2b3a687
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2925137
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-20 05:35:59 +00:00
Dennis Kempin
d05bcbe9e0 Uprev all submodules
This fixes the annoying __pycache__ files virglrenderer used to
create.

BUG=b:200554399
TEST=./tools/presubmit passes

Change-Id: Ib5bfa5205f0b1432243ef53ec1b5a14d6cdd10d7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3232278
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-10-19 19:12:53 +00:00
Dennis Kempin
65740a6842 Uprev to rust 1.55.0
Includes some fixes for new clippy checks. A rebuilt
dev_container that ships the new toolchain.

This allows us to get rid of the annoying cargo clean
before running clippy.

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

Change-Id: I9d486fbcf7b2d468f6a1375ac7df95091a2c1465
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3232277
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-10-19 19:12:52 +00:00
Dennis Kempin
8a1277de1a Kokoro: Rebase changes to ToT before testing
By default Kokoro will use changes as they come from gerrit, which may
have an outdated parent. We want to make sure that we are always testing
against tip of tree so we are confident the presubmit test result will
reflect the postsubmit results.

BUG=b:202275156
TEST=Tested in Kokoro

Change-Id: I2a1d2860a361eee741dc522c9859e32890ff15bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3229947
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-19 17:10:04 +00:00
Dennis Kempin
76e6fd051b Fix push-to-github Kokoro builder
One more fix. Everything seems to work, but the remote is rejecting
an update of the active main branch. Hopefully the last fix needed.

BUG=b:199692764
TEST=Testing in prod.

Change-Id: I4f341cc374080454317cb3ac29cade59fec6aeee
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3229958
Tested-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-18 23:22:27 +00:00
Dennis Kempin
2d50ccb4a7 Fix push-to-github kokoro build
We were in the wrong directory.

BUG=b:199692764
TEST=Testing in prod...

Change-Id: Idbc60f7f6084109220186e56cd7fad2e6553da9a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3229950
Tested-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-18 22:00:22 +00:00
Dennis Kempin
49c169a410 Add push-to-github kokoro config and script
This is hard to test. I verified that kokoro can access
the github token and use it to access github by adding
a git clone into the x86 presubmit build file in patchset 3.

But we can only really test the full process by submitting this
CL and have it pass through the continuous builder.

BUG=b:199692764
TEST=Needs to be tested in prod...

Change-Id: Ifdcd385552c61ecea75a43fb71b08950e8b036ca
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3229941
Tested-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-18 21:37:58 +00:00
Dennis Kempin
1b284f8dcd Docs: Update linux build instructions for new tooling
BUG=b:199951064
TEST=None

Change-Id: I7518790461f43a97db007eda86f56027f527ec95
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3226277
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-18 20:10:43 +00:00
Dennis Kempin
d1dbefc9dc Integrate new container and test runner with Kokoro
This replaces the existing tooling at ./ci/ with the new tooling
at ./tools.

BUG=b:199951064
TEST=./ci/kokoro/simulate_all

Change-Id: Id0296d5a46ca0f3eb0f655d85d1aed801ee3b434
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3226275
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-18 20:10:42 +00:00
Dennis Kempin
ee56b2ddec Add presubmit script
Consolidates the utility scripts from bin/ into tools/.
Adds a 'presubmit' utility script to run a set of checks and
tests.

This won't be a git hook, but can be manually used to verify
changes before uploading.

BUG=b:199951064
TEST=./tools/presubmit --quick
./tools/dev_container ./tools/presubmit

Change-Id: Iac7c11fca0beaa6d4f214319149ef385fa5ced70
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3225139
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-10-18 20:10:41 +00:00
Dennis Kempin
18724772c2 Add test runner ./tools/run_tests
The new runner makes use of the simplified crosvm build and greatly
improves execution speed by gathering test binaries from cargo output
and executes them directly in parallel.

This allows all of our tests to execute in ~5 seconds when run locally.

The new test runner also makes use of the new testvm tools to make it
easy to switch between testing on the host, in a VM or via SSH on a
remote device.

See ./tools/run_tests --help for usage instructions.

To allow more iterative testing with the same test targets, this CL
includes a set_test_target script to write env vars that instruct cargo
to build for the target arch and run on the test target.

Note: The test runner can build for armhf, but we need build file fixed
to allow armhf to build successfully.

BUG=b:199951064
TEST=Inside ./tools/dev_container:
./tools/run_tests --target=host
./tools/run_tests --target=vm:aarch64
./tools/run_tests --aarch=armhf --build-only
./tools/set_test_target vm:aarch64 && source .envrc
cargo test

Change-Id: I60291fa726fb2298f62d1f032e55ed6e7ab1c4ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3221779
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-15 22:12:03 +00:00
Dennis Kempin
c4ec996103 Add new dev container and install-deps scripts
The new container just provides a standard debian box with a
rust toolchain.
Installation of dependencies has been extracted into scripts
which can also be used to set up a machine for development.

This will replace the current ./ci/ containers.

BUG=b:199950887,b:199950423
TEST=./tools/dev_container ./tools/run_tests

Change-Id: I832bc5b129246923df937a34614b4d74955304dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3221781
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
2021-10-15 22:12:02 +00:00
Dennis Kempin
af0144e51b testvm: Use prebuilts instead of building on-the-fly
We need to download a base image anyway, so we might as well make
that a full prebuilt of our VM image. This makes the initial
startup of ./tools/aarch64vm significantly faster. It also makes
it easier to add the prebuilt into a Docker dev container later.

Also move the VM data into the cargo target dir so we do not
dirty the src dir.

A Makefile for building and uploading the prebuilt has been added.

This change also moved the testvm code from ./tools/testvm into
./tools/impl so the python code can be shared with future scripts
(relative imports from other folders are tricky in Python).

BUG=b:199951064
TEST=./tools/aarch64vm ssh

Change-Id: I3fb57bfb8f7330b765e9be5ded821615ecddd841
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3221704
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-15 22:02:24 +00:00
Woody Chow
1b16db18bd devices: Add vhost-user snd vmm
BUG=b:184322202
TEST=tast run $DUT_IP vm.Audio*.vhost_user_cras
     (with https://crrev.com/c/3185059)

Change-Id: Icb3b2dd1268f183bf57754345b9302fd5e78a7ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2801654
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Woody Chow <woodychow@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-10-15 04:51:19 +00:00
Tom Cherry
1cfd2d627d x86_64: pass the ramoops command line to bios
This was an oversight from the previous commit to pass the kernel
command line to a bios.

BUG=b:200208446
TEST=Observe pstore working across reboots

Change-Id: Ie93cc3399000a83099d396f4dde1da9d835704be
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3197732
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Tom Cherry <tomcherry@google.com>
2021-10-15 00:05:12 +00:00
Woody Chow
2e1332276e Reland "Add StreamEffect to new(_async)_capture_stream"
This is a reland of 79d6696394

Original change's description:
> Add StreamEffect to new(_async)_capture_stream
>
> It is needed to support AEC in virtio-snd (cras backend)
>
> BUG=b:201472965
> TEST=cargo test
>
> Change-Id: If79eee8a41d1da7e6d643e8187bbc75768f31ad9
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3193841
> Reviewed-by: Judy Hsiao <judyhsiao@google.com>
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
> Commit-Queue: Dennis Kempin <denniskempin@google.com>
> Tested-by: kokoro <noreply+kokoro@google.com>

Bug: b:201472965
Change-Id: I14f16dc8397e153ba54c676dabe396efda81cb82
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3222221
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Judy Hsiao <judyhsiao@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Woody Chow <woodychow@google.com>
2021-10-14 14:31:33 +00:00
Woody Chow
eaf4518b0d devices: virtio-snd cras-backend cleanup
in preparation for vhost-user device implementation.

* Use <I: SignalableInterrupt> in handle_*_queue methods. start_queue of
  VhostUserBackend has a different interrupt type.
* Avoid sharing of pcm queues to ctrl queue. start_queue of
  VhostUserBackend is called per queue, and provides the queue object
  for that queue only.

BUG=b:179755683
TEST=tast run $DUT_IP vm.Audio*.virtio_cras_snd

Change-Id: Ic53135ac317896f1ebeb3b11795e80736c466996
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3168560
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Woody Chow <woodychow@google.com>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
2021-10-14 09:15:06 +00:00
Dylan Reid
68c9bb610c Rutabaga: don't always build virglrenderer
If the virglrenderer feature isn't enabled, skip building virglrenderer.
This fixes cross-compiling for architectures that don't have libdrm
ready.

Change-Id: I397864ea6104896e1d12a838834d7d0b09a485be
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3221693
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-10-13 22:59:16 +00:00
Dennis Kempin
3b7a45792d Remove Cargo.lock from version control
The Cargo.lock file has been source of much annoyance and does not
really serve it's purpose in crosvm anyway. Both Android and ChromeOS
builds will not use Cargo.lock files but use their own infra to pin
dependencies to fixed versions.
Cargo.lock files are only used for development builds, but can cause
frequent merge issues, especially once our hacky 'setup_cros_cargo.sh'
script is involed.

Since we are planning to migrate towards bazel in the not-so-far future,
the easiest short term plan is to just remove Cargo.lock from version
control and deal with potential discrepancies in development builds.

BUG=None
TEST=None

Change-Id: I23736a61a4cc8131888d5ee2c19793066267f608
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3140584
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-10-12 19:28:43 +00:00
Jason Macnak
ab4be4298a rutabaga_gfx: rutabaga_gralloc: Handle device creation failure
... with mulitple devices. On my machine, Nvidia device creation
succeeds but then llvmpipe device creation fails because llvmpipe
reports having VK_EXT_external_memory_dma_buf but not
the required VK_KHR_external_memory_fd.

BUG=b:189133053
TEST=launch Cuttlefish w/ Vulkano enabled in Crosvm

Change-Id: I1709aa9895834be6b225104fbfda20e418ae7d1c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3203234
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
2021-10-12 19:13:10 +00:00
Woody Chow
5acd4ee978 snd: Add debug prints and comments to virtio-snd (cras)
BUG=None
TEST=cargo test

Change-Id: Id4d0795f9001215dea07b8ff4edeee723782d7c0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3217344
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Woody Chow <woodychow@google.com>
2021-10-12 05:29:41 +00:00
Junichi Uekawa
e2947e0f12 Reland "Dump backing File system type."
BUG=b:199094605
TEST=tast run localhost:2229 arc.Boot.vm_o_direct
  # logs: Disk image file is hosted on file system type ef53
TEST=emerge-hana crosvm

This is a reland of 4ea81e3003

Original change's description:
> Dump backing File system type.
>
> To aid investigation, the root file system image needs to reside on a
> file system with O_DIRECT support.
>
> BUG=b:199094605
> TEST=tast run localhost:2229 arc.Boot.vm_o_direct
>   # logs: Disk image file is hosted on file system type ef53
>
> Change-Id: Ifd393e7009721c697d3d23177129f187454534a8
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3203719
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>

Bug: b:199094605
Change-Id: Ie1cb9b515d7b95fd9b108e9a6963a7c77fee652e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3215931
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2021-10-11 23:10:07 +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
Junichi Uekawa
ce6cf4efe2 ci: Quote underscores.
My editor doesn't like them, and probably they should be.

BUG=None
TEST=read it.

Change-Id: I40041e41841e47cb386fcd12a4622efeca33474d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3215932
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
2021-10-11 18:28:42 +00:00
Woody Chow
0c9c4baa7f seccomp: Add timerfd_* to cras_snd_device.policy
Following CL:3047951 for cras_audio_device.
Without these, the device would crash under crostini.

BUG=b:198730031
TEST=tast run $DUT_IP crostini.PulseAudioBasic.*

Change-Id: I87a60b87461ff10594ebe7643a631630eabc94ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3213791
Auto-Submit: Woody Chow <woodychow@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Woody Chow <woodychow@google.com>
2021-10-11 05:10:11 +00:00
Jason Macnak
0024533253 rutabaga_gfx: rutabaga_gralloc: Request instance extensions
VK_KHR_external_memory requires VK_KHR_external_memory_capabilities which
requires VK_KHR_get_physical_device_properties2. Ash has started to check
that the instance extensions were required when creating devices.

BUG=b:189133053
TEST=launch Cuttlefish w/ Vulkano feature enabled in Crosvm

Change-Id: Ifaafda72500ccbd16dd461bcd5dc2633de4b8cfc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3203233
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-10-09 00:34:29 +00:00
Dennis Kempin
60102cdd2f Revert "Dump backing File system type."
This reverts commit 4ea81e3003.

Reason for revert: Breaks ToT. See: https://ci.chromium.org/ui/p/chromeos/builders/cq/hana-cq/b8833931827711281905/overview

Original change's description:
> Dump backing File system type.
>
> To aid investigation, the root file system image needs to reside on a
> file system with O_DIRECT support.
>
> BUG=b:199094605
> TEST=tast run localhost:2229 arc.Boot.vm_o_direct
>   # logs: Disk image file is hosted on file system type ef53
>
> Change-Id: Ifd393e7009721c697d3d23177129f187454534a8
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3203719
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>

Bug: b:199094605
Change-Id: I3da7c8284d1e6f2496e300d9f02c0063bbb5467c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3213363
Reviewed-by: Raul E Rangel <rrangel@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-10-08 19:05:47 +00:00
Daniel Verkamp
ecab88ad99 devices: virtio: block: suppress error for GET_ID
If the guest sends a VIRTIO_BLK_T_GET_ID request and the block device
does not have an ID configured, crosvm prints an error message:

  [devices/src/virtio/block/asynchronous.rs:191] failed executing disk
  request: unsupported (8)

Since there is no corresponding feature flag for GET_ID support, the
guest can only detect if the command is supported by just trying it.
However, the error message is confusing to the crosvm user, since this
request failure is not indicative of a problem, just a part of normal
operation.

To avoid this confusion, suppress the error message when GET_ID fails
while still returning the unsupported status to the guest.

BUG=None
TEST=crosvm run -r vm_rootfs.img vm_kernel # check syslog for no error

Change-Id: I05fcd3c428ff1314998ac88fd92d78423155dba3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3213115
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-10-08 17:01:37 +00:00
Junichi Uekawa
4ea81e3003 Dump backing File system type.
To aid investigation, the root file system image needs to reside on a
file system with O_DIRECT support.

BUG=b:199094605
TEST=tast run localhost:2229 arc.Boot.vm_o_direct
  # logs: Disk image file is hosted on file system type ef53

Change-Id: Ifd393e7009721c697d3d23177129f187454534a8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3203719
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-10-08 07:07:50 +00:00
Chirantan Ekbote
84091e5331 Add vhost-user vsock vmm
Add the vmm side for the vhost-user vsock device.

BUG=b:179756331
TEST=Connect to vshd inside a VM with a vhost-user vsock device

Change-Id: I332adbb6f8d6cfc8dff16375e93d946ecad2e84b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3153213
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-10-08 07:00:06 +00:00
Chirantan Ekbote
f08bdddf58 Add vhost-user vsock device
Since vhost-user messages have a 1:1 mapping to vhost ioctls, this
device doesn't use DeviceRequestHandler but processes incoming messages
directly.

BUG=b:179756331
TEST=Connect to vshd inside a VM with a vhost-user vsock device

Cq-Depend: chromium:3105429
Change-Id: I9811e29282f7e79140be1203bce9030ec37a3343
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3153212
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-08 07:00:04 +00:00
Yusuke Sato
31e136aeda crosvm: Allow all vCPU threads to share same cookie for core scheduling
This CL adds --per-vm-core-scheduling command line option to crosvm
to allow ARCVM to use per-VM core scheduling for better performance.
Note that per-VM core scheduling makes all vCPU threads to share the
same core scheduling cookie.

The feature is disabled by default, and does not change Linux VMs
behavior unless the new command line flag is explicitly passed in.
Also, this CL never affect Parallels since it uses the plugin
infrastructure (src/plugin/).

For ARCVM, the feature will be enabled by default via Chromium's
base::Feature (see crrev.com/c/3207747) as an interim solution until
the optimized two-level core scheduling is ready. This is based on
the latest recommendation from the security team (newfel@, resch@,
and others) at go/arcvm-core-scheduling-recommendations.

Credit: This CL is based on an idea from joelhockey@ and bgeffon@
at go/exawj

BUG=b:194022819
TEST=boot ARCVM with the new flag and verify all vCPU threads have
  same cookie.

Change-Id: Ib97ab9942b2516df9fbffe35517919f29b309a83
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3101607
Commit-Queue: Yusuke Sato <yusukes@chromium.org>
Owners-Override: Yusuke Sato <yusukes@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Joel Hockey <joelhockey@chromium.org>
Reviewed-by: Jorge Lucangeli Obes <jorgelo@chromium.org>
2021-10-07 21:34:10 +00:00
Daniel Verkamp
cce4054aa8 third_party/minijail: uprev to commit 6aa0392
This includes https://r.android.com/1835176 in order to prevent bindgen
from modifying libminijail.rs on every build, causing the submodule to
be marked as dirty.

BUG=None
TEST=cargo build
TEST=./test_all

Change-Id: I73e97231c37ef49bff463b7cc282a1cb42d7bc84
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3209926
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-10-06 23:01:30 +00:00
Daniel Verkamp
31b6a00062 argument: convert to ThisError and sort
BUG=b:197143586
TEST=cargo check

Change-Id: I8d75003c65e647f1cf4962f390823d5c15169a57
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105434
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
2021-10-06 21:38:37 +00:00