Commit graph

2711 commits

Author SHA1 Message Date
Keiichi Watanabe
1d0ef4d7a3 mdbook: Fix broken links detected by mdbook-linkcheck
Run mdbook-linkcheck locally and fix detected errors.
Note that we avoid running mdbook-linkcheck in CI, as its installation
takes ~1min.

BUG=none
TEST=run GitHub Action

Change-Id: I2bbd5f30486573454dc9ece86353296eca55be70
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3255194
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-11-01 19:07:01 +00:00
Keiichi Watanabe
73b68faf7f CONTRIBUTING: Add more instruction on use of mdbook command
BUG=none
TEST=check rendered results

Change-Id: I10532c45317f5189bd867850f36e7ae93b4abcc4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3252187
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-11-01 15:32:26 +00:00
Marc Zyngier
17b1e02fb6 aarch64: Provide the maximum supported IPA size as the machine type
The value 0 passed to KVM_CREATE_VM has a special meaning for KVM/arm64.
It indicates that the VM is configured with a 40bit IPA space.
However, not all HW support such an IPA space, and the KVM_CREATE_VM
call fails on these systems.

In order to maximize compatibility, we can ask KVM for the maximum
supported IPA size, and use that as an input to KVM_CREATE_VM, at
which point the kernel will instantiate a VM with that IPA size.

This enables crosvm on exotic hardware such as the Apple-M1.

TEST=tools/run_tests

Change-Id: I7ea39ac6e5de6a1389c0c30cdfeb7c970c411589
Signed-off-by: Marc Zyngier <mzyngier@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3124677
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-11-01 14:24:27 +00:00
Andrew Walbran
d80eabc803 Use constants for third_party code locations rather than hard-coding.
The constants already existed but weren't being used consistently. This
will make the Android downstream patches to change the paths a little
simpler.

BUG=b:204072128
TEST=tools/run_tests

Change-Id: If9b81ef9ca0a7c52f0d9fe7cf836841027a2c92d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3253369
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Andrew Walbran <qwandor@google.com>
Auto-Submit: Andrew Walbran <qwandor@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-11-01 13:26:18 +00:00
Dennis Kempin
8f5978fda2 crosvm: Do not use .cargo/config.toml
Building crates in common/ will try to access the file, but won't
be allowed to read it with CROS_WORKON_SUBTREE set.

BUG=b:195126527
TEST=./tools/run_tests --target=vm:aarch64

Change-Id: Ic455ca6c3102dd363daf70468e5d89003d10bb4c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3254042
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-by: Abhishek Bhardwaj <abhishekbh@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
2021-10-30 00:16:33 +00:00
Dennis Kempin
8a1c50d5cd Refactoring: Move various general purpose crates to common/
This change contains the results of running

./tools/contib/cargo_refactor.py

This will break the next uprev, and needs to be synchronizized
with the corresponding ebuild changes in https://crrev.com/c/3248925

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

Change-Id: Ied15a1841887bb8f59fba65b912b81acf69beb73
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3248129
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-29 22:31:43 +00:00
Keiichi Watanabe
cb14f61ce7 mdbook: Explain how to build a binary for beginner
Add a section to explain how to build crosvm binary for beginners who
may not have used cargo.
Also, ran mdformat on the file.

BUG=none
TEST=check

Change-Id: I902157cd471652b829d73bb27fc52e04db64d6d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3252186
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-29 16:43:56 +00:00
Keiichi Watanabe
99020040f9 github: Don't use 80-char rule in pull_request_template
Unlike usual markdowns, GitHub comments don't ignore line breaks. So we
should avoid breaking lines at the middle of paragraph.

BUG=none
TEST=none

Change-Id: I1dfc933c8cfba91d7a7b1e411b2cd4193a3487c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3251825
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-29 16:19:21 +00:00
Keiichi Watanabe
80801406ce github: Use install-deps script
We now install newer meson via pip instead of apt-get.

BUG=none
TEST=run GitHub action on my personal account

Change-Id: Icbe55bf06e84253cd26e676647bca17408ab9d9b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3251824
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-29 16:19:21 +00:00
Keiichi Watanabe
787e5c3dcc CONTRIBUTING: Add a guide for contributing to the book
BUG=b:199687531
TEST=check rendered result

Change-Id: I1fcb4bb2853658866a599394d54d344d4ebc2e50
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3250154
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-10-29 03:21:07 +00:00
Keiichi Watanabe
24d6f7a8a3 github: Add yaml for mistaken-pull-closer app
ref. https://opensource.google/docs/github/disable-features/#close

BUG=none
TEST=none

Change-Id: I850718d059737c14f546d9fad438db14bfe3955d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3250156
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-10-29 03:21:06 +00:00
Keiichi Watanabe
04eff872d8 navbar: Update navbar contents
BUG=none
TEST=see Gitiles view at Gerrit

Change-Id: I6af5b8f3b65ac5e43d769011843874f9fcee7782
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3250153
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-10-29 01:56:24 +00:00
Keiichi Watanabe
daa5b7b27d github: Add pull request template to tell we use Gerrit
BUG=none
TEST=none

Change-Id: I003f0084b8b057d669ec0c6160f4d8fed2871919
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3250152
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-10-29 01:56:24 +00:00
Keiichi Watanabe
105a94aaaf README: Use PNG logo image
Use PNG instead of SVG as Gitiles doesn't render SVG well.
In order to make ImageMagick's conversion work well, fill-opacity and
stroke-opacity are explicitly specified in the SVG.

Also, the PNG image will be put at the bottom of README so people can
read contents at first glance without scrolling over the logo.

BUG=none
TEST=check gitiles view on Gerrit
TEST=mdbook build

Change-Id: I2203be1258265400be3caf2ad8d8a1e8cacc5aab
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3250151
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-10-29 01:56:23 +00:00
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