Commit graph

2928 commits

Author SHA1 Message Date
Daniel Verkamp
0739c780c3 crosvm-fuzz: add hypervisor dependency for block_fuzzer
https://crrev.com/c/3330204 changed the block fuzzer to depend on
hypervisor but did not add the necessary reference to Cargo.toml. Add it
to fix the fuzzer build.

BUG=None
TEST=Build crosvm ebuild with USE=fuzzer

Fixes: 00f1c9fd46 ("Update to the latest pKVM ABI.")
Change-Id: Ic90c6bdd29f87af1c78093a970056467e9c4c36e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3364963
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-01-05 21:46:34 +00:00
Chih-Yang Hsia
e31731c1e5 virtio: move cras-snd creation after virtio GPU
In ARCVM `genfs_contexts`, we have hard-coded rules with device node id for
network and virtio-gpu. In crosvm virtio devices creation, the
device node id is assigned by order, so introducing 2 virtio-snd devices
will shift id to id+2 for those devices created after virtio-snd.

This will break ARCVM-next boot.

Changes:
Move virtio-snd device creation after virtio GPU.

BUG=b:213249578, b:199001477
TEST=cargo build

Change-Id: I2fd6ee2c892ae65b0e41d7f42613714a31d7833f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3366166
Auto-Submit: Chih-Yang Hsia <paulhsia@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-01-05 10:06:51 +00:00
Haiwei Li
3cde974af0 devices: vfio: Fix vfio device initialization missing 'group.add_device_num()'
This fixes a bug introduced by [1] when removing vfio device and
'device_num' is zero.

A panic occured when unplug a vfio device:

[ERROR:src/panic_hook.rs:90] thread 'crosvm_vcpu4' panicked at 'attempt to subtract with overflow', devices/src/vfio.rs:462:9

The variable group.device_num is 0 when subtract. And when initalizes a
vfio device from hot-plugging workflow, 'group.add_device_num()' is
missing.

BUG=b:185084350
TEST=hotplug in and out a vfio-pci device in guest repeatedly

[1]: 7b80554473

Change-Id: I9a039cd15e9f9414a4a0501c64da13be76e59c1b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3365212
Reviewed-by: Xiong Y Zhang <xiong.y.zhang@intel.corp-partner.google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-01-04 21:07:39 +00:00
Andrew Walbran
0bbbb688b9 Add option to run VM in protected mode without pVM firmware.
This is useful mostly for development and testing.

BUG=b:209795495

Change-Id: Ie8c4dfade2cbc770daa7d97e22b1574fdf895a19
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3330210
Reviewed-by: Will Deacon <willdeacon@google.com>
Reviewed-by: Chirantan Ekbote
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-01-04 19:35:29 +00:00
Andrew Walbran
00f1c9fd46 Update to the latest pKVM ABI.
This involves two main changes:
 * Protected VMs must be created with KVM_VM_TYPE_ARM_PROTECTED.
 * pVM firmware is now loaded by IPA rather than memslot ID.

There are also a lot of trivial changes because the ProtectionType enum
was moved from the devices crate to the hypervisor crate.

BUG=b:209794844
TEST=Will tested manually with patched kernel and dummy firmware

Change-Id: I1dd75e20063ca4736f155292ca5f70b94664fdd9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3330204
Auto-Submit: Andrew Walbran <qwandor@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-01-04 19:35:27 +00:00
Keiichi Watanabe
7df3a323f7 devices: vhost-user: Use anyhow instead of thiserror
Since users of `DeviceRequestHandler` don't match on `HandlerError`
enum, there are no advantages on using thiserror. So let's switch to
anyhow.

BUG=none
TEST=cargo test

Change-Id: I6d4697e174a4e587c52ec71ef99b453e1d00cc35
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3353058
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-23 14:06:47 +00:00
Keiichi Watanabe
4960f63d6d devices: vvu: Add utilities to bind vfio-pci device
Add utilities to bind a vfio-pci device, which will be used in
the virtio-vhost-user driver.

This works like the following use of DPDK's devbind script [1].
$ dpdk-devbind -b vfio-pci 'Bus:Slot.Func'

[1]: https://doc.dpdk.org/guides/tools/devbind.html

BUG=b:194137301
TEST=cargo test in devices

Change-Id: I67fb34ae2ad55320231751ea553a2094bb8cdde4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3295303
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Abhishek Bhardwaj <abhishekbh@chromium.org>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-22 13:55:23 +00:00
Keiichi Watanabe
65d4a3e712 devices: vfio: Fix comment on VfioContainer::new_noiommu
BUG=none
TEST=none

Change-Id: Ib7dd0efba9679fbc4c10bb65cc114735fccabcc0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3351435
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-22 06:06:17 +00:00
Yiwei Zhang
2e0a6532fd gpu_render_server: allow syslog and signalfd again
BUG=b:211008411
BUG=b:210908665
TEST=venus on kukui-arc-r and emerge on trogdor64

Change-Id: I5773363857779ecd6c563af331ff7e96dd7f10e9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3352664
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Chia-I Wu <olv@google.com>
2021-12-22 06:01:25 +00:00
Alexandre Courbot
9bb22153ae libvda: ignore pkg_config errors if chromeos feature is not set
pkg_config has introduced a new error type, Error::ProbeFailure, with
version 0.3.23 and returns this new error for the pattern we were trying
to match using Error::Failure. This causes the build script to fail if
the host is using version 0.3.23 or later.

Chrome OS is still using an older version, but trying to build with
cargo is likely to pull a newer one. The pkg_config crate explicitly
advises against matching these errors anyway, so change the strategy by
ignoring the errors if the chromeos feature is not set. That way we
still get clippy coverage while making sure a missing libvda package is
caught during builds that actually use it (libvda is not used outside of
Chrome OS).

BUG=None
TEST=cargo build --features "video-decoder,libvda"
TEST=emerge-zork-arc-r chromeos-base/crosvm

Change-Id: Ib2aad9f41541d3f4fe3cfb89f8b0f857d8033dcb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3347307
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2021-12-22 05:47:05 +00:00
Chirantan Ekbote
ea956bd908 cros_asyncv2: Add async version of SafeDescriptor
Add a `Descriptor` type that allows callers to asynchronously wait for
the descriptor to become readable or writable.  This is meant to be a
temporary solution so that we slowly convert code over to async rather
than having to do it all at once.

BUG=b:195468578
TEST=unit tests

Change-Id: Ib3ccefe09c25e222afe872d4e6d076e1e3b57b39
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3329741
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-12-22 04:36:39 +00:00
Chirantan Ekbote
1c4bb91c03 cros_asyncv2: Add async UnixSeqPacket
BUG=b:195468578
TEST=unit tests

Change-Id: Id9242a4b94d9e1ea72fc09449acbeefc1e2cb9df
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3312767
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-12-22 04:36:37 +00:00
Abhishek Bhardwaj
9df49a3624 crosvm: vvu: proxy: Implement reset and keep_rds method for virtio device
This change implements the reset and keep_rds logic for the VVU proxy
device.

BUG=b:194136484
TEST=Compile.

Change-Id: I01d301f86dfbab766332cb919d32b9e1a0efe82d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3288878
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Abhishek Bhardwaj <abhishekbh@chromium.org>
2021-12-22 02:53:48 +00:00
Dennis Kempin
78ff88e7bc Revert "gpu_render_server: allow syslog and signalfd"
This reverts commit 7a4e207896.

Reason for revert: Fails on aarch64, the send syscall does not exist. See http://go/bbid/8827215539398029665

Original change's description:
> gpu_render_server: allow syslog and signalfd
>
> BUG=b:211008411
> BUG=b:210908665
> TEST=venus on kukui-arc-r
>
> Change-Id: I541277b0be64a96a26ee6745ea759679e6dc5230
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3344109
> Tested-by: kokoro <noreply+kokoro@google.com>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Reviewed-by: Chia-I Wu <olv@google.com>
> Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>

Bug: b:211008411
Bug: b:210908665
Change-Id: Ia838bde85c5e5f7c70a051b55735bb18b75c3d77
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3352488
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2021-12-21 19:38:39 +00:00
Dennis Kempin
2574507dcb libvda: Fix-forward typo in https://crrev.com/c/3340692
The commit broke the chromeos build. The fix forward is easy, it's
just a typo and a reminder we really need to get libvda code compiling
in Kokoro.

BUG=b:210749428
TEST=emerge-amd64-generic crosvm

Change-Id: I47e0c0b8f843e8b66c00513221b58c6197fe644b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3352172
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
2021-12-21 17:22:31 +00:00
Dennis Kempin
8d8a136eaa create_merge: Collect Cq-Depend of included commits
This passes Cq-Depend lines through to the merge commit.
Right now this is done manually by the oncaller, which then
requires another person to CR+2, slowing down the process.

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

Change-Id: I4adacef8b5fb39aa3a300b56fec5ed0ed79980f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3342734
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
2021-12-21 17:21:53 +00:00
Alexandre Courbot
c11063edd8 virtio: video: decoder: allow resource type to be changed through params
Make the decoder able to switch the resource type of its queues when the
new S_PARAMS_EXT command is used.

BUG=b:193202566
TEST=Youtube can play videos on Hatch.

Change-Id: I1ff3c15ae1924c2fdf1b99af9ea24716f17c864f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3340692
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2021-12-21 05:37:42 +00:00
Alexandre Courbot
3847d47fca virtio: video: let resource type be specified dynamically
Originally the resource type of both the input and output queue needs to
be provided when the stream is created.

This however does not work well with guest drivers that allow to change
the memory type being used for buffers after the stream is created, e.g.
V4L2.

To mitigate this, allow to specify the resource type as part of the
stream parameters by introducing new GET_PARAMS_EXT and SET_PARAMS_EXT
that work exactly like the original ones, but handle the resource type
in addition. The old commands are still supported to preserve
compatiblity with guests relying on the old commands.

BUG=b:193202566
TEST=Youtube can decode videos on Hatch.

Change-Id: I84277f8b82773a1d8f4f99bb5050345320807cad
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3143583
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2021-12-21 05:23:03 +00:00
Alexandre Courbot
c9b4c23601 virtio: video: rename GuestObjectHandle to VirtioObjectHandle
This is a more accurate name since the object does not initially come
from the guest.

BUG=b:161774071
BUG=b:209523781
TEST="emerge-hatch chromeos-base/crosvm" passes.

Change-Id: I618419dc7cfb7203669a5c72b015d5acea50ff24
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3340693
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2021-12-20 12:12:21 +00:00
Alexandre Courbot
54cf834c7e virtio: video: fix typo
LibvdaVd was incorrectly spelled LibvdaVD in two places. This goes
unnoticed unless the libvda feature is enabled.

BUG=b:189278506
TEST=cargo build --features "video-decoder,libvda"

Change-Id: Iec7f35b972f8bb7b04d4be373aeac9ae5b7f7da3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3347305
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2021-12-20 10:27:42 +00:00
David Staessens
a78ae7a4ea virtio: video: Add support for libvda-vd decoder backend.
This CL adds support for the new GAVD backend that connects directly to
a Chrome media::VideoDecoder through the new mojo::VideoDecoder
interface. The mojo::VideoDecodeAccelerator interface currently used by
the GAVDA libvda backend is deprecated and will be removed in the
future.

To enable the libvda GAVD backend the "--video-decoder=libvda-vd"
argument needs to be provided to crosvm.

BUG=b:189278506
TEST=arc.VideoDecodeAccel.h264_vm

Change-Id: I8383bbc1e4371093bde7b0385efc51752c7bc466
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3026654
Auto-Submit: David Staessens <dstaessens@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2021-12-20 08:24:20 +00:00
Alexandre Courbot
22740d88b3 crosvm: linux: allow video device to be created even if /usr/lib64 does not exist
`create_video_device` currently fails if `/usr/lib64` does not exist on
the host, because it cannot be bound to the jail in that case. This
should not be a fatal error as this directory is only needed for AMD
devices and may not exist on all hosts.

In case this directory does not exist on the host, the video device
process will just exit with an obscure error code as minijail's
`process_mounts_or_die` cannot mount it. Logging is not visible to the
user for some reason, so this makes it a pretty difficult issue to
debug.

Fix this by extracting the code that mounts existing directories in
`gpu_jail` and using it from `create_gpu_device` as well.

BUG=b:210599385
TEST=crosvm can start with `--video-decoder` on a host where
`/usr/lib64` does not exist.

Change-Id: Iacdfe6d3925689ba645c07d6cdbcbab5e1729b5c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3341133
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2021-12-17 02:38:32 +00:00
Phillip Pearson
1675e32f36 virgl_renderer: Fix incorrect usage of CString
Calling CString::into_raw, changing the length of the string, then
passing it to CString::from_raw is not allowed:
https://doc.rust-lang.org/std/ffi/struct.CString.html#method.into_raw

This uses a vector instead, and truncates it to the length reported by
vsnprintf.

BUG=b:209867862
TEST=Borealis boots, and accelerated graphics work.

Change-Id: I4b08eabda74086819b3fb437247a5f2ef962defe
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3324614
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Phillip Pearson <philpearson@google.com>
2021-12-16 21:58:33 +00:00
Yiwei Zhang
7a4e207896 gpu_render_server: allow syslog and signalfd
BUG=b:211008411
BUG=b:210908665
TEST=venus on kukui-arc-r

Change-Id: I541277b0be64a96a26ee6745ea759679e6dc5230
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3344109
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chia-I Wu <olv@google.com>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-12-16 20:40:57 +00:00
Alexandre Courbot
c3b98b3daf virtio: video: move resource type to queue parameters
The memory type of resources is a per-queue property, so move it here.
On top of making sense, this will also allow us to extend the
virtio-video protocol to support changing the resource type as part of
the parameters, which is something we need to do in order to support
both guest memory and virtio objects as resources.

BUG=b:193202566
TEST=Youtube can decode videos on Hatch.

Change-Id: I4315292a33d4f145d815fef44803881002d59c3b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3340691
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2021-12-16 07:58:15 +00:00
Dennis Kempin
82f9987349 Remove uprev section from CONTRIBUTING.md
It's ChromeOS specific and we just added a separate file for that.

BUG=None
TEST=None

Change-Id: I67e77c3d30e4e4bf456677a13130563c57a87464
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3336216
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2021-12-16 06:26:53 +00:00
Alexandre Courbot
cd88647f7d seccomp: x86_64: inline common_device syscalls into video_device
The video device needs to redefine the filters for mmap and mprotect,
which the minijail compiler rejects:

    compile_file: /usr/share/policy/crosvm/video_device.policy(35): syscall mmap redefined here
    compile_file: /usr/share/policy/crosvm/common_device.policy(26): previous definition here
    compile_file: /usr/share/policy/crosvm/video_device.policy(36): syscall mprotect redefined here
    compile_file: /usr/share/policy/crosvm/common_device.policy(27): previous definition here
    compile_filter: compile_file() failed
    failed to compile seccomp filter BPF program in '/usr/share/policy/crosvm/video_device.policy'

Prevent this error from happening by inlining the common_device
declarations in video_device and removing the declarations for mmap and
mprotect.

BUG=b:210601086
TEST=Video device can be created when making crosvm use the .policy
files instead of compiled .bpfs.

Change-Id: Ifa7aa84772ae59123cc04e8c9ea845ba6ed7b559
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3341131
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2021-12-16 03:50:58 +00:00
ZhaoLiu
1e6e7b2ee9 x86: Expost HT flag to Guest in host-cpu-topology
At present, host-cpu-topology won't set HT flag for vCPU.

It's reasonable to allow Guest have the same HT flag setting as Host
when set host-cpu-topology.

BUG=None
TEST=cargo build
TEST=set host-cpu-topology and check ht flag in /proc/cpuinfo

Change-Id: I116e49975ab32d37c733690bc0f0f96148fbd4f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3314869
Reviewed-by: David Stevens <stevensd@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-12-15 23:51:57 +00:00
ZhaoLiu
77aa069b67 x86: Fix HT flag in CPUID when set no_smt
At present, if no_smt is set, the cpus of Guest still has the HT flag.

To fix this issue, won't set HT flag in Guest's CPUID if no_smt is set.

BUG=None
TEST=cargo build
TEST=set no_smt and check if there's HT flag in /proc/cpuinfo

Change-Id: I8a986867f272face39253b523462dc8a26ab479c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3314868
Reviewed-by: David Stevens <stevensd@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Mattias Nissler <mnissler@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-12-15 23:51:56 +00:00
Zhuocheng Ding
79eb86a5b9 x86: Expose hybrid CPU info to Guest
At present, when set host-cpu-topology option, the Guest still can't
get the hybrid information.

Now, for ADL, the hybrid related info is needed. These info include the
hybrid part flag (bit 15) in leaf 7 of CPUID, the core type and native
model id in leaf 1A of CPUID.

BUG=None
TEST=cargo build
TEST=Check the CPUID dump of Guest and Host

Change-Id: Icc03bc50160fdffc221e992d90225e7ed8081e8d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3314867
Reviewed-by: David Stevens <stevensd@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-12-15 23:51:31 +00:00
Daniel Verkamp
01de4049ec usb_util: do not silently drop non-EAGAIN errors
Fix the error check in the poll_transfers() loop so that ioctl errors
other than EAGAIN are propagated to the caller.

BUG=chromium:1278424
TEST=Connect USB device to Crostini

Change-Id: I5508550011101a98e4d32099ac0044a3d9137018
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3335303
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-12-15 19:34:08 +00:00
Daniel Verkamp
782087b038 devices: event_loop: delete hung-up events
When a file descriptor is returned from the poll context that has the
hungup flag set, it should no longer be polled. Remove it from both the
poll context and the map of handlers when hangup occurs.

Additionally, instead of stopping the whole event loop when an event
handler error occurs, just remove the failing event handler from the
watched set and continue. This should improve robustness of the USB
controller emulation.

BUG=chromium:1278424
TEST=Share USB device with Crostini via vmc, then physically unplug

Change-Id: Iccaae0ea24b43d0b5e593ca2fe4418eb3892300a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3335302
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-12-15 19:34:07 +00:00
Daniel Verkamp
9c7fd94996 devices: usb: use anyhow to provide better errors
Previously, if any event handler in the event loop failed, it would
print a generic "event loop stopping due to handle event error" message
and stop working. This is not particularly useful for determining which
event handler actually failed. Instead of returning an empty Err, use
anyhow::Context to associate each potential failure with a
human-readable error string.

chromium:1278424
TEST=Cause USB event loop failure, observe more useful message

Change-Id: I438a96bf757946efbd03a99ef0e17dfbf0d4e1c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3339793
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-12-15 19:34:06 +00:00
Chih-Yang Hsia
7c97b2e7d3 devices: virtio: snd: Change start_pcm_worker to be polled by streams
Improvements:
- Once a {playback, capture} stream is initiated.
  We should start write (read) audio in each callback period or
  the underlaying audio server will underrun (overrun).
  (Even in the WorkerStatus::Pause state).

- Change the polling loop logic to

  wait for next buffer
  -> check status
  -> try_next desc_chain or exit
  -> transfer data or exit

  And make start_pcm_worker act like real audio hw device, which
  consumes data in every fixed period.

- Right before leaving from WorkerStatus::Quit, we still need to
  transfer data to/from the running stream to prevent
  underrun or overrun.

Changes:
- changes in start_pcm_worker:
  - extract read_data, write_data utils
  - implement From<Result<()>, Error> for virtio_snd_pcm_status
  - poll next_{capture, playback}_buffer
  - if status == WorkerStatus::Pause, still need to transfer data to
    prevent underrun or overrun
  - split Output and Input stream logic
- use copy_from or copy_to instead to io::copy
- remove Condvar usage
- changes in audio_streams
  - add copy_from in AudioBuffer and AsyncPlaybackBuffer
  - add copy_to in AudioBuffer and AsyncCaptureBuffer

BUG=b:210197743
TEST=alsa_conformance_test and make sure there is no
     `ERR cras_server[1818]: Error reading msg from client: rc: -104` or
     `ERR cras_server[1818]: fetch err: -32 for 6490001`
     errors.

Change-Id: I004969040881cb2d46b54589e3e7e634ea67d152
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3341135
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
2021-12-15 11:28:55 +00:00
Anton Romanov
234f81100d kvm_sys|virtio_sys|net_sys: disable tests failing on 32bits
BUG=b/210015827
TEST=./tools/run_tests --target vm:aarch64 --arch armhf

Change-Id: I4b1968d85969e6094ed393bb4f83c67328591cce
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3340226
Reviewed-by: Anton Romanov <romanton@google.com>
Auto-Submit: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-12-15 00:55:48 +00:00
Dennis Kempin
a5ad6aeb30 cros_asyncv2: Do not add crates.io patch
This patch will cause libcras to be built with the new v2 library,
which it has not been updated for yet.

BUG=None
TEST=None

Change-Id: I4353877aea1e0e611d4b1152733ab40aed2ec3b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3340227
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-12-15 00:40:15 +00:00
Dennis Kempin
e204dda759 Kokoro: Allow manual merge targets in merge-into-chromeos
This allows us to manually specify the merge target when triggering
the Kokoro job to do partial merges.

BUG=b:209034086
TEST=None

Change-Id: If68231b46981dec679445dde50e1fb5ff66e57c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3340211
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-12-14 23:41:33 +00:00
Anton Romanov
c8970b7a76 Add continuous and presubmit-cr armhf job configs for kokoro
Change-Id: Ifb00dc70e8a2af690722a40cbdcd9836b950d929
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3339182
Reviewed-by: Anton Romanov <romanton@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
Auto-Submit: Anton Romanov <romanton@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-12-14 19:45:21 +00:00
ameron Lutes
cde1b5416f crosvm: Rename libcrosvm_control to crosvm_control
The current inclusion of the 'lib' prefix is redundant and results
in 'liblibcrosvm_control' once built.

These changes remove the 'lib' prefix from the source files.

BUG=b:188858559
TEST=cros_run_unit_tests --board ${board} --packages chromeos-base/crosvm

Change-Id: Ic1bcdce9aa5d879f5867232ffec60f40fe57d3a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3321731
Reviewed-by: Hikaru Nishida <hikalium@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Christian Blichmann <cblichmann@google.com>
Commit-Queue: Kameron Lutes <kalutes@chromium.org>
2021-12-14 18:38:42 +00:00
Anton Romanov
c20f783733 Enable some tests for armhf builds
TEST=./tools/dev_container --hermetic bash -c "./tools/run_tests --target=vm:aarch64 --arch armhf"
BUG=b/203152778

Change-Id: I76da1d029e9b11016b1ed9245c5b09095703fb63
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3328099
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
2021-12-14 18:11:32 +00:00
Anton Romanov
19ea70b293 sys_util: fix CMSG_SPACE test on arm32
BUG=b/210015827
TEST=cd common/sys_util; cargo test sock_ctrl

Change-Id: I385719ee606279c7d6cbf9faed142fb51bcaef53
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3331736
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Anton Romanov <romanton@google.com>
2021-12-14 18:11:31 +00:00
Chia-I Wu
b86f7f6110 gpu: allow syslog from the render server
BUG=b:177267762
TEST=run vk and gl apps on volteer

Change-Id: I6fe2ce831eb671fedd1c0aa749066c41d181d152
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3335301
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Chia-I Wu <olv@google.com>
2021-12-14 16:54:22 +00:00
Junichi Uekawa
670f9987cb crosvm: Wordsmith.
On Gerrit, fontifying is disabled when a line is > 500 chars. Try to
reduce the DAX description.

BUG=None
TEST=view in gerrit.

Change-Id: I96af91af5e546fc9d86f38ffaa56a7a4c11fd95a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3334325
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2021-12-14 04:44:45 +00:00
Junichi Uekawa
ec8ee49ada crosvm: use underscores for hex constants.
BUG=None
TEST=None

Change-Id: I1833862771baa922c58bc8be91c5bd0d898e9c35
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3329285
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2021-12-14 04:44:44 +00:00
Junichi Uekawa
4d3120526d crosvm: output the command-line parameter.
Instead of the error message, the user would want to know what caused
the error.

Original: invalid value "cannot parse integer from empty string":
invalid base range value

New: invalid value "/dev/mem@": invalid base range value

BUG=None
TEST=unit test.

Change-Id: Ia63a45fde2c47365062d7dfac9d61f242e95c209
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3325821
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2021-12-14 04:44:43 +00:00
Dmitry Torokhov
df1a2d1195 acpi: fix offset of the reset value in FADT.
The correct offset for the reset value in FADT is 128.

BUG=b:3169569
TEST=Build and boot.

Change-Id: If8bb9dc4218261464ce6100456c1386c3abb3936
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3336217
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2021-12-14 00:25:53 +00:00
Junichi Uekawa
89ee18e135 crosvm: Remove _mem_size
Seems like it's not used anymore.

BUG=None
TEST=cargo test --features=direct  # has less warnings.

Change-Id: Id53f89a89c8e2aa8755394503aac8e773e785c54
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3327806
Auto-Submit: Junichi Uekawa <uekawa@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-14 00:07:34 +00:00
Abhishek Bhardwaj
8ca1345c02 crosvm: vvu: proxy: Implement activate and forwarding of master messages
This change caches the parameters received in the activate method. It
spawns a Worker thread to process Vhost master communication.
Furthermore, it forwards all non-action messages to the Vhost slave.

BUG=b:194136484
TEST=Compile.

Change-Id: Ie853add605ea4daa1c62ec9ce93cbac083e57de7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3288870
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Abhishek Bhardwaj <abhishekbh@chromium.org>
2021-12-13 21:57:50 +00:00
Dennis Kempin
47eccc1cfd tpm2-sys: Remove dependency on num_cpus
It's no longer used, and pulling in the crate hermit-abi
which does causes problems in Kokoro with the latest update.

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

Change-Id: I0344ea32dcc97923bb7b0010a6e5c33003598df0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3328943
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Anton Romanov <romanton@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-12-13 21:53:40 +00:00
Daniel Verkamp
e4db26f1ca sys_util: add basic netlink generic recv wrapper
This only supports receiving messages for now; sending can be added
later if needed.

BUG=b:197247746
TEST=bin/clippy

Change-Id: I40c31d5def6f68da3b0f613695a4e18d2ed3e1f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3319403
Reviewed-by: Allen Webb <allenwebb@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-12-13 20:48:23 +00:00