Add PCI PM capability to virtio pci devices, and generate PMEs for all
virtio device interrupts. PMEs are GPEs advertised ACPI, so they are x86
only. PCIe PME signalling can be investigated in the future.
This is the VMM side patch to [1], which allows Linux guests to enter
system-wide low power states like s2idle without needing to reset the
virtio devices when PCI PM with No_Soft_Reset is advertised.
[1] https://lore.kernel.org/all/20231208070754.3132339-1-stevensd@chromium.org/
BUG=b:301865273
TEST=Manually enable ARCVM s2idle feature
Change-Id: I6b0a122820c5d6932dc3e181d2fd2852b3640e5e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4666701
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
Shmems can be sealed up to be read-only for the guest clients. The
hypervisor has to work around with MAP_PRIVATE to avoid EPERM for now:
- https://lore.kernel.org/bpf/20231013103208.kdffpyerufr4ygnw@quack3/T/
One example is: zwp_linux_dmabuf_v1 (version 4) protocol allows wayland
server to send tranche formats to the client via a feedback shmem. The
Gnome wayland server, Mutter, seals that shmem read-only.
BUG=b:290125852
TEST=glxgears, vkcube works via virtgpu channel against mutter
Change-Id: I1648b9e26ef3137e7a7ed894b56699c4eccd00c9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5081864
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
When multiple PCI devices are hotplugged in before PCI enumeration, the
devices may be listed in a different order than they are hotplugged.
This CL fixes the issue by allocating hotplug ports in the same order as
they would be enumerated by the guest OS.
BUG=b:315923326
TEST=./tools/dev_container ./tools/presubmit
TEST=manual feature tests
TEST=tast run ${DUT} arc.MultiNetworkingConnectivity (with patch
http://crrev/c/5096163, http://crrev/c/4798333, and http://ag/25574078)
Change-Id: I3c023788eb5828d22dae5b71744e7bf26abe487a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5113785
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Ningyuan Wang <ningyuan@google.com>
When Wayland server seals the dmabuf feedback shmem read-only, virtio-wl
must drop PROT_WRITE for O_RDWR.
BUG=b:290125852
TEST=glxgears, vkcube works via virtio-wl against mutter
+/- --enable-linux-dmabuf (additionally tested vkcube-wayland)
Change-Id: I27d3a9fae38de483a0f283cb370c0aa69613756e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5081023
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This is a follow-up of crrev.com/c/4318264.
BUG=b:272146562
TEST=boot crosvm with gpu
Change-Id: Iff205c19d8c9eea603b16e36af79148ad5fba5d9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5103928
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Rust 1.73 changes the default panic information formatting in a way that
breaks the ChromeOS memfd panic handler collection system. Update the
panic hook so that it uses the same formatting as libchromeos-rs, which
matches the pattern expected by the crash-reporter collector.
This version differs slightly from the one used in libchromeos-rs in
that it does not try to retrieve the message from PanicInfo::message().
This function is only available in nightly, and it also should only be
used for panics originating from core (rather than std), which doesn't
apply to our use case.
BUG=b:309651697
TEST=manually add panic and verify message formatting
Change-Id: Id3e890f8d7db0c9d44c05e55b236f943ec17e148
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5078851
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Subtract the size of `ChromeOsTmpfileIn` from the buffer size, because
otherwise the function fails at `read_exact` due to an unexpected end of
input.
BUG=b:315460740
BUG=b:315718103
TEST=arc.DataMigration.r_to_t_x86_virtiofs arc.CxxCrash.mock_consent_vm
TEST=Confirm that open(O_TMPFILE) succeeds inside ARCVM virtio-fs /data
Change-Id: Ic7e09cc10948741f1b605a3e1478a0cc58af2479
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5106949
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Yuan Yao <yuanyaogoog@chromium.org>
Generate bindings for the installed version of the ffmpeg libraries at
build time instead of checking in a static version of the bindings.
BUG=b:309563850
TEST=cargo build --features=ffmpeg
Change-Id: I38d922dd7332c4385ae6a0ae93e893538c3b1cce
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5027711
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
There's no behavior change introduced in this commit. The map flags are
able to be resolved in one place. This is to prepare for later map flags
changes.
BUG=b:290125852
TEST=build
Change-Id: I1eb52e767967b80a327b542910648c5cac01b369
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5081863
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
This CL adds pci-hotplug feature flag to crosvm-control FFI. This flag
is required since otherwise vm_control for crosvm_control target would
be built without pci-hotplug flag.
BUG=b/294777126
TEST=manual VmConciergeClient DBus call workds with crrev/c/4798333
Change-Id: Iad4a7f47185025709bb2ae5029d42a06df8f555b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5098244
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Ningyuan Wang <ningyuan@google.com>
Direct use of `VhostBackendReqConnection` by devices makes the code more
complex and more difficult to share with standard virtio device
implementations.
The `Interrupt` type is already shared between virtio and vhost-user
code and it provides a method to send config change notifications. This
commit fixes it to do the right thing for vhost-user backends.
If you unfurl the new field of `DeviceRequestHandler`, it is something
like
Arc<Mutex<Option<Arc<(Arc<Slave>, ...)>>>>
which isn't great. We can can probably squash some of those layers
together.
Change-Id: Ia5ac99568eefa549e3c913f2d1c17ca78cd2b01d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5096137
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This will make it possible for our vhost-user framework to keep a ref to
the connection and use it to build abstractions around the backend
request features.
Change-Id: Id7420b132d4368ac25520c7abf870ac8e240952d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5096136
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
There is only one implementation and it doesn't use `self` params, so we
can delete all of the "ops" plumbing.
Change-Id: I2f98141a912bf0679f931d6779172a366a1e185e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5089977
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Make the connection API provide a send_message() API instead of
send_iovec(). This moves the responsibility for ensuring all data of a
message is sent into the platform-specific code (SocketConnection and
TubeConnection), which can now use different approaches.
The send_iovec_all() function is moved into the socket code, and the
socket implementation of send_message() now sends all of the data in a
single sendmsg() call. This is acceptable now, since the
Windows-specific requirement for splitting the header and data into
separate sends does not apply to the unix-only socket code.
The tube code now relies on the Tube::send() function to ensure all data
is delivered, removing the send_iovec_all() retry loop from Windows
entirely.
BUG=b:273574299
Change-Id: I9652e4ee3e95bb9ecf700dac93b0d5b806469ab2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5075018
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
All the fields are `Send`, so `EventAsync` is implicitly `Send`.
This was probably added originally because the predecessor to `IoSource`
was always `!Send` even when the underlying type was `Send`.
BUG=b:271297810
Change-Id: If72de71c6f37c72f5b791391c657d1234d9f765f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5086674
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
FUSE minor version 36 and beyond can append the security context for
newly created inodes to create, mkdir, mknod, and symlink requests for
backend filesystems that support the feature, indicated by setting the
FUSE_SECURITY_CONTEXT flag. Support this extension by appending the
security context (via /proc/thread-self/attr/fscreate) before creating
files, directories, nodes, or symlinks. This ensures that these
entries appear atomically with the correct selinux labels when the
guest is running with a kernel that does not have the patch at
https://crrev.com/c/2992595.
This change also extends the fuse init flags to accommodate flags
added with the new kernel version.
These changes are based on https://crrev.com/c/2239728.
BUG=b:304606864
TEST=vm.Virtiofs, arc.Boot.vm, tested with GKI kernel version 5.15
and existing arcvm kernel. verified that adb_keys files are
correctly labeled with security context.
Change-Id: I607e26d34428af9cfbf93d73eee751ee29160ed1
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4979355
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Tiffany Yang <ynaffit@chromium.org>
Reviewed-by: Yuan Yao <yuanyaogoog@chromium.org>
KVM_CHECK_EXTENSION will return 0 if XSAVE2 is not available.
fmayle@ had noticed that we are creating Xsave with size 0, which would
be an error.
Check if size == 0, and if so, set it to Xsave max size.
BUG=N/A
TEST=AOSP TH
Change-Id: I10c7344aae1005bab2981fbeaf2c7906b871594c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5085548
Auto-Submit: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
This cleans up the API and avoids the need for the caller to wrap each
descriptor in Some() first.
Change-Id: Iaf38a0882f2c9dbc39fb7b910abfa3fedf425f30
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5074591
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
We're trying to identify a stall in the vsock device that appears to
occur when handling a connection request. It's not entirely clear where
or why we're stalling in the codepath, so this CL adds a bunch of
logging to help us narrow things down. It also normalizes some of the
formatting for vsock info & error messages to increase log readability.
BUG=b:313558198
TEST=ran emulator w/ guest that uses vsock.
Change-Id: I89e50a1949f160ec152344e870e1e43dcf8f2e79
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5079245
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Richard Zhang <rizhang@google.com>
The interface of trace_marker & noop drifted from the Perfetto
interface. This CL re-unifies the interfaces and cleans up some
parameter types that were too permissive.
BUG=b:314218142
TEST=builds on both platforms.
Change-Id: I5b2da1f6de8e1df5cab6a0a434f3135b16f1f3c3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5080936
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Noah Gold <nkgold@google.com>
disk
Current implementation did not raise errors when trying to modify a
read-only disk. This commit makes it to raise error in that situation.
BUG=b:300042376
TEST=./tools/presubmit
Change-Id: Ib4185e47c109016410a81b78040897ee13f5dee4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5075903
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
The current scsi integration test does not include test cases for the
block discard operation. Because of the lack of the test case, it could
not catch some bugs caused by other CLs (https://crrev.com/c/5019243).
This adds a test function in the e2e_tests crate for the discard
operation.
BUG=b:300042376
TEST=./tools/run_tests --dut=vm -E 'test(test_scsi)'
Change-Id: Ia7ec3850fdf493371fab8fc102d4bf7f978da696
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5075901
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
Currently we have an experimental SCSI device, but documentation does
not exist. This commmit adds a SCSI section to the crosvm book.
TEST=mdbook build
BUG=b:300042376
Change-Id: Ie54f6ed364436963fc0169b456e8033f4616866d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5075264
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Joe Hattori <hattorij@google.com>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
Handle the Vec allocation and resizing internally in ScmSocket instead
of making each caller deal with it.
This also prevents file descriptor leaks since the fds are immediately
wrapped in SafeDescriptor, which will close them if dropped, rather than
the previous API which used un-owned RawDescriptors.
Change-Id: Icb44bd744ea18bbdfc63f816b4b992f320a36823
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5075016
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
The send and recv functions are renamed and refactored to provide
consistent API:
- send_with_fds()/recv_with_fds() accept plain non-iovec &[u8]/&mut[u8]
- send_vectored_with_fds()/recv_vectored_with_fds() accept iovecs
AsIobufs is implemented for &[IoSlice], so a separate `_bufs` entry
point is not needed.
The `with_fd` (singular) function was only used in one place, in a unit
test, which can be adjusted to call `with_fds` instead.
As a semi-related cleanup, raw_sendmsg() and raw_recvmsg() now take
&[iovec] directly rather than AsIobuf, which matches the raw libc API
more closely and avoids the need for the functions to be generic.
Change-Id: Id4ed18d96a01c6622b2c7bc459e95cb2fa499069
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5075015
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
This doesn't have mac os or windows equivalents, so delete the stubbed
implementations.
Test: tools/dev_container tools/presubmit
Change-Id: Id1898889d57d362078631980373f71644ae2c492
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5074589
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
These are equivalent to as_iobufs()/as_iobuf_slice() except the slices
containing the IoBufs are mutable.
Change-Id: I2fdb96a700142b148add94d5d6b40e6335fe0232
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5074588
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
No implementors used `VhostUserSlaveReqHandler` directly, so it is
merged with `VhostUserSlaveReqHandlerMut`. The locking would have been
moved into `SlaveReqHandler`, however, the handler only processes one
request at a time, so no locking is actually necessary.
Change-Id: Iaa8896b09d2d1eb393c2eed794c295183cc5e099
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5076928
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
Now that the trait methods accept `&mut self`, there is no need for an
internal mutex.
Change-Id: Idb626317100e9d5ec421a114d6c93a74c3c7ba54
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5076927
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Only `Slave` implemented `VhostUserMasterReqHandler` direcly and it was
internally using a mutex to guard everything just as done by
`VhostUserMasterReqHandlerMut` implicitly. To simplify things, the trait
now only supports `&mut self` methods and users of the trait need to add
a mutex themselves as needed.
There are two users of `VhostUserMasterReqHandler`:
1. `VhostBackendReqConnection`: Uses an `Arc` for memory management and
so does need the lock to get a `&mut`. Added a `Mutex` directly to
it (effectively at the same level of granularity as before).
2. `MasterReqHandler`: Already has a `&mut` (it can only process one
request at a time) and so doesn't need a lock.
`Slave` no longer needs a lock internally. That will be cleaned up in a
separate CL.
Change-Id: Icf8edd40087b68e7d2b55a0569ffde1afde6bfcf
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5076926
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Platform-specific symbols with the same name are now re-exported in
`base` directly, and other symbols are accessed through `base::linux` or
`base::windows`.
Change-Id: Ib76f537fc562cdf42dfcbd25b7f8e49956993708
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4996627
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
The original usb transfer implementation assumes usbdevfs semantics and
relies on the usb_util crate. With this refactor we abstract the
semantics so we can support different backends and more generic
transfers that only care about allocating transfer buffers and passing
around generic callbacks.
BUG=b:307660802
TEST=built and tested USB functionality on a DUT is unchanged
Change-Id: If31beac94642d4fc63a51f2ac39514998abef536
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5065368
Reviewed-by: Ryuichiro Chiba <chibar@chromium.org>
Commit-Queue: Ryuichiro Chiba <chibar@chromium.org>
Auto-Submit: Morg <morg@google.com>
Currently the queue size of virtio-scsi device is set to 256, but the
FIO performance result improved on a larger size 1024. This commit
changes the queue size to 1024 given the performance increase.
BUG=b:300042376
TEST=tools/presubmit
Change-Id: Iad29541436e9a0c2f9acd2587e3bb9ae5e4110cf
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5067394
Reviewed-by: Takaya Saeki <takayas@chromium.org>
Commit-Queue: Joe Hattori <hattorij@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
SerialParameters implements FromKeyValues, so it does not need a custom
from_str_fn to be parsed.
Additionally, fix a typo in the multi-port error message.
BUG=b:295881923
TEST=tools/dev_container tools/presubmit
Change-Id: If72b325c0ab4422dfce9381e78e06fbd25943e5d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5053920
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
It only handles bytes and FDs now.
Change-Id: Ie28ee94c04d9fcd34b9803581ff0e0f087555fce
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5073072
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>