Introduce `State` enum to handle vvu-proxy's lifecycle.
This state will be used to support recovery from sibling disconnection in the follow-up CL.
BUG=b:216407443
TEST=run VVU
Change-Id: I47f9c69abb9d08520ec90a4a9a87fc4d230c96a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3591105
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Abhishek Bhardwaj <abhishekbh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
vhost-user implementations of the net device can currently not
specify a MAC for the guest, even though they would support this.
This adds the corresponding feature to the allowlist and increases
the queue size to 1k to avoid situations where the device runs out
of available descriptors.
BUG=None
TEST=./tools/run_tests
Change-Id: Iefe8ce21215b36c65ee2516428249c41bf13f285
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3683380
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Kevin Hamacher <hamacher@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Pull the declaration of the `EventToken` enum up to the top level of the
base crate, replacing the identical implementations inside sys/windows
and sys/unix.
Use the `EventToken` name consistently throughout the tree to remove the
unix-flavored "poll" nomenclature.
BUG=b:213153157
TEST=tools/dev_container tools/presubmit --all
Change-Id: I0ba42037b533b796797a7a3f6d8d7e71a5592aba
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3642673
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
The main distinction between PollContext and EpollContext was that the
latter was safe to use from multiple threads. This was not true of the
more widely-used PollContext for two reasons:
1. The `events` array was stored inside the `PollContext` structure,
whereas `EpollContext` required the caller to pass their own storage
for events.
2. `PollContext` had a hangup detection feature used to debug busy
looping cases that result from a failure to remove hungup file
descriptors from the context.
Point 1 is resolved by returning a `SmallVec` of events that avoids
allocation for the normal case (and in fact it should avoid allocation
in all cases on Linux, where the maximum number of events returned from
a single `epoll_wait()` call is limited to the same size as the
preallocated `SmallVec`). This simplifies the API and also means that
there is no need for per-context storage.
Point 2 can't easily be resolved, since it would require the `wait` call
to mutate shared state (this could be done by adding a mutex around the
shared data, but that seems like too much overhead for the value of the
feature). Instead, this patch just removes the hangup detection code.
BUG=b:213153157
TEST=tools/dev_container tools/presubmit --all
Change-Id: Ia48c46de96976da27cb5387e3e5e8fcf92d0e85b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3633111
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Example help output (note that in main crosvm device help is broken)
```
Usage: crosvm device <command> [<args>]
Devices
Options:
--help display usage information
Commands:
block Block device
net Net device
console Console device
fs FS Device
gpu GPU device
vsock Vsock device
wl Wayland device
```
crosvm device wl help:
```
Usage: crosvm device wl --socket <PATH> --vm-socket <PATH> [--wayland-sock <PATH[,name=NAME]...>] [--resource-bridge <PATH>]
Wayland device
Options:
--socket path to bind a listening vhost-user socket
--vm-socket path to a socket for wayland-specific messages
--wayland-sock path to one or more Wayland sockets. The unnamed socket is
used for displaying virtual screens while the named ones are
used for IPC
--resource-bridge path to the GPU resource bridge
--help display usage information
```
Change-Id: Ie976b5545644c10b24cb3cdfcb17b213641064f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3668920
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Anton Romanov <romanton@google.com>
This reverts commit e84d9c1d7c.
Reason for revert: vfio-pci fails on ManaTEE with an out-of-range BAR index (8), so further investigation is required
Original change's description:
> devices: pci: PciBarIndex API cleanup
>
> Everything that takes a PCI BAR index should use the appropriate
> PciBarIndex type rather than u8 (or usize) for better type safety and
> descriptiveness.
>
> BUG=b:232838930
> TEST=tools/presubmit
>
> Change-Id: I0a918a6da6327c963fb297ba765563774a7e5e49
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3664282
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
> Reviewed-by: Anton Romanov <romanton@google.com>
Bug: b:232838930
Change-Id: Id5d19e779289e47045af67fa51c301ba2b79ee7d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3687516
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Once we have opened /dev/vfio/vfio we can leverage new_from_container().
BUG=None
TEST=cargo build
Change-Id: Ib309ab708cf561ec5dde8a606164a7df9a1bc4aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3675886
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
This reverts commit 56c0d02760.
Reason for revert: Break ARCVM after suspend/resume
BUG=b:234067421
TEST=Checked that ARCVM kept working after suspend/resume
Original change's description:
> crosvm: remove balloon stats request timeout
>
> It was done to avoid deadlock when stats are requested before guest is
> up. Implement a stub BalloonStats::NotReady replier until host is up so
> that timeout is no longer necessary.
>
> BUG=b:232289535
> TEST=few tast crostini/arc tests
>
> Change-Id: I6731b4ee9eaecdd65aebdd3f530f0932b0660c85
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3652887
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Anton Romanov <romanton@google.com>
> Auto-Submit: Anton Romanov <romanton@google.com>
Bug: b:232289535
Change-Id: Iffafaef1e1136ebc050d69d001d384eedd0a2319
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3686789
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Hikaru Nishida <hikalium@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Hikaru Nishida <hikalium@chromium.org>
Move this function to a place closer from its call site - this will make
the following CL less cluttered.
BUG=None
TEST=cargo build
Change-Id: I2837af9bb1f721967d7b7676140a8bd11973a34b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600171
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Use the newly introduced async queue structs to manage the vhost-user
console device queues. This allows the device to restart its queues
after they are stopped or reset. The previous implementation was losing
the input and output streams as the queue was stopped.
BUG=b:228385297
BUG=b:228912920
TEST=vhost-user console device is working (with input) on Linux.
Change-Id: Ie968af7cfa77734c86c088da3a52f4d6937c3d0d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600170
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Add a structure that facilitates managing the state and resources of a
queue running on an async executor. This is to be first used by the
console device, but the goal is also to extend these helpers and use
them on as many devices as possible.
BUG=b:228385297
BUG=b:228912920
TEST=cargo build
Change-Id: I72a3df7d9bf900cff38b189380d3c8ec4f098a0b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600169
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
With this and some pending hacks, dEQP works inside sibling
guest with VVU.
Device can be started with "crosvm device gpu --vfio <PCI ID>"
BUG=b:213532598
TEST=manual - run dEQP from a sibling guest when using VVU.
Change-Id: I97fa0e44c36cd5be13b6d31592878bdc19e48aed
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3682201
Auto-Submit: Lepton Wu <lepton@chromium.org>
Commit-Queue: Lepton Wu <lepton@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
This has only a tiny change outside of unix-specific code so shouldn't
complicate windows upstreaming
Change-Id: Iae68e761d730ed7497b4586b9b9a948524224d8e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3671093
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Skip logging an error when the translate request tube closes. That
happens whenever the process on the other side of the tube closes, and
isn't an error in and of itself.
BUG=None
TEST=exit crosvm and observe no virtio-iommu error message
Change-Id: I5f0460182a96d00f8c348224c838554710fc5451
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3659815
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
Make sure the endpoint is removed from the endpoint and domain maps when
a vfio device is removed.
BUG=b:232161488
TEST=Boot a guest, hotplug in and out a vfio-pci device repeatedly
Change-Id: Ie9838b412cac22a9e14bb6e986be39303aeb01e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3676692
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Refactor shared state so that it can be shared between multiple async
callbacks. This moves all state from the Worker to a dedicated State
struct, which allows it to be passed via Rc<RefCell<>> to the various
async callbacks. The collection of endpoints can also be passed as part
of the shared state, rather than as its own dedicated argument.
There should be no behavioral changes in this CL.
BUG=b:232161488
TEST=Boot a guest, hotplug in and out a vfio-pci device repeatedly
Change-Id: I1e65ef3e4048bf0889fdee0f18fa5b58be264666
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3659554
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
Check that the same mapper isn't used for multiple domains. This ensures
that there won't be mapping collisions/leaks if the guest tries to use
the same mapper with multiple domains.
BUG=None
TEST=Boot ManaTEE with devices managed by viommu
Change-Id: I45889e6fe020c3a24b355fc05a8f74734bece78a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3641221
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
Remove incomplete support for detaching a virtio endpoint from domains
with multiple endpoints. We could technically handle this by checking
domain mappings when handling TranslateRequests, but there are no use
cases for this at the moment.
BUG=None
TEST=Boot ManaTEE with devices managed by viommu
Change-Id: I9d1cb86f246f7d8639058eaaf158f6538f1c1c57
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3676697
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>
Refactor create_vfio_device so that it returns the created viommu
related mapper, if any. This allows add_vfio_device to be written more
cleanly.
BUG=None
TEST=Boot ManaTEE with devices managed by viommu
Change-Id: Ieaa345ed5f9146fde8e305fc7bc37001ff708683
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3676698
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
For vfio devices which we expect to have granular, dynamic IOMMU
mappings (i.e. passthrough devices using viommu/coiommu), use the
ChromeOS specific VFIO_TYPE1v3_IOMMU if available, as it is optimized
for that use case.
BUG=b:217479627
TEST=boot ManaTEE, observe reduced hypervisor memory usage after IO
Change-Id: I7b3a04adb5049c165885917fa29cedf2ccdee1d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3675885
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
When creating shared memory, 'name' can have one of two meanings. It
could either be a debugging tag with no semantic meaning, or it could
uniquely identify a shared memory object within some namespace. Linux
memfd uses name in the first meaning, whereas Windows (and Linux shm)
uses it in the second meaning.
Currently, crosvm has no use cases for the named shared memory of the
second type, so it is not supported. Make it clear that the SharedMemory
APIs treats name as a debugging-only name. Remove the "anon" and "named"
constructors, since they had no semantic meaning. Also require a name
when constructing a SharedMemory, since there's no reason not to provide
one to make debugging easier.
The only semantic change is setting the name of GuestMemory's underlying
shmem to "crosvm_guest", which it was until recently. This fixes some
ManaTEE tests which use the name to determine CrOS guest memory usage.
BUG=None
TEST=compiles
Change-Id: I78d5046df04d6f19640abbbc67af6bd433a177b0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3676695
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Change the comparison from an `if let` into a regular `if ... ==` by
implementing `PartialEq` for the relevant types. This makes the lifetime
of the `wl_state.borrow_mut()` end before calling
`kick_evt.next_val().await()`.
Fixes a new clippy warning from Rust 1.61.0:
<https://rust-lang.github.io/rust-clippy/master/index.html#await_holding_refcell_ref>
BUG=None
TEST=tools/clippy # with Rust 1.61.0
Change-Id: I067c2ab532d753306cd5334df5bb4f2c7c2e6584
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3671130
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Anton Romanov <romanton@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
The Worker struct is storing a Descriptor obtained from a timer for the
sole purpose of adding it to a WaitContext when the worker thread starts
running. Instead of doing this, create the WaitContext and pass it as
part of the worker data, so all ioctls involving that descriptor are
performed directly on the timer, guaranteeing that the descriptor is
valid.
BUG=233968702
TEST=Linux VM starts and boots with `--split-irqchip` specified.
Change-Id: Ie5da1e9866742108f52c526100e936d292167ab7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3670105
Reviewed-by: Michael Hoyle <mikehoyle@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
WaitContext::build_with expects an array of &dyn AsRawDescriptor, which
the events we pass to it all implement. There is no need to use a
temporary Descriptor here.
BUG=233968702
TEST=cargo build
Change-Id: Ie39e1683ed13e474ef43bdad9375d60c6bf55f5a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3670104
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Michael Hoyle <mikehoyle@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
We can avoid temporarily storing the descriptor by passing a reference
to the providing device directly to EventLoop::add_event().
BUG=233968702
TEST=cargo build
Change-Id: I78ce17b8a2c7c8a695cf65597459719812c175a5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3670103
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Michael Hoyle <mikehoyle@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Descriptor here was used to pass a raw descriptor from a type that
implements AsRawDescriptor to a function that takes an AsRawDescriptor
as argument. Passing the provider directly is strictly equivalent.
BUG=233968702
TEST=cargo build
Change-Id: I638d01f1d5b47eb9773e7b1ad3802f6d8d0e5f6a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3670102
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Michael Hoyle <mikehoyle@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
vmm_vhost comes with its own set of listeners that implement the same
interface. Switch to use its socket listener as that will allow us to
further factorize code.
BUG=b:229554679
TEST=vhost-user console device works.
TEST=vvu console device works.
Change-Id: I19d0c9b95a0cca57eefd6c72b875e8a166d06b89
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3591110
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
The SlaveReqHandler should be the sole owner of a VhostUserBackend since
it calls its mutable methods, so we shouldn't need an Arc here. If
sharing is necessary users can use their own locking mechanism.
Single ownership will help to retrieve the backend after a client
disconnects, to reuse it for another connection if needed.
BUG=b:229554679
BUG=b:216407443
TEST=cargo test -p vmm_vhost
TEST=vhost-user console device works.
TEST=cargo test -p devices
Change-Id: I2358c807ac3ddb1ee4b29d97df0ade5a3e30a85a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3591108
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Richard Zhang <rizhang@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Submit after crrev.com/c/3664859 is merged.
BUG=b:215043150, b:183217901
TEST=HEVC playback works in ExoPlayer on guybrush w/ full set of changes
Change-Id: If775435040a77f4620a55d6838353836c40291c4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3664289
Commit-Queue: Jeffrey Kardatzke <jkardatzke@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
This is a reland of commit 129840471d
Original change's description:
> devices: debugcon: add bochs-style debugcon device
>
> This allows for creating a simple write-only debug connection that uses
> a single IO port. This method is supported by both bochs and qemu[1].
>
> The main motivation here is to help in improving crosvm's ability to
> boot OVMF, which makes use of this simple debug device on port 0x402.
> For that one would use `--serial
> type=stdout,hardware=debugcon,debugcon_port=1026` or something similar.
>
> Note that serde_keyvalue doesn't support parsing hex values, hence the
> need to use `1026`, but I intend to address that as well to allow the
> more natural `debugcon_port=0x402` phrasing.
>
> [1]: https://github.com/qemu/qemu/blob/master/hw/char/debugcon.c
>
> BUG=b:233610263
>
> Change-Id: I73238e5c35925668d133bfaa542fcbcf1e28765f
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3661255
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Commit-Queue: Mike Gerow <gerow@google.com>
> Tested-by: kokoro <noreply+kokoro@google.com>
Bug: b:233610263
Change-Id: I2f2125da95e8907f4f0c16930952e9b765d33e6c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3671087
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Mike Gerow <gerow@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This reverts commit 129840471d.
Reason for revert: This conflicts with https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600167 breaking the build
Original change's description:
> devices: debugcon: add bochs-style debugcon device
>
> This allows for creating a simple write-only debug connection that uses
> a single IO port. This method is supported by both bochs and qemu[1].
>
> The main motivation here is to help in improving crosvm's ability to
> boot OVMF, which makes use of this simple debug device on port 0x402.
> For that one would use `--serial
> type=stdout,hardware=debugcon,debugcon_port=1026` or something similar.
>
> Note that serde_keyvalue doesn't support parsing hex values, hence the
> need to use `1026`, but I intend to address that as well to allow the
> more natural `debugcon_port=0x402` phrasing.
>
> [1]: https://github.com/qemu/qemu/blob/master/hw/char/debugcon.c
>
> BUG=b:233610263
>
> Change-Id: I73238e5c35925668d133bfaa542fcbcf1e28765f
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3661255
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Commit-Queue: Mike Gerow <gerow@google.com>
> Tested-by: kokoro <noreply+kokoro@google.com>
Bug: b:233610263
Change-Id: Ia70540c3041611f59968cb7929b238eecfe2530d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3671082
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Mike Gerow <gerow@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
This allows for creating a simple write-only debug connection that uses
a single IO port. This method is supported by both bochs and qemu[1].
The main motivation here is to help in improving crosvm's ability to
boot OVMF, which makes use of this simple debug device on port 0x402.
For that one would use `--serial
type=stdout,hardware=debugcon,debugcon_port=1026` or something similar.
Note that serde_keyvalue doesn't support parsing hex values, hence the
need to use `1026`, but I intend to address that as well to allow the
more natural `debugcon_port=0x402` phrasing.
[1]: https://github.com/qemu/qemu/blob/master/hw/char/debugcon.c
BUG=b:233610263
Change-Id: I73238e5c35925668d133bfaa542fcbcf1e28765f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3661255
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Mike Gerow <gerow@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Using the new `SerialInput` trait, we can create an async input source
and get rid of the polling thread.
BUG=b:228912920
TEST=vhost-user console device is working (with input) on Linux.
Change-Id: I1be9ae499f9c782b4aacba44e1eca524f1b701c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600168
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Introduce a new dedicated trait for types that can be used as serial
input. This trait adds the requirement that the type must implement
`AsRawDescriptor`, which will allow us to use the input as a poll source
instead of having to spin a dedicated thread to call `read()` on it.
BUG=b:228912920
TEST=cargo build
Change-Id: Ib07f7b4e63545fa0f27940553ad6124796f5b3cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600167
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Everything that takes a PCI BAR index should use the appropriate
PciBarIndex type rather than u8 (or usize) for better type safety and
descriptiveness.
BUG=b:232838930
TEST=tools/presubmit
Change-Id: I0a918a6da6327c963fb297ba765563774a7e5e49
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3664282
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Anton Romanov <romanton@google.com>
The read_bar() and write_bar() functions had an open-coded equivalent of
BAR lookup to find out if the access was intended for the settings BAR
or one of the device-specific extra BARs. Instead, we can reuse the same
BAR lookup code to find the index of the relevant BAR and compare it
against the settings_bar field.
BUG=b:232838930
TEST=tools/presubmit
Change-Id: I2e5f3ccff47d31718e835ccb745db75dbda2e4ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3664281
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Define constants for the end of the ranges that exist within the
settings BAR so we can use the range syntax in the match instead of
manually checking against the start and end.
This uses inclusive range (..=) syntax, since exclusive range pattern
syntax (..) is experimental. Therefore, each range has a `_LAST`
constant that is equal to the address of the last valid byte in that
range (first + size - 1).
Rewriting the matches in this way allows us to clean up the two clippy
ignores and makes the code a bit easier to read.
BUG=b:232838930
TEST=tools/clippy
TEST=Boot x86-64 Crostini
Change-Id: Ibb8b5ea055e598c19504b7b1b6753706ad458875
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3664280
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Anton Romanov <romanton@google.com>
We need to open vvu device before we go to jail since we don't have
access to sysfs in jail.
BUG=b:233690640
TEST=manual - fs is usable from a sibling guest when using VVU.
Change-Id: I0340d105b667cce2ba88d7557e64771fa2bedf9e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3665907
Auto-Submit: Lepton Wu <lepton@chromium.org>
Commit-Queue: Lepton Wu <lepton@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
This was fixed in crrev.com/c/3659824, but a subsequent commit somehow
reverted that line.
BUG=None
TEST=`cargo build` does not display any warning.
Change-Id: Id50ee4f615117ada8c27552e073f7fb04d8d009e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3664166
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
We want to eventually reuse these functions in the regular virtio device
code, which uses a different kind of interrupt, so make that parameter
generic.
BUG=b:228912920
TEST=cargo build
Change-Id: I1139ce6626ac7b952b7769db6e66d677607d3307
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600166
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
The error path reproduces the code outside of the match arm, so it can
be removed.
BUG=b:228912920
TEST=cargo build
Change-Id: Ibd485a52441be03501041bc4136bab9293c7066b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600165
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Used tx buffers are returned to the driver with 0 bytes written by the
device. The current code makes it look like we return the number of
received bytes, even though this is not the case since
process_transmit_request always returns 0 for some reason.
Make this more clear by explicitly setting 0 bytes used, and making
process_transmit_request return nothing.
BUG=b:228912920
TEST=cargo build
Change-Id: I9094f7a43847d7e29d5390f274d6650ca5ec7c4d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600164
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>