No description
Find a file
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
.cargo clippy: Disallow len_without_is_empty and len_zero 2023-05-22 21:27:21 +00:00
.config Enable test retries in nextest 2023-06-07 17:43:18 +00:00
.devcontainer dev_container: Replace better toml extension 2023-07-27 23:37:15 +00:00
.github Cleanup: Remove old, deprecated and no longer used files 2022-09-20 21:05:57 +00:00
.vscode Document feature flags and introduce new feature sets 2022-10-14 20:31:19 +00:00
aarch64 cros_fdt: Rename FdtWriter to Fdt 2023-10-16 11:04:06 +00:00
acpi_tables crosvm: Uprev zerocopy to 0.7.x 2023-10-10 17:34:32 +00:00
arch cros_fdt: Rename FdtWriter to Fdt 2023-10-16 11:04:06 +00:00
argh_helpers Update all copyright headers to match new style 2022-09-13 18:41:29 +00:00
audio_streams_conformance_test Rename "unix" to "linux" in code and docs 2023-10-11 01:15:07 +00:00
audio_util tree-wide: apply nightly rustfmt 2023-03-27 21:30:45 +00:00
base Rename "unix" to "linux" in code and docs 2023-10-11 01:15:07 +00:00
bit_field bit_field: suppress clippy cast warnings 2023-04-10 23:41:28 +00:00
broker_ipc crash_report: refactor product specific code 2023-06-09 23:10:04 +00:00
common data_model: eliminate unsafe code in zerocopy_from_reader() 2023-10-16 17:49:03 +00:00
cros_async Rename "unix" to "linux" in code and docs 2023-10-11 01:15:07 +00:00
cros_fdt cros_fdt: Rename FdtWriter to Fdt 2023-10-16 11:04:06 +00:00
cros_tracing Add AOT for GPU display. 2023-09-20 17:17:11 +00:00
cros_tracing_types Upstream cros_tracing_types. 2023-05-11 18:08:00 +00:00
crosvm_cli Fix some cargo doc warnings in Windows-only code 2023-09-22 00:59:46 +00:00
crosvm_control Replace #[cfg(unix)] with #[cfg(any(target_os = "android", target_os = "linux"))] 2023-10-11 00:43:29 +00:00
crosvm_plugin Replace #[cfg(unix)] with #[cfg(any(target_os = "android", target_os = "linux"))] 2023-10-11 00:43:29 +00:00
devices devices: virtio: queue: add PeekedDescriptorChain 2023-10-13 18:28:20 +00:00
disk Rename "unix" to "linux" in code and docs 2023-10-11 01:15:07 +00:00
docs/book Rename "unix" to "linux" in code and docs 2023-10-11 01:15:07 +00:00
e2e_tests Rename "unix" to "linux" in code and docs 2023-10-11 01:15:07 +00:00
fuse Replace #[cfg(unix)] with #[cfg(any(target_os = "android", target_os = "linux"))] 2023-10-11 00:43:29 +00:00
fuzz Replace #[cfg(unix)] with #[cfg(any(target_os = "android", target_os = "linux"))] 2023-10-11 00:43:29 +00:00
gpu_display Rename "unix" to "linux" in code and docs 2023-10-11 01:15:07 +00:00
hypervisor cros_fdt: Rename FdtWriter to Fdt 2023-10-16 11:04:06 +00:00
infra Roll recipe dependencies (trivial). 2023-10-13 22:07:55 +00:00
io_uring Replace #[cfg(unix)] with #[cfg(any(target_os = "android", target_os = "linux"))] 2023-10-11 00:43:29 +00:00
jail Replace #[cfg(unix)] with #[cfg(any(target_os = "android", target_os = "linux"))] 2023-10-11 00:43:29 +00:00
kernel_cmdline Rust 1.65: Fix clippy derive_partial_eq_without_eq lints 2022-12-01 01:32:30 +00:00
kernel_loader data_model: eliminate unsafe code in zerocopy_from_reader() 2023-10-16 17:49:03 +00:00
kvm Replace #[cfg(unix)] with #[cfg(any(target_os = "android", target_os = "linux"))] 2023-10-11 00:43:29 +00:00
kvm_sys Replace #[cfg(unix)] with #[cfg(any(target_os = "android", target_os = "linux"))] 2023-10-11 00:43:29 +00:00
libcras_stub devices: snd: Use PCM device client_type and stream_type for CRAS 2023-03-02 06:22:40 +00:00
linux_input_sys crosvm: Uprev zerocopy to 0.7.x 2023-10-10 17:34:32 +00:00
logo README: Use PNG logo image 2021-10-29 01:56:23 +00:00
media Replace #[cfg(unix)] with #[cfg(any(target_os = "android", target_os = "linux"))] 2023-10-11 00:43:29 +00:00
metrics Rename "unix" to "linux" in code and docs 2023-10-11 01:15:07 +00:00
net_sys Fix remaining Chrome/Chromium OS instances 2023-01-03 22:14:30 +00:00
net_util Rename "unix" to "linux" in code and docs 2023-10-11 01:15:07 +00:00
perfetto Replace #[cfg(unix)] with #[cfg(any(target_os = "android", target_os = "linux"))] 2023-10-11 00:43:29 +00:00
power_monitor Cargo.toml: upgrade protobuf 2.x -> 3.x 2023-04-28 19:32:01 +00:00
prebuilts Rename "unix" to "linux" in code and docs 2023-10-11 01:15:07 +00:00
proto_build_tools Cargo.toml: upgrade protobuf 2.x -> 3.x 2023-04-28 19:32:01 +00:00
protos Replace #[cfg(unix)] with #[cfg(any(target_os = "android", target_os = "linux"))] 2023-10-11 00:43:29 +00:00
resources Remove virtio-vhost-user (VVU) support 2023-09-05 17:59:33 +00:00
riscv64 cros_fdt: Rename FdtWriter to Fdt 2023-10-16 11:04:06 +00:00
rutabaga_gfx Rename "unix" to "linux" in code and docs 2023-10-11 01:15:07 +00:00
sandbox Add paste handling into the emulator 2023-09-08 21:29:23 +00:00
serde_keyvalue serde_keyvalue: add tests for outer-braces in arguments 2023-06-09 04:59:54 +00:00
src gpu: enable astc emulation for arcvm 2023-10-13 14:58:34 +00:00
swap Rename "unix" to "linux" in code and docs 2023-10-11 01:15:07 +00:00
system_api Replace #[cfg(unix)] with #[cfg(any(target_os = "android", target_os = "linux"))] 2023-10-11 00:43:29 +00:00
tests Rename "unix" to "linux" in code and docs 2023-10-11 01:15:07 +00:00
third_party Rename "unix" to "linux" in code and docs 2023-10-11 01:15:07 +00:00
tools Rename "unix" to "linux" in code and docs 2023-10-11 01:15:07 +00:00
tube_transporter Fix some cargo doc warnings in Windows-only code 2023-09-22 00:59:46 +00:00
usb_sys devices: usb: Add the OWNERS file 2023-10-13 01:34:19 +00:00
usb_util devices: usb: Add the OWNERS file 2023-10-13 01:34:19 +00:00
vendor Replace #[cfg(unix)] with #[cfg(any(target_os = "android", target_os = "linux"))] 2023-10-11 00:43:29 +00:00
vfio_sys vfio_sys: undo non-upstream change and add it with --raw-line 2023-10-11 18:06:09 +00:00
vhost Rename "unix" to "linux" in code and docs 2023-10-11 01:15:07 +00:00
virtio_sys crosvm: Uprev zerocopy to 0.7.x 2023-10-10 17:34:32 +00:00
vm_control Rename "unix" to "linux" in code and docs 2023-10-11 01:15:07 +00:00
vm_memory Rename "unix" to "linux" in code and docs 2023-10-11 01:15:07 +00:00
win_audio win_audio: Upstream changes 2023-10-02 21:13:40 +00:00
win_util Fix some cargo doc warnings in Windows-only code 2023-09-22 00:59:46 +00:00
x86_64 cros_fdt: Rename FdtWriter to Fdt 2023-10-16 11:04:06 +00:00
.dockerignore add docker supported builds and tests 2019-05-15 13:36:19 -07:00
.envrc Automatically register tools/ on PATH 2023-03-03 00:33:15 +00:00
.gitignore Automatically register tools/ on PATH 2023-03-03 00:33:15 +00:00
.gitmodules devices: remove --software-tpm support 2023-10-02 23:28:45 +00:00
.rustfmt.toml rustfmt: add rules for imports 2023-10-11 14:54:30 +00:00
ARCHITECTURE.md docs: book: update architecture docs 2023-06-01 22:37:17 +00:00
Cargo.lock crosvm: Remove DataInit 2023-10-10 19:40:48 +00:00
Cargo.toml Replace #[cfg(unix)] with #[cfg(any(target_os = "android", target_os = "linux"))] 2023-10-11 00:43:29 +00:00
CONTRIBUTING.md Replace #[cfg(unix)] with #[cfg(any(target_os = "android", target_os = "linux"))] 2023-10-11 00:43:29 +00:00
DIR_METADATA DIR_METADATA: Add public buganizer component 2022-09-21 17:43:59 +00:00
LICENSE Update all copyright headers to match new style 2022-09-13 18:41:29 +00:00
mypy.ini Add python configs for consistency between IDE and CI 2022-08-16 18:33:23 +00:00
OWNERS OWNERS: Add takayas@ to OWNERS 2023-04-24 11:15:25 +00:00
OWNERS_COUNCIL Require council review for changes to Cargo.lock 2022-12-01 18:50:48 +00:00
PRESUBMIT.cfg Cleanup: Remove old, deprecated and no longer used files 2022-09-20 21:05:57 +00:00
pyproject.toml Add python configs for consistency between IDE and CI 2022-08-16 18:33:23 +00:00
README.chromeos.md crosvm: update book and doc links to crosvm.dev 2022-07-29 22:54:01 +00:00
README.md Fix remaining Chrome/Chromium OS instances 2023-01-03 22:14:30 +00:00
rust-toolchain Upgrade to 1.68.2: Set default version and rebuild container 2023-05-25 18:30:55 +00:00

crosvm - The ChromeOS Virtual Machine Monitor

crosvm is a virtual machine monitor (VMM) based on Linuxs KVM hypervisor, with a focus on simplicity, security, and speed. crosvm is intended to run Linux guests, originally as a security boundary for running native applications on the ChromeOS platform. Compared to QEMU, crosvm doesnt emulate architectures or real hardware, instead concentrating on paravirtualized devices, such as the virtio standard.

crosvm is currently used to run Linux/Android guests on ChromeOS devices.

Logo