Commit graph

10 commits

Author SHA1 Message Date
Daniel Verkamp
c3622e7f8d devices: virtio: make Queue own its Event
This cleans up the activate() signature and avoids the need to pass two
related (Queue, Event) variables everywhere a queue is needed.

No functional change intended.

BUG=None
TEST=tools/dev_container tools/presubmit

Change-Id: I9e5259428b39ad3a677fbb8a0bf574b3f15a7f35
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4738991
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-08-08 22:57:48 +00:00
Daniel Verkamp
b3c8e72a49 devices: virtio: pass GuestMemory to queue activate
Now that an active Queue is a separate type than the pre-activation
QueueConfig, we can ensure that a Queue has a valid reference to the
GuestMemory at creation time instead of passing it to every queue
operation.

No functional change, but simplifies Queue callers and prepares for
use of AtomicU* types in a later change.

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

Change-Id: I30266a5eadbd4f643da5595fbdd2c8f5df34bab3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4671481
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-08-01 21:45:08 +00:00
yuanyaogoog
9dda510bdf devices: Support packed virtqueue at run-time in block device
To support packed virtqueue in block device, add packed-queue runtime
flag to block device. If flag is set true, block deivice uses packed
virtqueue. If flag is not set or set to false, block device use split
virtqueue as default.

BUG=b:243621596
TEST=crosvm run —block ”…,packed-queue=true”

Change-Id: Iaca015392103858e06c9368553540ba937ec3b3d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4648470
Reviewed-by: Takaya Saeki <takayas@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Yuan Yao <yuanyaogoog@chromium.org>
2023-07-25 06:12:22 +00:00
Frederick Mayle
e678ede359 Reland "virtio: pass explicit queue indices on device activation"
This reverts commit 0efcbc5a46.

Reason for revert: Adjusted virtio-balloon code to match linux and qemu behavior instead of the virtio spec

Original change's description:
> Revert "virtio: pass explicit queue indices on device activation"
>
> This reverts commit 6199bb371a.
>
> Reason for revert: it broke virtio-balloon on ChromeOS
>
> Original change's description:
> > virtio: pass explicit queue indices on device activation
> >
> > In some cases, I changed the code to actually use the explicit indices
> > defined by the virito spec. In other cases, I was lazy and used
> > `pop_first` to emulate the old behavior.
> >
> > Change-Id: I9f1e4b6681e84b54ddca19e4d41c6508404fce4b
> > Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4697479
> > Reviewed-by: Noah Gold <nkgold@google.com>
> > Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> > Commit-Queue: Frederick Mayle <fmayle@google.com>
>
> Change-Id: I13ac499308f29d8a6a226e98d0eb4748b8e60944
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4705624
> Commit-Queue: Frederick Mayle <fmayle@google.com>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>

Test: use kernel with CONFIG_VIRTIO_BALLOON=y and boot crosvm with --balloon-page-reporting
Change-Id: I59691b1a9c60a44708a0e6c5c05e77e122675934
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4706390
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
2023-07-20 23:06:27 +00:00
Keiichi Watanabe
0efcbc5a46 Revert "virtio: pass explicit queue indices on device activation"
This reverts commit 6199bb371a.

Reason for revert: it broke virtio-balloon on ChromeOS

Original change's description:
> virtio: pass explicit queue indices on device activation
>
> In some cases, I changed the code to actually use the explicit indices
> defined by the virito spec. In other cases, I was lazy and used
> `pop_first` to emulate the old behavior.
>
> Change-Id: I9f1e4b6681e84b54ddca19e4d41c6508404fce4b
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4697479
> Reviewed-by: Noah Gold <nkgold@google.com>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Commit-Queue: Frederick Mayle <fmayle@google.com>

Change-Id: I13ac499308f29d8a6a226e98d0eb4748b8e60944
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4705624
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-07-20 17:49:54 +00:00
Frederick Mayle
6199bb371a virtio: pass explicit queue indices on device activation
In some cases, I changed the code to actually use the explicit indices
defined by the virito spec. In other cases, I was lazy and used
`pop_first` to emulate the old behavior.

Change-Id: I9f1e4b6681e84b54ddca19e4d41c6508404fce4b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4697479
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
2023-07-19 21:31:56 +00:00
Daniel Verkamp
0c29eac704 devices: virtio: factor Queue into QueueConfig+Queue
This change creates a new type (QueueConfig) that represents a queue
configuration before it has been activated. The QueueConfig::activate
function serves the same purpose as the previous Queue::activate, but
now it also returns the Queue type, which now always represents an
actively running queue.

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

Change-Id: I502ac6b29bf9f0cfc33ef15f6fb7fe482214eafd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4111872
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Yuan Yao <yuanyaogoog@chromium.org>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
2023-07-12 20:21:02 +00:00
yuanyaogoog
72e6f31102 devices: Change virtqueue to use enum interface
Previously, devices used the split virtqueue implemented in
/src/virtio/queue.rs by default. In order to support packed virtqueue in
the future, we implemented the enum type for virtqueue to abstract over
different virtqueue types. We migrated existing split virtqueue to a new
mod in /src/virtio/queue/ directory.

To support different types of virtqueue for each device, we enhanced
virtio_device trait by defining queue_type method to decide which
virtqueue type the device should use. We also modified base_feature function to accept queue type as a parameter.

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

Change-Id: If6cb3e3dd93a7ee3621e54a95742f6f9a524c79b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4648252
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Yuan Yao <yuanyaogoog@chromium.org>
2023-07-06 03:08:52 +00:00
Daniel Verkamp
5da3111c57 fuzz: improve virtqueue fuzzer coverage
Exercise more of the virtqueue descriptor chain API by consuming the
reader and writer. This also makes the fuzzer match the real-world usage
of the DescriptorChain APIs.

BUG=None
TEST=cargo +nightly fuzz run virtqueue_fuzzer

Change-Id: Ic56362cda87dd482a7c8fa6b3dd89cebfee8bc30
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4553720
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-05-23 00:24:32 +00:00
Dennis Kempin
981f304f84 fuzz: Move fuzzers to standard cargo fuzz location
This simplifies `cargo fuzz` usage. Fuzzers can be built with
`cargo fuzz build` without any other arguments.

BUG=b:279217867
TEST=`cargo fuzz build`

Change-Id: I11b8a8ba4c2b3e2d1a42973699e4d9c3920635b6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4540001
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-05-16 20:43:37 +00:00