Commit graph

2984 commits

Author SHA1 Message Date
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
Alexandre Courbot
cfe5ab52ea mdbook: add instructions for network device setup
BUG=none
TEST=mdbook serve

Change-Id: Id72c44201b248e20761ec38e2c892f5c4993ef46
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3237468
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-01-18 05:13:48 +00:00
Woody Chow
f364d020f3 devices: Add vhost-user snd device with CRAS backend
To launch,
crosvm device cras-snd --config $CONFIG --socket $SOCKET

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

Change-Id: I636f01167e4a6326c25bccb4084425e842f95ea2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3167247
Reviewed-by: Chirantan Ekbote
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Woody Chow <woodychow@google.com>
2022-01-17 01:40:09 +00:00
Alexandre Courbot
2354f6e211 virtio: video: expose backend name to guest
Knowing the decoding method used on the host can be useful to the guest,
e.g. in order to decide which format to use for buffers or to choose
between several acceleration options if more than one decoder or encoder
device exists.

Since this change only adds additional data to the device configuration
space, it does not introduce any incompatibility with existing guests.

BUG=b:161774071
BUG=b:169295147
TEST=Android Youtube plays properly on Hatch.

Change-Id: I2ba47504c17cefbceef16ccacc211856ef9fa30e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3026356
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-01-14 05:10:32 +00:00
Alexandre Courbot
1667d99e64 virtio: video: let virtio features be specified per-backend
The features supported by a video device will depend on the backend in
use. For instance, the libvda backend only supports virtio objects for
memory buffers, whereas the ffmpeg backend will support both virtio
objects and guest pages.

BUG=b:209523781
TEST=Android Youtube can play videos on Hatch.

Change-Id: Ib55d959ae6a6d446d8ce0b75b411e50bc40204f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3143584
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-01-14 05:10:31 +00:00
Abhishek Bhardwaj
103c1b75b9 crosvm: vvu: proxy: Implement instantiating a VVU proxy device
This change adds a command line parameter for instantiating a VVU proxy
device.

BUG=b:194136484
TEST=Test with sibling VM with Vhost master connecting to a device VM.

Change-Id: I5ff56e6f1ebca5a7078eca3d951ddbfd411d14fc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3290381
Reviewed-by: Chirantan Ekbote
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Abhishek Bhardwaj <abhishekbh@chromium.org>
2022-01-14 04:21:21 +00:00
Maciek Swiech
d98f01af14 x display: ST event emulation for MT events
Mirroring Linux kernel behavior, we would like to have devices emit
MT (multitouch) events, and have these generate simlated ST events.

BUG=b:201796434
TEST=recreated kernel,virgl etc configuration from @ryanneph to confirm

Change-Id: Iaac625358bddefb7dfe0037c91ababdc30185cdd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3330723
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Maciek Swiech <drmasquatch@google.com>
2022-01-13 18:36:41 +00:00
Alexandre Courbot
580231bda0 Cargo: stop enabling the libvda feature by default
Libvda can only be successfully used and linked against on Chrome OS.
Making the video decoder and encoder depend on it makes it impossible to
use these features on non-Chrome OS platforms. Remove the libvda feature
by default since the Chrome OS builders have been updated to enable it
explicitly.

BUG=b:161774071
TEST="cargo build --feature "video-decoder,video-encoder" fails.
TEST="cargo build --feature "video-decoder,video-encoder,libvda"
     succeeds and embeds the libvda backend.

Cq-Depend: chromium:3023696
Change-Id: I54d31312e87e5d9a8e5c1a39955416bf892270d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3026352
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-01-13 11:50:14 +00:00
Alexandre Courbot
11da15b688 virtio: video: error: add backend failure creation method
Having to create a Box for each backend failure is cumbersome. Add a
backend failure creation method that takes care of this for us.

BUG=b:161774071
TEST=Android Youtube can play videos on Hatch.

Change-Id: I3f290504820f855c30b17364c3cbc9997ad74b36
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3308317
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-01-13 09:42:36 +00:00
Alexandre Courbot
99e6af58df virtio: video: resource: add CPU mapping method
Add a method that allows to conveniently map resources into a linear
buffer, even if the resources are initially sparse (as is often the case
with user memory).

BUG=b:209523781
BUG=b:169295147
TEST=Android Youtube can play videos on Hatch.

Change-Id: If9a9b7764e6522da20d85e2ebca59a77b58573ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3308315
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-01-13 08:11:25 +00:00
Alexandre Courbot
1a3c424752 virtio: video: add support for guest memory
Supporting guest memory is necessary for many guests that expect to
render into guest-allocated memory (as opposed to the virtio-object
method that is for now rather specific to Chrome OS). Add support for
this kind of memory in the form of SG lists.

BUG=b:209523781
TEST=Android Youtube plays properly on Hatch.
TEST=v4l2r's test decoder can allocate MMAP buffers.

Change-Id: I9864113ca2b88a23db8204ee7dd8d38801857c25
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2982247
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-01-13 07:47:56 +00:00
Alexandre Courbot
40ab5caf1d virtio: video: support multiple entries per resource
The current code assumes that we will only ever have one entry per
memory resource, which is accurate for now, but doesn't allow us to
support memory pages resources (which can have several entries) or
multi-planar formats.

Fix this by reading the actually expected number of resources and
passing them to the device in a double-vector containing one set of
entries per memory plane.

BUG=b:209523781
TEST=arc.VideoDecodeAccelPerf.h264_1080p_30fps_vm passes on zork-arc-r with crrev.com/c/3358090 applied to the guest.
TEST=arc.VideoEncodeAccel.h264_192p_i420_vm passes on zork-arc-r with crrev.com/c/3358090 applied to the guest.

Change-Id: I984ee49c588c3a188e72bc04bc7f568f582523f5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3379629
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-01-13 06:35:11 +00:00
Dennis Kempin
fe0d2a633a merge-into-chromeos: Automatically set CQ+1
Since we have a chain of commits, we need to set all of
them to CQ+1 for the dry run to happen.
Unfortunately, the CQ will only ever run a single build
for a chain of commits. So the dry run will only happen
when all builds have finished.

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

Change-Id: I1883b22ab97da604a4188528ccfb3231a23cb7f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3384220
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-01-12 20:26:36 +00:00
Jason Macnak
9b812ce96f rutabaga_gfx: gfxstream: Update gfxstream_backend_init()
... to add the `gfxstream_callbacks` param which was added in
aosp/1927497. This param is only used in specific forks of Crosvm
but is present in the common Gfxstream project.

BUG=b:214097104
TEST=launch_cvd --gpu_mode=gfxstream

Change-Id: I3870692dd7ea55653c9761e787ff747d20df44d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3381902
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alistair Delva <adelva@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Andrew Walbran <qwandor@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
2022-01-12 18:27:22 +00:00
Alexandre Courbot
339b7b6801 virtio: video: rename UnresolvedGuestResource to UnresolvedResourceEntry
The current naming is a bit confusing: a resource is one or several
buffers that are each made of one or several entries. The elements that
we return to the device are thus resource entries (that need to be
resolved into a single resource) and not the whole resources themselves.

BUG=b:209523781
TEST=cargo build --features "video-decoder,video-encoder"

Change-Id: Ie3d89c48f9b3e7758b455ea1b2d4954daf248d0c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3379628
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-01-12 07:58:53 +00:00
Dennis Kempin
5a250fcb26 merge-into-chromeos: Create chain of merge commits
We can use the gerrit api to detect previous merge commits
the bot has made, then use those as the base for the next merge.

This will create smaller merges and is easier to manage as we do not
have to abandon so many changes.

One complication is detecting possible cherry picks the oncall may
have added to the previous merge commit.

Only open merge commits are taken into account.

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

Change-Id: I795109be4c45bec49068c3e292a3947505755442
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3381832
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-01-11 23:35:39 +00:00
Daniel Verkamp
a06f22f2ac aarch64: actually load kernel at 8MB
The comment above indicates that it was intended to be loaded at an
offset of 8 megabytes, but it was missing a zero, so it was being loaded
at an offset of 512 kilobytes instead. Fix the constant to match the
comment.

Fixes a warning from newer kernels:

  Kernel image misaligned at boot, please fix your bootloader!

BUG=None
TEST=Boot Linux 5.10 on trogdor64, verify no error in dmesg

Change-Id: I2650d23458a13adff89a7f214734866c47d6f7cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3364972
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Andrew Walbran <qwandor@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-01-11 22:41:43 +00:00
Daniel Verkamp
891ea3e88a aarch64: limit high MMIO addresses to VM phys addr range
The high MMIO region of the system allocator was previously set up with
the upper limit of 2**64 - 1, but physical addresses on actual systems
are not that large. Now that pmem allocates from the upper end of the
high MMIO region, the size of the allocator actually matters.

Limit the aarch64 high MMIO allocator to the VM's physical address size
so that addresses at the end of the allocation range are usable and pmem
devices can be created on aarch64.

BUG=b:210727578
TEST=Boot with pmem device on aarch64

Change-Id: I67962c2b03f0f265349ae889c988eb69ef526f4a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3366858
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Andrew Walbran <qwandor@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-01-11 22:41:42 +00:00
Daniel Verkamp
3c2abaf838 aarch64: deduplicate MMIO region calculations
The get_high_mmio_base_size() function duplicates and hard-codes the
math from get_platform_mmio_base_size(). Since these are both only
called in one location now, pull them into get_resource_allocator() so
the plat_mmio variables can be used instead of duplicating the math.

Also reorder the SystemAllocator::builder() calls so that they are in
the same order as the layout of the regions in memory; this makes no
functional difference, but it is less confusing to read.

BUG=b:210727578
TEST=Boot crosvm on trogdor64

Change-Id: I1238e5b1d412e41d0b4b9be5b93b59fec6598734
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3373451
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-01-11 22:41:41 +00:00
Daniel Verkamp
a475cd4754 aarch64: avoid recalculating MMIO regions
Rather than calling get_high_mmio_base_size() twice, once in the Arch
create_system_allocator() callback and once in build_vm(), it would be
cleaner to retrieve the MMIO regions from the existing system allocator.
Add a couple of helper functions to AddressAllocator so we can get the
original region back.

This also helps in the next patch, which will pass additional
information to get_high_mmio_base_size() that is messy to calculate
twice.

BUG=b:210727578
TEST=Boot crosvm on trogdor64

Change-Id: Ia5c7d7c7ff7edb406a9b4af482b277204f865474
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3373450
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-01-11 22:41:40 +00:00
Daniel Verkamp
6f4f8223b8 hypervisor: add API to query VM physaddr size
Add a function that returns the size of guest physical addresses. This
wraps KVM_CAP_ARM_VM_IPA_SIZE on aarch64 and CPUID to query host
physical address size on x86_64. This replaces the phy_max_address_bits
function from x86_64, and all callers are migrated to use the new Vm
function instead.

BUG=b:210727578
TEST=check on trogdor64 with debug prints

Change-Id: I3107fe6357fcf166b7ad0e2a7c55919705da3b0c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3364971
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Andrew Walbran <qwandor@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-01-11 22:41:38 +00:00
Bartłomiej Grzesik
f64db6a932 virtio: video: decoder: pass frame formats to input formats
On the guest side application using V4L2 frontend can query frame
sizes using VIDIOC_ENUM_FRAMESIZES ioctl. This ioctl accepts pixel
format as an argument. It is correct to query frame sizes for input
format. In this scenario virtio-video would always return 0x0
resolution provided by crosvm, which is incorrect.

This patch fixes this issue by suppling correct frame sizes into
returned input formats.

BUG=b:160440787
TEST=tast run eve arc.Video*

Change-Id: Ib12b19ca515056aa8fa9470ece34309db2475817
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3377642
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Marcin Wojtas <mwojtas@google.com>
2022-01-11 10:33:50 +00:00
Dmitry Torokhov
dd8a12c715 Stop defaulting to reporting extended status when in direct mode
Now that users of crosvm-direct have been adjusted to request extended
status from crosvm we no longer need to have this default.

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

Change-Id: I15d9690979d77902329872ef9644a3279d653415
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3373480
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-01-10 21:01:01 +00:00
Daniel Verkamp
24fcef386a p9: re-add OWNERS file for fuzzer ownership
The dev-rust/p9 ebuild passes the OWNERS file to fuzzer_install, so we
can't remove it entirely.

BUG=None
TEST=USE='asan fuzzer' emerge-amd64-generic dev-rust/p9

Change-Id: I34c4cdf505a64a73dc7d213dce0eb58de208cc1e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3373452
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-01-10 20:43:27 +00:00
Grzegorz Jaszczyk
2c0459db66 sys_util: netlink: fix wrong setting of the netlink msg data end boundary
The netlink data end boundary should be actually set by msg_len. The
previous calculation of data_end and its usage was probably confused with
data size.

This bug prevented access to the entire netlink's message data.

BUG=b:197247746
TEST=Build and print the `data` when netlink message arrives.

Change-Id: I601bcfee9132649f48f774e23426281ba1e88fde
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3375544
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-01-10 20:42:35 +00:00
Grzegorz Jaszczyk
477459aea6 sys_util: netlink: use better naming for netlink message length
The hdr_len was actually keeping length of the netlink message including
header (nlmsg) which was misleading. Rename it to msg_len which is more
accurate.

BUG=b:197247746
TEST=Build with 'USE=crosvm-direct emerge-${BOARD} crosvm'

Change-Id: Id4adcd038d41960eeeb8bda3623c8b3b129ef9df
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3375543
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-01-10 20:42:34 +00:00
Daniel Verkamp
98813a4f0b Revert "Remove empty OWNERS files"
This reverts commit 34df9a13cb.

Reason for revert: dev-rust/p9 ebuild depends on common/p9/OWNERS

Original change's description:
> Remove empty OWNERS files
>
> These directories can just inherit the top-level crosvm OWNERS now.
>
> BUG=None
> TEST=None
>
> Change-Id: Iea439e92aac4a03fcf821e4ce715266161209809
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3370743
> Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>

Bug: None
Change-Id: I1043a89e17588cd727614dfc39d69bcf06d82221
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3373453
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
2022-01-07 23:35:49 +00:00
Andrew Walbran
b87d17f769 Update value of KVM_VM_TYPE_ARM_PROTECTED to match temporary pKVM ABI.
android13-5.10 will use this value to avoid conflicts with any other
flags introduced in upstream Linux before the pKVM ABI is upstreamed.

BUG=b:209794844
TEST=tools/dev_container tools/run_tests

Change-Id: Idee7c095ea5350baf2c38ab9190d4cdb46efbf25
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3372683
Auto-Submit: Andrew Walbran <qwandor@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-01-07 17:18:21 +00:00
Daniel Verkamp
34df9a13cb Remove empty OWNERS files
These directories can just inherit the top-level crosvm OWNERS now.

BUG=None
TEST=None

Change-Id: Iea439e92aac4a03fcf821e4ce715266161209809
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3370743
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-01-07 15:52:04 +00:00
Xiong Zhang
e2ff2c41a0 linux: Disable sandbox for hotplug device
When sandbox is enabled, forking a process for hotplug device
is failure, the error message is:
Failed to fork jail process: Attempt to call fork() while
multithreaded.

This means minijail couldn't fork a new process for added device
when vm has started, so disable sandbox for hotplug device.

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

Change-Id: I2983399f41a44984a113c9846aff93fd978a02b5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2955581
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-01-06 23:32:55 +00:00
Xiong Zhang
4fbc554e60 Vfio-pci: Release irq_num at pci device remove
Device gets irq_num from system_allocator when device is added, this
irq_num should return to system_allocator when device is hotplug removed.

this commit adds a ReleseOneIrq interface into VmIrqRequest, it release
one gsi into system_allocator. So vfio-pci device could call it at device
close function.

For msi and msix interrupt vectors, they have irq tube already and could
call ReleaseOneIrq easily.
For legacy INTx, the gsi for vfio-pci's INTx is gotten from host, and this
gsi maybe share with other device, so the commit doesn't release this gsi
at vfio-pci device's remove, otherwise the gsi shared device will be broken.

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

Change-Id: Ibcca226b4b5b2092b5bc94bef8219eea82979086
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2955580
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-01-06 23:32:54 +00:00
Xiong Zhang
cf6c67a422 Vfio-pci: Don't allocate mmio for hotplug device
When a hotplug vfio-pci device is attached to a bridge parent, kernel will allocate
mmio from its parent's bridge window, so crosvm doesn't need to allocate it.

But previously mmio_regions is used to track existing bar's address and size, but this
commit doesn't allocate mmio, so the initial bar address in mmio_regions is zero,
so this exception should be handled in bar's reallocation code that address 0 isn't
a valid bar address.

BUG=b:185084350
TEST=Hotplug in and out vfio-pci device in a vm repeatedly

Change-Id: I1a082b02065d42eccf46e24941727edf7b6355a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3319707
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-01-06 23:32:53 +00:00
Xiong Zhang
ed1572d78c Pcie: Reserve bridge window and prefetch window for pcie rp
For bridge's memroy and prefetch memory window, current the limit is
smaller than the base, this means pcie rp doesn't support this window,
but OS still allocates 2M memroy window and 2M prefetch memory window
for it, this has two problems:
a. kernel allocates mmio, but crosvm's system allocator doesn't capture
this allocation and crosvm still use system allocator to allocate mmio
for hotplug in device, so it may have conflict between kernel and crosvm.
b. the 2MB window is too small, as the added device behind this bridge
is allocated mmio from this window by kernel, if device required mmio
is large than 2MB, the device couldn't work.

This commit preallocates 8MB memory window and 64MB prefetch memory window
for one pcie rp, and let kernel allocate mmio for its children devices
from this window, kernel also maintains the allocation and free of this
window, crosvm system allocator doesn't care about which device own the
segment of this window.

BUG=b:185084350
TEST=Boot a guest and check pcie rp bridge window's base, limit and size

Change-Id: I566a2d81b458da1d2d5f07b689fa898453586adc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3319706
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-01-06 23:32:52 +00:00
Junichi Uekawa
5e91be7064 crosvm: Commit Cargo.toml with a useful description.
This is what I do all the time manually, maybe this can be automated.

BUG=None
TEST=run it and observe.

Change-Id: Ia32790ca7dd0b8313ce05dcff28509b8a21d4f76
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3336823
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-01-06 22:59:57 +00:00