Commit graph

44 commits

Author SHA1 Message Date
Daniel Verkamp
52b8e42869 Cargo.toml: avoid "*" versions for external crates
Ensure that every Cargo.toml dependency on a third-party crates.io crate
specifies at least a major version, or a minor version for 0.x crates,
to ensure that if a new major version is published, it cannot cause API
breaks.

The versions are selected to match the ones already in Cargo.lock, so
this should have no functional change, but it will help prevent new "*"
versions from being introduced via copy-and-paste.

For rationale, see the Cargo FAQ:
<https://doc.rust-lang.org/cargo/faq.html#can-libraries-use--as-a-version-for-their-dependencies>

`minijail`, `audio_streams`, and `cras` are left as "*" for now, since
they have unusual situations (imported from a submodule and/or replaced
at build time with ebuild magic).

BUG=None
TEST=tools/dev_container tools/presubmit
TEST=verify Cargo.lock is unchanged

Change-Id: Ifa18199f812f01d2d10bfb4146b3353c1a76527c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5555656
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2024-05-22 01:01:42 +00:00
Noah Gold
b63c3f4d76 vm_control: add snapshot encryption.
Introduces a new switch/option on snapshot commands/IPCs that turns on
encryption using the crypto crate.

BUG=b:286345300
TEST=builds upstream; tested end to end downstream.

Change-Id: Ia04074bb23332274d4e6b99eb242c84b0af7a8a9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5371444
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2024-03-18 17:33:29 +00:00
Daniel Verkamp
2c96bed807 Cargo.toml: Remove unused data_model deps
Several crates still declared a dependency on data_model despite not
using any imports from it.

BUG=b:312312646
TEST=tools/dev_container tools/presubmit

Change-Id: I63a67696c205f684b1e4ac8bdad4de5f294b63dc
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5370964
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2024-03-13 20:00:26 +00:00
Ludovic Barman
cd04b6198d Upgrade gdbstub and gdbstub_arch.
gdbstub 0.6.3 -> 0.7.0
gdbstub_arch 0.2.4 -> 0.3.0

There is small change in API, see src/crosvm/gdb.rs. `read_addrs` now returns a `usize` instead of a `()`.

This change is needed to submit this AOSP topic: https://android-review.git.corp.google.com/c/platform/external/crosvm/+/2879249

BUG=b:286979636

TEST=tools/presubmit --all

Change-Id: I124d65e673c5943070c2bb5e39e3a7e5506e5528
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5146447
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2024-01-04 02:06:22 +00:00
Wang Ningyuan
6b1a35298c crosvm: virtio-net device hotplug
This CL implements PCI hotplug feature for virtio-net device. The
feature is controlled by pci-hotplug feature flag and pci-hotplug-slots
runtime flag. No behavior change to crosvm unless pci-hotplug-slots flag
is set to a nonzero value.

BUG=b:243767476
TEST=tools/presubmit
TEST=e2e_test::tap_hotplug for TAP device hotplug and removal
TEST=manual test for TAP device hotplug and removal with swap

Change-Id: I5a60314293ef8a27981d7b550a61822491c254bb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4473610
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Shin Kawamura <kawasin@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Ningyuan Wang <ningyuan@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Jason Iman <jasongustaman@chromium.org>
2023-07-27 04:35:26 +00:00
David Stevens
326afd881e balloon: don't wait for replies in the control loop
Instead of synchronously waiting for balloon stat responses in the
control loop, add the balloon tube to the wait context and handle the
responses asynchronously. This allows us to get rid of the 100ms timeout
on stat requests, which in turn means we can get rid of the id field in
stat/wss messages because there are no longer "stale" requests.

The fact that balloon stat requests will no longer timeout may require
that clients handle timeouts themselves, instead of relying on a
hardcoded timeout in the crosvm implementation. This adds a new function
to crosvm_control to allow getting the balloon stats with a timeout.

BUG=b:259503518
TEST=test run DUT multivm.*
TEST=cargo test -p vm_control

Change-Id: I89c72d13e28527e432041de53cf8eda25f630bea
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4651166
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
2023-07-21 08:03:38 +00:00
Vikram Auradkar
45a629e3e6 vm_control: refactor product specific code
BUG=b:286107739
TEST=none

Change-Id: I8228a34476daf83dfa809de8d1f70165b6fd6035
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4605895
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2023-06-09 23:09:47 +00:00
maciek swiech
fac9000051 balloon: use protos for registered events
since the RegisteredEvent model is effectively an external API, switch
to using protobuf as a more formal/stable means of communicating
messages. also introduces exporting the registered_events.proto file as
part of crosvm_control build, alongside the currently existing header
file.

this patch also introduces feature-gating for registered_events and
protos so as not to bring in too many third party dependencies for a
base build.

BUG=b/278117550
TEST=run bzImage locally
TEST=sidecar program available at https://x20.corp.google.com/users/dr/drmasquatch/socket-pinger-proto

Change-Id: I5d91d87f7807effc125352caf5c75eee2593f70d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4521604
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: maciek swiech <drmasquatch@google.com>
2023-05-22 19:28:45 +00:00
Shintaro Kawamura
8590cdcc8a swap: expose Status interface to all variants
Status does not depend on any swap related feature. Exposing Status to
all variants is easy to implement swap status FFI at crosvm_control.

The new "swap/enable" feature switches the actual vmm-swap functionality
to be compiled. The feature is enabled by default on "swap" crate but
disabled on the root package for test dependency.

Vmm-swap feature is enabled by `--features=swap` flag on cargo build as
before.

swap/src/controller.rs is copied from swap/src/lib.rs.

BUG=b:265386761
TEST=tools/dev_container tools/run_tests2

Change-Id: Ifc2539a62d0f594fd5bbb41623c735ea2621f7b6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4486546
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
2023-05-04 12:30:09 +00:00
David Stevens
df2625c599 Reland "vm_control: reduce user memory region modifications"
This is a reland of commit 22c212d54f

This reland avoids using the new pre-mapped memory regions on arm
devices, since there is insufficient address space. The new path is
still used on aarch64.

Original change's description:
> vm_control: reduce user memory region modifications
>
> Reduce how often KVM_SET_USER_MEMORY_REGION is called when the tdp mmu
> is enabled. With the tdp mmu, there is no memory overhead from creating
> large memory regions (at least until a nested VM is started). Simply
> mmap'ing/munmap'ing fds within a pre-created memory region is more
> efficient. It also addresses audio jank caused by removing a memory
> region.
>
> Adding this support to VmMemoryRequest will allow FsMappingRequest to be
> removed in a later change.
>
> BUG=b:274037632
> TEST=tast run arc.Boot.vm
> TEST=manually launch gedit in crostini
>
> Change-Id: I2ac02454ecb734c9707b6d67546135134b887527
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4402068
> Reviewed-by: Dennis Kempin <denniskempin@google.com>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Commit-Queue: David Stevens <stevensd@chromium.org>

Bug: b:274037632
Change-Id: I5deedfd3a030640f9af950cee675fac0d9a411a0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4421352
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-04-17 20:16:39 +00:00
Dennis Kempin
e0c9e789d0 Revert "vm_control: reduce user memory region modifications"
This reverts commit 22c212d54f.

Reason for revert: Suspected to break crostini http://go/bbid/8783938922329906785

Original change's description:
> vm_control: reduce user memory region modifications
>
> Reduce how often KVM_SET_USER_MEMORY_REGION is called when the tdp mmu
> is enabled. With the tdp mmu, there is no memory overhead from creating
> large memory regions (at least until a nested VM is started). Simply
> mmap'ing/munmap'ing fds within a pre-created memory region is more
> efficient. It also addresses audio jank caused by removing a memory
> region.
>
> Adding this support to VmMemoryRequest will allow FsMappingRequest to be
> removed in a later change.
>
> BUG=b:274037632
> TEST=tast run arc.Boot.vm
> TEST=manually launch gedit in crostini
>
> Change-Id: I2ac02454ecb734c9707b6d67546135134b887527
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4402068
> Reviewed-by: Dennis Kempin <denniskempin@google.com>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Commit-Queue: David Stevens <stevensd@chromium.org>

Bug: b:274037632
Change-Id: Id5caebd0bd33f4984567ff604f117ae4d95a71ab
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4422453
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2023-04-13 21:39:27 +00:00
David Stevens
22c212d54f vm_control: reduce user memory region modifications
Reduce how often KVM_SET_USER_MEMORY_REGION is called when the tdp mmu
is enabled. With the tdp mmu, there is no memory overhead from creating
large memory regions (at least until a nested VM is started). Simply
mmap'ing/munmap'ing fds within a pre-created memory region is more
efficient. It also addresses audio jank caused by removing a memory
region.

Adding this support to VmMemoryRequest will allow FsMappingRequest to be
removed in a later change.

BUG=b:274037632
TEST=tast run arc.Boot.vm
TEST=manually launch gedit in crostini

Change-Id: I2ac02454ecb734c9707b6d67546135134b887527
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4402068
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2023-04-11 00:58:43 +00:00
Daniel Verkamp
ac0fc378a3 Fix remaining Chrome/Chromium OS instances
These should be written as ChromeOS and ChromiumOS (without the space)
to match the updated branding. The copyright headers were already
migrated to the new style (https://crrev.com/c/3894243), but there were
some more instances left over.

BUG=None
TEST=tools/cargo-doc

Change-Id: I8c76aea2eb33b2e370ab71ee9b5cc0a4cfd00585
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4129934
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-01-03 22:14:30 +00:00
Hikaru Nishida
2b35bf353b swap: add commands for vmm-swap out
Added new crosvm commands "crosvm swap enable" and "crosvm swap status".

swap crate exposes SwapController to control the vmm-swap feature.

When vmm-swap is enabled, all the pages on the GuestMemory are swapped
out to a file and are freed to give a lot of memory back to OS.

design document: go/tanooki-phase1-dd

BUG=b:215093219
TEST=manually tested

Change-Id: Ideb10b0119edd9f47b66c8ac61add21ac08181d4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3871758
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
2022-11-17 02:39:55 +00:00
Pujun Lun
b849ebd0e1 crosvm: GPU and display arg parsing for Windows.
This replaces the handwritten arg parser with the serde_keyvalue
based parser. Eventually we will unify the arg parsing with Unix.

BUG=b:233676779
TEST=cargo b --features all-msvc64,gpu --no-default-features
TEST=cargo t -p vm_control --features all-msvc64,gpu
     --no-default-features
TEST=cargo t -p crosvm sys::windows::config::
     --features all-msvc64,gpu --no-default-features

Change-Id: I36a563be9767c7e5cbd3ab44f6a9ba23cd64cdb6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3939033
Commit-Queue: Pujun Lun <lunpujun@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-10-18 05:17:53 +00:00
Jason Macnak
1e077db461 devices: gpu: Support display hotplug
Adds `crosvm gpu <>` commands which allows for interactively
adding/listing/removing virtio-gpu displays/scanouts.

Also updates the virtio gpu device to use a Map<u32, Scanout>
instead of a Vec<Scanout> and always report the maximum number
of displays (16) with enabled/disabled. This helps handle the
case of removing a display that is not the last display number.

BUG=b:163864461
TEST=cargo build
TEST=cargo build (with gpu feature disabled)
TEST=Android build
TEST=launch Cuttlefish
TEST=crosvm gpu list-displays <socket>
TEST=crosvm gpu add-displays
     --gpu-display=width=900,height=600
     --gpu-display=width=600,height=480
     <socket>
TEST=crosvm gpu list-displays <socket>
TEST=crosvm gpu remove-displays
     --display-id=1
     <socket>

Change-Id: I7530498897eb4e84199eaeb3d66df006df62817f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3911102
Commit-Queue: Jason Macnak <natsu@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-10-11 16:20:31 +00:00
Pierre-Clément Tosi
4a11ffc891 gdb: Upgrade gdbstub & gdbstub_arch dependencies
Bump the versions of these crates as we're about to require support for
unavailable register values and AArch64. Do it in a separate commit to
ease future bisects.

BUG=b:222222882
BUG=chromium:1141812
TEST=tools/dev_container ./tools/run_tests

Change-Id: I0bfa3559d172faf2df6bcffdc77714830f442051
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3785466
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Pierre-Clément Tosi <ptosi@google.com>
Tested-by: Pierre-Clément Tosi <ptosi@google.com>
Commit-Queue: Pierre-Clément Tosi <ptosi@google.com>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
2022-09-01 16:24:00 +00:00
Pierre-Clément Tosi
33fe685fc6 gdb: Make feature less x86_64-centric
Remove target_arch-specific #[cfg]s where the underlying code is
architecture-agnostic.

Introduce a GdbOps trait for architectures to implement.

Make use of the generic gdbstub::arch::Arch trait where relevant.

Import base::Tube unconditionally in arch/src/sys/unix.rs.

Expand crate::gdb::* in vm_control/src/lib.rs for clarity.

Keep target_arch checks in x86-specific code to exclude 32-bit builds as
those don't seem to provide GDB support.

BUG=b:222222882
BUG=chromium:1141812
TEST=tools/dev_container ./tools/run_tests

Change-Id: I3f5ceeeb9031bee222ecd388dddb815e256748e8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3785464
Tested-by: Pierre-Clément Tosi <ptosi@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Pierre-Clément Tosi <ptosi@google.com>
Commit-Queue: Pierre-Clément Tosi <ptosi@google.com>
2022-09-01 16:24:00 +00:00
Zihan Chen
11812a5bf9 crosvm: Make ballooning a compile time feature
Balloon support can not be compiled out, and don't need to be
disabled at run time.

BUG=b:235887451
TEST=Guest has balloon device by default, does not have balloon
device when disabled. Ballooning via cli functions by default,
return not supported when running vm has ballooning compiled out.

Change-Id: I737851496fe4c14cdbb69c48e6edf1ca9186c15a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3786928
Tested-by: Zihan Chen <zihanchen@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2022-07-27 19:21:50 +00:00
Vikram Auradkar
7874d2011e vm_control: Upstream windows patches and enable tests
BUG=b:213152502
TEST=presubmit after enabling vm_control tests

Change-Id: Ie4709dfeb428c527091447bd6f0bda2c14b5492e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3698049
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-13 17:34:44 +00:00
David LeGare
740c824fe8 Update to gdbstub 0.6.1
Update the GDB stub implementation to the 0.6 version of the gdbstub
crate API, attempting to preserve the current behavior as much as
possible. Hardware breakpoints and single stepping still work, but some
existing issues with software breakpoints are still present.

BUG=None
TEST=Manual

Cq-Depend: chromium:3578400
Change-Id: I522242a1a2055ecdf47b2010a615dc9e0136ebd0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3578025
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: David LeGare <legare@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-04-13 12:52:24 +00:00
Dennis Kempin
ef516189db Refactoring: Move common/base into base
Executes the script in https://crrev.com/c/3530502

BUG=b:223206469
TEST=presubmit

Change-Id: Ibeffdc8de0b2270f070e60bb2de8d9fdc78a2a6d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3530503
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-03-17 00:01:27 +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
David Stevens
0f924dd693 balloon_control: expose rust API for balloon
Add a crate containing an API for controlling the balloon. This is done
by reusing the API between the control socket and the balloon device.

BUG=b:213962590
TEST=compiles

Change-Id: I5d89d5ebee55162d28ba45ca2c49b7083561b916
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3394440
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-01-28 03:52:35 +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
c42ef90be1 vm_control: convert to ThisError and sort
BUG=b:197143586
TEST=cargo check

Change-Id: Ibf99cd24cc0c246fa1e70f3c91b45bc1716adf41
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105430
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-10-06 21:38:32 +00:00
Joel Galenson
06392aabd4 Migrate to gdbstub 0.5.0.
BUG=b:191784608
TEST=Build and run atest in Android tree

Cq-Depend: chromium:3073700
Change-Id: I5fcfa166caf8c5a5f759a8f62ef78a293db95f1a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3071900
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Andrew Walbran <qwandor@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-08-13 18:30:47 +00:00
Hikaru Nishida
a0e381b0d8 Change balloon_stats output format to JSON
This CL changes the output format of `crosvm balloon_stats` command to
JSON to ease parsing the result.

BUG=b:181267848
TEST=built and checked the output of crosvm balloon_stats

Change-Id: I4af40237109efdd02b5b70375ef8aa706cf5de55
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2914247
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Hikaru Nishida <hikalium@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Charles William Dick <cwd@google.com>
2021-06-15 17:29:30 +00:00
Zach Reizner
d49bcdb081 replace all usage of MsgOnSocket derives
Replaced all usage of MsgSocket with Tube.

BUG=b:176847362
TEST=run_tests

Change-Id: Ie647f79926bc0414c125a776eafe7f60c071bab2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2710324
Auto-Submit: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2021-04-02 15:40:41 +00:00
Gurchetan Singh
293913c01a rutabaga_gfx: rutabaga_gralloc: a shimmering beacon of hope
rutabaga_gralloc is a cross-platform, Rust-based buffer
manager.

The rationale for this change is:

1) For the {cross-domain, wayland} context type, we need to
have a good story for the crucial "wl-dmabuf" feature.  As
minigbm has been thoroughly tested on ChromeOS and currently
powers the "wl-dmabuf" feature, it only makes sense for us to
have a path to minigbm for the cross-domain prototype.  This
will be used by Sommelier.

2) While minigbm allocation works well on Chromebooks, it is
not sufficient for cross-platform purposes.  For their Virtual
Graphics Interface (VGI) initiative, Android graphics
virtualization experts have expressed their desire for a Vulkan
based allocator.  This will to go alongside cros_gralloc in
minigbm, which is considered by many to be the ""world's
premiere gralloc implementation".

3) Android graphics virtualization experts have expressed their
desire for vkMapMemory(..) to be used when crosvm is in
multi-process mode.  Currently, only dma-buf mmap() is supported
for zero-copy blobs in multi-process mode.  dma-buf mmap() is not
guaranteed to work on Nvidia (a "must have" for Cuttlefish) or
any other driver for that matter (we *make* it work for ChromeOS).
Possibly only solution: vkMapMemory ;-)

With these goals in mind, here's a summary of the revelant changes:

* Renamed the {gpu_allocator.rs, GpuMemoryAllocator trait} to be
  {gralloc.rs, Gralloc trait}.

* Moved all GPU allocation out of the resources crate and into
  the rutabaga_gfx crate.  This will allow the resources crate to
  be focused on managing resources for virtual machines.

* Moved the gpu_buffer crate into the gralloc module in the
  rutabaga_gfx crate.  The same functionality is now under
  "minigbm.rs", "minigbm_bindings.rs" and "rendernode.rs"

* Added an optional dependency on vulkano.rs.  vulkano.rs is a safe
  Rust wrapper around the Vulkan api [a].  It's emphasis on type
  safety makes a good fit for crosvm, though there are other high
  quality crates out there (gfx-rs, ash.rs).  Though development
  has slowed down, it should satisfy goals (2) and (3) quite easily.

* Added a system_gralloc implementation based on memfd.  This can be
  used when minigbm or Vulkano features are not used, to replicate the
  highly useful "wl-shm" feature in Sommelier.  Astute observers will
  note this can also enable seamless Wayland windowing without GPU
  features for Android too.  Some minor changes to the base crate were
  needed.

* Cut down on the amount of DrmFormats to the subset needed by
  Sommelier and cros_gralloc.

* Moved checked arithmetic into it's own file.

* Internally renamed to "wl-dmabuf" feature to be the "minigbm"
  feature.  This is because "wl-dmabuf" has a dependency on minigbm.

* Small rutabaga_gfx cleanups

[a] https://github.com/vulkano-rs/vulkano/blob/master/DESIGN.md

BUG=b:146066070, b:173630595, b:150239451
TEST=launch virtual machine with 2D mode
TEST=launch virtual machine with 3D mode
TEST=run sommelier with "wl-dmabuf" and "wl-shm"

Change-Id: I693a39cef64cd98e56d843d3c60caa7983d4d6e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2626487
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2021-02-04 02:35:52 +00:00
Keiichi Watanabe
c5262e9fad linux: Support GDB remote serial protocol for x86_64
Add a flag '--gdb <port>' to provide GDB remote protocol interface so
a developer can attach GDB to the guest kernel.
In this CL, we support read/write operations for registers and memories.

BUG=chromium:1141812
TEST=Attach gdb and see register values on workstation and intel DUT

Change-Id: Ia07763870d94e87867f6df43f039196aa703ee59
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2440221
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2020-11-12 08:47:59 +00:00
Steven Richman
f32d0b48fd Use hypervisor abstraction to run VMs
Calls to the kvm crate have been replaced by calls to hypervisor and
devices::irqchip.  Plugin is unchanged and still KVM-specific.

x86 creates and configures vcpus on the vcpu thread instead of the main
thread.

Code that still depends on kvm or kvm_sys:

  - crosvm_plugin, plugin, and protos use kvm and kvm_sys if built with
    the plugin feature

  - devices::VfioGroup does a kvm_sys ioctl

  - devices::irqchip and hypervisor use kvm_sys.  hypervisor uses
    kvm::Cap and kvm::CpuId internally for now.

BUG=chromium:1077058
TEST=runs es2gears_wayland on kukui
TEST=runs evince on amd64-generic with kernel and split irqchip
TEST=build_test excluding tpm2
TEST=cargo check --features plugin

Change-Id: I0068e34da6a5ff0079b1237be1958933bf12ffe4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2307711
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Steven Richman <srichman@google.com>
2020-08-11 04:51:34 +00:00
Michael Hoyle
6b19695c81 Add "base" crate and transition crosvm usages to it from sys_util
For now, this crate simply re-exports all of sys_util, but it will
be updated to provide new interfaces when needed. This is the
first step to making crosvm not directly depend on sys_util, so
that we can make the interface changes we need without fear of
negatively affecting (i.e. completely breaking) other usages
within chromeos.

BUG=b:162363783
TEST=./build_test

Change-Id: I7d0aa3d8a1f66af1c7fee8fd649723ef17027150
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2325168
Tested-by: Michael Hoyle <mikehoyle@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Michael Hoyle <mikehoyle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2020-08-06 18:19:44 +00:00
Dylan Reid
ec058d6c46 vm_memory: A crate to hold vm-specific memory objects
Move GuestAddress and GuestMemory to a new crate for VM memory. This
will make separating sys_util and crosvm independent making it easier
to use sys_util functions outside of crosvm.

Change-Id: I12e14948ea85754dfa6267b3a3fb32b77ef6796e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2311251
Auto-Submit: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2020-07-24 21:42:34 +00:00
Lingfeng Yang
d6ac1ab3a7 kvm: allow registering memory from current address space
This is good for enabling non-exportable Vulkan host coherent memory,
along with anything else where an exportable OS object isn't supported.

This CL introduces:

1. ExternalMapping, which wraps an external library mapping using
function callbacks, for purposes of sharing device memory to the guest
in the case where the device memory is not compatible with the mmap interface.
This is common in Vulkan when VkDeviceMemory is host visible but not
external, or external but based on an opaque fd.

The lifetime of the library mapping is tied to the lifetime of the
ExternalMapping.

2. Usually, we would send such memory requests over a socket to the main
thread. However, since these new objects require more metadata than
other requests that are sent over the wire (because there's information
about inheritance and refcounts), we also plumb the "map_request" field,
which wraps a single ExternalMapping.

Note that this ExternalMapping will not work in the sandbox case. In the
sandbox case, we will then have to figure out how to serialize/deserialize
ExternalMapping requests over a socket.

BUG=b/146066070, b/153580313
TEST=compile and test

Change-Id: I3b099b308aec45a313a8278ed6274f9dec66c30b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2034029
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2020-07-24 00:19:11 +00:00
Daniel Verkamp
6494117e17 usb: replace libusb with Rust usb_util library
Drop the dependency on libusb and reimplement the host USB backend using
usb_sys to wrap the Linux usbdevfs ioctls.

This allows sandboxing to work without any dependency on libusb patches,
and it gives us the flexibility to modify and update the USB backend
without depending on an external third-party library.

BUG=chromium:987833
TEST=`adb logcat` on nami with Nexus 5 attached
TEST=deploy app to phone with Android Studio
TEST=Run EdgeTPU USB accelerator demo (including DFU mode transition)

Cq-Depend: chromium:1773695
Change-Id: I4321c2b6142caac15f48f197795a37d59d268831
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1783601
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2019-10-17 00:20:24 +00:00
Daniel Verkamp
a445ae1fbe Remove remaining byteorder crate references
Remove the last (unused) reference to byteorder in vm_control/Cargo.toml
and remove it from the list of external crates in README.md.

BUG=None
TEST=./build_test

Change-Id: Ie70c0bc2f96c19b34ef1596885245eca7bc202f4
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1761156
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-08-26 23:41:54 +00:00
David Tolnay
48ff4165d2 cargo: Sort all dependency lists in Cargo.toml
This may help reduce cases of conflicts between independent CLs each
appending a dependency at the bottom of the list, of which I hit two
today rebasing some of my open CLs.

TEST=cargo check --all-features

Change-Id: Ief10bb004cc7b44b107dc3841ce36c6b23632aed
Reviewed-on: https://chromium-review.googlesource.com/1557172
Commit-Ready: David Tolnay <dtolnay@chromium.org>
Tested-by: David Tolnay <dtolnay@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2019-04-09 01:55:14 -07:00
David Tolnay
4a0fa14059 edition: Update vm_control to 2018 edition
Separated out of CL:1513058 to make it possible to land parts
individually while the affected crate has no other significant CLs
pending. This avoids repeatedly introducing non-textual conflicts with
new code that adds `use` statements.

TEST=cargo check
TEST=cargo check --all-features
TEST=cargo check --target aarch64-unknown-linux-gnu

Change-Id: Iedc030e90e4c4e11cf69dde711df24caafc0ea4c
Reviewed-on: https://chromium-review.googlesource.com/1520074
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: David Tolnay <dtolnay@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Tolnay <dtolnay@chromium.org>
2019-04-08 02:51:35 -07:00
Jingkui Wang
257d004b0c usb: add host backend
Host backend implement backend device. It will attach a read device to
xhci controller.

Also squashed from ce6b35, author: zachr@.

CQ-DEPEND=CL:1510820
BUG=chromium:831850
TEST=local build

Change-Id: Idcf2d7d6aca92de9859b7c38d1bf1d98032eae91
Reviewed-on: https://chromium-review.googlesource.com/1512761
Commit-Ready: Jingkui Wang <jkwang@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-03-16 15:25:23 -07:00
Jingkui Wang
e13b180f74 crosvm: use msg_socket in vm_control
Refactor existing code to use msg_socket.

BUG=None
TEST=local build and run

Change-Id: Iee72326b330e035303f679e1aedd6e5d18ad4f8a
Reviewed-on: https://chromium-review.googlesource.com/1260260
Commit-Ready: Jingkui Wang <jkwang@google.com>
Tested-by: Jingkui Wang <jkwang@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2018-11-19 16:28:35 -08:00
Dylan Reid
ef7352f208 Remove the device manager and use the new resource allocator
Allow IRQs to be assigned before creating device manager.

For PCI, we need to add devices with interrupts before MMIO setup. Add
the ability to tell the architecture device manager about IRQs that we
have stolen.

There was only one function in device_manager and all of its state is
now delegated to the resource allocator, remove it.

Change-Id: I9afa0e3081a20cb024551ef18ae34fe76a1ef39d
Reviewed-on: https://chromium-review.googlesource.com/1089720
Commit-Ready: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
2018-06-29 17:50:17 -07:00
Dylan Reid
d44320488f main: Add inflate/deflate interface for balloon
Change-Id: I0fc63abbed8db303c7d283ce392fd47777b60d19
Reviewed-on: https://chromium-review.googlesource.com/818207
Commit-Ready: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2018-01-02 23:36:26 -08:00
Dylan Reid
94bf1bf6b4 Move vm_control to a top-level crate
Break out vm_control to a crate that will be able to used by more
modules. Having vm_control usable from outside crosvm makes it possible
to move the devices out of crosvm in a later commit.

Change-Id: I1f060700ed49b5d77519d55efa2430490d521256
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/706558
Reviewed-by: Zach Reizner <zachr@chromium.org>
2017-10-09 17:39:04 -07:00