Commit graph

18 commits

Author SHA1 Message Date
David Stevens
9442ff41e1 devices: virtio: Support virtio suspend
Add support for virtio suspend feature, which is currently under
discussion upstream. This change implements a basic version of the
feature that simply defers interrupts while a device is suspended.
Device implementations can be quiesced to reduce their resource
consumption in later changes if necessary.

BUG=b:301862490
TEST=Manual test with ArcS2Idle feature flag

Change-Id: Id8f656e66577bb65b961523b97e42da4f248e613
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5491343
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2024-05-02 01:20:09 +00:00
Joe Hattori
d3dff927db devices: virtio: scsi: Implement controlq
Currently crosvm's virtio-scsi implementation only handles requests from
the request queues. This commit handles requests in the controlq and
also implements a sub-action of MAINTENANCE IN command.

The control requests contain operations such as async task cancellation,
LUN reset, asynchronous notifications. The sub-action REPORT SUPPORTED
TASK MANAGEMENT FUNCTIONS reports the supported actions, and we
currently implement LOGICAL UNIT RESET and TARGET RESET.

BUG=b:300042376
TEST=sg_opcodes --tmf /dev/sda
TEST=sg_reset -d /dev/sda
TEST=cargo t -p devices
TEST=./tools/run_tests2 --dut=vm -E 'test(test_scsi)'

Change-Id: Ie1015d7e78c02cb46e5f20ac724838fc91dff4fe
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4958314
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
2023-11-01 01:29:48 +00:00
Zihan Chen
cbba480ebe crosvm: Uprev zerocopy to 0.7.x
zerocopy 0.7.x has finally released as a stable version, uprev it
to allow some remaining structs to be derivable.

TEST=CQ

BUG=b:300969352
FIXED=b:300969352

Change-Id: I90f0dfb09494f875fef1cd11bfcbd48030846092
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4878761
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2023-10-10 17:34:32 +00:00
Noah Gold
f9a2dc5563 virtio_sys: fix ID for pvclock.
The ID used here was not the one in the kernel driver. Historically
61 was the ID for virtio-vhost-user, but that device no longer exists
and was only present in some ChromeOS kernels.

BUG=none
TEST=presubmit & tested downstream.

Change-Id: Ie1cdbe0d564e9c60084ca3a8bb11e7b973468c3d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4885410
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Noah Gold <nkgold@google.com>
2023-09-22 19:06:16 +00:00
Joe Hattori
172dceda0d devices: virtio: scsi: Receive commands from virtqueue
This commit enables popping requests from virtqueue and processing them.
As for this commit, we pretend we do not have any SCSI device, therefore
we return status 3 (= VIRTIO_SCSI_S_BAD_TARGET) on every INQUIRY
request, which is the very first SCSI command from the guest driver.
This strategy makes the guest kernel boot successful but the scsi
device is not visible from the guest.

BUG=b:300042376
TEST=tools/presubmit
TEST=guest kernel boots with the --scsi-block option.
e.g.) ./crosvm run -b /path/to/root-image --scsi-block
"/path/to/another-image,ro" /path/to/kernel

Change-Id: I714d2bf908e6e210569c75e670baa52ec6e89703
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4845154
Reviewed-by: Takaya Saeki <takayas@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-09-21 08:15:20 +00:00
Daniel Verkamp
94b400d586 virtio_sys: remove VVU device ID
Unused since VVU is now removed.

BUG=b:276993009
TEST=virtio_sys/bindgen.sh

Change-Id: Id219193e5665505e22a8d2ea8e46b607d2456b1a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4875217
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2023-09-21 05:27:20 +00:00
Frederick Mayle
4b8e8f3b43 virtio: vsock: send TRANSPORT_RESET event on restore
BUG=b:290833798

Change-Id: Ib2e20b5aade6c27aea1fd079883940f30439c4f9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4684832
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Elie Kheirallah <khei@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
2023-07-14 21:27:23 +00:00
Zihan Chen
7cfc97d736 virtio_sys: Update bindgen to derive zerocopy
With uprev-ed bindgen, we can now customize derive directly.

TEST=CQ

BUG=b:204409584

Change-Id: Iba96cdb8329e9254249b247af55e11974620087c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4234067
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2023-02-09 22:59:10 +00:00
Richard
52c8cee36a devices: virtio: add pvclock device
Currently only used on windows, but should be able to work on other
platforms.

TEST=CQ
BUG=b:213149162

Change-Id: Ie2f518b0a5dc7f1b5650b15c76c0fbcfd5eadea6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4018114
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Colin Downs-Razouk <colindr@google.com>
2023-01-11 17:49:10 +00:00
Daniel Verkamp
bb54c5e169 virtio_sys: add virtio_fs bindings
Replace the hand-written bindings in the virtio-fs device with
automatically generated bindings from bindgen.

BUG=None
TEST=./virtio_sys/bindgen.sh

Change-Id: Ia11a2d97f3546515196a41764107e7aaece8ad82
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4103907
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-12-14 18:07:51 +00:00
Daniel Verkamp
74f1ca4e78 bindgen: update bindings to Linux 5.15
This requires a few tweaks to non-generated code:
- VIRTIO_ID_VIDEO_ENC/DEC -> ENCODER/DECODER
- io_uring unnamed union layout change

Change-Id: I58e118efa5c6bf28ff56d211fec5603651cb60bc
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3893753
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-09-14 22:09:30 +00:00
Daniel Verkamp
7c6d8bec3f health-check: enforce blank line after copyright
While we are tweaking all of the copyright headers, let's take the
opportunity to ensure there is always a blank line after the copyright
header for consistency. (Almost all files already follow this style.)

This includes a slightly ugly regex to allow the end of a C-style
comment block after the end of the copyright:

/*
 * Example comment block
 */   <-- this line

Change-Id: Idfd0855861e5ecb3d33afae942fdba908af0dcff
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3892521
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-09-13 22:24:35 +00:00
Dennis Kempin
1dab58a2cf Update all copyright headers to match new style
This search/replace updates all copyright notices to drop the
"All rights reserved", Use "ChromiumOS" instead of "Chromium OS"
and drops the trailing dots.

This fulfills the request from legal and unifies our notices.

./tools/health-check has been updated to only accept this style.

BUG=b:246579983
TEST=./tools/health-check

Change-Id: I87a80701dc651f1baf4820e5cc42469d7c5f5bf7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3894243
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-09-13 18:41:29 +00:00
Tomasz Nowicki
8189007f76 devices: virtio: Virtio over MMIO support
Virtual environments without PCI support (a common situation in embedded
devices models) might use simple memory mapped device instead of the PCI
device. The memory mapped Virtio device behavior is based on the PCI
device specification. Therefore most operations including device
initialization, queues configuration and buffer transfers are nearly
identical. For more details and existing differences please see:
http://docs.oasis-open.org/virtio/virtio/v1.0/cs04/virtio-v1.0-cs04.html#x1-1090002

BUG=b:189182339
TEST=boot manatee and verify that Virtio PCI devices work properly

Change-Id: If7aeb03b96137a672438f85ba2b86296deeef9ca
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3855006
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Tomasz Nowicki <tnowicki@google.com>
Commit-Queue: Tomasz Nowicki <tnowicki@google.com>
2022-08-26 12:22:31 +00:00
Daniel Verkamp
78c474d423 virtio: create a DeviceType wrapper enum
This makes the VirtioDevice::device_type() function return type more
descriptive, and it lets us implement fmt::Display for the type instead
of a custom type_to_str() function.

BUG=None
TEST=tools/presubmit --all

Change-Id: Icfc2be37cf31ecab5e73f4b29c2eaaaa417317ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3582523
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Abhishek Bhardwaj <abhishekbh@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-10 21:00:07 +00:00
Daniel Verkamp
3fab3baecc virtio-sys: add virtio_config and clean up imports
Restrict the bindgen patterns so that only the declarations from the
appropriate header are included in each binding, and add the
virtio_config binding to get the source of the VIRTIO_F_ and
VIRTIO_CONFIG_ #defines.

BUG=None
TEST=tools/presubmit --all

Change-Id: I216bd8d3540d918ad9bba162db0ae86b76d73f31
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3582522
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-09 21:20:27 +00:00
Noah Gold
3a3d73b3cb virtio_sys: add DataInit for net struct.
On Windows, we have to generate virtio_net_hdr_mrg_rxbuf ourselves since
there is no actual TAP device. Since we have to serialize it onto a
binary pipe, we need to get it as a binary slice, so here we implement
DataInit on that struct.

BUG=b:213151463
TEST=builds

Change-Id: I25a3333c20a87d6bf576f0225aac3e1c816a46ba
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3609237
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-05-02 21:00:19 +00:00
Daniel Verkamp
f620437e8b virtio_sys: regenerate bindings
BUG=b:218388029
TEST=tools/presubmit --quick

Change-Id: I381dbc4d97e3a0a99dedd4416a347388daf4ccf8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3339853
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-04-11 21:14:01 +00:00