Commit graph

4224 commits

Author SHA1 Message Date
Noah Gold
2bb4f97051 base: add nanoseconds to log timestamps.
We accidentally removed nanosecond precision at some point (likely when
I redid the formatter). This CL fixes that.

BUG=b:237004396
TEST=tested format string in the playground

Change-Id: Iaa502c13c34c9cc8f4b7be05821a63c8f10cb360
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3722782
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-24 19:09:49 +00:00
Pattara Teerapong
5cf9a8fb87 devices: virtio: snd: Support num_{output,input}_devices
Add support to create multiple PCM devices in virtio-snd
in addition to multiple streams support. Android will
use different PCM devices for different use cases.

Change num_{output,input}_streams to number of streams
per device.

Changes:
- Add num_{output, input}_devices support in ChromeOS's backend
- Update num_{output, input}_streams in ChromeOS's backend
- Update help message

BUG=b:236924546
TEST=unit test for Parameters parsing
TEST=`aplay -l` with different number of output devices/streams
TEST=`arecord -l` with different number of input devices/streams

Change-Id: I29a3ecc6002ce669c5f771ef490f10419848380e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3722007
Commit-Queue: Pattara Teerapong <pteerapong@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-24 16:04:19 +00:00
Kameron Lutes
d220083da9 crosvm: Add documentation for crosvm_control
Adds documentation and best practices for the crosvm_control library.

BUG=b:188858559
TEST=cq

Change-Id: I8b03b9b78e72e0d47489d145476e33aa4310fef2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3717537
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Kameron Lutes <kalutes@chromium.org>
2022-06-24 04:55:42 +00:00
Alexandre Courbot
8297d745c6 devices: virtio: console: use ReadNotifier trait for polling
AsRawDescriptor is a very generic trait and some of the types we want to
use as input sources already implement it for other purposes.
ReadNotifier makes the purpose of the returned descriptor obvious (wait
for some data), so use it instead.

BUG=b:228912920
TEST=console device works in both regular and vhost-user modes.

Change-Id: I68a4ce05be449e07ea71e7cb472e8cda00e9d84d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3671059
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-06-24 03:19:46 +00:00
Alexandre Courbot
947754f011 devices: virtio: console: add async console device shared with vhost-user
Move the async runner of the vhost-user console device into its own
module and implement a regular VirtioDevice on top of it. This makes
both the virtio and vhost-user console devices use the same
ConsoleDevice struct and runner code, and also removes the input reader
thread from our virtio implementation.

The Windows support cannot use async and thus still needs the older
console device, so keep it around for now even though it is not used on
Linux.

BUG=b:228912920
TEST=virtio console device is working (with input) on Linux.
TEST=vhost-user console device is working (with input) on Linux.
TEST=VVU console device is working (with input) on Linux.

Change-Id: I0a8dfe6c507ef9b765d8d1cdf9870cdcd128a9aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600172
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-06-24 01:56:17 +00:00
Clarissa Garvey
3b2d0d6cfc base: Add safety comments in net.rs
Bug: b:231641496
Change-Id: If743749735190ebe41f889d781dc396e6d840b21
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3722779
Commit-Queue: Clarissa Garvey <clarissagarvey@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-23 23:37:02 +00:00
Daniel Verkamp
9fde8f499a examples/baremetal: exit instead of hanging
Use an INT3 (0xCC) instruction to cause the example to exit after
printing the message. This is more convenient than having to manually
kill crosvm from another terminal.

BUG=None
TEST=Run baremetal and observe that it exits

Change-Id: I4baeecca41d156c82bb1e1b27d0f8c2ba93959f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3691966
Reviewed-by: Anton Romanov <romanton@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-23 22:30:40 +00:00
Daniel Verkamp
bf7d3bd38f examples/baremetal: make paddr == vaddr
Fix loading of the example baremetal kernel with the fixed ELF kernel
loader:
- Remove the "RAM" address space so virtual and physical address match.
- Remove the 0x200-byte padding now that entry point address is used.

BUG=b:234155022
TEST=Run baremetal as in tools/examples/baremetal/README.md

Change-Id: I61394cdf4bf71f91736da5a636b0088ecfe78c84
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3691965
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Anton Romanov <romanton@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-23 22:30:39 +00:00
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
Daniel Verkamp
102d03b380 x86_64: return kernel load address from load_kernel
This will be used in a follow-up commit to set the initial instruction
pointer register.

BUG=b:234155022
TEST=tools/presubmit

Change-Id: I3a75f3929beb9e7dbccea0a0d245cf0bfebfe99f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3673614
Reviewed-by: Anton Romanov <romanton@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-06-23 22:30:36 +00:00
Daniel Verkamp
333bf60e91 kernel_loader: return entry point of loaded kernel
BUG=b:234155022
TEST=cargo test -p kernel_loader

Change-Id: I807d42a1cc5e2a88006fa4acc5bc7b089d0406af
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3673613
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Anton Romanov <romanton@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-06-23 22:30:35 +00:00
Daniel Verkamp
b5dbe329be x86_64: pass initial registers in VcpuInit
This allows passing the entry point of the kernel as the initial
instruction pointer value to each vcpu initialization call.

BUG=b:234155022
TEST=Boot vmlinux ELF kernel on x86-64

Change-Id: I6e7bd710ff304601dc6ec56acc0380cbef72c055
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3711619
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-06-23 22:30:34 +00:00
Daniel Verkamp
569a96bed8 hypervisor: x86_64: impl Default for Regs
Replace the automatically derived Default with a manual implementation
so we can set bit 1 of the flags register to 1. This is architecturally
defined to be an always-1 bit (for reasons dating back to 8080/8085
source-level compatibility on the 8086), so we should not create a value
where bit 1 isn't set.

BUG=b:234155022
TEST=tools/presubmit

Change-Id: I7835e5a04385654a667b55e2e2ea2121b5807288
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3717524
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-06-23 22:30:32 +00:00
Dennis Kempin
066276676b infra: Add crosvm_windows builder
This will enable a luci build on windows as post-submit while
we test the build_windows recipe.

BUG=b:233914170
TEST=lucicfg validate main.star

Change-Id: I46ba9309f5dbd6077c73d42bbaafe8986ab18af3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3718901
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-23 22:23:54 +00:00
Junichi Uekawa
3349a67660 crosvm: Add a first filter_cpuid test.
Now that we're trying to change how we copy cpuid, let's add a way to
test them.

BUG=None
TEST=tools/dev_container cargo test -p x86_64 --features=direct

Change-Id: Ic5f1a59b6f0bcda809b908ba2e852e8b03e037a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3716013
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-06-23 22:17:15 +00:00
Junichi Uekawa
6af7ff8540 crosvm: Pass down CpuidResult instead.
So that a copy becomes a straightforward copy.

We were copy-pasting eax ebx ecx edx many times here.

BUG=None
TEST=build

Change-Id: Ibdabdd0da3876159bda3d29aa2a3927b9a3f40ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3717927
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-06-23 22:17:13 +00:00
Keiichi Watanabe
982c92bb98 ci: kokoro: Add presubmit configs for x86_64-direct
BUG=b:220292205
TEST=continuous-x86_64-direct build looks stable

Change-Id: Ib148b8d2a7601ced633b8ea768e8694dcd5da4bc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3715200
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-23 22:04:33 +00:00
Vaibhav Nagarnaik
ab004ddc01 irqchip: Upstream tests
Also remove `dead_code` annotation from `apic.rs` since the consumers
have been added.

BUG=b:213149158
TEST=Ran `cargo test -p devices irqchip -- --nocapture`

Change-Id: Ifda216e23f52ce05b5fee7e80a0751cb3524cf1f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3722189
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vaibhav Nagarnaik <vnagarnaik@google.com>
2022-06-23 21:43:11 +00:00
Richard
ff3a722691 devices: Upstream virtio console Windows implementation
This CL also changes the Console::new constructor to only contains
variables in its parameters that it needs.

BUG=b:213149162
TEST=built and presubmits

Change-Id: Iab2a7e7b90cc3f203b8d9ae72320a0c2c50d81f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3671594
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Richard Zhang <rizhang@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-23 20:57:43 +00:00
Tinghao Zhang
b6ef09ecc5 devices: pci: don't reserve bridge window for hot added bridges
We do not need to reserve bridge window for hot added bridges
because guest will do that for us. This chunk of bridge window is
also reserved by pcie root port, so no extra MMIO allocation is
needed. So we config zeros sized window here for hot added bridges.

BUG=b:199986018
TEST=./tools/presubmit

Change-Id: I7e64b7596e1b5c060cf628a488e2399ae9c257fc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3709794
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-23 17:52:57 +00:00
Tinghao Zhang
4d854e80b4 devices: pci: support hotplugged pci bus to be removed from tree
When pcie switch get removed from the system, we need to remove
their pci buses. This patch adds a new bool field in PciBus
structure to mark it as a hotplug bus and add support to remove
a pci bus from a pci bus tree. Also some other helper functions
is added for hotplug out usage.

BUG=b:199986018
TEST=./tools/presubmit

Change-Id: I71064127345424bf050d993f60f9d766a299de8b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3709793
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-23 17:44:21 +00:00
Tinghao Zhang
0e1faf9898 devices: pcie: make pcie root port use PciePort
Since we've had a common code base PciePort for all pcie ports, pcie
root port should also use this code base. This patch refactored pcie
root port to let it use this code base.

BUG=b:199986018
TEST=./tools/presubmit

Change-Id: I9e1d3f3ebe0a0d89a947771306f4a819e106d30c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3692431
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-06-23 17:31:45 +00:00
Tinghao Zhang
61052012a4 devices: pcie: add pcie upstream and downstream port
To support pcie switch, we need to add both pcie upstream and
downstream port. This patch adds a new file pcie_switch.rs and add
basic implementation for pcie upstream and downstream port.

BUG=b:199986018
TEST=./tools/presubmit

Change-Id: I7cc40d4fd0f017e06c5a0e8b0e3b68a8df9ee185
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3508737
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-23 17:31:43 +00:00
Noah Gold
0d8eef2074 broker_ipc: fix child process logging init order.
Logging was initialized after crash reporting. This meant that any
errors or info lines, from crash reporting would be dropped on the floor (the
logger drops all messages prior to initialization).

BUG=236850894
TEST=tested downstream

Change-Id: I34be3808bf2d094af22bae434397c9fab298d2c0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3718543
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-23 17:04:27 +00:00
Noah Gold
972ed6d094 base: log with local timestamps instead of UTC
00068bc0a2f02bd79235ff50b9d6f81a6133986f caused the timestamps on
crosvm logs to switch to UTC (ISO 8601). The 8601 part is great,
but the UTC time is a little annoying for local debugging.

Thanks to auradkar@ for coming up with the new formatter code.

BUG=b:236004673
TEST=ran downstream crosvm & verified logs appear w/ local timestamps.

Change-Id: I715f68b7f4ba545e3eadbfd1b9be9abba69d8258
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3712544
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-06-23 17:04:25 +00:00
David Stevens
918bdde54f crosvm: re-add '-d' short arg
Re-add the '--disk' short arg '-d' that was dropped by CL:3684144.

BUG=None
TEST=compiles

Change-Id: I797f9995ad55d74e55d8c106ed42e61624c0f00f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3716014
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-23 03:27:27 +00:00
Kameron Lutes
ffad493f61 crosvm_control: Add shared and unevictable memory to BalloonStats
Adds the shared_memory and unevicatble_memory fields to BalloonStatsFfi
struct and also returns them from crosvm_client_balloon_stats.

BUG=b:188858559
TEST=cq

Change-Id: I9ff52b77cd19e16a860596f24ff45407a2acdd1e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3713864
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Kameron Lutes <kalutes@chromium.org>
2022-06-23 03:10:51 +00:00
Alexandre Courbot
b3f5fbae62 tools: install-deps: add libva-dev and libudev-dev as dependencies
These libraries are needed to build the upcoming vaapi backend. Also
update the container so they are included.

BUG=b:214478588
TEST=./tools/dev_container ./tools/presubmit --all

Change-Id: Id30c38557d56b4c94ca5f2419c73b34520916ed0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3715087
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-06-23 01:12:15 +00:00
Lepton Wu
1973802bea crosvm: Add a flag to disable INTx for virtio devices.
Sometimes we got buggy interrupt entries in ACPI table which
could confuse linux kernel. Add a new flag to disable it so
virtio devices can skip this part of initialization since they
should all support MSI-X.

BUG=b:236206320
TEST=manual - Run crostini on volteer-manatee

Change-Id: I98764b7cd31a2e68ddcd78d8175442f90ad8b164
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3719139
Commit-Queue: Lepton Wu <lepton@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-06-23 00:59:52 +00:00
Vikram Auradkar
32cabe0cd4 devices: enable tests
BUG=b:213149155
TEST=presubmit

Change-Id: Iff1a721dddfaed3e2728222a75348745be9ef05a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3710851
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-23 00:26:06 +00:00
Noah Gold
dd40d069b2 x86_64: cross platform cleanup
* Splits platform specific bits of test_integration into a sys module.
* Cleans up Cargo.toml & platform specific imports.

BUG=b:213152505
TEST=builds

Change-Id: I95eff1f240e98b09a600239a77fc54e5222edebf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3701040
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Richard Zhang <rizhang@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-06-22 23:34:17 +00:00
Keiichi Watanabe
d001987d6b ci: kokoro: Add continuous-x86_64-direct
Add postsubmit test config for crosvm-direct binary on x86_64.

BUG=b:220292205
TEST=./ci/kokoro/simulate.py ./ci/kokoro/build-x86_64-direct.sh

Change-Id: I326c52924cc154485c5941cec82be56547d7d862
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3715071
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-06-22 23:18:35 +00:00
Peter Collingbourne
2f74118ecf Remove madvise from *_audio_device.policy.
It was already present in common_device.policy, causing
errors such as:

crosvm[1384]: libminijail[1384]: compile_file: crosvm/seccomp/aarch64/null_audio_device.policy(8): syscall madvise redefined here
crosvm[1384]: libminijail[1384]: compile_file: /home/pcc/crosvm/seccomp/aarch64/common_device.policy(25): previous definition here
crosvm[1384]: libminijail[1384]: compile_filter: compile_file() failed

Change-Id: I857cefd3075dbda001b07217ae7f20c85b3ef908
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3703886
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Peter Collingbourne <pcc@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-06-22 23:08:02 +00:00
Keiichi Watanabe
eb8cfb4b18 tools: Add crosvm-direct support for run_tests
BUG=b:220292205
TEST=./tools/run_tests --target=host --crosvm-direct

Change-Id: Ife25129d405cd1e514bf812cc31621313f2007b5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3708759
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
2022-06-22 21:51:53 +00:00
Frederick Mayle
7bba2599cf gpu_display: Don't include linux kernel headers
This makes it easier to integrate crosvm into Android (which doesn't
have the kernel headers available for all the build targets crosvm is
needed in).

The BTN_LEFT constant is already hardcoded in virtio/input/constants.rs,
so the additional tech debt seems acceptable.

BUG=b:228881829
TEST=cargo build && cargo test

Change-Id: Ia25586e855a29fc5f475904cad028eef30d3f016
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3717525
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
2022-06-22 15:52:39 +00:00
Daniel Verkamp
959a05e7cc devices: virtio-tpm: pass base_features to constructor
Allow the device_helpers code to evaluate base_features() with the value
of protected_vm from the configuration to match the pattern used with
other devices.

BUG=b:227283268
TEST=emerge-hatch crosvm # board with chromeos and tpm features enabled

Change-Id: I15b73bbb32d684c1f29130929ec25c4dc9644967
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3717184
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Yi Chou <yich@google.com>
2022-06-22 15:20:13 +00:00
Keiichi Watanabe
0974be8042 integration_tests: Define Config struct
Define `struct Config` to specify crosvm arguments so it'll make it
easier to add more complicated arguments in future CLs.

BUG=b:220292205
TEST=./integration_tests/run

Change-Id: I89921e171a81071dbfc58d22b233e9c71abcdf54
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3686717
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-22 01:46:18 +00:00
Noah Gold
f54f7ed040 devices: fix double init of logging on blk for Windows.
BUG=235867298
TEST=tested downstream

Change-Id: I81ff30c9c953b8f2674e1fd8f258a90aad92282a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3712543
Commit-Queue: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-06-22 01:05:50 +00:00
Vikram Auradkar
731c22bbe2 crosvm: build/test few more crates on windows
BUG=213146128
TEST=presubmit

Change-Id: I7fcb5f4d61ee677595df32edbba7f50383ab0731
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3707422
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-06-22 00:48:23 +00:00
Daniel Verkamp
19fc097eb8 crosvm: replace lazy_static with once_cell
We depend on both lazy_static and once_cell, which do basically the same
thing.

The once_cell crate has a few advantages:
- once_cell is on track to be included into libstd.
  (https://github.com/rust-lang/rust/issues/74465)
- once_cell doesn't require macro magic.

Replace the uses of lazy_static with their once_cell equivalents so we
don't need to pull in both crates.

BUG=b:236191006
TEST=tools/presubmit --all
TEST=tools/run_tests --target=host --arch=win64 --build-only
TEST=cargo test --features=plugin

Change-Id: I7cabcd837ef4878e8e8ae635bb4f235a58e4cae3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3707624
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
2022-06-21 23:40:55 +00:00
Kameron Lutes
6e0ac7de54 crosvm_control: Add cbindgen configuration options
Adds necessary configuration to cbindgen to correctly format the
generated crosvm_control.h header.

BUG=b:188858559
TEST=cq

Change-Id: I7abab7a5f9d260451540c5938719ec51cad56457
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3713865
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Kameron Lutes <kalutes@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-06-21 23:25:39 +00:00
Daniel Verkamp
b33353cc46 base: remove use of cvt crate
cvt isn't used anywhere else in the base crate, and it isn't included in
the ChromeOS crosvm ebuild, so this breaks the CrOS build. Just check
the result and return an error the same way we do elsewhere in base.

BUG=b:231641496
TEST=cargo build
TEST=emerge-hatch crosvm

Fixes: 21445b1b83 ("base: Upstream unix net set_nonblocking fn")
Change-Id: Iba8beee21810210e50e0c715a1b84de29278625a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3716851
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-06-21 22:04:32 +00:00
Vaibhav Nagarnaik
24b9db5095 irqchip: Add WhpxSplitIrqChip implementation
Implement `WhpxSplitIrqChip` for `whpx` (Hyper-V) which has a split IRQ
chip architecture. Add dependencies for the root `whpx` feature on the
`devices/whpx` feature set.

BUG=b:213149158
TEST=Compiled on windows.

Change-Id: I3b0aec441b5abdff3f0266a9467380b0cdc4fdee
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3717187
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vaibhav Nagarnaik <vnagarnaik@google.com>
2022-06-21 21:31:21 +00:00
Daniel Verkamp
927488df91 devices: tsc: pass cpuid as a function pointer
Rather than having a global CPUIDS variable that is used by all tests
for the TSC CPUID code, we can pass a function pointer to the
tsc_frequency_cpuid() function to retrieve a specified CPUID value. For
normal use, we provide a host_cpuid_count function that uses the normal
__cpuid_count intrinsic as before. For the tests, we provide a fake
CPUID function that returns the desired test values.

This removes the potential for problems when running multiple tests in
parallel (which was hypothetical, since we only had one test so far, but
worth fixing).

BUG=b:234508273
TEST=cargo test -p devices tsc

Change-Id: Ic963b21f09f8e8d7665386ad134ae5e242b3051d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3707623
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Vaibhav Nagarnaik <vnagarnaik@google.com>
2022-06-21 21:25:28 +00:00
Daniel Verkamp
d42d2004a1 devices: tsc: move logs to debug level
Don't log the TSC calibration results for every core at the default info
log level, since that can be quite noisy on machines with many CPUs.

The logs can be re-enabled using the `--log-level` option:

  crosvm --log-level=devices::tsc=debug run ...

BUG=b:234508273
TEST=crosvm run doesn't print tsc logs by default

Change-Id: I5051e22740b6b2136d35936c60dee776abd1d00d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3707388
Reviewed-by: Colin Downs-Razouk <colindr@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-06-21 21:24:57 +00:00
Daniel Verkamp
8cac16bf75 kernel_loader: return a struct for better naming
The new LoadedKernel structure also splits out the size and end address,
which are both used in different places (x86_64 wants end, aarch64 wants
both).

BUG=b:234155022
TEST=tools/presubmit
TEST=cargo test -p kernel_loader

Change-Id: I86a7e412c983f29a2c614cc9e6896aa11db6ba94
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3673611
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-06-21 19:39:40 +00:00
Clarissa Garvey
21445b1b83 base: Upstream unix net set_nonblocking fn
Bug: b:231641496
Upstream-Crate: base/src/sys/unix
Change-Id: I62b07f2fc3f7a02c1b72da735ac41d6dc73416f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3708762
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Clarissa Garvey <clarissagarvey@chromium.org>
2022-06-21 18:58:53 +00:00
Allen Webb
ac1b5734be common/sync: Bump the version to 0.1.99.
Avoid a collision with sync 0.1.0 on crates.io so patches.crates-io can
be used to override cargo.

BUG=None
TEST=CQ passes

Change-Id: I3f5eb33f20fa5ffab2675ad1a156eefdf687e5b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3707378
Commit-Queue: Allen Webb <allenwebb@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Allen Webb <allenwebb@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-21 18:02:52 +00:00
Junichi Uekawa
3d6c9542a7 crosvm: Reland "crosvm: split up --no-legacy flag"
This is a reland of commit 7110d673f2

Replace --no-legacy flag, which implied the removal of both i8042 and
rtc devices, with separate --no-i8042 and --no-rtc flags. The old
flag is still supported and implies the other two.

Because the original landing of this flag didn't protect it as an x86
specific option, this change just leaves that alone. But the new flags
are added as x86-only, because they are very x86 specific.

BUG=b:223443221
TEST=crosvm run --bios u-boot.rom --disk kernel
TEST=boot volteer-manatee

Change-Id: I57f9328483f24da29db663e261b3ccc2a97c3239
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3715083
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-06-21 17:59:38 +00:00
Alexandre Courbot
f9b74bfa18 crosvm: fix build with --no-default-feature
Fix a warning that would prevent `presubmit --all` to pass.

BUG=None
TEST=cargo build --verbose --no-default-features

Change-Id: Iff80e5dd49b284cf20c2dd119d0b985317962a54
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3715086
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-06-21 16:10:29 +00:00