0
Fork 0
mirror of https://github.com/Droid-VM/crosvm.git synced 2026-11-17 06:58:03 +00:00
Commit graph

143 commits

Author SHA1 Message Date
Elie Kheirallah
17f268191a Merge remote-tracking branch 'aosp/upstream-main' into merge
* aosp/upstream-main: (38 commits)
  aarch64: fix potential initrd size subtraction underflow
  Uprev pkg-config to 0.3.31
  crosvm: upgrade zerocopy to 0.8
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  devices: virtio-snd: simplify zerocopy usage in vios backend
  x86_64: fix potential setup_data overlap of mptable
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  hypervisor: aarch64: Add context to errors in snapshot
  Roll recipe dependencies (trivial).
  devices: virtio-wl: add missing padding in CtrlVfdNewCtxNamed
  devices: virtio-wl: add size check for CtrlVfdNewCtxNamed
  devices: vfio: avoid extra copy in read_config()
  devices: virtio-scsi: simplify write_config()
  Revert "rutabaga_gfx: Add rutabaga_resource_wait_sync interface"
  Roll recipe dependencies (trivial).
  Rename gfxabort to be agnostic of graphics stack
  devices: virtio-scsi: use read_from_prefix() in parse_command()
  ...

Bug: 398839628
Test: atest --test-mapping external/crosvm
Change-Id: I1214e25a5c34a735925c605b8440c870abb0d31b
2025-02-25 18:10:03 +00:00
Daniel Verkamp
f20af151e2 crosvm: upgrade zerocopy to 0.8
BUG=b:372549215
TEST=tools/dev_container tools/presubmit

Change-Id: I3fcc524d1c6c41ae92c51cecb6e4d856c3d60670
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/6255229
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2025-02-24 11:35:51 -08:00
Frederick Mayle
7ac4c9ad6b ANDROID: simplify crosvm_defaults
* All non-crosvm users of crosvm_defaults are gone, so we don't need a
  separate internal defaults module.
* Edition is set automatically by cargo_embargo.
* authfs only needs visibility on libfuse_rust, which is done via
  cargo_embargo.

Bug: 269356487
Test: m
Change-Id: I3091e76e86435021bc3b1c5deb77a5b5d514ca32
2025-02-10 18:41:03 -08:00
Frederick Mayle
f51ffa9d45 ANDROID: fix cargo_embargo diffs + new apex_avail setup
https://r.android.com/3484205 changed the Android.bp files directly to
fix an issue with setting apex_available on test modules. This commit
refixes the issue in a different way that works better with
cargo_embargo.

Instead of setting apex_available via the rust_defaults, which is used
for every module type, we use cargo_embargo's apex_available config
option, which only applies to non-test modules.

Bug: 269356487
Test: m
Change-Id: Ib7a10e23342ead86553232a7014747b46ffefaf2
2025-02-10 17:56:28 -08:00
Treehugger Robot
8b73ef1ac3 Merge "Make crosvm tests available to the platform" into main 2025-02-10 16:21:16 -08:00
Frederick Mayle
f992952555 Merge remote-tracking branch 'aosp/upstream-main'
* aosp/upstream-main: (30 commits)
  vm_memory: return the backing object from `Guest::offset_from_base`
  vm_memory: track --file-backed-mapping RAM regions in GuestMemory
  rutabaga_gfx: &str -> &Path for snapshot directory
  rutabaga_gfx: snapshot/restore rutabaga core to directory
  Roll recipe dependencies (trivial).
  devices: virtio_gpu: Pack rutabaga snapshot directory
  devices: virtio_gpu: move snapshot scratch into nested tempdir
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  Standardize on `anyhow = "1"` in Cargo.toml files
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  [clippy] use div_ceil() and next_multiple_of()
  kernel_loader: fix off-by-one in ELF address range end
  aarch64: fix off-by-one errors in kernel end calculations
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  ...

Bug: 392977518
Test: m
Change-Id: I0c9a490c3497cc29e1c2182d60eeb91a3aa35bdf
2025-02-07 15:59:01 -08:00
Colin Cross
f41e8eaddd Make crosvm tests available to the platform
Soong was accidentally allowing a corner case where modules that
were not supposed to be available to the platform (due to
apex_available being set to an apex and not including
"//apex_available:platform") were being made available to the
platform as long as no apex modules depended on them.  Split
crosvm_defaults into crosvm_defaults and crosvm_test_defaults,
where only crosvm_defaults gets apex_available: ["com.android.virt"],
and switch all the rust_test modules to use crosvm_test_defaults.

Bug: 394664568
Test: compare out/soong/installs-${TARGET_PRODUCT}.mk
Change-Id: I7ce4dabbcf1600cf44833b7883977e27a4ad7561
2025-02-07 20:36:04 +00:00
Daniel Verkamp
73e2c746e1 kernel_loader: fix off-by-one in ELF address range end
The address range returned by load_elf() was miscalculated due to the
different end address convention (inclusive versus exclusive). Replace
the AddressRange manual initialization with from_start_and_size() to
avoid confusion and fix the off-by-one mistake.

BUG=b:354116267
TEST=Verify DT kernel-size field matches expected value

Change-Id: Ideed730cb447a1ccc12287d0aa33e3439b374f3f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/6235945
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2025-02-05 14:44:54 -08:00
Elie Kheirallah
1ccd2a2619 Merge remote-tracking branch 'aosp/upstream-main' into merge
* aosp/upstream-main: (44 commits)
  vm_control: snapshot: use DirEntry fields in list_fragments()
  Roll recipe dependencies (trivial).
  x86_64: update comment about pvmfw ABI
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  Decouple cpu_ipc_ratio and cpu_capacity
  Re-use existing parse function for BTreeMap<usize, u32>
  vm_control: add snapshot parse error context.
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  jail: add fstat to jail_warden.policy to fix e2e hotplug tests
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  jail: let scsi make the same syscalls as block
  bindgen-common: use ChromeOS kernel 6.12 headers
  power_monitor: Only compile `protos` on the `powerd` feature
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  ...

Bug: 388347911
Test: atest --test-mapping external/crosvm
Change-Id: Ibb0dc3ec503280a211e2b08d76265f435a94b524
2025-01-13 21:04:06 +00:00
Daniel Verkamp
e8d03c74ac bindgen-common: use ChromeOS kernel 6.12 headers
Update the kernel version used to generate the bindings from Linux 6.6
to Linux 6.12, and remove the manual kvm_userspace_memory_region2
additions from kvm_sys/bindgen.sh.

The KVM_CAP_USER_CONFIGURE_NONCOHERENT_DMA capability index was changed
between ChromeOS v6.6 and v6.12, so a workaround to use the v6.6 value
is added; this maintains the existing behavior of querying cap index 236
on all kernels, which may return unexpected results on non-ChromeOS
kernels or ChromeOS v6.12 kernels.

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

Change-Id: Icccc022005de37e12d552951eaadcf6c20ac914a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/6150076
Reviewed-by: Ryan Neph <ryanneph@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2025-01-09 14:41:33 -08:00
Andrew Walbran
85f25f9403 Keep using old version of zerocopy.
Bug: 372549215
Test: m crosvm
Change-Id: I1cb74195c62fc9e05d0772a9a13dc90476324977
Merged-In: I1cb74195c62fc9e05d0772a9a13dc90476324977
2024-12-11 08:04:00 +00:00
Elie Kheirallah
f03534ac02 Merge remote-tracking branch 'aosp/upstream-main' into merge
* aosp/upstream-main: (29 commits)
  gpu_display/wayland: Add touch event for mouse
  x86_64: factor out e820 map generation
  Roll recipe dependencies (trivial).
  x86_64: return type of kernel from load_kernel()
  Roll recipe dependencies (trivial).
  x86_64: read maximum command line size from kernel
  kernel_cmdline: remove capacity from Cmdline
  ext2: Use builder pattern for creating fs
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  devices: virtio_gpu: simplify remove_displays()
  cmdline: simplify enable_fw_cfg with unwrap_or_default()
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  vmm_host: Make VhostUserStream blocking
  Roll recipe dependencies (trivial).
  disk: add option to disable file locking
  Roll recipe dependencies (trivial).
  vm_memory: improve MemoryNotAligned error message
  Roll recipe dependencies (trivial).
  ...

Bug: 365593627
Test: atest --test-mapping external/crosvm
Change-Id: I043e945f4182611205a1b2c2c3f1f09775621af0
2024-09-16 16:53:27 +00:00
Daniel Verkamp
ad41ae89ec kernel_loader: move load_cmdline() to x86_64
This is only used by the x86_64 arch code, and it isn't really related
to kernel loading. Moving it to x86_64 will also allow x86-specific
changes in upcoming CLs.

No functional change intended.

BUG=b:362168475

Change-Id: I4d01ba81d4f14fe73b38d62981a2c5a651b1bf03
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5842390
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2024-09-09 21:32:01 +00:00
Steven Moreland
b9af962d6d Merge remote-tracking branch 'aosp/upstream-main' into merge
* aosp/upstream-main: (23 commits)
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  devices: virtio: make Queue track its own Interrupt
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  Update a few older VM tests to work with more functional HAXM
  Added test to verify nonsupport of MONITOR and related instructions
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  Add arcvm_gki_cq test plan
  x86_64: move gdb support to a separate file
  Let UnixSeqpacketListener convert into OwnedFd
  hyp: Rename ProtectionType::loads_firmware()
  seccomp: allow socketpair for ipcz
  devices: virtio-console: consume self in WorkerHandle::stop()
  devices: virtio-console: restore port outputs when stopping worker
  devices: virtio-console: stop worker thread on reset
  docs: update kumquat instructions
  ...

Bug: 360912609
Test: TH

Change-Id: I43caf84d1fccc3b28c5b2b4eb155fb6a631ddc5f
2024-08-26 19:56:41 +00:00
Daniel Verkamp
008c3bc170 kernel_loader: add Multiboot kernel loader
BUG=b:354053941

Change-Id: I67d8766bc0a601fcb1c7d50ab0e5034571d14b3b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5727076
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
2024-08-19 19:56:57 +00:00
Devin Moore
64d5dea560 Running cargo_embargo after the merge
Create a new patch file for power_monitor
Fix rutabaga_gfx and disk Android.bp.patch files.

Test: m
Bug: 335312770
Change-Id: Ie08db8cabf55b38976be0343a8a41b7111a8d0f1
2024-06-25 22:54:34 +00:00
Devin Moore
b79815ee3a Merge remote-tracking branch 'aosp/upstream-main' into merge
* aosp/upstream-main: (472 commits)
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  hypervisor: add test for AVX state.
  ext2: Support so many directory entires that require multiple blocks
  ext2: Ignore host-side lost+found
  devices: virtio-blk: don't stop the worker thread on sleep/reset
  device: fs: Implement FS_IOC_PATHXATTR ioctl
  device: fs: Implement FS_IOC_SETPERMISSION ioctl
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  hypervisor: x86_64: add custom type for FPU regs
  Roll recipe dependencies (trivial).
  ...

Test: launch_cvd and Treehugger
Bug: 335312770
Change-Id: I7b388bcb43fdd60177a5b76470bd3526698cd421
2024-06-24 22:29:20 +00:00
Daniel Verkamp
7d2280f04e kernel_loader: simplify match of empty buf
Fixes a clippy warning in Rust 1.77.

BUG=b:344974550
TEST=tools/clippy

Change-Id: I05ce1a304943e56d03544169558e5012e6c04eb8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5609080
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2024-06-10 20:44:44 +00:00
Daniel Verkamp
52b8e42869 Cargo.toml: avoid "*" versions for external crates
Ensure that every Cargo.toml dependency on a third-party crates.io crate
specifies at least a major version, or a minor version for 0.x crates,
to ensure that if a new major version is published, it cannot cause API
breaks.

The versions are selected to match the ones already in Cargo.lock, so
this should have no functional change, but it will help prevent new "*"
versions from being introduced via copy-and-paste.

For rationale, see the Cargo FAQ:
<https://doc.rust-lang.org/cargo/faq.html#can-libraries-use--as-a-version-for-their-dependencies>

`minijail`, `audio_streams`, and `cras` are left as "*" for now, since
they have unusual situations (imported from a submodule and/or replaced
at build time with ebuild magic).

BUG=None
TEST=tools/dev_container tools/presubmit
TEST=verify Cargo.lock is unchanged

Change-Id: Ifa18199f812f01d2d10bfb4146b3353c1a76527c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5555656
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2024-05-22 01:01:42 +00:00
Frederick Mayle
c223989d84 Merge remote-tracking branch 'aosp/upstream-main'
Had to update the rust version to compile the new nix version.

The metrics protos have been deleted upstream, so those `out` files are
deleted (and we don't need to `sed` them in the script).

Added default_team for `hypervisor` to satisify a lint error, will add
it everywhere else later.

* aosp/upstream-main: (86 commits)
  Roll recipe dependencies (trivial).
  devices: vhost-user: fix test flake
  Roll recipe dependencies (trivial).
  Cargo.lock: switch to tokio 1.29.1
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  cros_async: Tokio IoSource for windows
  cros_async: Add AsyncFd to Tokio linux implementation
  cros_async: Blocking tokio executor for linux
  devices: Fix nested executor invocation in async virtio-console
  cros_async: Move `concurrency` to Overlapped enum
  Roll recipe dependencies (trivial).
  Create a minimal virtualization and hypervisor integration test.
  gpu_display: add max_num_displays to GpuParameters.
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  Refactor android display backend
  e2e_tests: wait for restore to complete before sending commands
  ...

Bug: 332584046
Test: TH
Change-Id: I25dd0124d719a59c312ba31f060c1b37f1d2a1b6
2024-04-15 13:00:06 -07:00
Jiyong Park
5f7ae3703d Rerun android-merge-2-cargo-embargo.sh
Rerun the tool to update the comments in the bp file. Also re-generate
the patch file for rutabaga_gfx. Below were what I did.

0. sync to ToT
1. delete rutabaga_gfx/patches/Android.bp.patch
2. stash rutabaga_gfx/Android.bp to somewhere else
3. run ./android-merge-2-cargo-embargo.sh (without the step 1)
4. create a temp commit
5. re-apply #2 and manually update the comment
6. git diff > rutabaga_gfx_patches/Android.bp.patch
7. amend the commit #4 with the changes in #5 and #6.

Bug: N/A
Test: N/A

Change-Id: Ieb9c8c6a811e9fd09b52910f504c454eaec9b80f
2024-03-12 16:40:32 +09:00
Steven Moreland
cd9ec81862 Merge remote-tracking branch 'aosp/upstream-main' into merge
* aosp/upstream-main: (37 commits)
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  devices: virtcpufreq: Add proxy syscall support through UDS
  rutabaga_gfx: Query cachability from minigbm
  base: macos: add pipe() implementation
  base: unix: add set_descriptor_cloexec()
  base: linux: remove pipe() close_on_exec argument
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  crosvm: add cmdline option wait on balloon adjust response
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  vmm_vhost: Check for errors on vhost-user WAKE
  vmm_vhost: Check for errors on vhost-user SLEEP
  vhost-user: gpu: Improve queue handling to prevent snapshot errors
  kernel_loader: Reserve memory according to 'image_size' header field
  Roll recipe dependencies (trivial).
  ...

Bug: 322835691
Test: TH

Change-Id: Ic739fe18df7edbf43068bb1f8ed5eb91167e9460
2024-02-05 23:13:36 +00:00
Will Deacon
fd4488b70f kernel_loader: Reserve memory according to 'image_size' header field
The arm64 kernel header contains an 'image_size' field indicating the
minimum size of the reserved memory region into which the kernel is
loaded. This is larger than the size of the Image file, as it also takes
into account NOBITS sections such as the .bss, which will be zeroed
during boot.

Although crosvm parses the kernel header, it fails to take 'image_size'
into account and can end up loading the initrd over the .bss if the
section is large enough to cross the next 16MiB alignment boundary after
the end of the Image.

Size the memory reservation according to the 'image_size' field in the
arm64 kernel Image header, warning if it's zero and falling back to the
current behaviour.

BUG=b:322966413
TEST=tools/dev_container tools/run_tests --platform=aarch64

Change-Id: I23316f201d8a7fd9025762be518aa505e716c642
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5249889
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Will Deacon <willdeacon@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2024-01-31 09:15:04 +00:00
Frederick Mayle
565d643567 Merge remote-tracking branch 'aosp/upstream-main'
* aosp/upstream-main: (45 commits)
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  [rutabaga_gfx:ffi] Locate target build directory.
  devices: virtcpufreq: stub out virtcpufreq
  rutabaga_gfx: add FFI API for snapshot-restore
  rutabaga_gfx: use thread_local for debug handler callback
  crosvm: add "writable" option for create_composite
  Cargo.lock: update to shlex 1.3
  kernel_loader: Add support for LZ4-compressed kernels
  Roll recipe dependencies (trivial).
  dev_container: Pass proxy setting
  Roll recipe dependencies (trivial).
  hypervisor: haxm: Update bindings
  Roll recipe dependencies (trivial).
  hypervisor: haxm: Disable read-only memslots
  docs: Fix link to the internal uprev playbook
  e2e_tests: Revert unnecessary version bump of anyhow/libc crates
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  ...

Bug: 320546603
Test: boot CF
Change-Id: I3e95152dc161e792dff2cb1012d71d489527632b
2024-01-26 14:19:05 -08:00
David Brazdil
d04f288a7a kernel_loader: Add support for LZ4-compressed kernels
Kernel images are often stored compressed because they can take up a
significant amount of disk space. One of the popular formats for this is
LZ4. Even though it does not offer the best compression ratio, it excels
at decompression speeds.

On arm64, kernels do not come with their own decompressor like they do
on x86. Instead, it is the job of the bootloader to decompress the
kernel before it is executed.

To this end, add crosvm support for LZ4 decompression of kernel images,
via the Rust-safe lz4_flex library. LZ4 file format is detected
automatically via one of its magic numbers. Otherwise crosvm will fall
back to loading the kernel as a raw image.

Some rough numbers using Android's Generic Kernel Image on Pixel 8:
 * compresion rate: 49% (33MB -> 16MB)
 * decompression time: 20-30ms
Given that the total VM boot takes about 1.5s, the overhead is more than
acceptable.

BUG=b:315141974
TEST=tools/dev_container tools/run_tests --platform=aarch64

Change-Id: I1030abe6fdf7087603cea9ac5273bf9136bad693
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5110323
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: David Brazdil <dbrazdil@google.com>
2024-01-24 22:48:25 +00:00
Pawan Wagh
c8efbbac3c Merge remote-tracking branch 'aosp/upstream-main' into merge
* aosp/upstream-main: (39 commits)
  devices: virtcpufreq: Add scaling factor to UClamp applied
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  seccomp: Add a policy for pvclock device
  e2e_tests: Update use_local_build.sh to include the initrd env var
  aarch64: fdt: Update compatible string for virt cpufreq
  hypervisor: x86: Add MSR allowlist and restore MSRs 1 at a time
  jail: seccomp: fix missing syscall for fs on arm
  Roll recipe dependencies (trivial).
  Clone host CPU capacity/clusters for --host-cpu-topology
  Roll recipe dependencies (trivial).
  swap: prevent guest memory in the main process munmap(2)ed
  swap: do not panic if main process dies while swapping in
  swap: do not panic on tube errors
  Roll recipe dependencies (trivial).
  devices: disable read-only memslots based on hypervisor
  hypervisor: kvm: Fix xsave size when Xsave2 is not supported
  jail: seccomp: add missing battery syscalls on non-x86
  book: Use v6.6 termina kernel in custom_kernel_rootfs
  linux_input_sys: simplify input event decoders
  ...

Bug: 319252379
Test: atest --test-mapping external/crosvm
Change-Id: I68e9777dfa707df75af64e1b66e2229bdd7b88a7
2024-01-16 21:04:50 +00:00
Daniel Verkamp
c970dd44f4 bindgen: update to Linux 6.6 headers
The obsolete KVM_SET_MEMORY_ALIAS ioctl was removed from the kernel; it
was already unused in crosvm, so remove the corresponding ioctl macro.

Change-Id: I1ecfce4b8df886680154c567f82ab7f006fbfd1f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5178535
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2024-01-09 00:37:43 +00:00
Daniel Verkamp
ae33ac2934 bindgen: regenerate all bindings with bindgen 0.68.1
This removes some auto-generated safety comments, but should otherwise
be a no-op.

Change-Id: Ibfcf75c6e296367fe1a6114ce2047fb79e34041b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5178534
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2024-01-09 00:37:43 +00:00
Frederick Mayle
4693681746 Merge commit 'aosp/upstream-main' (4 of n)
* commit '8aabb8d9': (268 commits)
  Update to syn-2
  devices: vsock: add connection logging for Windows.
  cros_tracing: fix interface drift.
  devices: virtio: scsi: Raise error when trying to modify a read-only disk
  e2e_tests: scsi: Add test cases for discard operations.
  docs: Add SCSI section.
  base: unix: return Vec<SafeDecriptor> from recv_with_fds()
  base: unix: rework ScmSocket send/recv functions
  Only support cpufreq on arm/aarch64
  base: add IoBuf/IoBufMut mut slice conversions
  vmm_vhost: eliminate locking in SlaveReqHandler and merge traits
  vmm_vhost: simplify Slave
  vmm_vhost: eliminate locking in MasterReqHandler and merge traits
  Don't expose `base::platform` as a public interface
  usb: refactor transfer structs for multi backends
  devices: virtio: scsi: Change the queue size.
  devices: vhost-user: console: clean up arg parsing
  hypervisor/README.md: add qualcomm contacts for gunyah
  vmm_vhost: remove type parameter from PlatformConnection
  vmm_vhost: simplify backend request connection creation
  ...

Bug: 307396704
Test: .
Change-Id: I35c8de63abb6ae8e20df78060e16dbb77e1454a9
2023-12-19 10:49:43 -08:00
Daniel Verkamp
fcc28f5573 data_model: move IoBuf and VolatileMemory to base
IoBuf is defined in a platform-specific way (it is either iovec on unix
or WSABUF for windows), so it fits into the mission statement of the
base crate, which is meant to be *the* platform abstraction layer in
crosvm.

IoBufMut and VolatileMemory/VolatileSlice are defined in terms of IoBuf,
so they are also moved into base for consistency. Every crate that uses
these types already depended on base, so no extra dependencies are
added, and a few can be removed.

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

Change-Id: I4dddc55d46906dfc55b88e8e6a967d7e1c1922dd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5046605
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-11-27 21:42:49 +00:00
Daniel Verkamp
be33277580 base: remove read_from/write_to_memory
These duplicate existing VolatileSlice and FileReadWriteAtVolatile
functionality. Removing them means that they don't need to be
reimplemented separately for each platform's MemoryMapping.

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

Change-Id: Ia4332159461efc001b4e980fdb2a9984e852c931
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5019440
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-11-10 18:41:10 +00:00
Devin Moore
1ba4fc65a4 Merge remote-tracking branch 'aosp/upstream-main' into merge
* aosp/upstream-main:
  devices: vmwdt: Fix race condition on VM reset
  base: upstream get_allocated_ranges
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  devices: proxy: remove socket timeout
  base: add helper to blockingly read overlapped file
  base: upstream changes to make device_io_control more generic
  devices: virtio: pass DescriptorChain to pop_peeked()
  data_model: eliminate unsafe code in zerocopy_from_reader()
  cros_fdt: Rename FdtWriter to Fdt
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  devices: virtio: queue: add PeekedDescriptorChain
  gpu: enable astc emulation for arcvm
  Roll recipe dependencies (trivial).
  devices: vsock: send reset on restore.
  devices: usb: Add the OWNERS file
  Roll recipe dependencies (trivial).

Test: m && launch_cvd
Bug: 305956161
Change-Id: Ia638e50a85264b011b2d842092845e9c1bcc8b90
2023-10-17 18:31:19 +00:00
Daniel Verkamp
13505b2b9e data_model: eliminate unsafe code in zerocopy_from_reader()
Rather than using MaybeUninit to create a zeroed instance of a type and
std::slice::from_raw_parts_mut() to get a mutable &[u8] referring to it,
we can use the zerocopy 0.7 FromZeroes trait new_zeroed() function and
the AsBytes + FromBytes as_bytes_mut() function to read from the reader
into the type as a mutable &[u8].

This removes all of the unsafe code in the zerocopy_from_reader()
function.

BUG=None
TEST=tools/dev_container tools/presubmit

Change-Id: I76b12b69b02e807a3e52ac9b9e7e7165ee1f55f4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4939612
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-10-16 17:49:03 +00:00
Frederick Mayle
ed50c9986c Revert^2 "Merge remote-tracking branch 'aosp/upstream-main'"
70cd6bf4d6

Change-Id: I6d4e43c5ab6aa3c01ab42ce8def24db5a419249d
2023-10-15 18:27:41 +00:00
Frederick Mayle
70cd6bf4d6 Revert "Merge remote-tracking branch 'aosp/upstream-main'"
Revert submission 2786927-fmayle-zerocopy-update

Reason for revert: broke build

Reverted changes: /q/submissionid:2786927-fmayle-zerocopy-update

Change-Id: I80fb748084467e5f70d9c182bcbb34a687dc7c3f
2023-10-15 03:50:34 +00:00
Frederick Mayle
ccb77cd8f1 Merge remote-tracking branch 'aosp/upstream-main'
* aosp/upstream-main: (49 commits)
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  data_model: replace loop with Vec::resize_with()
  vfio_sys: undo non-upstream change and add it with --raw-line
  rustfmt: add rules for imports
  devices: usb: clean up zerocopy usage
  devices: xhci: clean up wildcard imports
  Rename "unix" to "linux" in code and docs
  Replace #[cfg(unix)] with #[cfg(any(target_os = "android", target_os = "linux"))]
  bindgen: regenerate bindings with bindgen 0.68.1
  crosvm: Remove DataInit
  kvm_sys: Update bindings
  Roll recipe dependencies (trivial).
  crosvm: Uprev zerocopy to 0.7.x
  Roll recipe dependencies (trivial).
  devices: virtio: scsi: Implement READ_CAPACITY, READ_6, READ_10, and WRITE_10
  devices: virtio: scsi: Return Result<(), ExecuteError> in emulate() methods.
  Roll recipe dependencies (trivial).
  Cargo.toml: remove chromeos from base and devices
  Roll recipe dependencies (trivial).
  ...

Bug: 303132091
Test: TH
Change-Id: I82e2f6e59013c353e94646509310f9ed5dd1ab98
2023-10-12 14:18:37 -07:00
Daniel Verkamp
931fcafe0b bindgen: regenerate bindings with bindgen 0.68.1
In particular, this fixes the Clone impl for __BindgenUnionField, which
triggers clippy's incorrect_clone_impl_on_copy_type in Rust 1.73.

Additionally, --size_t-is-usize became the default and the option was
removed in bindgen 0.65.0, so the flag is dropped from our bindgen
command line.

BUG=None
TEST=tools/bindgen-all-the-things

Change-Id: I40a26cd4a9e2897af8a354f454f4909429d2feda
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4927831
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-10-10 22:54:22 +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
Elie Kheirallah
bd865eb659 Merge remote-tracking branch 'aosp/upstream-main' into merge
* aosp/upstream-main: (41 commits)
  Rename struct Window to GuiWindow.
  Replace thread messages with a message router window.
  devices: virtio: snd: Always generate new StreamSource in Prepare
  Roll recipe dependencies (trivial).
  virtio_sys: fix ID for pvclock.
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  plugin: add cfg checks for net feature
  base: windows: tube: simplify reading of MsgHeader
  Roll recipe dependencies (trivial).
  e2e_tests/guest_under_test: Fix Makefile
  Fix some cargo doc warnings in Windows-only code
  devices: usb: Demote the "cycle bit mismatch" message to debug
  tools: fix unit test filter
  devices: virtio: scsi: Implement TEST_UNIT_READY and REPORT_LUNS.
  devices: virtio: scsi: Implement INQUIRY command
  devices: virtio: scsi: Introduce Sense
  devices: virtio: scsi: Receive commands from virtqueue
  devices: virtio: scsi: Make scsi option experimental
  cros_tracing_analyser: Add events for flamegraph
  ...

Bug: 301274839
Test: atest --test-mapping external/crosvm
Change-Id: I150b81ce68fd5d95a8faaafdb5cc1f0cb03d9b6c
2023-09-25 20:04:10 +00:00
Daniel Verkamp
03dd1feab7 Cargo.toml: depend on zerocopy 0.6 explicitly
Previously all of the zerocopy imports just used "*", but there are
API changes in zerocopy 0.7, so ensure we get a compatible version by
depending on 0.6 everywhere.

This is a no-op since Cargo.lock already specifies a 0.6.x version, but
it will prevent accidentally upgrading to 0.7.x without updating to the
new API.

BUG=b:301283548
TEST=cargo build

Change-Id: Ifd702d982a09b5083dddd666dc6f3052cba22214
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4878502
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-09-20 21:28:58 +00:00
Steven Moreland
a14178eb69 Merge remote-tracking branch 'aosp/upstream-main' into merge
* aosp/upstream-main: (57 commits)
  data_model: Reland remove VolatileRef
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  kernel_loader: Use Linux UAPI header for bindings
  devices: Add trace point for virtio-net
  Roll recipe dependencies (trivial).
  devices: usb: Implement Reset Endpoint command handler
  devices: usb: Handle stall error
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  swap: add tests for UffdList
  clippy fixes for Rust 1.69
  swap: move UffdList into a single file
  swap: add SwapDeviceHelper for forking grand-child processes
  swap: garbage collect uffds for detached hot plug devices
  devices: irqchip: fix compiler error on riscv64
  data_model: windows: panic if IoBuf len is too large
  Roll recipe dependencies (trivial).
  ...

Bug: 284966293
Test: atest # cf TEST_MAPPING
Change-Id: Icf621d83cf587189b0b2cab67ba343388755fb6b
2023-05-30 18:16:27 +00:00
Keiichi Watanabe
c29732e2ea kernel_loader: Use Linux UAPI header for bindings
We should use UAPI headers, whose license is "GPL-2.0 WITH
Linux-syscall-note".

BUG=none
TEST=cargo build

Change-Id: I610f15f633f2ffe9ea0b4e56eb4b12aed1393e7c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4567976
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
2023-05-30 12:21:18 +00:00
Elie Kheirallah
3d37a0fbc4 Merge remote-tracking branch 'aosp/upstream-main' into merge
* aosp/upstream-main: (120 commits)
  presubmit: Run tests/builds with verbose output
  infra: Fix git unshallow in chromeos_hatch builder
  win_util: remove build.rs script
  dev_container: Add riscv64 support
  Add riscv target to main crosvm build
  riscv: limit dependencies to riscv builds
  crosvm: Uprev cbindgen dependency
  presubmit: Check lockfiles first
  presubmit: Remove crosvm direct build
  tools/presubmit: Add doctests
  seccomp: Add riscv64 policies
  devices: Add riscv irqchip support
  hypervisor: add riscv64 kvm support
  arch: Import riscv types when building that arch
  Add riscv arch crate
  devices: gpu: Add some log when gpu boots.
  dev_container: Always run as root inside container
  Revert "devices: Add some log for debugging purpose."
  rutabaga_gfx: nuke unnecessary gfxstream flags
  crosvm: cmdline: allow `cfg` to be used in configuration files
  ...

Bug: 277761955
Test: atest --test-mapping external/crosvm
Change-Id: I300216e9119766693308e4acd926922066319f8c
2023-04-28 15:08:37 +00:00
Daniel Verkamp
2c1d17fe41 tree-wide: remove unnecessary casts
Fixes clippy lint in Rust 1.68

BUG=b:276487055
TEST=tools/clippy # with rust 1.68

Change-Id: Ib9d83b8dc15a93e815600391e93b8bb1788f7dc4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4391107
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-17 23:43:59 +00:00
Frederick Mayle
82d28fc3d7 Merge remote-tracking branch 'aosp/upstream-main'
* aosp/upstream-main: (56 commits)
  swap: add trim command
  swap: introduce BackgroundJobControl for background jobs
  aarch64: Allow hypervisor to initialize boot context
  arch: Create GuestMemory with MemoryRegionOptions
  vm_memory: guest_memory: Add MemoryRegionOptions
  vm_memory: Convert GuestMemory::with_regions to use struct argument
  hypervisor: Allow for hypervisor-specific DT additions
  tools: Add PGO support
  x86_64: clarify cpuid leaf 0x15 TSC calibration
  testvm: Rebuild VM images
  crosvm: restore vCPUs during "cold restore"
  Roll recipe dependencies (trivial).
  crosvm_cli: implement exit_context() for Option
  Roll recipe dependencies (trivial).
  dev_container: Add strace to dependency
  tools: Collect syscall frequency stats via bench
  Roll recipe dependencies (trivial).
  rutabaga_gfx: gfxstream: enable stronger versioning
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  ...

Test: booted CF
Bug: 275386231
Change-Id: Id702d13eddc837a0eadaff38e7098434130db7ac
2023-03-31 11:17:23 -07:00
Zihan Chen
bbc4f68ebb crosvm: Convert DataInit to zerocopy 10/n
We are down to only 30 `unsafe impl DataInit` across our repo now!

TEST=CQ

BUG=b:204409584

Change-Id: I1b6cf95b2a15eac194f3b464330009fd898a0bfa
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4356907
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-03-24 18:12:38 +00:00
Elie Kheirallah
4a42fb3789 Merge remote-tracking branch 'aosp/upstream-main' into merge
* aosp/upstream-main: (40 commits)
  Reland "docs: book: fix memory layout source links and line numbers"
  Reland "x86_64: place setup_data immediately after cmdline"
  cros_fdt: remove max_size from FdtWriter::finish()
  Roll recipe dependencies (trivial).
  devices: virtio: block: test resize and reset
  Roll recipe dependencies (trivial).
  gpu_display: find wayland-scanner with which in build.rs
  Roll recipe dependencies (trivial).
  devices: block: fix race condition causing panic on shutdown
  tools: Do not use pip to install python packages
  devices: use fork_process() from ProxyDevice::new()
  infra: Use tools/run_tests instead of run_tests2 alias
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  e2e_tests: Restructure for initial benchmark support
  bindgen: update kernel bindings to Linux 6.1
  audio_streams: Implement Serialize and Deserialize for StreamEffect
  devices: convert various devices to use WorkerThread
  ...

Bug: 270404912
Test: m && launch_cvd
Test: atest --test-mapping external/crosvm

Change-Id: I5114fe8b06fa53f82ea947d690459684254707cf
2023-02-28 19:19:41 +00:00
Daniel Verkamp
2712fc59b1 bindgen: update kernel bindings to Linux 6.1
Switch to the ChromeOS v6.1 branch and regenerate all affected bindings
in the crosvm tree.

Some minor fixes were required in users of the bindings:
- KVM_SYSTEM_EVENT_RESET_FLAG_PSCI_RESET2 is available in the kernel now
  and was removed from the manually-added section of kvm_sys.
- The KVM system_event now contains an anonymous union, requiring a few
  renames.
- IORING_OP_* were moved into an enum, which required the enum name to
  be prefixed to the uses of those values.

BUG=None
TEST=tools/presubmit --all

Change-Id: I84568fb76658832130e2e9a631495ba82fd4c3ed
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4285742
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-02-23 21:31:44 +00:00
Frederick Mayle
cb2b2c9b9e ANDROID: add layer of indirection to crosvm_defaults module
Bug: 269356487
Test: m
Change-Id: I1079c5602219eb647875c23d383f26695142ab84
2023-02-15 15:57:00 -08:00
Steven Moreland
b68a6374ce Merge remote-tracking branch 'aosp/upstream-main' into merge
Bug: 268061413
Test: TEST_MAPPING

* aosp/upstream-main:
  Roll recipe dependencies (trivial).
  swap: refine swap status response
  base: fix mmap doc test on Windows.
  Roll recipe dependencies (trivial).
  tools: make scripts windows/downstream friendly
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  crosvm: unix: add bind_mounts to SandboxConfig
  crosvm: unix: refactor the interface of jail_helpers
  Roll recipe dependencies (trivial).
  New nextest based test runner
  Roll recipe dependencies (trivial).
  base: Add custom_serde lib for custom serializers
  Roll recipe dependencies (trivial).
  Roll recipe dependencies (trivial).
  devices: use base::error instead of eprintln
  e2e_tests: suspend_resume: consume exec_command_async response
  crosvm: Partially convert DataInit to zerocopy (1/n)
  Roll recipe dependencies (trivial).

Change-Id: I6339fed9f53069fba52015987657c6c5167386a1
2023-02-06 22:40:00 +00:00