Commit graph

3791 commits

Author SHA1 Message Date
Dapeng Mi
38208040ff crosvm: add missing doc comments for configure_vcpu method.
BUG=None
TEST=Run "cargo doc" generate documents and check the arguments
description is correct.

Change-Id: I481d950928587728fdb69215b867561d6752f4aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3670720
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-31 02:03:36 +00:00
Junichi Uekawa
3cb328aa10 crosvm: Script for rebasing on main from chromeos branch.
chromeos branch is a stable base to work on, but patches need to land on
the main branch. For uploading to that directory, it's always necessary
to rebase onto that branch.

BUG=b:227535695
TEST=rebase_for_review && repo upload --cbr .

Change-Id: I5f41e52f91adf15ade84ae09f6b34dcdbe733d23
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3565627
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-05-30 07:26:07 +00:00
Dapeng Mi
a5d52312d5 crosvm: implement KVM_X86_SET_MSR_FILTER ioctl
turbostat shows cpu freq/c-state/thermal statistics data by reading
some related MSRs. Unfortunately some MSRs such as MSR_IA32_POWER_CTL
are already emulated by KVM. The emulated value are not what we want
to expose to Chrome OS guest. KVM_X86_SET_MSR_FILTER ioctl provides
a way to skip KVM's emulation and let user space handle the MSR.

We added two MSR actions "MsrPassthroughFilter" and "MsrEmulateFilter"
to indicate the corresponding MSR needs to be filtered.

BUG=b:229770963
TEST=Run "turbostat" in Chrome OS guest and show correct value.

Change-Id: I5920ddba091589170dc326e10187aec66f75df79
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3641465
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-30 06:35:12 +00:00
Norman Bintang
6eda1c4eb4 audio: Add lseek in null_audio_device policy
This commit will fix crosvm crashes when playing audio
with ac97 device and null backend

BUG=b:233960497
TEST=run aplay -Dhw:0,0 -d 3 -f dat /dev/urandom inside a VM

Change-Id: Ic24853f308d92b2e5831d112f432f72f6fedd73c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3670934
Commit-Queue: Norman Bintang <normanbt@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-30 03:20:47 +00:00
Alexandre Courbot
aa2e59d82f base: improve documentation of Descriptor and AsRawDescriptor
Although it can be useful for some limited cases, the Descriptor wrapper
class should ideally be eschewed and an alternative based on
implementing AsRawDescriptor on the right type be preferred. Make sure
its documentation reflects that.

The reason for avoiding Descriptor is that it encourages storing raw
descriptors that can possibly be closed before the user expects it. A
reasonable alternative to doing this is to call as_raw_descriptor() at
the exact moment the descriptor is needed, and never storing the result
- this ensures that the providing object (and underlying descriptor)
remain alive for long enough. Update the documentation of
AsRawDescriptor to explain and hopefully encourage this practice.

BUG=233968702
TEST=cargo build

Change-Id: I91c2ef11152b3b6adcc25f40d6de0a0f131700dd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3670101
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-05-28 07:29:03 +00:00
Alexandre Courbot
ed66850d92 devices: pit: avoid storing raw file descriptor
The Worker struct is storing a Descriptor obtained from a timer for the
sole purpose of adding it to a WaitContext when the worker thread starts
running. Instead of doing this, create the WaitContext and pass it as
part of the worker data, so all ioctls involving that descriptor are
performed directly on the timer, guaranteeing that the descriptor is
valid.

BUG=233968702
TEST=Linux VM starts and boots with `--split-irqchip` specified.

Change-Id: Ie5da1e9866742108f52c526100e936d292167ab7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3670105
Reviewed-by: Michael Hoyle <mikehoyle@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-05-28 07:29:02 +00:00
Alexandre Courbot
756c0bea9b devices: bat: remove unneeded use of Descriptor
WaitContext::build_with expects an array of &dyn AsRawDescriptor, which
the events we pass to it all implement. There is no need to use a
temporary Descriptor here.

BUG=233968702
TEST=cargo build

Change-Id: Ie39e1683ed13e474ef43bdad9375d60c6bf55f5a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3670104
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Michael Hoyle <mikehoyle@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-28 07:29:01 +00:00
Alexandre Courbot
c9a294ced7 devices: usb: host: don't use Descriptor as temporary descriptor storage
We can avoid temporarily storing the descriptor by passing a reference
to the providing device directly to EventLoop::add_event().

BUG=233968702
TEST=cargo build

Change-Id: I78ce17b8a2c7c8a695cf65597459719812c175a5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3670103
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Michael Hoyle <mikehoyle@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-28 07:29:00 +00:00
Alexandre Courbot
9be279ca5f devices: input: stop using Descriptor in evdev
Descriptor here was used to pass a raw descriptor from a type that
implements AsRawDescriptor to a function that takes an AsRawDescriptor
as argument. Passing the provider directly is strictly equivalent.

BUG=233968702
TEST=cargo build

Change-Id: I638d01f1d5b47eb9773e7b1ad3802f6d8d0e5f6a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3670102
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Michael Hoyle <mikehoyle@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-05-28 07:28:59 +00:00
Dennis Kempin
039936a871 merge_bot: Make script Python 3.8 compatible
Another script that needs to run on python 3.8. I filed b/234173142 to
make this consistent across all scripts and environments.

BUG=b:233913643
TEST=vpython3 tools/chromeos/merge_bot

Change-Id: Ic42423040feaaa5741a123972978af364886dc9e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3674220
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-05-28 01:04:43 +00:00
Dennis Kempin
9c313915f5 infra: Set git name/email on all builders
Without, gerrit will not let us submit code and we won't be able to use
repo.

BUG=b:233913797
TEST=recipes.py test run

Change-Id: I59dc6633c716288094e02f38d613343e69c8c3e9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3674004
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-28 01:04:01 +00:00
Anton Romanov
f66af4f3f8 crosvm: jail sandboxed devices before calling .on_sandbox on rest
Some non-jailed devices may spawn threads. Do this to prevent threads
interferring with jails

BUG=b:234169724
TEST=run with shared dir locally

Change-Id: I0164a56e4d60ac8358ffc368021cf6b8e9a11eb5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3673787
Reviewed-by: Lepton Wu <lepton@chromium.org>
Commit-Queue: Anton Romanov <romanton@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-27 23:05:50 +00:00
Dennis Kempin
de651d0357 infra: Small process improvements
- Use vpython to call crovm tooling (This provides a predictable python
  environment and allow us to use argh).
- Add build_context() to provide a simple API that readies source and
  container.
- Nest preparation steps to reduce noise on builder page.

BUG=b:233913643
TEST=recipes.py test run

Change-Id: I6800e55f7311b32c6ef61918d13795af1fb3b588
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3674217
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Anton Romanov <romanton@google.com>
2022-05-27 20:59:12 +00:00
Daniel Verkamp
16f42b2337 devices: vvu: cras: update to SocketListener
Fixes the build with cras enabled.

BUG=b:229554679
TEST=emerge-trogdor crosvm

Fixes: b524833ab8 ("devices: vhost-user: handler: use vmm_vhost's socket listener")
Change-Id: I8237bc6d2b50a5f3bb150ae5ddc2920999b4b658
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3673020
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-05-27 19:34:39 +00:00
Dennis Kempin
507ac947ae infra: Use depot_tools for repo and cros_sdk
The builders do not have depot_tools installed globally, but
the recipes checkout contains them, so look up the proper
paths to the tools.

BUG=b:233913797
TEST=./recipes.py run build_chromeos

Change-Id: I5d50871fa0ccee769704b339a20d3406d23e0510
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3674216
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-05-27 19:01:29 +00:00
Grzegorz Jaszczyk
cadc84b32a crosvm: extend suspend commands about generating sleepbtn event
As a part of full guest suspension/resumption support extend crosvm
suspend command about generating sleepbtn press. This allows to emulate
PM1 and inject the vSCI to the guest. When the guest kernel is built
with ACPI button support enabled, it allows to suspend guest with use of
some guest daemon listening on ACPI events e.g. acpid
(acpid detects the ACPI sleepbtn event and triggers the guest
 suspension).

During suspension process (VmRequest::Suspend), before VmResponse::Ok is
advertise, there is need to wait for actual guest suspension.
This is required, e.g. when crosvm suspend command is triggered
automatically by vm_concierge during host suspension process and
prevents suspending host before the guest is suspended.

Above is achieved by taking advantage of KVM_SYSTEM_EVENT_S2IDLE
request sent by hypervisor on behalf of a non-privileged VM. It is used
to wake up blocked thread, which is awaiting non-privileged guest
suspension to finish.

The enhanced suspend process introduced by this patch is triggered
only when the --s2idle flag is passed.

BUG=b:194391015
TEST=Suspend the guest by issuing "crosvm suspend
/run/vm/vm.<hash>/crosvm.sock" and make sure that the guest actually
triggers suspend process and finalizes it.

Change-Id: I38cf5a786275fc4afa4ba7642ef0be779f8f1548
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3602869
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Grzegorz Jaszczyk <jaszczyk@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-27 18:59:16 +00:00
Grzegorz Jaszczyk
2e7ded3fbd crosvm: extend resume commands about generating powerbtn event
As a part of full guest suspension/resumption support extend crosvm
resume about generating powerbtn press during resume. This allows to
emulate PM1 and inject the vSCI to the guest. When the guest kernel
is built with ACPI button support enabled it allows to wakeup guest from
suspend (ACPI powerbtn fixed event is registered for the guest kernel
and since SCI is wakeup armed it allows to wakeup the guest).

Complementary patch for suspend: CL:3602869

The enhanced resume process introduced by this patch is triggered only
when the --s2idle flag is passed.

BUG=b:194391015
TEST=Suspend the guest by "echo mem > /sys/power/state" and wake it up
by issuing "crosvm resume /run/vm/vm.<hash>/crosvm.sock".

Change-Id: Ifa6626801b495cf96508531783c556804d5a51c6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3602868
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Grzegorz Jaszczyk <jaszczyk@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-27 18:43:30 +00:00
Dennis Kempin
455d04d0d1 merge_bot: Do not batch dry runs
This just creates unnecessary noise. Just create a single dry run
merge commit each time.

BUG=b:227224259
TEST=None

Change-Id: I54385fd80f01771bb83e02f2b48e604ad2d68d1e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3673021
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-27 18:23:48 +00:00
Alexandre Courbot
22ba1728be devices: vvu-proxy: remove obsolete comment
We don't use `expect` in this block code anymore.

BUG=None
TEST=cargo build

Change-Id: I5c1887a42a0922f7b5d9d850d9c94dff8dc0d2f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3664171
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Abhishek Bhardwaj <abhishekbh@chromium.org>
2022-05-27 15:17:38 +00:00
Alexandre Courbot
2532c07b39 vmm_vhost: fix the VFIO implementation of set_nonblocking()
The set_nonblocking() implementation of the VFIO Listener was marked as
unimplemented and caused a crash. However, given that accept() on a VFIO
listener never blocks, it is just as safe to mark the operation as
successful, since the behavior of accept() won't be impacted and it will
behave properly both in blocking and non-blocking modes.

Removing this panic will allow us to safely use the Listener's interface
set_nonblocking() method in generic code.

BUG=b:229554679
TEST=vhost-user console device works.
TEST=vvu console device works.

Change-Id: Ibbde7bcd048505fc3a84eb4881a74285bae6bf54
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3591111
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-05-27 06:53:08 +00:00
Alexandre Courbot
b524833ab8 devices: vhost-user: handler: use vmm_vhost's socket listener
vmm_vhost comes with its own set of listeners that implement the same
interface. Switch to use its socket listener as that will allow us to
further factorize code.

BUG=b:229554679
TEST=vhost-user console device works.
TEST=vvu console device works.

Change-Id: I19d0c9b95a0cca57eefd6c72b875e8a166d06b89
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3591110
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-27 06:53:07 +00:00
Alexandre Courbot
64a3fc2d08 devices: vhost-user: remove Arc from SlaveListener and SlaveReqHandler
The SlaveReqHandler should be the sole owner of a VhostUserBackend since
it calls its mutable methods, so we shouldn't need an Arc here. If
sharing is necessary users can use their own locking mechanism.

Single ownership will help to retrieve the backend after a client
disconnects, to reuse it for another connection if needed.

BUG=b:229554679
BUG=b:216407443
TEST=cargo test -p vmm_vhost
TEST=vhost-user console device works.
TEST=cargo test -p devices

Change-Id: I2358c807ac3ddb1ee4b29d97df0ade5a3e30a85a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3591108
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Richard Zhang <rizhang@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-27 06:53:06 +00:00
Alexandre Courbot
c9b84cf570 base: fix cargo doc warnings
Fix a few link-related (either dead links or typos) in the base crate.

BUG=None
TEST=cargo doc

Change-Id: I520dd2fbfc16de72fcf19ecdd90943a7a963103c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3671057
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-05-27 05:29:02 +00:00
Peter Collingbourne
09f4513745 book: document that --gdb is x86 only
Change-Id: I26599a7e95b2caf899ed5ca95c56b9c7219440d3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3671957
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Auto-Submit: Peter Collingbourne <pcc@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-05-27 03:28:04 +00:00
Dennis Kempin
4977f49b8b dev_container: Move --stop logic before calculation of command
Otherwise we may exit thinking we are trying to run an interactive
command in a non-interactive terminal.

BUG=None
TEST=./tools/dev_container --stop </dev/null

Change-Id: Ie34cf662b82090b100533306572552c5a550211e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3671132
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-27 02:36:53 +00:00
Dennis Kempin
b360cd9fa9 infra: Add ChromeOS post-submit builder
This re-creates the Kokoro equivalent crosvm/ci/build-chromeos.sh.

It is a very inefficent builder that does a fresh checkout of
chromeos for every build.

We may want to consider using some of the chromiumos recipes
for caching the repo or sdk between builds.

BUG=b:233230344
TEST=./recipes.py test run
./recipes.py run build_chromeos

Change-Id: I5d545bae4817cae5b79c5d65901081d9b1391466
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3664842
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-26 22:03:51 +00:00
Dennis Kempin
ab93b5c3dc infra: Add verify builder for health_check
Adds a builder for both pre- and post-submit, executes the newly
added health_check recipe.

BUG=b:233913455
TEST=lucicfg validate main.star

Change-Id: I69e9738a02bb298d3b2556058d2df1ee9979bda4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3669815
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-26 20:33:29 +00:00
Kaiyi Li
d6b6a991df virtio-gpu: move parameters to a separate file
BUG=b:233676779
TEST=build on Android

Change-Id: I20cf4c330844f5048553ba44e002747c874b54bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3668927
Auto-Submit: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Commit-Queue: Kaiyi Li <kaiyili@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-26 20:19:46 +00:00
Daniel Verkamp
6792731800 seccomp: arm: allow fstatat for xhci
glibc 2.33 uses the fstatat64 syscall to implement statx(), which is
called by the USB emulation code when a device is added. Allow it along
with fstat64 to fix a crash on USB device insertion.

aarch64 and x86_64 use the newfstatat syscall instead, so they do not
need to be adjusted.

BUG=chromium:1328120
TEST=Attach yubikey to Crostini on kevin

Change-Id: I6a592e25126a5baebdbc8839ba11b971950f4575
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3671085
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-26 20:14:08 +00:00
Jeffrey Kardatzke
dd94f70697 crosvm: Add support for HEVC profile
Submit after crrev.com/c/3664859 is merged.

BUG=b:215043150, b:183217901
TEST=HEVC playback works in ExoPlayer on guybrush w/ full set of changes

Change-Id: If775435040a77f4620a55d6838353836c40291c4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3664289
Commit-Queue: Jeffrey Kardatzke <jkardatzke@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-05-26 20:09:50 +00:00
Daniel Verkamp
a6f7cbf5fb seccomp: aarch64: fix USB ioctl struct sizes
The ioctl allow list for the emulated xhci USB controller device was
copied from the 32-bit ARM version, but the structure sizes are
incorrect for 64-bit aarch64. Update the constants for ioctls that take
a structure with a different size:

- USBDEVFS_REAPURBNDELAY: struct usbdevfs_urb
- USBDEVFS_SUBMITURB: struct usbdevfs_urb
- USBDEVFS_CONTROL: struct usbdevfs_ctrltransfer

BUG=chromium:1328120
TEST=Share USB device with Crostini on trogdor64

Change-Id: I45d69021257af55cfeaf72dd33a500a358adc5ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3670055
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-26 19:37:54 +00:00
Mike Gerow
539ba3dcc9 Reland "devices: debugcon: add bochs-style debugcon device"
This is a reland of commit 129840471d

Original change's description:
> devices: debugcon: add bochs-style debugcon device
>
> This allows for creating a simple write-only debug connection that uses
> a single IO port. This method is supported by both bochs and qemu[1].
>
> The main motivation here is to help in improving crosvm's ability to
> boot OVMF, which makes use of this simple debug device on port 0x402.
> For that one would use `--serial
> type=stdout,hardware=debugcon,debugcon_port=1026` or something similar.
>
> Note that serde_keyvalue doesn't support parsing hex values, hence the
> need to use `1026`, but I intend to address that as well to allow the
> more natural `debugcon_port=0x402` phrasing.
>
> [1]: https://github.com/qemu/qemu/blob/master/hw/char/debugcon.c
>
> BUG=b:233610263
>
> Change-Id: I73238e5c35925668d133bfaa542fcbcf1e28765f
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3661255
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Commit-Queue: Mike Gerow <gerow@google.com>
> Tested-by: kokoro <noreply+kokoro@google.com>

Bug: b:233610263
Change-Id: I2f2125da95e8907f4f0c16930952e9b765d33e6c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3671087
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Mike Gerow <gerow@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-26 19:25:02 +00:00
Richard
b22eff068e devices: upstream virtio balloon for Windows
BUG=b:213149162
TEST=built and presubmits

Change-Id: I4323cbe8457501ab6988110b53b2c790a51ce8b8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3655755
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Richard Zhang <rizhang@google.com>
2022-05-26 18:23:34 +00:00
Mike Gerow
d46572f47e Revert "devices: debugcon: add bochs-style debugcon device"
This reverts commit 129840471d.

Reason for revert: This conflicts with https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600167 breaking the build

Original change's description:
> devices: debugcon: add bochs-style debugcon device
>
> This allows for creating a simple write-only debug connection that uses
> a single IO port. This method is supported by both bochs and qemu[1].
>
> The main motivation here is to help in improving crosvm's ability to
> boot OVMF, which makes use of this simple debug device on port 0x402.
> For that one would use `--serial
> type=stdout,hardware=debugcon,debugcon_port=1026` or something similar.
>
> Note that serde_keyvalue doesn't support parsing hex values, hence the
> need to use `1026`, but I intend to address that as well to allow the
> more natural `debugcon_port=0x402` phrasing.
>
> [1]: https://github.com/qemu/qemu/blob/master/hw/char/debugcon.c
>
> BUG=b:233610263
>
> Change-Id: I73238e5c35925668d133bfaa542fcbcf1e28765f
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3661255
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Commit-Queue: Mike Gerow <gerow@google.com>
> Tested-by: kokoro <noreply+kokoro@google.com>

Bug: b:233610263
Change-Id: Ia70540c3041611f59968cb7929b238eecfe2530d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3671082
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Mike Gerow <gerow@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-05-26 18:23:30 +00:00
Dennis Kempin
cb99b70b1d infra: Add health check builder
The builder calls ./tools/health-check for fmt/clippy/python checks.

BUG=b:233913455
TEST=recipes.py run health_check

Change-Id: Ia4b8298ef921b33a687d4e64956fc1f017649e7f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3668814
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-26 17:47:46 +00:00
Dennis Kempin
bcbf2cb678 infra: Preserve container between steps
This allows us to run multiple steps with the same intermediate
build data.
To make sure we start with a clean slate, any existing containers are
deleted at the beginning of each recipe.

BUG=b:233913455
TEST=./recipes.py test run

Change-Id: Ieda684d40bf08937183cba34242360c025724af8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3668813
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-26 17:47:46 +00:00
Mike Gerow
129840471d devices: debugcon: add bochs-style debugcon device
This allows for creating a simple write-only debug connection that uses
a single IO port. This method is supported by both bochs and qemu[1].

The main motivation here is to help in improving crosvm's ability to
boot OVMF, which makes use of this simple debug device on port 0x402.
For that one would use `--serial
type=stdout,hardware=debugcon,debugcon_port=1026` or something similar.

Note that serde_keyvalue doesn't support parsing hex values, hence the
need to use `1026`, but I intend to address that as well to allow the
more natural `debugcon_port=0x402` phrasing.

[1]: https://github.com/qemu/qemu/blob/master/hw/char/debugcon.c

BUG=b:233610263

Change-Id: I73238e5c35925668d133bfaa542fcbcf1e28765f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3661255
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Mike Gerow <gerow@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-26 17:13:59 +00:00
Alexandre Courbot
532cce15b1 devices: vhost-user: console: poll input asynchronously
Using the new `SerialInput` trait, we can create an async input source
and get rid of the polling thread.

BUG=b:228912920
TEST=vhost-user console device is working (with input) on Linux.

Change-Id: I1be9ae499f9c782b4aacba44e1eca524f1b701c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600168
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-26 11:17:52 +00:00
Alexandre Courbot
738adc7072 devices: serial: introduce SerialInput trait
Introduce a new dedicated trait for types that can be used as serial
input. This trait adds the requirement that the type must implement
`AsRawDescriptor`, which will allow us to use the input as a poll source
instead of having to spin a dedicated thread to call `read()` on it.

BUG=b:228912920
TEST=cargo build

Change-Id: Ib07f7b4e63545fa0f27940553ad6124796f5b3cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600167
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-26 10:09:52 +00:00
Dennis Kempin
784ab4b469 health-check: Add option to run only some checks
The default is still to run all of them, but this will allow us to run
checks in separate luci steps to provide an easier to read result.

BUG=b:233913455
TEST=./tools/health-check python fmt

Change-Id: Iddc803f8f423db36ece53a13acfe564560b789a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3668812
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-26 01:03:59 +00:00
Dennis Kempin
c2292ef52f dev_container: Keep alive with 'sleep infinity'
We run a neverending command in the container to keep it alive in the
background.
By default, this would be bash, which does the job when --tty is
specified. But we no longer do that all the time.

Instead we can use sleep, which does not rely on such tricks.

BUG=b:233913455
TEST=./tools/dev_container true

Change-Id: I2d04aabbef6b670daf6b94fdc2c65c7bd759c61b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3669682
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-26 01:03:59 +00:00
Daniel Verkamp
ac65c32e6e main: only allow --gdb option when compiled with gdb feature
Without this cfg check, execution can reach an unreachable!() statement
in the arg handling code on non-gdb builds.

BUG=None
TEST=cargo build # without --features=gdb

Change-Id: I8bec7abbb39e658d5c8f45946fd4fc28f0ae97a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3668741
Reviewed-by: Anton Romanov <romanton@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-25 22:45:55 +00:00
Vikram Auradkar
a243d3115c crosvm: refactor main.rs
- make gpu-display related code unix only
- add/use
  - use_host_cpu_topology
  - get_vcpu_count
  - net_vq_pairs_expected

BUG=b:227659915
TEST=presubmit

Change-Id: I6a1901d25de351bfbdf9d5b1210123ac3b1ddb55
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3663966
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-25 20:43:20 +00:00
Daniel Verkamp
e84d9c1d7c devices: pci: PciBarIndex API cleanup
Everything that takes a PCI BAR index should use the appropriate
PciBarIndex type rather than u8 (or usize) for better type safety and
descriptiveness.

BUG=b:232838930
TEST=tools/presubmit

Change-Id: I0a918a6da6327c963fb297ba765563774a7e5e49
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3664282
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Anton Romanov <romanton@google.com>
2022-05-25 20:36:40 +00:00
Daniel Verkamp
18203fa00f devices: virtio-pci: refactor BAR lookup
The read_bar() and write_bar() functions had an open-coded equivalent of
BAR lookup to find out if the access was intended for the settings BAR
or one of the device-specific extra BARs. Instead, we can reuse the same
BAR lookup code to find the index of the relevant BAR and compare it
against the settings_bar field.

BUG=b:232838930
TEST=tools/presubmit

Change-Id: I2e5f3ccff47d31718e835ccb745db75dbda2e4ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3664281
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-25 20:36:40 +00:00
Daniel Verkamp
19da3a6c48 devices: virtio: clean up write_bar/read_bar matches
Define constants for the end of the ranges that exist within the
settings BAR so we can use the range syntax in the match instead of
manually checking against the start and end.

This uses inclusive range (..=) syntax, since exclusive range pattern
syntax (..) is experimental. Therefore, each range has a `_LAST`
constant that is equal to the address of the last valid byte in that
range (first + size - 1).

Rewriting the matches in this way allows us to clean up the two clippy
ignores and makes the code a bit easier to read.

BUG=b:232838930
TEST=tools/clippy
TEST=Boot x86-64 Crostini

Change-Id: Ibb8b5ea055e598c19504b7b1b6753706ad458875
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3664280
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Anton Romanov <romanton@google.com>
2022-05-25 20:36:40 +00:00
Daniel Verkamp
337d123007 x86_64: gdb: add support for FPU and SSE registers
BUG=None
TEST=connect gdbstub and run `info all-registers`

Change-Id: I2800134923d73117122b0cb136021d30ebe4cd76
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3657060
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-25 17:33:30 +00:00
Lepton Wu
911a2d0671 devices: vhost-user: fs: open vvu device outside jail.
We need to open vvu device before we go to jail since we don't have
access to sysfs in jail.

BUG=b:233690640
TEST=manual - fs is usable from a sibling guest when using VVU.

Change-Id: I0340d105b667cce2ba88d7557e64771fa2bedf9e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3665907
Auto-Submit: Lepton Wu <lepton@chromium.org>
Commit-Queue: Lepton Wu <lepton@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-25 16:44:13 +00:00
Alexandre Courbot
1f486e2313 gpu: fix (again) unused_mut warning when no gpu feature is enabled
This was fixed in crrev.com/c/3659824, but a subsequent commit somehow
reverted that line.

BUG=None
TEST=`cargo build` does not display any warning.

Change-Id: Id50ee4f615117ada8c27552e073f7fb04d8d009e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3664166
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-25 09:14:18 +00:00
Alexandre Courbot
4212e80393 devices: vhost-user: console: make async functions generic
We want to eventually reuse these functions in the regular virtio device
code, which uses a different kind of interrupt, so make that parameter
generic.

BUG=b:228912920
TEST=cargo build

Change-Id: I1139ce6626ac7b952b7769db6e66d677607d3307
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600166
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-05-25 09:12:23 +00:00