Commit graph

3149 commits

Author SHA1 Message Date
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
Daniel Verkamp
a3c6e95bb5 sys_util: add LayoutAllocation as_(mut_)slice()
These functions allow access to the allocated memory as a slice of a
generic type T, rather than just a single element of T like the existing
as_mut() function.

BUG=b:197247746
TEST=tools/presubmit --quick

Change-Id: I09287407b6179066fc14c96539c3032be19736a5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3327573
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:22 +00:00
Chia-I Wu
a946256c0b seccomp: allow waitid in gpu_renderer_server
virglrender changed from waitpid to waitid.

BUG=b:177267762
TEST=run vk and gl apps on volteer

Change-Id: If056776d934e0c2376d316dcfe37ff2c168933f3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3331738
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chia-I Wu <olv@google.com>
2021-12-13 06:23:12 +00:00
Chia-I Wu
4b94a925df rutabaga: rename VIRGL_RENDERER_MULTI_PROCESS
It was renamed to VIRGL_RENDERER_RENDER_SERVER in virglrenderer.

BUG=b:177267762
TEST=run vk and gl apps on volteer

Change-Id: Ic00be726e720686023ab90e611df67b4e733beb9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3331737
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chia-I Wu <olv@google.com>
2021-12-13 06:23:11 +00:00
Chih-Yang Hsia
ec65fbec1c devices: virtio: extract drain_desc_receiver
Changes:
- Extract drain_desc_receiver
- Wait future only in the last DescriptorChain.

BUG=b:210197743
TEST=alsa_conformance_test

Change-Id: I463517622404f72254e34911a3c296ca8ad45101
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3331978
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-13 05:04:57 +00:00
Chih-Yang Hsia
9ec39843ed devices: virtio: snd: Add 4/6 channel playback support
ARCVM is using 4 ch with chmap {FL, FR, RL, RR}.
Borealis is using 6 ch with chmap {FL, FR, FC, LFE, RL, RR}.

From amixer we should see
```
localhost / # amixer -c0 cget numid=1
numid=1,iface=PCM,name='Playback Channel Map'
  ; type=INTEGER,access=r----R--,values=6,min=0,max=36,step=0
  : values=0,0,0,0,0,0
  | container
    | chmap-fixed=FL,FR
    | chmap-fixed=FL,FR,RL,RR
    | chmap-fixed=FL,FR,FC,LFE,RL,RR
```

BUG=b:199001477
BUG=b:201382814
TEST=`amixer -c0 cget numid=1`
TEST=alsa_conformance_test -Phw:0,0 -c 4
TEST=alsa_conformance_test -Phw:0,0 -c 6

Change-Id: I6b8a6e4a637fe0413ba9b8d91727bf5c4ee8cd26
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3331977
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-13 05:04:56 +00:00
Chih-Yang Hsia
34b48775ab audio_streams: Fix incorrect write impl in AudioBuffer
If frame_size is not "power of 2" (e.g. 12 bytes in 6channel/S16_LE),
current write implementation will trigger io::copy error since
- io::copy will split reader into multiple buffers with len() = "power of 2"
  if writer.capacity() >= DEFAULT_BUF_SIZE (which is 8192) and
- trigger early return since current write don't support incomplete frames
  writing.

Changes:
- Remove redundant write impl
- Fix write implementation in AudioBuffer
- Add io_copy_audio_buffer unit test

BUG=b:199001477
BUG=b:201382814
TEST=`cargo test`
TEST=`cargo clippy --all-targets --all-features -- -D warnings`
TEST=`aplay -Dhw:0,0 -f dat /dev/zeros -c 6` with virtio-snd

Change-Id: Ia6b587ab20f474d8c620b69940ca0cc7095da6db
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3331976
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-13 05:04:55 +00:00
Chih-Yang Hsia
a2b4fc07ff devices: virtio: snd: Set capture to false by default
When running cras-snd without "capture=true" parameter,
Parameters.capture could be false.

BUG=b:201382814
BUG=b:210197743
TEST=./tools/chromeos/setup_cargo && \
       cargo test -p devices --features=audio_cras
TEST=Launch VMs without microphone toggle turned on

Change-Id: Iac54d7985f5b07c39e23516df10641601ab9cca6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3331982
Reviewed-by: Woody Chow <woodychow@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
2021-12-13 05:04:54 +00:00
Alexandre Courbot
3abfaa540f crosvm: display error chain when device fails
Use the '{:#}' formatter to display the complete error chain, similarly
to what we already do for VM failures.

BUG=None
TEST=cargo build

Change-Id: I6cc23c71f4441361ee42fa261dd80c7fe0982009
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3329288
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
2021-12-12 13:03:37 +00:00
Chirantan Ekbote
520ad43e5b Add scudo as an optional feature
BUG=none
TEST=`cargo build --features scudo`

Change-Id: If670ba1644ff508dfd15d7dd3846672904e0125a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3314441
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-12-10 09:09:17 +00:00
Alexandre Courbot
993aa7fd49 crosvm: add option to use persistent TAP interface as network device
Currently we have two ways to enable networking on crosvm:

1) Pass all 3 of `--host_ip`, `--netmask` and `--mac` to have crosvm
create and configure a TAP device. This requires crosvm to either be run
as root, or to have the CAP_NET_ADMIN capability,

2) Have another process with the above privileges create and configure
the TAP device before exec'ing crosvm with the TAP FD still open and
passing it to crosvm with the `--tap-fd` argument.

None of these ways are very convenient for development as they either
require to get some privilege every time crosvm is invoked, or to use
another program (not distributed with crosvm) to do the setup.

This patch adds the `tap-name` command-line option which allows to
create a network device from a configured persistent TAP interface,
which doesn't require any kind of privilege.

A persistent TAP interface can be configured on the host as follows:

    # ip tuntap add mode tap user $USER vnet_hdr crosvm_tap
    # ip addr add 10.0.2.1/24 dev crosvm_tap
    # ip link set crosvm_tap up

Then after this one-time setup, $USER will be able to use the
`crosvm_tap` interface by simply passing `--tap-name crosvm_tap` to
crosvm, without any extra option or tool.

This is convenient for development setups as one just needs to
permanently configure the TAP interface using standard Linux tools on
the host once.

BUG=None
TEST=Check that networking works after passing `--tap-name` to crosvm.

Change-Id: Id053a97d69e47a6fefdbe7f3134841d2bfa1757b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3325827
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-10 07:31:03 +00:00
Alexandre Courbot
911773a667 crosvm: factorize net device creation code
Some of the network creation device is copy/pasted across functions.
Since we are going to add one more of these functions, make sure we stop
repeating it by consolidating it into a single function that takes a
device creation closure as parameter.

BUG=None
TEST=Successfully created a network interface using `--host_ip`,
`--netmask` and `--mac`.

Change-Id: Id0d01ffd14f2b827fb54cf68878b015682f39df2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3327803
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2021-12-10 07:31:02 +00:00
Dmitry Torokhov
dacf10487c Add option to control whether crosvm reports extended status
Allow callers to control whether they want crosvm return basic
completion status (0 - success, 1 - failure), or additional statuses are
allowed (if available).

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

Change-Id: I44f3ae5f6d2b5ddff93cd12f3871c97755c93467
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3328410
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-12-10 07:27:31 +00:00
Dennis Kempin
0fcc7ace5a Uprev rust toolchain to 1.56.1
Two new clippy fixes are affecting us, but will be easy to fix in
a follow-up.
Fixed the dev-container so we can create a new version with the new
toolchain.

BUG=b:210037151
TEST=Kokoro

Change-Id: I9ac4d84aff72b1ee5219d6dab0a88667ca6c5951
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3328954
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-12-10 02:34:50 +00:00
Chia-I Wu
cba95dba9c rutabaga_gfx: fix gfxstream build
Fix

error[E0560]: struct `renderer_utils::VirglCookie` has no field named `None`
   --> rutabaga_gfx/src/gfxstream.rs:213:13
    |
213 |             None,
    |             ^^^^ `renderer_utils::VirglCookie` does not have this field
    |
    = note: available fields are: `fence_state`, `render_server_fd`

Also silience all warnings related to render server.

Change-Id: I19ef8746b63379a5517ba9abd3faf4e9da0abfc3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3328098
Auto-Submit: Chia-I Wu <olv@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
2021-12-10 01:54:35 +00:00
Chia-I Wu
16fb659272 devices: gpu: add render server support
When "--gpu-render-server path=<path>" is specified, start the render
server shipped with virglrenderer and initialize virglrenderer with
VIRGLRENDERER_MULTI_PROCESS flag.

The flag makes virgl_renderer_context_create_with_flags create proxy
contexts instead of venus contexts.  Each proxy context requests the
render server to fork a subprocess and executes GPU commands in the
subprocess.

BUG=b:177267762
TEST=run vk and gl apps on volteer

Change-Id: If5e2dc3353572cadb60b0c25a3e0ad14f633db91
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3283508
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chia-I Wu <olv@google.com>
2021-12-09 20:16:13 +00:00
Chia-I Wu
2bcec5c3d9 sys_util: impl From<UnixSeqpacket> for SafeDescriptor
BUG=b:177267762
TEST=run vk and gl apps on volteer

Change-Id: Icfd3994ef62f0c27b817a3824da18977a943cc00
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3315233
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chia-I Wu <olv@google.com>
2021-12-09 20:16:12 +00:00
Chia-I Wu
64ba89ac84 seccomp: add gpu_common.policy
Let gpu_device.policy include gpu_common.policy.  No functional change.

BUG=b:177267762
TEST=run vk and gl apps on volteer

Change-Id: Ic83c29b5713c95374562ee6eba35002142e00357
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3311904
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chia-I Wu <olv@google.com>
2021-12-09 20:16:10 +00:00
Chia-I Wu
fffb569137 gpu: refactor create_gpu_device
Add gpu_jail to create a simple jail and customize the jail.  No
functional change.

BUG=b:177267762
TEST=run vk and gl apps on volteer

Change-Id: I63df5f4009e83cfdfa122edac1788eab56a2dfa0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3311903
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chia-I Wu <olv@google.com>
2021-12-09 20:16:09 +00:00
Chia-I Wu
11e32f6ece rutabaga_gfx: prepare for VIRGL_RENDERER_MULTI_PROCESS
When the flag is set, virglrenderer can use the get_server_fd callback
to get the socket to the render server.

BUG=b:177267762
TEST=run vk and gl apps on volteer

Change-Id: I692b5068a04e841b0a0ed2344a77908e720e19eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3283506
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chia-I Wu <olv@google.com>
2021-12-09 20:16:07 +00:00
Chia-I Wu
e39bbbd025 rutabaga_gfx: add RUTABAGA_MEM_HANDLE_TYPE_SHM
virglrenderer can return an fd of type VIRGL_RENDERER_BLOB_FD_TYPE_SHM.

BUG=b:177267762
TEST=run vk and gl apps on volteer

Change-Id: Ie8def22f3dc6dc13a4972955aadabb91be838493
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3283505
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Chia-I Wu <olv@google.com>
2021-12-09 20:16:06 +00:00
Chia-I Wu
844160daf1 rutabaga_gfx: re-generate virglrenderer bindings
BUG=b:177267762
TEST=run vk and gl apps on volteer

Change-Id: Ife4ef9ef3db4ad421ed0b24e902dd0d06915273f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3283504
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chia-I Wu <olv@google.com>
2021-12-09 20:16:03 +00:00
Chia-I Wu
39ad06d10a rutabaga_gfx: impl Drop for VirglRenderer
We should clean up virglrenderer.

BUG=b:177267762
TEST=run vk and gl apps on volteer

Change-Id: I6fb0075f28a7c1fb35ff977e98652326e1297da4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3315232
Reviewed-by: Gurchetan Singh <gurchetansingh@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-09 20:16:02 +00:00
Keiichi Watanabe
9d7887049d tools: Stop generating API docs for libvda
This should fix the GitHub Action as well.

BUG=none
TEST=kokoro
TEST=Run GitHub Action on my crosvm fork

Change-Id: Iff00d7d68c8dc38cda8222850bcc06ba2b558d01
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3327801
Auto-Submit: Keiichi Watanabe <keiichiw@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-09 18:01:34 +00:00
Keiichi Watanabe
879868ad0f Fix cargo-doc warnings
BUG=none
TEST=./tools/cargo-doc

Change-Id: If2a89761d47464eb139f1f32c8cb3cb10fad3f81
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3305959
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-09 14:34:33 +00:00
Keiichi Watanabe
3e7c388efa tools: Add cargo-doc script
BUG=none
TEST=Run GitHub Action on my personal GitHub repository

Change-Id: I62de2693f3a654e0bbd327eff5931380a153395d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3305958
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-09 14:34:31 +00:00
Chirantan Ekbote
48ee10414c asyncv2: Split fallocate into separate functions
Rather than exposing fallocate directly, add separate functions for each
of the high level operations.  This should make it easier to add
cross-platform support as well as avoid the need to force callers to
deal with libc flags.

BUG=b:195468578
TEST=unit tests

Change-Id: I2aa6affa5cd87b299065b83bfc9bd400565308b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3276119
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-12-09 12:33:09 +00:00
Chirantan Ekbote
0e81fd02dd data_model: Add advance() truncate() to VolatileSlice
BUG=b:195468578
TEST=unit tests

Change-Id: I0f17cb13867fdc7681e3d2124e53adb1e5354b03
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3276118
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-12-09 12:33:08 +00:00
Chirantan Ekbote
0bf7cd0f2c data_model: Change VolatileSlice::as_iobuf() to return IoBufMut
This is more cross-platform and makes it easier to integrate with the
new async framework.

BUG=b:195468578
TEST=unit tests

Change-Id: Ia49413f35d71aaf3c1f9af86922372b96b69483d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3276117
Reviewed-by: Michael Hoyle <mikehoyle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-12-09 12:33:06 +00:00
Chirantan Ekbote
be39e5eff0 cros_asyncv2: Add support for timers
BUG=b:195468578
TEST=unit tests

Change-Id: I61f6bca1cfb5b0fe020e2fd5af33aa915c24ec54
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3225746
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-12-09 12:33:05 +00:00