Commit graph

2837 commits

Author SHA1 Message Date
Xiong Zhang
0b8318a2be Linux: Change root_config from PciConfigArch to PciRoot
Since PciRoot has been modified into Arc<Mutex<>>, RunnableLinuxVm->root_config
could be changed from PciConfigArch to PciRoot also, this could simplify code
and reduce two functions from PciConfigArch.

BUG=b:197877871
TEST=tools/presubmit

Change-Id: Ibc18587900d6f8259ac1d6f8fe7b3ea4fedad07e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3305942
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2021-12-08 12:30:28 +00:00
Chih-Yang Hsia
41dc04fc82 crosvm: Support multiple CRAS virtio-snd cards
Support creating multiple CRAS virtio-snd cards.

Changes:
- Change `cras_snd` to `cras_snds: Vec<CrasSndParameters>`
- Push multiple virtio-snd cards to device list

BUG=b:199001477
TEST=Run crosvm with 2 `--cras-snd` params and check
     `aplay -l` and `arecord -l`

Change-Id: I8c9f82a4f5b8749ca7a289226b209673646b62b0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3320921
Auto-Submit: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Woody Chow <woodychow@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
2021-12-08 08:38:50 +00:00
Keiichi Watanabe
60334439a1 vmm_vhost: Parametrize Endpoint in Master trait
Allow having a Master struct with a backend other than socket. This will
be helpful for multi-platform support.

BUG=b:194137301
TEST=cargo test --all-features in vmm_vhost

Change-Id: Ie1bd8949ddb708c87a964544c6ae2fe7391b1fb5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3320904
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-08 07:47:41 +00:00
Keiichi Watanabe
155d01df43 vmm_vhost: Implement From<UnixStream> for socket::Endpoint
Instead of having `from_stream()` method, use `From` trait.

BUG=b:206900656
TEST=cargo test --all-features in vmm_vhost

Change-Id: I8b6f06231c0b28e3e5f7b924221fe51f050c077b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3320903
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-08 07:47:40 +00:00
Keiichi Watanabe
5f5f6afacd vmm_vhost: Add TODO comments about IoSlice::advance_slice()
BUG=b:194137301
TEST=cargo test

Change-Id: I28466597209e4e81dc566d66d69875f59808eb0f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3317325
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-08 07:47:39 +00:00
Keiichi Watanabe
7d4d02fc94 vmm_vhost: Expose connection::{socket, vfio} module
Expose connection::{socket, vfio} modules so that we don't need to have
prefix for structs there.
e.g. SocketEndpoint -> connection::socket::Endpoint

BUG=b:194137301
TEST=cargo test --all-features in vmm_vhost
TEST=cargo check in crosvm

Change-Id: I7d992a0df5a838fa6a726f366e9595b20405ec3b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3317324
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-08 07:47:38 +00:00
Dmitry Torokhov
22eb7c044c x86_64: stop forcing reboot via keyboard port
Now that we have wired up PCI reset and exposed it via ACPI reset
register we no longer need to force resetting via keyboard port.

BUG=b:3169569
TEST=Reboot mantee board

Change-Id: I4bc02909199b3f519993794e28ed742432ebd64b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3317156
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2021-12-08 06:33:03 +00:00
Dmitry Torokhov
f75699f59c crosvm: return 32 exit code when guest issues reset request
Instead of returning 0 for both shutdown and reset/reboot, let's have
shutdown continue returning 0, but reset will now return 32 exit code,
so that callers will have an option to handle this case differently.

BUG=b:3169569
TEST=Examine crosvm exit codes when resetting and shutting down VM

Change-Id: I2c7c11b7f8c8528744f7e25e5d17c6fa9810f409
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3316835
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2021-12-08 06:33:02 +00:00
Dmitry Torokhov
d05fc4e6f4 acpi: expose PCI reset register in ACPI
This will allow guest OS to issue reset requests via ACPI methods.

BUG=b:3169569
TEST=Build and boot.

Change-Id: I6d29422f962c21a2e513cb4da78515e31468a1e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3316834
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2021-12-08 06:33:00 +00:00
Dmitry Torokhov
b41b9bbb42 devices: pci: wire up reset via 0xcf9 register
This is a bit of a hack, but crosvm does not support overlapping IO/MMIO
regions, so we have to handle reset register in PciConfigIo handler
(which covers 0xcf8 - 0xcff range) instead of installing a dedicated
reset handler separate from PCI root handler.

BUG=b:3169569
TEST=Try rebooting Manatee booted with "reboot=p"

Change-Id: I79991f456d4aaaab2c904e312996208aa72ab6ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3316833
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2021-12-08 06:32:59 +00:00
Alexandre Courbot
00065869cf linux: disambiguate error context messages
Error context messages should be unique to easily identify where they
come from.

BUG=None
TEST=cargo build

Change-Id: I1c1deb051a6c77f624c60c581ee680dbad1ae997
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3320914
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2021-12-08 05:41:56 +00:00
Alexandre Courbot
a184e31757 crosvm: display error chain when VM fails
Use the '{:#}' formatter to display the complete error chain. This turns
the following error:

	crosvm has exited with error: failed to set up virtio networking

into the more helpful:

	crosvm has exited with error: failed to set up virtio
	networking: failed to open tap device: failed to create tap
	interface: Operation not permitted (os error 1)

BUG=None
TEST=cargo build

Change-Id: I65126af54a9a3cef7823e55c021dcd591660077a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3320913
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2021-12-08 05:41:55 +00:00
Keiichi Watanabe
31bc5998bb devices: vhost: user: Add README
BUG=none
TEST=none

Change-Id: I6a7b27c5dbb44d417ff9e0e7b213403efee92ec5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3320905
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-12-08 05:29:58 +00:00
Xiong Zhang
fd032f2a77 x86_64: Add pcie enhanced configruation into mmio_bus
Reserved 64MB mmio space for pcie enhanced configuration access,
and added it into mmio_bus with PciConfigMmio.

Now pci_root will be added into PciConfigIo and PciConfigMmio, so
Arc<Mux<pci_root>> is used.

BUG=b:197877871
TEST=tools/presubmit

Change-Id: Ic90a4cc3dfb00b09358478e129cc8a16e91012c6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3305941
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2021-12-08 00:22:50 +00:00
Junichi Uekawa
b180f9ce0f crosvm: use BusRange in DirectIoOption.
Used to use an unnamed tuple there but instead use the BusRange because
it's semantic and now there's less copying.

BUG=b:188011323
TEST=cargo test --features=direct

Change-Id: I4a10251c758d330b8938090fb5971badcb9b7bdf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3319716
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2021-12-08 00:22:43 +00:00
Dennis Kempin
f18de38a02 kokoro: clean repo before merging
There can be leftover files from a previous build.

BUG=b:209034086
TEST=./ci/kokoro/simulate build-merge-into-chromeos.sh

Change-Id: I0f7223bc6dd1769db04408f595764931c3ff2af8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3321730
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
2021-12-07 21:03:03 +00:00
Dennis Kempin
fbb2de0188 kokoro: Various fixes to merge-into-chromeos job
- Adds the needed job config
- Makes a copy of the script before git checkout
- Follow naming scheme of other build scripts
- Add reviewer when uploading

BUG=b:209034086
TEST=./ci/kokoro/simulate build-merge-into-chromeos.sh

Change-Id: I279ff6aca7c3c304354a238ebd5c40b4dd272385
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3321726
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
2021-12-07 20:50:29 +00:00
Keiichi Watanabe
0d801c9cd2 devices: vfio: Avoid arch-dependent type conversion for IommuType
Since ioctl_with_val takes c_ulong, whose size is 64-bit in x86 but
32-bit in ARM, we must not assume it can be converted to u64.

BUG=none
TEST=cargo check

Change-Id: Ib0060bbbe2e06c94bf8802c8e775c808c07ff6a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3320123
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-12-07 17:45:57 +00:00
Anton Romanov
bbec8ebf65 Use tmpfs for /tmp in dev container
This works around quirkiness of sparse file support in overlayfs.

Revert "sys_util: ignore seek_hole tests for kokoro uprev"
This reverts commit 3d0e51f71c.

BUG=b:208901617

TEST=./tools/dev_container --hermetic bash -c "cd common/sys_util; cargo test seek_"

Change-Id: Id4d809f09a71b5cd134b5eb9bf6a5f970e5503c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3319404
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Anton Romanov <romanton@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
2021-12-07 17:44:17 +00:00
Abhishek Bhardwaj
e396dca250 crosvm: vvu: proxy: Implement device configuration
This change implements the proxy device configuration.

BUG=b:194136484
TEST=Compile.

Change-Id: I648890117e5609447086d130e7c3fe6b63dc8724
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3288869
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Abhishek Bhardwaj <abhishekbh@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-07 09:22:26 +00:00
Chih-Yang Hsia
049746fb8a device: virtio: snd: Call release_worker in prepare
Since VIRTIO_SND_R_PCM_PREPARE -> VIRTIO_SND_R_PCM_PREPARE is a valid
transition, we need to release the worker if it's already in
VIRTIO_SND_R_PCM_PREPARE state. Or we could trigger

```
Error in handling tx queue: Error in mpsc: send failed because receiver is gone
```

in handle_pcm_queue while sending `desc_chain` to start_pcm_worker
through the `stream_info.sender()`.

BUG=b:202368198
TEST=Run alsa_conformance_test multiple times

Change-Id: I5f8ee370832ee162fdef71d396dfe848d88af7e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3317328
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Woody Chow <woodychow@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-12-07 03:33:47 +00:00
Chih-Yang Hsia
c6d01914de device: virtio: snd: Add missing handle_irq_resample
While running alsa_conformance_test against the virtio-snd device, the
driver will randomly stop getting irq events forever. (vp_interrupt will
never get called).

At the same time, the host device will still see an uncleared
`interrupt_status` so the `trigger_interrupt` -> `signal`
will just drop the interrupt signal on
the host device side. And the device can't be used forever when the
issue happens.

Root cause:
Irq resample events never get handled in the virtio-snd device, so the
interrupt handler in guest just can't get notified if there are some
unhanded interrupts in the irq line during the resample event.

Changes:
- Add `f_resample` future in the run_worker
- Use `select!` from futures crate with `async-await` feature
- Change local interrupt in run_worker to Rc<RefCell<interrupt>>
- Use anyhow::Context for errors

BUG=b:202368198
TEST=vm.AudioAlsaConformance.virtio_cras_snd
TEST=Run alsa_conformance_test multiple times in guest VM

Change-Id: Id1440420dcfeccbbb455b1d342863e430ef4b6f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3317327
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-12-07 03:33:46 +00:00
Xiong Zhang
2b286f4305 pci_root: Don't assume register bit number is eight
In pcie enhanced configuration access, register bit number is 12, in order to
support such PciConfigAddress, this commit make register bit number
variable, it could be 8 or 12 decided by caller.

BUG=b:197877871
TEST=tools/presubmit

Change-Id: I96a317896b9536742534bee86f0e8f1acc323292
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3305940
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-12-07 01:11:42 +00:00
Dennis Kempin
e061930706 Add Kokoro build script for merging main into chromeos
The Kokoro build script sets up access to the chromium
gerrit, creates the merge commit and uploads it.

BUG=b:209034086
TEST=./ci/kokoro/simulate merge-to-chromeos.sh

Change-Id: Ia686b937c3d6b0b744d5c2162eb2847c5952e977
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3318793
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-12-06 23:28:26 +00:00
Allen Webb
89759de1d1 sys_util: Remove extra semicolon to fix warning on nightly.
Nightly rust generates errors of the following form:
warning: trailing semicolon in macro used in expression position
   --> /home/allenwebb/external/NoBackup/chromiumos/src/platform/crosvm/common/sys_util/src/syslog.rs:193:10
    |
188 | / macro_rules! lock {
189 | |     () => {
190 | |         match lock() {
191 | |             Ok(s) => s,
192 | |             _ => return,
193 | |         };
    | |          ^
194 | |     };
195 | | }
    | |_- in this expansion of `lock!`
...
336 |       let mut state = lock!();
    |                       ------- in this macro invocation
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>

BUG=None
TEST=cargo test

Change-Id: I323d5a4d88d1e2fe4b7745d3f49adef808ee7016
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3318767
Auto-Submit: Allen Webb <allenwebb@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-12-06 23:06:23 +00:00
Dennis Kempin
0830e2f11c chromeos: Add script for merging from cros/main
This script can be used to manually create merge
commits to be uploaded to gerrit, and will also
be used by the buildes doing automatic uprevs.

The main purpose of the script is to create a helpful
commit message describing the commits included.

BUG=b:209034086
TEST=./tools/chromeos/create_merge

Change-Id: I65715ebefb182a5287b5052b6af56361e41d8efd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3315374
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-12-06 21:19:19 +00:00
Junichi Uekawa
b6a6e94382 crosvm: Allow hex values in direct-io command-line options.
The configuration file is written in hex but what is passed through in
and command-line is decimal. Usually we think in hex, allow passing hex
into the command-line options.

BUG=b:188011323
TEST=cargo test --features=direct

Change-Id: I6e3589815fdd17c8d90bac1f9064f3abd352177d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3319036
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2021-12-06 21:17:15 +00:00
Junichi Uekawa
de923289a5 crosvm: Add _ every 4 digits.
Hex memory regions usually are better expressed with 4 digits as one
compound.

BUG=b:188011323
TEST=None

Change-Id: Ic42fcbb6fd8c4ada5f0fb18c2ff41e3dbffb3408
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3312863
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-12-06 21:07:57 +00:00
Mattias Nissler
58fc0682c1 Correct subsystem_{vendor,id} mixup in StubPciDevice
BUG=None
TEST=New unit test.

Change-Id: Idfe19e5d2f1625e7c76f390928342f02f0d17cff
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3308807
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-12-06 21:05:30 +00:00
Daniel Verkamp
3d0e51f71c sys_util: ignore seek_hole tests for kokoro uprev
These tests were failing when upgrading to the new Ubuntu 16.04
environment, so temporarily disable them while we diagnose the problem.

BUG=b:208901617
TEST=cargo test -p sys_util seek_ # check for "ignored"

Change-Id: Ia1152f98b0a6e88db02fb23ce8f61f663fa74ad5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3318783
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-12-06 20:53:03 +00:00
Daniel Verkamp
d572d8dda0 OWNERS: add dtor@
BUG=None
TEST=None

Change-Id: I457dcebd97a8108b448afcf0334125cc511c3202
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3315402
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-12-06 20:36:52 +00:00
Keiichi Watanabe
4b34573b46 devices: vfio: Define IommuType enum
BUG=none
TEST=build

Change-Id: Ia6de8f19cfc335a86bc5ba4d88f29e1839bd6ba7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3310340
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-12-06 14:58:11 +00:00
Keiichi Watanabe
7b80554473 devices: vfio: Add new constructor for VFIO driver
The current `VfioDevice::new()` definition is assuming that it's a VFIO
passthrough device that takes a VM guest. To reuse the `VfioDevice` for
cases other than passthrough, this CL rename that method to
`VfioDevice::passthrough()` and adds a simpler constructor.

BUG=b:194137301
TEST=build

Change-Id: I2bd420b17ed8675c1630c8fc41f47485351d8bb0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3149874
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-12-06 14:58:10 +00:00
Keiichi Watanabe
9c95cd2f8a vmm_vhost: Add VFIO backend for virtio-vhost-user
BUG=b:194137301
TEST=cargo test --all-features

Change-Id: I899c579779d51b7712ce4030856dfbe683c99df2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3270300
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-12-06 14:23:20 +00:00
Keiichi Watanabe
91f1262bcf sys_util: sock_ctrl_msg: Use IoSlice when sending buffers
Make `send_bufs_with_fd(s)` take `IoSlice` instead of `&[u8]`.
Note that no Chrome OS-side is needed for this API change because these
methods aren't used in any other Chrome OS projects.

BUG=b:204720423
TEST=cargo test in sys_utils and vmm_vhost

Change-Id: I02701d9c4e964ea95f0746b17254fa029fee7531
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3302696
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-12-06 14:23:19 +00:00
Chih-Yu Huang
d2c2bd1ba3 linux: mount all possible render nodes
Originally, we only mount 1 render node "/dev/dri/renderD128".
However, the working node might not be this one. This CL mounts all
the possible render nodes.

BUG=b:202352463
BUG=b:201738023
TEST=tast run $(DUT) arc.Boot.vm and confirm all render nodes are bound

Change-Id: I10331a1fba724ae2f75a96f59b1a9931e108e213
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3317006
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Auto-Submit: Chih-Yu Huang <akahuang@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chih-Yu Huang <akahuang@chromium.org>
2021-12-06 08:06:41 +00:00
Dmitry Torokhov
4eec83452d x86: make iterating through SDTs more Rusty
Instead of open coding a loop, use any() method to check if we have
matching entries.

BUG=None
TEST=./tools/presubmit

Change-Id: Ib1fe7e65436bc3c8cca99be69855eb0ebc3cf096
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3313842
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2021-12-06 03:29:47 +00:00
Abhishek Bhardwaj
ff0337423f crosvm: vvu: proxy: Implement notifications region read and write
This change implements read and write for notifications region in the
bar.

BUG=b:194136484
TEST=lspci in the guest and look for the proxy device.

Change-Id: I06a98e5cbabc01d8799a033cd1ad916d14de1644
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3288868
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Abhishek Bhardwaj <abhishekbh@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-12-04 03:49:26 +00:00
Daniel Verkamp
a8dc35123a x86_64: acpi: deduplicate PCI IRQs in MADT
The pci_irqs list contains an entry for each PCI device, but IRQ numbers
may be reused, so the MADT would contain duplicate interrupt override
entries in this case. This doesn't cause a problem in practice (the
duplicates are all identical and the guest kernel does not complain),
but it makes sense to remove the duplicates and only add a single
IOAPIC interrupt override entry per unique IRQ number.

BUG=b:207551552
TEST=x86_64 guest kernel only has 4 INT_SRC_OVR logs in dmesg

Change-Id: Iba4c57ca93d4be6c21e087b2f3f416fe022e8d35
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3315408
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
2021-12-04 00:18:01 +00:00
Daniel Verkamp
754068786a Revert "x86_64: remove acpi=noirq kernel option"
Basic functionality works with a purely ACPI-based boot (no MPTable),
but something is still missing in the ACPI tables for describing the
full interrupt routing configuration. The guest kernel complains:

  virtio-pci 0000:00:01.0: can't derive routing for PCI INT A
  virtio-pci 0000:00:01.0: PCI INT A: no GSI

Restore the acpi=noirq option for now until we fill out the ACPI IRQ
descriptors correctly; this was a cleanup only and not required to fix a
bug.

This reverts commit cb464a7c08.

BUG=None
TEST=Boot Crostini; no interrupt routing failures in dmesg

Change-Id: Ib73c5749b48134124b3ebcb472706f087e8a85a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3315226
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-12-04 00:16:50 +00:00
Dennis Kempin
39c2a45469 seccomp: Remove readlink from remaining aarch64 policies
Missed a couple that do not inherit from common_device.policy.

BUG=b:209021536
TEST=Cq

Change-Id: I672af4e7746bbf971193a10031f0ac27302ef3b0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3314284
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
2021-12-03 22:49:04 +00:00
Abhishek Bhardwaj
362d410255 crosvm: vvu: proxy: Allocate device capabilities
This change allocates device capabilities as per the VVU proxy device
spec.

BUG=b:194136484
TEST=Compile.

Change-Id: I6f8858468466278d6ce845ce21f431222ba66557
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3288867
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Abhishek Bhardwaj <abhishekbh@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-12-03 22:06:37 +00:00
Daniel Verkamp
cb464a7c08 x86_64: remove acpi=noirq kernel option
Now that we provide a correct MADT ("APIC" table ID), there is no need
to override the kernel ACPI option that made it ignore these tables.

BUG=None
TEST=Boot crosvm with setup_mptable() call removed, ACPI only

Change-Id: I9f4589738462c5693f151f60180c79d054a9084d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3313841
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-12-03 21:25:34 +00:00
Daniel Verkamp
0708961098 x86_64: acpi: report presence of 8259 PICs
KVM's irqchip emulation provides the traditional PC-style pair of 8259
PICs, so report this by setting the appropriate flag in the MADT (APIC)
table.

BUG=b:207551552
TEST=Boot crosvm with setup_mptable() call removed

Change-Id: Ib5adf7ac717156deb3cd19d74873c9745ae826ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3313840
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
2021-12-03 21:25:33 +00:00
Daniel Verkamp
5ceeda7964 x86_64: acpi: add PCI IRQs to MADT
Add interrupt redirection entries to MADT so that the legacy pin-based
interrupts are correctly reported as level triggered. This matches the
entries in the existing MPTable, but those are not availble when booting
with OVMF, which only provides ACPI tables.

This fixes an issue where USB device sharing was failing in some cases
when booted with ACPI only, since our xhci controller emulation only
supports pin-based interrupts (not MSI-X) and would not work correctly
when the guest incorrectly treated its IRQ as edge triggered.

BUG=b:207551552
TEST=Start crosvm with setup_mptable() call removed
TEST=Share USB device when booted with ACPI via OVMF

Change-Id: Id3e4ff5ba9587aadbeadbcc8eceaa771c4c2d5df
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3312577
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
2021-12-03 21:25:33 +00:00
Daniel Verkamp
ee12ec1bdf x86_64: mptable: make pci_irqs a slice instead of Vec
This function doesn't need to consume the pci_irqs vector, just iterate
over it.

BUG=None
TEST=tools/presubmit

Change-Id: Ibb66fa6ab8c45f58eeb89b976bcfc57e00d718a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3313996
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-12-03 21:25:32 +00:00
Dennis Kempin
e6ad05efc0 seccomp: Remove readlink from aarch64 policies
aarch64 only has the readlinkat syscall.

BUG=b:209021536
TEST=Cq

Change-Id: I0a6a76bbc388f598f639a97832269256f6e9a61e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3314710
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-12-03 19:35:07 +00:00
Xiong Zhang
5d8d238b6a vfio-pci: Don't call enable_intx if device doesn't support intx
Pci spec defines Interrupt Pin register that devices don't use an interrupt pin
must put a 0 in this register. The values 05h throgh FFh are reserved. So if
vfio-pci reads interrupt pin register and gets value like 0, 0x5~0xFF, it means
vfio pci device doesn't support legacy intx, then interrupt_evt and
interrupt_resample_evt don't need to be saved, finnaly enable_intx ioctl won't
be called into kernel vfio.

This fixes an error message during CrOS reboot, poweroff, xhci controller's
suspend and resume on Brya ManaTEE:
ERROR: vfio 0000:00:0d.0 device Intx enable failed: failed to enable vfio device's
irq: Invalid argument (os error 22).

BUG=None
TEST=check vfio-pci xhci controller (00:0d.0)'s function during suspend and resume.

Change-Id: Ib25c8877f0e10431c097914aa5cc7b7ad0e24612
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3312579
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-12-03 19:17:39 +00:00
Abhishek Bhardwaj
5c86fef96d crosvm: vvu: proxy: Allocate bar and add handler stubs
This change allocates the additional resource bar for the VVU proxy
device and adds read / write stubs for the notification region.

BUG=b:194136484
TEST=Compile.

Change-Id: Ia7b0e522462aea68fb6ccf11037320393cc4ffd5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3288866
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Abhishek Bhardwaj <abhishekbh@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-12-03 13:04:35 +00:00
Abhishek Bhardwaj
00d939bc88 crosvm: vvu: proxy: Fix constants and add VVU proxy type
This change separates the number of queues of the proxy device from the
number of queues of the actual VVU device. It also fixes the device type
constant to the number specified by the spec. Also, change PciClassCode
for legacy devices. The guest VFIO driver code doesn't enumerate the
proxy device without it.

BUG=b:194136484
TEST=Compile.

Change-Id: I105a46168302b1cc53a7c61c55019d8b1e703b40
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3288865
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Abhishek Bhardwaj <abhishekbh@chromium.org>
2021-12-03 01:53:35 +00:00