Commit graph

2848 commits

Author SHA1 Message Date
Chih-Yang Hsia
99829b3e17 devices: virtio: snd: Support num_{output,input}_streams
Since Android needs separated PCM devices for different use
cases, we add multiple PCM streams support in virtio-snd
for both input and output direction.

Changes:
- Add num_{output, input}_streams support in ChromeOS's backend
- Remove todos since hardcoded_snd_data and
  hardcoded_virtio_snd_config are used in cras_backend
  implementation only.
- Update help message

BUG=b:199001477
TEST=`cargo test` for Parameters parsing
TEST=`crosvm run --cras-snd=num_output_streams=<num> ...`
     and check with `aplay -l`
TEST=`crosvm run --cras-snd=num_input_streams=<num> ...`
     and check with `arecord -l`

Change-Id: I59b2fd547b101d099f837f85c0b739f720795990
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3322796
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Woody Chow <woodychow@google.com>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
2021-12-09 02:05:09 +00:00
Anton Romanov
14e024ae4e Make aarch64 vm usable for running armhf binaries.
BUG: b/203152778
TEST: ./tools/run_tests --target vm:aarch64; ./tools/run_tests vm:aarch64 --arch armhf
Change-Id: I5b774ebf66f1a0a71e025dc364a6e85d43d3b6cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3324410
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
2021-12-09 01:08:45 +00:00
Xiong Zhang
91a56fe9da x86_64: Change E820Type from constants to enum
In order to comply with kernel E820Type definition and make code more
readable, this commit changes E820Type from constants to enum.

BUG=None
TEST=tools/presubmit

Change-Id: I514a3f71c734305c19cebbca6844f09d1fb16dab
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3314866
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-12-09 00:19:44 +00:00
Xiong Zhang
65700032fb x86_64: remove "pcie_ports=native" command line
Since _OSC is added, OS could negotiate any pcie features with firmware
through _OSC, so remove "pcie_ports=native" parameter from command line.

BUG=b:197877871
TEST=check pcie native hotplug compability in VM

Change-Id: Iba363aa0d5c6acaf61d72ed9cc4697677f9ace6c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3305946
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-12-09 00:19:43 +00:00
Xiong Zhang
b5fa790d53 x86_64: Add _OSC for pcie hotplug
OS call acpi _OSC method to request control for PCIE natvie features like
pcie hotplug, pcie advanced error report, pcie PME. But currently crosvm
lack of _OSC method, so OS couldn't enable these pcie features.

This commit add _OSC method, enable pcie hotplug and pcie cap structure
control, but disable SHPC hotplug, pcie PME and pcie AER.

BUG=b:197877871
TEST=Check pcie hotplug capability in VM

Change-Id: If4b6c8026c312ebfdeb18df7c0673571e3e9b631
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3305945
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-12-09 00:19:42 +00:00
Dennis Kempin
f4d5d32970 Add documentation for ChromeOS integration
BUG=b:209034086
TEST=None

Change-Id: Ia26a1fdd110dd72e3801a189d2854fd876469030
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3321735
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
2021-12-08 18:50:50 +00:00
Dennis Kempin
cd0c2b846a kokoro: Add user name / email to commits
This prevents gerrit from claiming we are forging email addresses.

BUG=b:209034086
TEST=None

Change-Id: I9f5bab0684f40ad5220d8c88d89a34e23facab99
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3321734
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-12-08 18:50:50 +00:00
Keiichi Watanabe
d448be0d0d devices: vfio: Add methods to read/write region at specified address
Add utility methods to read/write VFIO memory region

BUG=b:194137301
TEST=build

Change-Id: Ia1054bb74bed791451e7bb8c87c2eb9b84353a2d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3149873
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-08 16:19:48 +00:00
Keiichi Watanabe
75da78b21b vmm_vhost: Remove SlaveReqHandler type parameter in SlaveReqHelper
The type parameter `S: SlaveReqHandler` for `SlaveReqHelper` was
introduced to check if it's vvu or not.
Howver, SlaveReqHelper shouldn't take a type parameter of
`SlaveReqHandler` because the helper will be used in the VVU proxy
device which doesn't  have its own req_handler.

So, instead of taking the type parameter, we should have a new bool
field which indicates if it's VVU or not.

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

Change-Id: I35f20ef7c42cd74678ab5d87b68bbb58586d2fa5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3320122
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-08 14:50:59 +00:00
Xiong Zhang
a41f6c9be5 pci_root: Emulate PCIE base address register in host bridge
Intel acpi method reads PCIEBAR Base Address Register in host bridge to
get the pcie config mmio base address. This commit emulates this
register, so the acpi method could get the right information.

BUG=b:197877871
TEST=Verify this regsiter's value in a vm

Change-Id: I93bf8e678acc0e085b102a2eb3a88cbf466aed78
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3305944
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:30 +00:00
Xiong Zhang
4c55b20376 x86_64: Add acpi MCFG table
In order to enable pcie enhanced configurtion access mechanism in kernel,
acpi mcfg table is mandatory. So kernel could know the base and size of
pcie enhanced configuration access mmio.

BUG=b:197877871
TEST=Boot a vm and r/w pci config regiser through pcie ECAM

Change-Id: Icecedba3f31cd94bed76e48932c5e77f56effb9c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3305943
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:29 +00:00
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