Commit graph

7930 commits

Author SHA1 Message Date
Vikram Auradkar
2768f223ee clippy: enforce safety block comments
BUG=b:316174930
TEST=none

Change-Id: I5c7811b2c548155aa003e4b71a54bbc16e2f2588
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5120567
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-12-14 18:21:54 +00:00
recipe-roller
90c2ff0432 Roll recipe dependencies (nontrivial).
This is an automated CL created by the recipe roller. This CL rolls
recipe changes from upstream projects (recipe_engine) into this repository.

The build that created this CL was
https://ci.chromium.org/b/8763143154807435681

Please review the expectation changes, and LGTM+CQ.

recipe_engine:
ee2fea4d6a
  ee2fea4 (iannucci@chromium.org)
      [file] Clean up some py2 compatibility things.

Please check the following references for more information:
- autoroller, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#autoroller
- rollback, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#rollback
- cross-repo dependencies, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/cross_repo.md

Use https://goo.gl/noib3a to file a bug.

R=denniskempin@google.com

Recipe-Tryjob-Bypass-Reason: Autoroller
Ignore-Freeze: Autoroller
Bugdroid-Send-Email: False
Change-Id: I148c13fc54e2ad25927c7f429d928eaeb01d8b69
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5068398
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
2023-12-14 18:05:22 +00:00
Vikram Auradkar
96b82c0294 clippy: enforce safety doc comment
BUG=b:316168567
TEST=none

Change-Id: I4e0a74e509ed4ef672fb9f334654a50aa5e257f1
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5118513
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2023-12-14 17:46:29 +00:00
David Stevens
32bf962689 devices: Add power management to virtio devices
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>
2023-12-14 03:25:11 +00:00
Yiwei Zhang
65b30e2ece base: linux: mmap: workaround to use MAP_PRIVATE for read-only seal
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>
2023-12-13 07:51:42 +00:00
Wang Ningyuan
8edf58db92 crosvm: Preserve order of early hotplugged device
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>
2023-12-13 06:25:03 +00:00
Yiwei Zhang
a60d7df02d devices: virtio: wl: rw shm to drop prot write for read-only seal
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>
2023-12-13 04:19:12 +00:00
Keiichi Watanabe
4608ef9545 jail: seccomp: allow syscalls for panic handling in GPU
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>
2023-12-12 09:27:23 +00:00
A. Cody Schuffelen
3987aeb0c9 base: Move linux::tube to unix
Bug: b/309020556
Test: tools/mac-build && tools/presubmit
Change-Id: Ie04f152d44843dc0d64886d1cef24397f5512d23
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5106604
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
2023-12-11 23:27:03 +00:00
A. Cody Schuffelen
beb03577ba base: Move linux::{syscall!, *_fd_flags} to unix
Bug: b/309020556
Test: tools/mac-build && tools/presubmit
Change-Id: I56602d031eebf3e065707dd610a7a2610a450497
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5106603
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
2023-12-11 23:08:50 +00:00
A. Cody Schuffelen
b6dd14d6f0 Mac OS version of crrev.com/c/5096135
Test: tools/mac-build
Change-Id: I19c01598c665c0a4841f65e0164402846b24084e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5106602
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
2023-12-11 22:06:59 +00:00
Daniel Verkamp
f2b7cd9a2d base: linux: manually format panic information
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>
2023-12-11 19:30:44 +00:00
Youkichi Hosoi
ed0cb393a4 fuse: Fix buffer size for reading security context in chromeos_tmpfile
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>
2023-12-11 06:26:41 +00:00
Daniel Verkamp
324877dbd8 media: ffmpeg: generate bindings in build.rs
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>
2023-12-08 20:58:57 +00:00
Keiichi Watanabe
9aab2b6647 jail: x86_64: Allow pread64/pwrite64 for scsi
On x86_64 boards with v5.4 or older kernels, virtio-scsi device uses
pread64 and prwrite64 instead of preadv and pwritev.

BUG=b:314859349
TEST=tast run dedede vm.Fio.scsi_rand*

Change-Id: I4e154f55d28bc070665051ea6fae8700b0bc49ee
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5095286
Reviewed-by: Takaya Saeki <takayas@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2023-12-08 10:28:41 +00:00
Yiwei Zhang
c26545a574 rutabaga_gfx: linux: mmap: map ACCESS_WRITE to PROT_WRITE
A tiny bug fix.

BUG=b:290125852
TEST=build and shmem mapping works

Change-Id: Ib0440739f995da83adcd0b7f5fed5df350821345
Reported-by: Ryan Neph <ryanneph@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5084680
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2023-12-07 21:25:46 +00:00
Yiwei Zhang
048757ea4f base: linux: mmap: resolve map flags in one place
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>
2023-12-07 21:18:39 +00:00
Yiwei Zhang
6e3391fc92 base: linux: mmap: remove some duplicate code
and amend some missing comments

BUG=b:290125852
TEST=build

Change-Id: I24561b97dc528e2041389af74de070e20a5918aa
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5081862
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2023-12-07 21:18:12 +00:00
Wang Ningyuan
c855a3824b crosvm-control: Add pci-hotplug flag
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>
2023-12-07 08:20:29 +00:00
Frederick Mayle
f178c3de48 devices: virtio: support vhost-user in Interrupt::signal_config_changed
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>
2023-12-07 02:38:17 +00:00
Frederick Mayle
65a58d32df devices: vhost: user: move VhostBackendReqConnection into an Arc
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>
2023-12-07 02:38:17 +00:00
Frederick Mayle
70df96ff17 devices: vhost: user: convert File to Event without unsafe
Change-Id: Iccf30aa6f8b31a8988b71d06fac6209127c7f2ae
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5096135
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
2023-12-06 22:22:36 +00:00
Frederick Mayle
a1a8a3224c devices: delete VhostUserPlatformOps trait
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>
2023-12-06 22:22:36 +00:00
Daniel Verkamp
2a417a0b1b vmm_vhost: change Connection send API to send_message()
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>
2023-12-06 20:37:20 +00:00
Frederick Mayle
69a9a0e4a0 cros_async: remove EventAsync's redundant unsafe Send impl
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>
2023-12-05 21:04:39 +00:00
Frederick Mayle
3df3d4ab51 base: remove UnixSeqpacket's redundant unsafe Send impl
The only field, `SafeDescriptor`, is already `Send`.

Change-Id: Ife76c31da6a8b54b1a665ff36cb0363c5e7fbcdb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5086675
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-12-05 21:04:39 +00:00
Tiffany Yang
54a5693cd7 devices: fs: Extend init flags and send security context on creation
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>
2023-12-05 20:19:19 +00:00
Elie Kheirallah
a10c83864e devices: kvm: Fix Xsave size in x86_64
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>
2023-12-04 23:25:20 +00:00
Daniel Verkamp
f5f2aa4594 base: remove unused MemoryMappingBuilder::build_fixed()
BUG=b:230901659
TEST=tools/dev_container tools/presubmit

Change-Id: I6f12f1ef2425dec8dd03795ea2670d622acc0143
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5084678
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
2023-12-04 22:45:09 +00:00
Daniel Verkamp
1199e8767c base: pass IntoIterator to deserialize_with_descriptors()
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>
2023-12-04 19:38:55 +00:00
Yiwei Zhang
521ee98d41 rutabaga_gfx: adding missing nix ioctl feature for rutabaga_gralloc
Fix regression in f3dbf20eed

BUG=b:314785753
TEST=rutabaga_gralloc builds

Change-Id: Id2715076ab239b49fb00d230b4a76f4c4493e55e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5081852
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Andrew Walbran <qwandor@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2023-12-04 17:58:53 +00:00
Matthew Maurer
8aabb8d9c0 Update to syn-2
Change-Id: I0043acbdcd7a697063931a3505f6e90354f92d2a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5078521
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-12-02 00:23:50 +00:00
Noah Gold
f832d41758 devices: vsock: add connection logging for Windows.
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>
2023-12-02 00:19:51 +00:00
Noah Gold
9d51088b78 cros_tracing: fix interface drift.
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>
2023-12-02 00:02:41 +00:00
Joe Hattori
7da8372d09 devices: virtio: scsi: Raise error when trying to modify a read-only
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>
2023-12-01 12:09:11 +00:00
Joe Hattori
547aa2aaf5 e2e_tests: scsi: Add test cases for discard operations.
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>
2023-12-01 12:07:56 +00:00
Joe Hattori
70f5f0ddaa docs: Add SCSI section.
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>
2023-12-01 11:10:03 +00:00
Daniel Verkamp
a0aad9eb0f base: unix: return Vec<SafeDecriptor> from recv_with_fds()
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>
2023-12-01 02:11:32 +00:00
Daniel Verkamp
aec2b91fa3 base: unix: rework ScmSocket send/recv functions
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>
2023-12-01 01:11:48 +00:00
A. Cody Schuffelen
98a6921246 Only support cpufreq on arm/aarch64
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>
2023-12-01 00:56:01 +00:00
Daniel Verkamp
c585ae80bc base: add IoBuf/IoBufMut mut slice conversions
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>
2023-12-01 00:25:30 +00:00
Frederick Mayle
7166a22943 vmm_vhost: eliminate locking in SlaveReqHandler and merge traits
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>
2023-11-30 23:42:32 +00:00
Frederick Mayle
c9c8daa8b1 vmm_vhost: simplify Slave
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>
2023-11-30 23:42:32 +00:00
Frederick Mayle
1ff6199db8 vmm_vhost: eliminate locking in MasterReqHandler and merge traits
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>
2023-11-30 23:42:32 +00:00
A. Cody Schuffelen
616a35b988 Don't expose base::platform as a public interface
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>
2023-11-30 23:12:24 +00:00
Federico 'Morg' Pareschi
f1829e78f4 usb: refactor transfer structs for multi backends
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>
2023-11-30 10:17:44 +00:00
Joe Hattori
e68276c609 devices: virtio: scsi: Change the queue size.
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>
2023-11-30 06:55:53 +00:00
Daniel Verkamp
9d054ab7b1 devices: vhost-user: console: clean up arg parsing
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>
2023-11-30 01:33:28 +00:00
Frederick Mayle
0ec42b028f hypervisor/README.md: add qualcomm contacts for gunyah
BUG=b:308979341

Change-Id: I3e75e3a7e69d07cefa756403286acecd10f239e2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5072116
Reviewed-by: Elliot Berman <quic_eberman@quicinc.com>
Reviewed-by: Steven Moreland <smoreland@google.com>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
Auto-Submit: Frederick Mayle <fmayle@google.com>
2023-11-29 19:20:17 +00:00
Frederick Mayle
2db5f6e4c0 vmm_vhost: remove type parameter from PlatformConnection
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>
2023-11-29 19:11:59 +00:00