No description
Find a file
Daniel Verkamp b4244d3952 kernel_loader: load ELF kernels at the right paddr
Previously, we were loading ELF kernels at the provided kernel_start
address plus the p_paddr (physical address) field of each program
header. This resulted in the kernel being loaded after a big gap of
zero bytes, which accidentally worked on x86_64 because 0x00 0x00
encodes a valid instruction, and the entry point was at the beginning of
the first section, so execution would effectively "nop slide" its way
from the supposed entry point all the way to the actual beginning of the
correct code. In addition, the Linux kernel entry point is compiled as
position-independent code, so the mismatched address did not matter.

Fix this by loading ELF kernels at whatever physical address they
specify, without adding any extra offset. The load_kernel() function
still accepts a start address, but this is now used simply to verify
that the ELF file does not try to load any sections outside of the
desired kernel region.

As a demonstration, we can look at the instructions at the kernel's
declared entry point (0x1000000 for a normal x86-64 Linux kernel in ELF
format) by attaching to the gdb stub and running:

   (gdb) disas 0x1000000,+8

With the old behavior, we get purely 0x00 0x00 opcodes, decoding as:
   0x0000000001000000:  add    BYTE PTR [rax],al
   0x0000000001000002:  add    BYTE PTR [rax],al
   0x0000000001000004:  add    BYTE PTR [rax],al
   0x0000000001000006:  add    BYTE PTR [rax],al

With the new behavior, we get the correct entry point instructions:
   0x0000000001000000:  lea    rsp,[rip+0x1203f51]        # 0x2203f58
   0x0000000001000007:  lea    rdi,[rip+0xfffffffffffffff2] # 0x1000000

BUG=b:234155022
TEST=cargo test -p kernel_loader
TEST=Boot x86-64 ELF vmlinux kernel

Change-Id: Iae4c8db022674e6311e54dffe479a1ed430a1ef4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3673612
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Anton Romanov <romanton@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-06-23 22:30:37 +00:00
.cargo Run some win64 tests with wine as part of presubmit 2022-04-06 19:45:49 +00:00
.devcontainer Make vscode devcontainer usable 2022-01-25 21:30:49 +00:00
.github Reland "github: Minimize dependencies for document generation" 2022-04-12 22:30:10 +00:00
aarch64 kernel_loader: load ELF kernels at the right paddr 2022-06-23 22:30:37 +00:00
acpi_tables doc: add a top-level comment to all crates 2022-05-06 20:46:57 +00:00
arch devices: pci: support hotplugged pci bus to be removed from tree 2022-06-23 17:44:21 +00:00
argh_helpers crosvm: move run command to argh 2022-06-13 23:55:20 +00:00
base base: log with local timestamps instead of UTC 2022-06-23 17:04:25 +00:00
bin Deprecate old dev tooling scripts 2021-11-02 22:23:03 +00:00
bit_field crosvm: migrate to Rust 2021 edition 2022-03-09 01:16:03 +00:00
broker_ipc broker_ipc: fix child process logging init order. 2022-06-23 17:04:27 +00:00
ci/kokoro ci: kokoro: Add presubmit configs for x86_64-direct 2022-06-23 22:04:33 +00:00
common common/sync: Bump the version to 0.1.99. 2022-06-21 18:02:52 +00:00
cros_async cros_async: add async_from_local() 2022-06-08 02:29:19 +00:00
crosvm-fuzz devices: virtio: convert Interrupt to use IrqLevelEvent 2022-04-06 18:54:41 +00:00
crosvm_control crosvm_control: Add shared and unevictable memory to BalloonStats 2022-06-23 03:10:51 +00:00
crosvm_plugin Rust 1.60 clippy fixes 2022-04-11 20:40:36 +00:00
devices crosvm: Pass down CpuidResult instead. 2022-06-23 22:17:13 +00:00
disk disk: upstream windows support 2022-05-19 18:25:30 +00:00
docs/book docs: book: add documentation for the video device 2022-06-21 05:18:01 +00:00
fuse doc: add a top-level comment to all crates 2022-05-06 20:46:57 +00:00
gpu_display devices: enable tests 2022-06-23 00:26:06 +00:00
hypervisor x86_64: pass initial registers in VcpuInit 2022-06-23 22:30:34 +00:00
infra infra: Add crosvm_windows builder 2022-06-23 22:23:54 +00:00
integration_tests tools: Add crosvm-direct support for run_tests 2022-06-22 21:51:53 +00:00
io_uring base: remove WatchingEvents in favor of EventType 2022-06-06 17:07:33 +00:00
kernel_cmdline crosvm: migrate to Rust 2021 edition 2022-03-09 01:16:03 +00:00
kernel_loader kernel_loader: load ELF kernels at the right paddr 2022-06-23 22:30:37 +00:00
kvm base: clarify SharedMemory API 2022-06-01 03:55:47 +00:00
kvm_sys crosvm: Enable windows tests for a few crates 2022-06-07 14:37:43 +00:00
libcras_stub crosvm: migrate to Rust 2021 edition 2022-03-09 01:16:03 +00:00
linux_input_sys doc: add a top-level comment to all crates 2022-05-06 20:46:57 +00:00
logo README: Use PNG logo image 2021-10-29 01:56:23 +00:00
media virtio: video: decoder: add ffmpeg-based software decoder backend 2022-06-07 11:44:21 +00:00
metrics crosvm: replace lazy_static with once_cell 2022-06-21 23:40:55 +00:00
net_sys doc: add a top-level comment to all crates 2022-05-06 20:46:57 +00:00
net_util Use 4-space indent in cfg_if treewide 2022-06-07 17:36:51 +00:00
power_monitor crosvm: build/test few more crates on windows 2022-06-22 00:48:23 +00:00
protos doc: add a top-level comment to all crates 2022-05-06 20:46:57 +00:00
qcow_utils doc: add a top-level comment to all crates 2022-05-06 20:46:57 +00:00
resources resources: introduce AddressRange type 2022-06-16 20:29:26 +00:00
rutabaga_gfx rutabaga_gfx: Upstream cross_domain.rs 2022-06-13 17:34:42 +00:00
seccomp Remove madvise from *_audio_device.policy. 2022-06-22 23:08:02 +00:00
serde_keyvalue serde_keyvalue: parse hex, octal, and binary nums 2022-06-02 22:03:20 +00:00
src crosvm: re-add '-d' short arg 2022-06-23 03:27:27 +00:00
system_api_stub crosvm: migrate to Rust 2021 edition 2022-03-09 01:16:03 +00:00
tests crosvm: replace lazy_static with once_cell 2022-06-21 23:40:55 +00:00
third_party devices: vhost-user: handler: make run_with_listener() generic 2022-06-08 02:29:21 +00:00
tools tools: install-deps: add libva-dev and libudev-dev as dependencies 2022-06-23 01:12:15 +00:00
tpm2 doc: add a top-level comment to all crates 2022-05-06 20:46:57 +00:00
tpm2-sys doc: add a top-level comment to all crates 2022-05-06 20:46:57 +00:00
tracing tracing: Add noop tracing 2022-06-16 21:13:55 +00:00
tube_transporter tube_transporter: Upstream this Window's specific crate 2022-04-20 01:24:35 +00:00
usb_sys doc: add a top-level comment to all crates 2022-05-06 20:46:57 +00:00
usb_util doc: add a top-level comment to all crates 2022-05-06 20:46:57 +00:00
vfio_sys Revert "direct_irq: Add support for host wakeup capable IRQs" 2022-05-19 14:28:46 +00:00
vhost crosvm: enable windows tests for vhost crate 2022-06-07 20:46:28 +00:00
virtio_sys virtio: create a DeviceType wrapper enum 2022-05-10 21:00:07 +00:00
vm_control vm_control: clarify that USB attach only uses dev_path 2022-06-17 23:18:24 +00:00
vm_memory crosvm: Enable vm_memory tests on windows 2022-06-07 16:31:38 +00:00
win_audio win_audio: Upstream Window's audio crate 2022-06-10 19:04:05 +00:00
win_util crosvm: replace lazy_static with once_cell 2022-06-21 23:40:55 +00:00
x86_64 kernel_loader: load ELF kernels at the right paddr 2022-06-23 22:30:37 +00:00
.dockerignore add docker supported builds and tests 2019-05-15 13:36:19 -07:00
.gitignore infra: Initial setup of linux pre/post-submit builders 2022-05-24 23:13:13 +00:00
.gitmodules Switch to submodules based workflow 2021-08-05 18:32:32 +00:00
.rustfmt.toml rustfmt, win_util: update to 2021 edition 2022-05-31 23:35:02 +00:00
ARCHITECTURE.md base: replace PollToken with EventToken tree-wide 2022-06-02 22:30:38 +00:00
Cargo.toml crosvm: replace lazy_static with once_cell 2022-06-21 23:40:55 +00:00
CONTRIBUTING.md Add documentation for ChromeOS workflows 2022-04-18 19:05:49 +00:00
LICENSE add LICENSE and README 2017-04-17 14:06:21 -07:00
navbar.md docs: Use mdformat to format markdown files 2022-01-27 21:29:11 +00:00
OWNERS Adding Vikram to crosvm OWNERS 2022-06-06 17:20:10 +00:00
PRESUBMIT.cfg Add check_cq_depend to PRESUBMIT 2022-05-18 18:54:34 +00:00
README.chromeos.md Add documentation for ChromeOS workflows 2022-04-18 19:05:49 +00:00
README.md Add new email lists to README.md and book 2022-06-13 19:39:11 +00:00
run_tests Deprecate old dev tooling scripts 2021-11-02 22:23:03 +00:00
rust-toolchain Upgrade rust toolchain version to 1.58.1 2022-02-04 02:20:36 +00:00
setup_cros_cargo.sh Deprecate old dev tooling scripts 2021-11-02 22:23:03 +00:00
test_all Deprecate old dev tooling scripts 2021-11-02 22:23:03 +00:00
unblocked_terms.txt unblocked_terms.txt: clean up trivial cases 2021-04-26 20:32:38 +00:00

crosvm - The Chrome OS 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 Chrome OS 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 Chrome OS devices.

Logo