Commit graph

2647 commits

Author SHA1 Message Date
Dennis Kempin
6e3350a956 Add base crate to cargo_refactor
We are adding an ebuild file for this crate in a future
CL: https://crrev.com/c/3251800

BUG=b:195126527
TEST=Run the script

Change-Id: If58c28075d5f3a3d2ad2b8c55714d1f8cdb968ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3251784
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-10-28 21:04:59 +00:00
Jorge E. Moreira
e40fb21c0d Allow sched_yield in all devices' seccomp policy
The sched_yield system call is somehow called by the code the rust
compiler generates and not directly by the author's implementation. That
along with the fact that it won't get called on every run makes it very
easy to miss when adding a new device (that happened with virtio-snd).
Since that call is quite harmless (it could be argued minijail shouldn't
even block it in the first place) it makes sense to allow it for all
devices.

BUG=b/201306350

Change-Id: I9895da6c8060ae83053474ed9e4472ea2cd8d3e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3248126
Auto-Submit: Jorge Moreira Broche <jemoreira@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jorge Moreira Broche <jemoreira@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-28 19:10:45 +00:00
Keiichi Watanabe
31ef2d0b76 mdbook: Add links to source code at top page
BUG=none
TEST=none

Change-Id: Ife7f1d7c8d5885f72e9b489e62735e8b236c1750
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3245056
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-28 10:44:45 +00:00
Dennis Kempin
70c66baed0 Revert "Devices: Allocate non pci bar mmio at top of HighMmio"
This reverts commit 9557588786.

Reason for revert: Causes crosvm to not start on AMD based devices b/204222491

Original change's description:
> Devices: Allocate non pci bar mmio at top of HighMmio
>
> Some devices like virtio-pmem, intel host bridge need private mmio, these private
> mmio isn't exposed to Vm through pci bar, and crosvm use mmio allocation interface
> to allocate them, so guest OS pci bus driver couldn't detect them, and once guest
> OS reallocate pci mmio, these private mmmio could be assigned to pci device bar.
> then resource conflict happens.
>
> This patch allocates these non pci bar mmio at the top of HighMmio, since HighMmio
> is large enough and OS allocates pci mmio from low to high. So these non pci bar
> mmio won't conflict with pci bar.
>
> BUG=b:199442120
> BUG=b:185084350
> TEST=crosvm run --pmem-device xxxx
>
> Change-Id: I615d7901d595dd46ba6362f88b71d96baa9c4c8f
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3184549
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>

Bug: b:199442120
Bug: b:185084350
Change-Id: Ida1369bf0b70782633b1073ceef50e1bab108f55
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3248906
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-10-27 23:22:53 +00:00
Dennis Kempin
783791441d Refactor script: Move non-workspace crates to common/
This CL contains just a refactoring script, a follow-up contains
the result of running it. This is easier to review than 100s of
search/replace.

I think it makes sense to leave this script around for future
reference if we need to shuffle things around again.

BUG=b:195126527
TEST=None

Change-Id: Ic8cc69946b8e6908877e4fbde44230d40a1ea566
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3232967
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-27 22:51:25 +00:00
Dennis Kempin
6fdbcacce7 Add uprev_ebuilds script
This script allows us to generate manual uprev CLs the same way
PUpr creates them.

BUG=b:204223210
TEST=./tools/chromeos/uprev_ebuilds

Change-Id: I45f9f0f4d33f8782637455b578688fa9b504fe8e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3248905
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-10-27 22:51:24 +00:00
Dennis Kempin
df7d744fec test_runner: Parallelize building of common/ crates
Each of these is a separate workspace and can be built in
parallel.

BUG=b:195126527
TEST=./tools/run_tests

Change-Id: I9ad61b5d5d83903fda36c948ba470bba8f608d46
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3248128
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-27 19:53:07 +00:00
Dennis Kempin
85d5655160 test_runner: Refer to crates by their names, not paths
When looking up crate options from test_options.py we used their
path relative to the crosvm root (e.g. common/p9). But when looking
up options for binaries, the name is parsed from cargo output and
just the crate name (e.g. p9). Fix this by just using the crate
name.

BUG=b:195126527
TEST=./tools/run_tests

Change-Id: I09a3469daa071dc66295d777449dc101a6564162
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3248127
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-27 19:53:06 +00:00
Allen Webb
f28bca1ddc sys_util: Include EPOLLRDHUP in hangup checks.
TCP uses EPOLLRDHUP to indicate when the other side has sent a FIN.
Include EPOLLRDHUP in the hangup checks so TCP connections can be used
with the poll module.

BUG=None
TEST=manatee shell works in interactive mode.

Change-Id: I39d0527d992ee915f8b807a7ee75f831bc92b26a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3244224
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Allen Webb <allenwebb@google.com>
2021-10-27 18:04:04 +00:00
Jack Rosenthal
5d5192a7f6 README: Fix typo
"devies" -> "devices"

BUG=none
TEST=none

Change-Id: I779668ea461e0f02c222a6e68edb0ca8b732f2cf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3248022
Auto-Submit: Jack Rosenthal <jrosenth@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-10-27 16:54:24 +00:00
Mattias Nissler
de2c640f17 Add stub PCI device implementation.
Introduce a very simple stub PCI device that can be added to the bus
at a specified address with given PCI config parameters (vendor,
device, etc.). This is useful for cases where we just require a device
to be present during PCI enumeration.

The case that motivates this is a vfio device passthrough
configuration that passes only selected functions of a given device at
the original addresses, but function 0 is not passed through. Absence
of function 0 would be interpreted in enumeration as the entire device
being absent (in accordance with the specification). Putting a stub
device at function 0 fixes this.

BUG=b:167947780
TEST=New unit test, boot minimal Linux image and verify enumerated PCI device.

Change-Id: Iaedffe1c4ac2ad8f6ff6e00dfeebbbfeb5490551
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3245497
Auto-Submit: Mattias Nissler <mnissler@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Mattias Nissler <mnissler@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-27 14:06:35 +00:00
Mattias Nissler
fce74e6fc2 Add TryFrom implementation for PciClassCode
This is useful for example when parsing numeric PCI class code values
from the command line.

BUG=b:167947780
TEST=None

Change-Id: I55515af2fa7e38bc26f4c2eebb083f1e45aebf22
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3245496
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Mattias Nissler <mnissler@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-27 13:06:55 +00:00
Mattias Nissler
441a68194a Add multifunction bit to PCIConfiguration
It's the highest bit in the header type field, this change allows to
set the bit and thus indicate that a device is a multifunction device.

BUG=b:167947780
TEST=None

Change-Id: I71372e2490897bc3d5c24717c9504e337792a48f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3245495
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Mattias Nissler <mnissler@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-27 13:06:54 +00:00
Mattias Nissler
1afcde90c2 Command line key=value option parsing helpers
Many command line options take comma-separated key-value pairs. A lot
of the parsing boilerplate is duplicated for various options in
main.rs. This change introduces generic helpers to make this easier.
Subsequent changes will convert the existing option parsing to make
use of this infrastructure.

BUG=b:167947780
TEST=New unit tests.

Change-Id: I5ff1e4a09ac92c10d99b0b81d7d7cd7ce153fadb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3245494
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Mattias Nissler <mnissler@chromium.org>
2021-10-27 13:06:53 +00:00
Jiyong Park
5d5a128943 devices: Serial devices can be backed by FD via /proc/self/fd/N
Like disks, serial devices can be backed by file descriptors using the
/proc/self/fd/N syntax.

BUG=b:200914564
TEST:cargo test
Change-Id: Idd6f5763db24e61a80dc34732c9e2118d613cefc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3241083
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-10-27 00:38:43 +00:00
Keiichi Watanabe
d73e41276e devices: vfio: Reorder use statements
BUG=none
TEST=build

Change-Id: I8ce2d48cce787fe6352d784fe0b583657d51ad39
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3245354
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-26 19:33:07 +00:00
Daniel Verkamp
0c2f9c749f bindgen: switch to allowlist/blocklist options
Rust bindgen now supports --allowlist and --blocklist option names as of
https://github.com/rust-lang/rust-bindgen/pull/1990 - use them in the
various bindgen invocations in scripts and comments.

BUG=b:178821708
TEST=../dev/contrib/search_blocked_words.sh unblocked_terms.txt

Change-Id: I9797f049999a01ab2c41617823463236b4d03cbb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3243012
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-10-26 18:32:51 +00:00
Keiichi Watanabe
9abac407ac OWNERS: Remove tjeznach
BUG=none
TEST=none

Change-Id: Ia2a2f613e254082e456fc17bbbb3c17581910aa9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3241905
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-10-26 16:58:37 +00:00
Woody Chow
f5db3e5186 Add missing HwBreakpointOps impl to GdbStub
Migration to gdbstub 0.5.0 broke hardware breakpoints.
(https://crrev.com/c/3071900). This fixes it.

BUG=chromium:1259868
TEST=Manually with `hbreak start_kernel` on a volteer device

Change-Id: I35097b4ad2ec9990e78e68c3274c12ba7a5dbea9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3244555
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Woody Chow <woodychow@google.com>
2021-10-26 07:12:23 +00:00
Keiichi Watanabe
4ca0429e8d CONTRIBUTING: Add a link to crbug
Since bug reporting is one of ways to contributing the project, let's
add a section for it in CONTRIBUTING.md.

Also, ran mdformat to the file.

BUG=none
TEST=none

Change-Id: Id09216fe95baa4c2173aa71d19f3a1c96aa57b0d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3241904
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-10-26 05:07:00 +00:00
Keiichi Watanabe
feb0e8d728 CONTRIBUTING: Add code submit workflow
Explain how to submit a CL for non-Chromium OS developers.

BUG=none
TEST=none

Change-Id: I3ee0e47eac1f0320f4c086a895f91ebf5fbf2d74
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3241903
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-10-26 05:06:59 +00:00
Xiong Zhang
6d1b2df054 pci-bridge: Set limit smaller than base at initialize
According to pci bridge spec, the io/mem/prefetch mem limit register
must be programmed to a smaller value than the corresponding base register
if there is no io/mem/prefetch mem on the secondary side of the brige.

When bridge is created, it doesn't have any child device, then
no io/mem/prefetch mem on the secondary side of the bridge, so this
patch set limit to 0, but base to 0xffff.

When a device is attached behind the bridge, kernel will assign
resource and set the right value to these base and limit register.

BUG=b:199442120
BUG=b:185084350
TEST=crosvm run --bios OVMF.fd
TEST=hotplug in/out a pcie device to pcie root port repeatly

Change-Id: Id1c2ff1132d59e1aafd548fc17ab5aee2023dd8c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3166883
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-10-25 22:03:13 +00:00
Xiong Zhang
9557588786 Devices: Allocate non pci bar mmio at top of HighMmio
Some devices like virtio-pmem, intel host bridge need private mmio, these private
mmio isn't exposed to Vm through pci bar, and crosvm use mmio allocation interface
to allocate them, so guest OS pci bus driver couldn't detect them, and once guest
OS reallocate pci mmio, these private mmmio could be assigned to pci device bar.
then resource conflict happens.

This patch allocates these non pci bar mmio at the top of HighMmio, since HighMmio
is large enough and OS allocates pci mmio from low to high. So these non pci bar
mmio won't conflict with pci bar.

BUG=b:199442120
BUG=b:185084350
TEST=crosvm run --pmem-device xxxx

Change-Id: I615d7901d595dd46ba6362f88b71d96baa9c4c8f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3184549
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-10-25 22:03:12 +00:00
Keiichi Watanabe
0851e14a2b CONTRIBUTING: Add Contributor License Agreement
See go/releasing/preparing#CONTRIBUTING for the detail.

BUG=none
TEST=none

Change-Id: I1fd6ad8da2fdd447d71acc383e1f388f21726710
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3241902
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-25 19:23:42 +00:00
Keiichi Watanabe
4a0ceade44 Add crosvm logo in README and mdbook
BUG=none
TEST=none

Change-Id: Ifc5851b2936fe11f28ddec66af6a5d3e42c2c047
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3237467
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-10-25 14:48:14 +00:00
Keiichi Watanabe
17f167aaef Simplify README
Since we've already moved contents of README to mdbook, let's have only a simple
description and a list of links in README.

BUG=b:199874828
TEST=none

Change-Id: I42213a0be915154309443cdd07493ef3c64842a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3159890
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-10-25 14:48:13 +00:00
Keiichi Watanabe
3e45862750 mdbook: Add page of "Basic Usage"
Add a starter document.
The most of content is moved from example usage doc [1] except GUI features.

[1]: https://google.github.io/crosvm/appendix/example_usage.html

BUG=b:195003973
TEST=none

Change-Id: I5fd1398795087edc1b41984cb579b59b9f34be5f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3188677
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-25 14:48:12 +00:00
ZhaoLiu
2aaf7ad9fc x86: Support Host exposes CPU topology to Guest VM
At present the Guest generates its own CPU topology. To mitigate
cross-hyperthread speculative execution side channel attacks, allow
Guest to use mirror CPU topology of Host is needed for future scheduling
optimization.

Add a config option "--host-cpu-topology" to ask the vCPU number to be
identical to physical CPUs, and make the vCPU has the same APIC ID in
MADT and CPUID as the corresponding physical CPU. The same APIC ID can
ensure the same topology.

"--host-cpu-topology" requires vCPU number must equal to pCPU number,
and it has the default vCPU number setting, which equals to pCPU number.

"--host-cpu-topology" also defaultly sets CPU affinity for each vCPU to
the pCPU which has the same processor ID, like 1=1:2=2:3=3:4=4, so that
the vCPU and its corresponding pCPU will have the same processor ID and
the same APIC ID. User can't set CPU affinity if "--host-cpu-topology"
was set.

BUG=b:197875305
TEST=Set "--host-cpu-topology" option and check Guest's /proc/cpuinfo,
  lscpu, CPUID for different vCPU

Change-Id: Ibc4eb10649e89f43b81bde6d46d6e0e6c7234324
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3217035
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-10-25 04:19:45 +00:00
ZhaoLiu
4e9b1444a4 x86: Support vCPU CPUID keep same topology as pCPU
At present the Guest use the cpu id (enum number) as the APIC ID in vCPU
CPUID and set the different topology with pCPU.

To support the feature vCPU has the same topology as pCPU, vCPU need the
same APIC ID as pCPU. So let vCPU can use the APIC ID from pCPU in
vCPU's CPUID and keep pCPU's topology related information (include CPU
count and topology mask) unchanged.

Now this change is a preliminary preparation and doesn't work.
Additional feature options and corresponding CPU number and CPU affinity
settings are still required.

BUG=b:197875305
TEST=cargo build
TEST=./test_all

Change-Id: I04150ac6c35534d0ff56667b01f448da2ca9f9fc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3217034
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: David Stevens <stevensd@chromium.org>
2021-10-25 04:19:44 +00:00
ZhaoLiu
535271094f x86: Support Guest MADT can use APIC ID of pCPU
At present the Guest use the cpu id (enum number) as the APIC ID in
Guest MADT.

To support the feature vCPU has the same topology as pCPU, vCPU need
the same APIC ID as pCPU. So let Guest MADT can use the APIC ID from
Host is needed.

Now this change is a preliminary preparation and doesn't work. The APIC
ID related changes for vCPU CPUID are still required.

BUG=b:197875305
TEST=cargo build
TEST=./test_all

Change-Id: I0e7dfba8cd57fefd85b7d7e37de3bb9935ff19ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3217033
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: David Stevens <stevensd@chromium.org>
2021-10-25 04:19:43 +00:00
ZhaoLiu
952feb761d sys_util: Add the interface to get CPU affinity
At present we only have a interface to set the CPU affinity and don't
implement the 'get_cpu_affinity' interface.

With a 'get_cpu_affinity' interface, after the thread iterates through
all physical CPUs by setting CPU affinity, it can reset its original CPU
affinity that was obtained and stored through 'get_cpu_affinity' in
advance.

BUG=None
TEST=cargo build
TEST=./test_all
TEST=set the CPU affinity and check the return value of
  'get_cpu_affinity'

Change-Id: I169fbbbb141ca80c980900ed16e4bceed1ba6432
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3217032
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-10-25 04:19:42 +00:00
Daniel Verkamp
81d454515f tempfile: remove from crosvm
All users of the in-tree implementation of tempfile have been moved to
the crates.io tempfile version.

BUG=b:199204746
TEST=emerge-hatch crosvm

Change-Id: Ie94d8cf87141f6d01d928f269e880c5493fc17a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3209840
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-10-21 22:04:50 +00:00
Gurchetan Singh
9aa5b0b4b4 rutabaga_gfx: make certain types usable across FFI boundaries
This is useful for the upcoming C/C++ interface to Rutabaga.

BUG=b:173630595
TEST=compile

Change-Id: Id543edb8c3fd3a0475b832a3c17e15e89b766e4d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3230330
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-10-21 22:04:41 +00:00
Dennis Kempin
66431d7f45 Add onboarding resources to mdbook
This is converted from our onboarding doc with internal references
removed.

BUG=b:199926026
TEST=None

Change-Id: Ibb94e194583b12c1ec7fe3d80306156e34e50000
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3229948
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-10-21 19:32:14 +00:00
Keiichi Watanabe
26b03d02bd mdbook: Fix typos in proper names and script paths
Apply changes of crrev.com/c/3236708 to mdbook

BUG=none
TEST=none

Change-Id: Ida84a9157197a435156957a7eccce07de16b9cec
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3237466
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-21 17:10:59 +00:00
Christian Blichmann
10bc771df8 README: Fix typos in proper names and script paths
TEST=Documentation only change

Change-Id: I0f03f3c58f8f1dea26814b5079e1e55b57c246f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3236708
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Christian Blichmann <cblichmann@google.com>
2021-10-21 15:26:45 +00:00
Xiong Zhang
3022a234b0 devices: Use Mutex to protect bus->devices
With vfio pci device hotplug, bus->devices will be inserted and removed at
runtime in different vcpu threads, so mutex should be used to protect it.

Both each vcpu thread and pci_root share mmio_bus and io_bus, so use Arc
for mmio_bus and io_bus. But pci_root is inserted into io_bus for pci cfg io,
in order to resolve reference loop and memory leak, weak is used for
pci_root.mmio_bus and pci_root.io_bus.

BUG=b:174705596
TEST=boot a vm and check its function

Change-Id: I7b3e63db76a90bc3873619b4d80a66db741ce78f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3184724
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-21 05:42:49 +00:00
A. Cody Schuffelen
bc50b0420a Use a shared buffer for virtio-console data
The strategy of passing Vec<u8> types introduced in crrev.com/c/2470376
can cause panics when the receiving side doesn't have the capacity to
receive the full buffers produced by crosvm. For example, a
virtio-console implementation with only one-byte buffers
(https://android-review.googlesource.com/c/1853082) almost always won't
have the capacity to receive the full buffers.

Using a VecDeque ring buffer allows continually appending data from the
input in the read thread and pulling off as much as the guest can handle
in the guest communication thread, without sacrificing performance when
the guest can handle higher volumes.

Bug: b/182849835
Bug: b/203138623
Test: Pass some input with an unbuffered single-character console driver
Test: Run CtsKeystoreTestCases against cuttlefish (high volume transfers)
Change-Id: I6b52a729d5af82f4626a9b1f29176116299b9297
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3227733
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-20 22:17:21 +00:00
Keiichi Watanabe
610158aa55 ci: kokoro: push-to-github: Use git push --all instead of --mirror
Unlike git push --mirror, git push --all won't delete remote branch so
that gh-pages branch won't be removed by kokoro, I think.

BUG=b:199692764
TEST=none

Change-Id: I2a5ce2f59e966775d24c25b996a1091af1d6efc9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3234557
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-10-20 16:06:04 +00:00
Keiichi Watanabe
8e4f87b44c devices: vfio: Use Result<> alias
BUG=none
TEST=build

Change-Id: Ia2be89464073f6e210bd64639929c8c1418c0388
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3149871
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-20 12:04:59 +00:00
Keiichi Watanabe
7db73604ea devices: vfio: Move VfioPciConfig to vfio.rs
Move the definition of VfioPciConfig, which is currently used by VFIO
passthrough, to vfio.rs so that we can use them when implementing VFIO
driver.

BUG=b:194137301
TEST=cargo build

Change-Id: Ia35d04d1871f5d4917dba81c1b4cc49bfbc3bf4b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3149870
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-20 12:04:58 +00:00
Keiichi Watanabe
226dae5c20 devices: vhost: user: device: Add Doorbell type in VhostUserBackend trait
Add Doorbell type in VhostUserBackend trait.
While it's CallEvent type having an underlying callfd for vhost-user, it'll be a doorbell struct for virtio-vhost-user.

BUG=b:194137301
TEST=cargo test

Change-Id: I569870b8285c6e82423e0d478f83dce7e08d386b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3205229
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-10-20 12:04:57 +00:00
Yiwei Zhang
95ac52a975 seccomp: gpu: allow vulkan loader/layer and virglrenderer
This is the arm equivalent for the below x86_64 CLs
- crrev/c/2634993
- crrev/c/2728307
- crrev/c/2959464

BUG=b:203588512
TEST=vkjson

Change-Id: I0f421d88a9abd9568923573d3135c24c513ed7eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3232961
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chia-I Wu <olv@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Lepton Wu <lepton@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-10-20 07:20:27 +00:00
Tomasz Jeznach
9e6c633ada crosvm: MMIO forwarding.
BUG=b:188011323
TEST=None

Change-Id: I93b722893c29add6e5de173d40ff1523d2b3a687
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2925137
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-20 05:35:59 +00:00
Dennis Kempin
d05bcbe9e0 Uprev all submodules
This fixes the annoying __pycache__ files virglrenderer used to
create.

BUG=b:200554399
TEST=./tools/presubmit passes

Change-Id: Ib5bfa5205f0b1432243ef53ec1b5a14d6cdd10d7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3232278
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-10-19 19:12:53 +00:00
Dennis Kempin
65740a6842 Uprev to rust 1.55.0
Includes some fixes for new clippy checks. A rebuilt
dev_container that ships the new toolchain.

This allows us to get rid of the annoying cargo clean
before running clippy.

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

Change-Id: I9d486fbcf7b2d468f6a1375ac7df95091a2c1465
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3232277
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-10-19 19:12:52 +00:00
Dennis Kempin
8a1277de1a Kokoro: Rebase changes to ToT before testing
By default Kokoro will use changes as they come from gerrit, which may
have an outdated parent. We want to make sure that we are always testing
against tip of tree so we are confident the presubmit test result will
reflect the postsubmit results.

BUG=b:202275156
TEST=Tested in Kokoro

Change-Id: I2a1d2860a361eee741dc522c9859e32890ff15bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3229947
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-19 17:10:04 +00:00
Dennis Kempin
76e6fd051b Fix push-to-github Kokoro builder
One more fix. Everything seems to work, but the remote is rejecting
an update of the active main branch. Hopefully the last fix needed.

BUG=b:199692764
TEST=Testing in prod.

Change-Id: I4f341cc374080454317cb3ac29cade59fec6aeee
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3229958
Tested-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-18 23:22:27 +00:00
Dennis Kempin
2d50ccb4a7 Fix push-to-github kokoro build
We were in the wrong directory.

BUG=b:199692764
TEST=Testing in prod...

Change-Id: Idbc60f7f6084109220186e56cd7fad2e6553da9a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3229950
Tested-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-18 22:00:22 +00:00
Dennis Kempin
49c169a410 Add push-to-github kokoro config and script
This is hard to test. I verified that kokoro can access
the github token and use it to access github by adding
a git clone into the x86 presubmit build file in patchset 3.

But we can only really test the full process by submitting this
CL and have it pass through the continuous builder.

BUG=b:199692764
TEST=Needs to be tested in prod...

Change-Id: Ifdcd385552c61ecea75a43fb71b08950e8b036ca
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3229941
Tested-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-18 21:37:58 +00:00