Commit graph

3017 commits

Author SHA1 Message Date
Vikram Auradkar
0108238474 Upstream windows build/test script
The patch also adds files to skip building and testing crates on
windows. When we run
```
tools/windows/build_test.py --skip_file_name .windows_build_test_skip
```

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

Bug: 213170957
Test: Ran script on downstream repo
Change-Id: Iebd2cea463ee722be4feaed88229e1fb5e9fd6c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3417918
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-01-28 00:55:08 +00:00
Dennis Kempin
722dcd4afd OWNERS: Add crosvm-bot
This should allow the bot to submit dry-runs to the CQ.

BUG=chromium:1290646
TEST=None

Change-Id: I44fc74c94129e7d136a161c1ba11445d7bf675c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3421730
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-01-27 23:41:23 +00:00
Dennis Kempin
6b06f405ff docs: Use mdformat to format markdown files
The tool is added to ./tools/fmt which will be called during
./tools/presubmit as well as by Kokoro during testing.

This requires a new dev container version to bundle the mdformat
tool in the container.

Note: mdformat does not have any IDE integrations, but the prettier
plugin with prose-wrap enabled and a line length of 100 provides
almost identical results.

BUG=None
TEST=./tools/fmt --check

Change-Id: I0ae5659eff8555df7c85c70e62095a1e116b98da
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3416098
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-01-27 21:29:11 +00:00
Dennis Kempin
cde666cd54 Reorganize usage doc and add example usage
BUG=b:214104901
TEST=mdbook serve

Change-Id: I7039493212912cb698f74967abef228df278f4c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3399872
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-01-27 21:29:10 +00:00
Vineeth Pillai
2b6855e725 crosvm: Add support to pass vcpu-cgroup-path to crosvm
The latency reduces to 50-100ms max from over 1 second, when we overload
the system.

BUG=b:208138181
TEST=run stress-ng inside and outside VM.

Change-Id: I10a22807b47a1ed2dd181c2ddcc995eebef7f652
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3383936
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vineeth Pillai <vineethrp@google.com>
2022-01-27 21:19:21 +00:00
Daniel Verkamp
33f982e179 crosvm: allow --stub-pci-device multifunction again
The previous multifunction change removed this option entirely, but that
makes the transition difficult, since the caller and crosvm need to be
updated simultaneously. To make the changeover simpler, allow the
multifunction option but make it do nothing, since the PCI root code
will already do the right thing.

BUG=b:210795995
TEST=Run crosvm with --stub-pci-device with multifunction enabled

Change-Id: I5d378001d495ec54bd4c1869de796ba6a418f43a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3421006
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-01-27 20:39:52 +00:00
Dennis Kempin
32c3f30e05 merge-into-chromeos: Set Bot-Commit+1 as well
This is an experiment to figure out the permissions needed by
crosvm-bot.
See https://crbug.com/1289780 for details.

BUG=chromium:1289780
TEST=None

Change-Id: Ic202532ceaa2b0d86f51c8670137bde2d8f16868
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3419296
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-01-27 20:08:51 +00:00
David Stevens
06d157a7b6 crosvm: add param to limit initial memory
Add an init-mem parameter that limits how much memory the VM can use on
startup. If set, the balloon is inflated on startup to (mem - init-mem).

BUG=b:213962590
TEST=set param and verify balloon inflates on startup

Change-Id: I920bf9cfa26081ee544219406f8cf9827ff84bfa
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3394439
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-01-27 15:11:30 +00:00
Andrew Walbran
3cd9360fac Disable virtio balloon device for protected VMs.
It is not compatible with pKVM and leads to RCU stalls on the host due
to the virtio_balloon thread getting stuck.

BUG=b:215517095

Change-Id: Ibd1c9db53bfa001e07ba6399ff50e9073476017d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3412776
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Andrew Walbran <qwandor@google.com>
2022-01-27 11:23:47 +00:00
Junichi Uekawa
8764deb8dd crosvm: Minimal change for manatee memory mapping.
Do not map RAM to where the coreboot regions are.

Shift boot time GDT and IDT a bit to make way for coreboot region at
0..fff.

BUG=b:188011323
TEST=boot volteer-manatee
TEST=tast run rammus-arc-r arc.Boot.vm  # ARCVM still boots.
TEST=tast run rammus-arc-r crostini.Basic.bullseye_stable

volteer-manatee memory map:

after:

localhost ~ # dmesg | grep e820
[    0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable
[    0.000000] BIOS-e820: [mem 0x0000000000200000-0x00000000cfffffff] usable
[    0.000000] BIOS-e820: [mem 0x00000000f4000000-0x00000000f7ffffff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000100000000-0x00000003f05fffff] usable

before:

localhost ~ # dmesg | grep e820
[    0.000000] BIOS-e820: [mem 0x0000000000001000-0x000000000009fbff] usable
[    0.000000] BIOS-e820: [mem 0x0000000000200000-0x000000005fffffff] usable
[    0.000000] BIOS-e820: [mem 0x00000000f4000000-0x00000000f7ffffff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000100000000-0x0000000460600fff] usable

Change-Id: Ifa19988c444d79dc81eb77c59e5b5434abf883fb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3405402
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-01-27 02:29:32 +00:00
Junichi Uekawa
57d7eba097 crosvm: Use MB and GB across the file.
BUG=None
TEST=build

Change-Id: Ibd101c10ccc9425c389bbf3d43a1d44e3ebea7f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3405401
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-01-27 00:27:14 +00:00
Dmitry Torokhov
9cbe543e6a devices: gpu: control lifetime of render server jail
Rearrange the code that creates devices and starts the VM so that the
jail object is not destroyed while VM is running and also make sure we
kill the process when vm stops.

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

Change-Id: Id35791e7264a52e34d2ddfac86425ad4b3c2d059
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3416101
Reviewed-by: Chia-I Wu <olv@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-01-27 00:06:10 +00:00
Dmitry Torokhov
cbfef3b3e3 plugin: switch to using resize_with() when initializing per-VCPU states
Now that resize_with() has stabilized and is available in version of
Rust we are using we can switch to it instead of implementing the same
by hand.

BUG=None
TEST=./tools/presubmit

Change-Id: I08b418ad898ecbc52c63bd7a47f6470af30c8a66
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3417961
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-01-26 23:08:50 +00:00
Dennis Kempin
d6c3154b13 merge-into-chromeos: Create a dry run merge as well
The dry run merge is re-created every day and automatically
set to CQ+1. This allows us to check for bad crosvm changes
while we submit parts of the merge chain.

BUG=b:215741244
TEST=./tools/ci/simulate merge-into-chromeos.sh

Change-Id: I0773a99f9858962e9f25bebff1b233d455d33cdd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3417508
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-01-26 20:47:46 +00:00
David Stevens
4700aa062f sys_util: add more features to UnixSeqpacket
Add an accept_with_timeout method to UnixSeqpacket and implement a few
basic traits for UnixSeqpacket.

BUG=b:213962590
TEST=cargo test

Change-Id: I1b8461e54aac2be31604213b252c15ce2195e33a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3394438
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-01-26 13:42:19 +00:00
Mattias Nissler
bbd91d088d Add generalized file-backed mapping functionality
This is a generalization of the existing --direct-mmio option with the
following improvements:

 * Memory is mapped directly into the guest namespace rather than
   handled via MMIO exits.
 * The --file-backed-mapping option can be specified multiple times to
   set up mappings backed by different files.
 * Command line option format is extensible, allowing to add further
   parameters in the future as needed.
 * O_SYNC mapping is configurable from the command line, making this
   useful for mapping both MMIO regions and regular system memory into
   the VM.

One limitation that this new implementation brings is that mappings
need to be page-aligned (which isn't the case for --direct-mmio). I'm
not aware of existing users that require fine-granular file-backed
MMIO mappings though, so this is hopefully OK.

The existing --direct-mmio option code is left untouched, but will be
removed later after converting over existing usage.

BUG=b:184815519, b:188011323
TEST=unit tests for command line parsing, manual test to specify --file-backed-mapping and observe that the backing file content is accessible from the guest.

Change-Id: I86aee74d2032caaf9130569203d5749994a4413d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3328602
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Mattias Nissler <mnissler@chromium.org>
2022-01-26 10:03:19 +00:00
Alexandre Courbot
f70a014c32 virtio: video: decoder: fix computed picture plane size
The picture buffer size was computed from the size of the visible
rectangle, which is potentially incorrect: if the origin of the visible
rectangle is not (0, 0) then the buffer is going to be larger.

Fix this by using the provided coded width and height, which correspond
to the actual size of the buffer and not just its visible area.

BUG=b:161774071
TEST=Android Youtube decodes properly on zork-arc-r.

Change-Id: I80e15248f41d6202190456d2ab61f8f50d3b6ebb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3412457
Reviewed-by: Chih-Yu Huang <akahuang@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: David Staessens <dstaessens@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-01-26 03:54:45 +00:00
Junichi Uekawa
63d127f45c crosvm: Merge README.chromeos to CONTRIBUTING.
Docs are scattered around, and README.chromeos isn't markdown.  Merge to
CONTRIBUTING doc and update the relevant parts.  Rename to
README.chromeos.md and make it point to the other doc.

BUG=None
TEST=read it.

Change-Id: Ib1df58e1a7c48d6faad71faffc9527da5f3218be
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3405403
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-01-26 01:33:23 +00:00
Dmitry Torokhov
fbc43370b8 plugin: switch to using anyhow for error reporting
Switching to anyhow allows us to get rid of the unwieldy error enum in
places where we do not care about error codes.

BUG=None
TEST=./tools/presubmit and run Parallels VM on CrOS

Change-Id: I4b9636801a7daa1d1289ce1bc4f9a92d47efaeb0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3416093
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-01-26 00:10:32 +00:00
Dmitry Torokhov
2e6e61d1b7 Teach create_base_minijail() to set up remount mode
Instead of having to adjust this after the fact, let's teach
create_base_minijail() handle this request.

BUG=None
TEST=./tools/presubmit

Change-Id: Iabfd583f1d198c243d7d073785066a343ceac94e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3416094
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-01-26 00:06:00 +00:00
Dennis Kempin
151ae7eed4 Docs: remove --global from git config
This causes problems with repo and should only be set on the crosvm
repo.

BUG=None
TEST=None

Change-Id: Id63a60f9ccebf3f7785a1473d15d6a9f88f8cdd0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3414497
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-01-25 23:03:00 +00:00
Dennis Kempin
53c216fd07 Make vscode devcontainer usable
The container was pretty much untested. Now that vscode supports dev
containers via SSH I got to test this properly.

This provides a workable dev environment out of the box.
./tools/presubmit passes and
common extensions for rust, python and bash are added.

BUG=None
TEST=Open in vscode, re-open in dev container. Run ./tools/presubmit

Change-Id: I542f3d26c29c4051000e6ec8b81d77d297bcad7d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3402447
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-01-25 21:30:49 +00:00
Dmitry Torokhov
507536ddd8 x86: pass host's processor brand string to guests
Let's pass host's processor brand string to guests, so that lscpu and
/proc/cpuinfo do not fall back to printing numeric model numbers
but rather print vendor string, such as:

	Intel(R) Core(TM) i3-10110U CPU @ 2.10GHz
or
	AMD Ryzen 3 3250C 15W with Radeon Graphics

BUG=None
TEST=boot zork and hatch, examine lscpu in crostini

Change-Id: I7cd3ccd4a6328695cc180ee4c13d19d2e48f3def
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3410647
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-01-25 01:56:29 +00:00
Chuanxiao Dong
2fef35537f coiommu: add unpin_gen_threshold parameter optimize the LRU unpin
The pages which are frequently used by the VM are likely not to be
unpinned. So an optimization is to skip the unpin scan for those pages
in the LRU unpin policy. The unpin_gen_threshold defines a threshold
number that, if a page cannot be unpinned in a period of
(unpin_gen_threshold* unpin_interval) seconds, then this page will be
marked as inactive. Those inactive pages will be scanned every
(unpin_gen_threshold* unpin_interval) seconds if there is no enough
active pages to unpin.

BUG=b:188481989
TEST=Boot a VM with coiommu lru unpin policy + pass through devices.

Change-Id: Ie020173097b6f4f925cafc121a802243ef65f165
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3292941
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
2022-01-22 06:48:27 +00:00
Chuanxiao Dong
e88502f216 coiommu: add two new commands to park and unpark unpin
Unpin is handled indepently with the coiommu frontend driver. To
support the DTT shrinker happened in coiommu, it needs a way to
park the unpin thread for a while in case unpin is also accessing
the DTT. When the shrink is done, frontend can unpark to make unpin
thread work again.

BUG=b:188481989
TEST=Boot a VM with coiommu lru unpin policy + pass through devices.
In VM, use command #echo 2 > /proc/sys/vm/drop_caches to trigger
shrink.

Change-Id: Icea6aee6424f09339b549eb2735c73551a87a505
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3292940
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-01-22 06:48:16 +00:00
Chuanxiao Dong
8b72132e2a coiommu: add deactivate command support
Deactivate command is used when the CoIOMMU driver in the guest
is failed to probe, or CoIOMMU device is removed by the guest.
But these are not expected to happen. Once this happened, the
guest won't be functional as all the pass-through devices on top
of CoIOMMU will not work. So in the backend side, just panic when
receive such command.

BUG=b:188481989
TEST=Boot a VM with coiommu and remove it in the guest.

Change-Id: I912c71d80e6cbd02bf7edc6bfb30ef11051dc490
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3292939
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
2022-01-22 06:48:05 +00:00
Chuanxiao Dong
d446861e27 coiommu: expose policy parameter to allow user to set through cmdline
Add a crosvm parameter to allow user to sepcify the coiommu unpin
policy. Besides unpin the pages when balloon inflate, coiommu also
supports to periodically unpin with a LRU policy.

The usage is like this:
"--coiommu unpin_policy=lru,unpin_interval=10,unpin_limit=8192"
which means to use LRU unpin policy with unpin interval is 10 seconds
and the unpin count limit for each cycle is 8192 pages.

Without specify the parameter, coiommu will use the default
configuration which is to turn off the periodically unpin.

BUG=b:188481989
TEST=Boot a VM with coiommu lru unpin policy + pass through devices.

Change-Id: I10414cc6b2520b804685450dfd1560cfe49455a7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3292938
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
2022-01-22 06:47:55 +00:00
Chuanxiao Dong
9ab8349c98 coiommu: add LRU unpin policy
LRU unpin policy is an internal unpin policy which is triggered by
a timer. This policy can be used when there is no external balloon
unpin request.

BUG=b:188481989
TEST=Boot a VM with coiommu enabled + pass through devices.

Change-Id: Icb6e19073cb668fa954aec97e02be77f1b8f6a04
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3292937
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
2022-01-22 06:47:41 +00:00
Chuanxiao Dong
146a13bb5e balloon: create balloon with tube for unpinning request
Put the VFIO pass-through devices and coIOMMU creating earlier
than the virtio device so that when creating virtio-balloon
it can use the tube from coIOMMU to send the unpining request
when processing the inflate.

BUG=b:188481989
TEST=Boot a VM with Network device pass through w/ coiommu, and do
the iperf test. Then perform balloon inflate/deflate.

Change-Id: If3ff9b3b0293ce49a39498a18feae1d697523f92
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3292936
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
2022-01-22 06:47:29 +00:00
Chuanxiao Dong
cb03ec6430 Set rlimit if virtio IOMMU or coIOMMU is used
vIOMMU will dynamically pin VM's memory and in the extreme case they
might pin the entire VM's memory. RLIMIT_MEMLOCK will control how
much memory can be pinned by the process. So set the RLIMIT_MEMLOCK
to be allow pinning the entire VM's memory in the extreme case.

BUG=b:188481989
TEST=Boot a VM with Network device pass through w/ coiommu, and perform
the iperf test.

Change-Id: Ibceaa274646d5a0afac183d30c8df75c44c92775
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3292935
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
2022-01-22 06:46:59 +00:00
Chuanxiao Dong
a8d427b9b1 coiommu: enable coiommu
Coiommu can be enabled through the command line. E.g.
To enable coiommu for a VFIO pass-through device:
--vfio=/sys/bus/pci/devices/0000:00:02.0,iommu=coiommu

BUG=b:188481989
TEST=Boot a VM with a VFIO pass through device w/ coiommu
TEST=Boot a VM with a VFIO pass through device w/o coiommu

Change-Id: Ica6145d7bc6a4c398f0fc10899f8ee24138615c4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3292934
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: David Stevens <stevensd@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-01-22 06:46:46 +00:00
Chuanxiao Dong
5fd2505cb5 balloon: add a tube for sending unpin request
When balloon to do inflate to release some memory to hypervisor, such
memory should also be unpinned by the component(e.g. coiommu) which
has pinned these memory. This tube will be used by balloon to send
the unpin request to the components(e.g. coiommu) to do the unpin
before releasing the memory.

BUG=b:188481989
TEST=Boot a VM and check balloon inflate/deflate

Change-Id: I06aa8bd8c11deeac9f133adbefa6442cf1b722de
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3292932
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
2022-01-22 06:46:08 +00:00
Chuanxiao Dong
5fd130e964 coiommu: add tube to allow coiommu handle the external unpin request
The memory pinned by coiommu cannot be release to hypervisor unless it
is unpinned. The balloon in VM will be used to inflate and release
memory to hypervisor. The tube added for coiommu will be used by balloon
to send the unpin request during inflating.

BUG=b:188481989
TEST=Boot a VM

Change-Id: I2c75346b721ac639c803490f8850a1ee03e74194
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3292933
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
2022-01-22 06:45:35 +00:00
Daniel Verkamp
44495f3a8e kokoro: update submodules after rebasing
In case the rebase brought in a commit that updated the submodules, we
should update them after the rebase instead of before. Otherwise the
submodules will be out of date compared to the source.

BUG=None
TEST=None

Change-Id: I398755abc76e9e6672c71ff1fe358a7c201c09fb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3403133
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-01-22 00:05:23 +00:00
Xiong Zhang
81ae6f366a devices/vfio-pci: Monitor req_irq eventfd for device hotplug out
If crosvm register a req_irq eventfd on a vfio-pci device, kernel
vfio-pci driver will trigger this req_irq eventfd when the physical
device is removed from host.

So crosvm should register and monitor req_irq eventfd for vfio pci
device hotplug out, once req_irq eventfd is triggered by host
vfio-pci driver, crosvm should should inject an hotplug out interrupt
into guest, then guest device driver will be unloaded, finally host
vfio-pci driver will be unloaded and physical device is removed from
host.

BUG=b:185084350
TEST=Boot a guest and hotplug in/out pcie device repeatedly

Change-Id: Ia6e4c74b0ad5e87a4d2bea5631ef81e7120e07cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3062742
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-01-21 20:48:27 +00:00
Xiong Zhang
c78e72b7cf main: Add hotplug vfio device commmand through control socket
Through control socket, user could request crosvm to hotplug a
vfio pci device.
Hotplug in vfio pci device:
    crosvm vfio add host_pci_device_sysfs_path control_socket_path
Hotplug out vfio pci device:
    crosvm vfio remove host_pci_device_sysfs_path control_socket_path

BUG=b:185084350
TEST=Boot a guest and hotplug vfio pci device repeatedly

Change-Id: Id66e05ae3da8eb85da49407d69fe1efe7e39fe85
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2955582
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-01-21 20:48:25 +00:00
Chuanxiao Dong
82b1a4b2b6 coiommu: add basic unpin page framework
The unpin page framework will be used to handle the unpin request.

BUG=b:188481989
TEST=Boot a VM

Change-Id: I6d19a679c4626b8775d81e09ecca2a0fe6c58ec8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3292931
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-01-21 12:25:03 +00:00
Chuanxiao Dong
c085b765bd coiommu: add coiommu device model basic support
Coiommu is a virtual PCI interface device. It provides pin page
functionality to the guest VM for the pass-through device through
the VFIO framework. With this, the guest VM doesn't need to pin pages
at the VM creating time but just need to do this through coiommu
frontend driver dynamically at runtime. Coiommu frontend driver will
send the pin request to the backend through device MMIO with the GFN
address. Backend then find out the proper HVA according to this GFN
and map this GFN to the HPA finally through the VFIO framework.

Unpin page functionality will be supported in the next patches.

BUG=b:188481989
TEST=Boot a VM

Change-Id: Iac347200305ed0cebe1456e3a0a353de83e6c80b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3292930
Reviewed-by: Chirantan Ekbote
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-01-21 08:51:47 +00:00
Chuanxiao Dong
c41ee08e99 crosvm: Extend VmMemoryRequest to support read_only map
Extend with read_only support so that the user can create a
read-only map for some read-only memory region, like read-only
memory backed MMIO bar.

BUG=None
TEST=Boot a VM

Change-Id: Ia6c1fd365808991f02298f7bbfaac0be8c801f8b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3292929
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-01-21 07:11:43 +00:00
Lepton Wu
a0638451f1 gpu: Mount driconf in gpu jail
BUG=b:202681679
TEST=`atest android.graphics.cts.VulkanFeaturesTest#testVulkanHardwareFeatures`

Change-Id: I6b63224c212fc694d1ab17d3226df165d0894982
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3402481
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Lepton Wu <lepton@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Lepton Wu <lepton@chromium.org>
2022-01-20 21:00:09 +00:00
Daniel Verkamp
ef084fa680 resources: use PCI functions if devices are exhausted
When allocating PCI addresses, prefer to allocate at the device
granularity (e.g. 00:01.0, 00:02.0, 00:03.0, etc.), but when these are
all allocated, start using functions (e.g. 00:01.1, 00:01.2, 00:01.3).
This enables us to add more PCI devices (31 x 8 instead of just 31)
while maintaining the existing PCI address allocation order for setups
that do not require many devices.

BUG=b:210795995
TEST=boot Linux with 32+ virtio-pci devices

Change-Id: Ic06d3c9939dd78061a51e49b4f7ec457c81c7621
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3343182
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-01-20 19:40:09 +00:00
Daniel Verkamp
13eb87aded devices: choose PCI interrupt pin based on function
Use the PCI address function field to evenly distribute the chosen
interrupt line across the available pins.

This does not change behavior when all devices are allocated on a
separate device number (they will all have function 0 and therefore
choose interrupt pin A, as they do already).

BUG=b:210795995
TEST=boot crosvm with multi-function devices

Change-Id: I4b3e525ef784ac41b3f66cfddea192dd933d9907
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3343181
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-01-20 19:40:08 +00:00
Daniel Verkamp
42b33600d4 devices: pci: determine multifunction bit at runtime
Each device does not know whether it is a multi-function device when it
is created; this is only possible to determine once all devices have
been added to the PCI bus. Change the PCI root code to check for this
and update the multi-function bit dynamically at runtime.

The multifunction option for the stub PCI device is also removed; it
will be determined automatically, so there is no need for the user to
specify it.

BUG=b:210795995
TEST=boot crosvm with multi-function devices

Change-Id: Iff8306a41bb2bf23f97f45d29edc7791efc754bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3343180
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-01-20 19:40:06 +00:00
Dennis Kempin
bf0066f4f9 merge-into-chromeos: Only merge if N commits have been added
We currently have a lot of merges with just 1 or 2 commits in them.
That's a lot of noise.

This CL makes the builder wait until we got at least 5 commits to
merge. This will delay merge commits being created, but our merge
process is usually a few days behind due to CQ delays, so it does
not matter much.

The MIN_COMMIT_COUNT variable can be overwritten when triggering
a manual build in Fusion.

BUG=b:215389423
TEST=./ci/kokoro/simulate build-merge-into-chromeos.sh

Change-Id: Ia24ee0b615ad402060775530e9eb0def7742200e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3402501
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-01-20 18:11:34 +00:00
Chia-I Wu
7f0f7c1fa0 gpu: add support for shader cache for the render server
BUG=b:213215649
TEST=run some gl and vk apps manually

Change-Id: I9250796f5fc3f086812d425ce2a3903cf3e0c2ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3384232
Reviewed-by: John Bates <jbates@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Chia-I Wu <olv@google.com>
2022-01-19 18:49:42 +00:00
Chia-I Wu
13ec6964b4 gpu: parse cache path/size into GpuCacheInfo
Add get_gpu_cache_info to parse cache path/size into GpuCacheInfo.

BUG=b:213215649
TEST=run some gl and vk apps manually

Change-Id: I24f76b6e46151936df54fd83528d7f8e2484e5fa
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3384231
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: John Bates <jbates@chromium.org>
Commit-Queue: Chia-I Wu <olv@google.com>
2022-01-19 17:18:05 +00:00
Dennis Kempin
df640d068c Add functional crosvm examples for running on linux
Two examples are added. A simple one and one with network
configured.

The examples are written in a way they can be integrated
with the mdbook to form a tutorial. This will ensure the
tutorial code snippets stay up to date.

The documentation for networking is added after
https://crrev.com/c/3237468 is merged.

BUG=b:214104901
TEST=./tools/examples/example_simple

Change-Id: I33682878858d8a0324fbb6a87e33cd55b29811b7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3388063
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-01-18 23:24:00 +00:00
Gurchetan Singh
fb7ee340dc rutabaga_gfx: use stream_renderer_map_info
Don't assume write combine mappings always.

BUG=b:213604148
TEST=dEQP-VK.memory.*

Change-Id: Ic1b50f52945e8735fa166b9dd5f37adbda809472
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3399584
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2022-01-18 22:40:30 +00:00
Daniel Verkamp
a48485090f aarch64: do not accept 0 as a valid address size
The newly-added KVM_CHECK_EXTENSION call to retrieve
KVM_CAP_ARM_VM_IPA_SIZE was checking for errors by looking for return
values less than 0, but KVM_CHECK_EXTENSION returns 0 for unknown
extensions (e.g. on older kernels before this extension was introduced).

Treat 0 as unsupported as well so the default 40-bit size is returned in
this case.

BUG=b:215174283
BUG=b:210727578
TEST=Boot crosvm on kevin (arm device with 4.4 host kernel)

Fixes: 891ea3e88a ("aarch64: limit high MMIO addresses to VM phys addr range")
Change-Id: I19a3ae00862882c030c1e776cb3ca10edeffd339
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3399344
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-01-18 21:30:32 +00:00
Alexandre Courbot
33e509a53b virtio: video: encoder: support GET_PARAMS_EXT as pending command
GET_PARAMS and GET_PARAMS_EXT's reply can be delayed if a session is
ongoing but no input buffer has been received yet. When this happens we
store the command into a set of pending commands, but when doing so we
only allowed for a reply to GET_PARAMS to be returned, which causes the
wrong reply to be sent if the guest used GET_PARAMS_EXT. Fix this by
storing whether the EXT variant has been used as a boolean in the
command and replying accordingly.

BUG=b:193202566
TEST=arc.VideoEncodeAccel.h264_192p_i420_vm passes without https://crrev.com/c/3349429
TEST=arc.VideoEncodeAccel.h264_192p_i420_vm passes with https://crrev.com/c/3349429

Change-Id: I6d135c611a32d0f107ac9f437b046f4309b54dba
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3382501
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-01-18 07:06:53 +00:00