Commit graph

1637 commits

Author SHA1 Message Date
Kaiyi Li
6404e457b5 gpu_renderer: add syncfd flag for gfxstream
Add a gpu argument to control the syncfd of gfxstream implemented in
these CL: https://android-review.googlesource.com/q/topic:%22gfxstream-sync-fd%22+(status:open%20OR%20status:merged).
Default to enabled.

BUG=None
TEST=launch_cvd

Change-Id: Id4933b8654fc1b1bb73784bd8e1a85e73d0266d6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2286237
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Lingfeng Yang <lfy@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2020-07-10 20:01:54 +00:00
Daniel Verkamp
4462eabaab docker: update platform2 commit for new libvda API
BUG=None
TEST=docker/build_crosvm_base.sh && docker/wrapped_smoke_test.sh

Change-Id: I78ff9e967c9f830f0222503a081266a24336d733
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2285186
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
2020-07-10 01:07:18 +00:00
Daniel Verkamp
f177920334 docker: remove rendernodehost build steps
The rendernodehost library has been removed from platform2:
https://chromium-review.googlesource.com/c/chromiumos/platform2/+/2240207

Remove its build steps from Dockerfile to fix docker build once the
platform2 commit is updated.

BUG=None
TEST=docker/build_crosvm_base.sh && docker/wrapped_smoke_test.sh

Change-Id: Ia15484a3ba870afb843b2d6acfd31bf1a5f1a4ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2285185
Reviewed-by: Lepton Wu <lepton@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
2020-07-10 01:07:15 +00:00
Steven Richman
2be73da5d4 hypervisor: add ARM vcpu functions
Add VcpuAArch64::set_one_reg, init, and init_pmu.  init combines
arm_preferred_target and arm_vcpu_init from the kvm crate.

BUG=chromium:1077058
TEST=cargo test -p hypervisor, ARM build

Change-Id: I5005d568c2337da3b9a96ec05ca9865c6ddbab74
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2247369
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Steven Richman <srichman@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2020-07-09 22:31:45 +00:00
Steven Richman
c3073ee6b1 hypervisor: add clone methods and cpuid flags
Move try_clone from Kvm to Hypervisor, and add try_clone to Vcpu.
Include a flags field in CpuIdEntry, since it's used by KVM_SET_CPUID2.
Tighten the bounds on Vcpu::Runnable so it derefs to the same type as
Vcpu.

BUG=chromium:1077058
TEST=cargo test -p hypervisor

Change-Id: I451f9156210eae342122f97fedfad630b89a7645
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2274837
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Steven Richman <srichman@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Udam Saini <udam@google.com>
2020-07-09 22:31:44 +00:00
Steven Richman
30010eb874 hypervisor: add pvclock_ctrl, sigmask, enable cap
These functions are mostly unchanged from the kvm crate.  Error code
checks were tweaked for consistency.

BUG=chromium:1077058
TEST=cargo test -p hypervisor

Change-Id: Ib4b30281eed877efcb4b55332f1f588213b98918
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2247370
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Steven Richman <srichman@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2020-07-09 22:31:43 +00:00
Steven Richman
44b82cbc03 hypervisor: add msr, xcr, and vcpu cpuid funcs
set_msrs, which had used std::alloc in x86_64/src/regs.rs, now uses
vec_with_array_field to allocate the msr struct like get_msrs.

BUG=chromium:1077058
TEST=cargo test -p hypervisor

Change-Id: I288bb18cc9e9ebf3e52b4ac46e36d03013b620ea
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2246654
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Steven Richman <srichman@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2020-07-09 22:31:42 +00:00
Steven Richman
2d3476630f hypervisor: add x86 register functions
BUG=chromium:1077058
TEST=cargo test -p hypervisor

Change-Id: I5ae215377a322b4520aca4207f4313ea9b7e4217
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2247368
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Steven Richman <srichman@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2020-07-09 22:31:40 +00:00
Colin Downs-Razouk
963e2ddcf2 devices: irqchip: lapic state
Added get/set_lapic_state functions to KvmKernelIrqChip and KvmVcpu.
Added tests for the KvmKernelIrqChip.

BUG=chromium:1077058
TEST=added associated tests for get/set_lapic_state

Change-Id: I0f1cebd9db370b5453a951f7827de511399cddf4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2260929
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Colin Downs-Razouk <colindr@google.com>
2020-07-08 01:36:24 +00:00
Alex Lau
3ce03649ad crosvm: Fix compiling video decoder with updated libvda decode bindings
BUG=b:140082257
TEST=emerge-$BOARD dev-rust/libvda crosvm

Cq-Depend: chromium:2282874
Change-Id: I7379209d49c8d4eea51788ccfcbed08242994712
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2282873
Tested-by: Alex Lau <alexlau@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alex Lau <alexlau@chromium.org>
2020-07-07 22:24:50 +00:00
Colin Downs-Razouk
0ae7c7c765 devices: irqchip: mp state
Added an emum for MPState, and functions to translate between MPState
and kvm_mp_state. Added get_mp_state and set_mp_state functions to KvmVm
and the IrqChip interface.

BUG=chromium:1077058
TEST=added associated tests for get/set_mp_state

Change-Id: I0825f81b1b4d85884690606d691e8b88e8306ae1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2261293
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Colin Downs-Razouk <colindr@google.com>
2020-07-07 19:49:41 +00:00
Colin Downs-Razouk
ce34d94b0e devices: irqchip: make generic x86 irqchip tests
In preparation of the KvmSplitIrqChip, moving tests out of the
irqchip::kvm module and into the irqchip::x86_64 module. This is because
the tests should be valid for any implementation of the IrqChipX86_64
trait.

Bug: chromium:1077058
Test: cargo test -p devices -p hypervisor
Change-Id: I57a15b275bce5e7d96f2736367b7aaef6b069fec
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2276322
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Colin Downs-Razouk <colindr@google.com>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2020-07-06 19:12:10 +00:00
Colin Downs-Razouk
883dbe845b sys_util: eventfd read_timeout function
Added a function to read from an eventfd with a timeout. This will be
useful for some IrqChip tests. Uses ppoll to check if an EventFd is
ready for reading.

Bug: chromium:1077058
Test: added a timeout test + cargo test -p sys_util
Change-Id: I10283e39ee21305c3e433aded417a7eea465def9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2276321
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Colin Downs-Razouk <colindr@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2020-07-06 19:12:09 +00:00
Colin Downs-Razouk
52e0cbf40c devices: pit updates for hypervisor abstraction
Update the pit to have get/set functions so it can be used as part of an
irqchip. Some of this translation is imprecise because we use a rust
Instant for storing the timer start time, where the PitState expects it
in terms of the host's monotonic clock, but it shouldn't really matter
because getting/setting the pit is only exposed as a plugin feature.

This also required adding some convenience functions to the sys_util
Clock.

Bug: chromium:1077058
Test: cargo test -p devices
Change-Id: I761747cd03ed123a2d2e685e0679a3d025a165ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2265043
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Colin Downs-Razouk <colindr@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2020-07-06 19:12:08 +00:00
Colin Downs-Razouk
9fef2380da sys_util: EventFd using SafeDescriptor
Update EventFd to use SafeDescriptor and add equality check to
SafeDescriptor. Two safe descriptors are equal if their underlying
RawFds are equal or if they are duplicates of each other created by
calling try_clone, which uses dup.

This will be used by the KvmSplitIrqChip so it's unregister_irq_event
functionality can match KVM's, which will not unregister an irqfd if the
event fd does not match.

Bug: chromium:1077058
Test: added a test for equality of a cloned SafeDescriptor, and ran all
 other sys_util tests
Change-Id: I8c55a083b4e0d693c7192fa869a60e192829db5e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2265042
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Colin Downs-Razouk <colindr@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2020-07-06 03:18:56 +00:00
Dylan Reid
0cbf9d3fb5 io_uring: initialze sqes to zero
Submission queue entries have whatever value is left from last time
stored. Clear them to zero when they are pulled out prior to being
filled. It's better to do this in a central location than making each
user responsible for setting all the fields.

Change-Id: I0436e24cd97fe4bbe808d7d0cc09fa81c1323d57
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2274995
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
2020-07-04 21:59:52 +00:00
Dylan Reid
e254389b63 io_uring: Don't set the num_wait value during submit
The value is ignored if WAIT isn't indicated in the flags, but it's more
clear what is happening if left as zero as well.

Change-Id: Ib3539e37d1eaad6f5a68f6c028cdd186f12a8dd4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2274994
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
2020-07-04 21:59:49 +00:00
Steven Richman
64a70c8003 hypervisor: add vcpu to_runnable, interrupts, I/O
Add methods for making RunnableVcpus, requesting vmexits on a vcpu,
injecting interrupts, and setting I/O data.  This code is unchanged
from the kvm crate.

A new Vcpu::handle_io_events method delivers pending IO events.  This is
for hypervisors that handle IO events in userspace.  On KVM it's a
no-op.

Delete integration tests, which were for showing how the hypervisor
traits fit together.

BUG=chromium:1077058
TEST=cargo test -p hypervisor

Change-Id: Ie9eb6dd38f168031bc0ae1b3c44638e8930284a3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2247367
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Steven Richman <srichman@google.com>
2020-07-02 10:04:08 +00:00
Steven Richman
583651a52a hypervisor: add ioevent, dirty log, TSS, ident map
These functions are mostly unchanged from the kvm crate.

BUG=chromium:1077058
TEST=cargo test -p hypervisor

Change-Id: I819e34b2d7895b10658ca7d8870b64435220ea9f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2202847
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Steven Richman <srichman@google.com>
2020-06-30 23:03:08 +00:00
Steven Richman
41e4d7153a hypervisor: add MemSlot type alias
Use a MemSlot type alias for memory region slots instead of u32, for
better type checking and self-documentation.

BUG=chromium:1077058
TEST=cargo test -p hypervisor

Change-Id: I0ee790f2eba432a6569c720a216d5bd5a66b07ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2253336
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Steven Richman <srichman@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2020-06-30 23:03:07 +00:00
Dylan Reid
95f1bca33a devices: interrupt: add simple resample
Instead of coupling the reading of the event fd and the resampling of
the interrupt, add a separate member to just do the resample.

This will be used by async code that waits for and reads the event fd in
one step.

Change-Id: Ic5b1fd9adf8e32a572f31dc1c0c5ab32e94f4981
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2268978
Commit-Queue: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2020-06-30 09:00:50 +00:00
Daniel Verkamp
5b09409f59 docker: update ADHD checkout for num_channels
Fixes docker/kokoro build failure due to usage of new audio_streams
APIs.

BUG=None
TEST=docker/build_crosvm_base.sh && docker/wrapped_smoke_test.sh

Change-Id: I9549b6301e78169d95498d40bb5383806d4c3b2c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2274417
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
2020-06-30 02:44:41 +00:00
Chirantan Ekbote
44336b9131 devices: fs: Fix posix acl handling
Posix acls are a truly incredible example of API design.  The presence
of a default posix acl in a directory completely changes the meaning of
the `mode` parameter for all system call that create inodes.  However,
this new behavior only applies when the inode is first created and not
for any subsequent operations that use the mode, like fchmod.

When a directory has a default posix acl, all inodes created in that
directory get the permissions specified in the default acl.  The mode
parameter is treated like a umask where any permissions allowed by the
default acl that are not allowed by the mode parameter are blocked.  The
actual umask is ignored in this case.

So to handle this properly we need to set FUSE_DONT_MASK to prevent the
kernel driver from preemptively applying the umask.  Then we have to
check if the parent directory has a default posix acl and only apply the
umask to the mode if it does not.  This also means that we cannot use
`mkdtemp` because that always creates directories with a mode of 0o700
and since the default posix acl calculation only applies on creation and
not on later operations, we need to apply the proper mode in the very
beginning.

BUG=b:159285544,b:152806644
TEST=vm.Virtiofs.  Use a test program to create files/directories in
     directories that have a default acl and ones that don't, and verify
     that the mode is correctly set after creation

Change-Id: Ieca8ac9db391feebe5719630c5f3b57b04b71533
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2260253
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
2020-06-29 10:14:42 +00:00
Dylan Reid
8b681873fd cros_async: MemRegion: use u64 for offset
On ARM32 systems with 64 bit guests, the regions in guest memory can be
mapped above the range of a u32, use a u64 instead of usize to hold the
offset.

TEST=runs on kevin-5.6 using mem regions an uring

Change-Id: Ib12db0b8056dd126c5ed2e6be35da96c1a12f750
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2268977
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
2020-06-29 01:46:04 +00:00
Judy Hsiao
fedb4eddbf ac97: Support 2, 4 and 6 output channels
1. Turn on the Extended Audio ID Register D6-8 to indicate the capability to
   support PCM Center DAC(CDAC), Surround L&R DACs (SDAC), PCM LFE DAC
   (LDAC).
2. Turn on the Global Status Register D21:20 to support 4 and 6 channels
   on PCM out.
3. Read the Global Control Register to configure the output channel count.
4. Enable start_playback unit test, and add assert for output stream channel count.

BUG=b:157433024
TEST=`sox -n -t s16 -r48000 -c2 - synth sine 440 vol 0.1 | aplay -D
hw:0,0 -f S16_LE -r 48000 -c 2`
TEST=`sox -n -t s16 -r48000 -c4 - synth sine 440 vol 0.1 | aplay -D
hw:0,0 -f S16_LE -r 48000 -c 4`
TEST=`sox -n -t s16 -r48000 -c6 - synth sine 440 vol 0.1 | aplay -D
hw:0,0 -f S16_LE -r 48000 -c 6`
TEST=cras_test_client --dump_a to check the num_channels of the opened
stream matches the aplay -c param.
TEST=cargo test

Cq-Depend: chromium:2259312
Change-Id: I2e1e48e78387b1b4bba72c63e6c93bf7b8012ea8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2256078
Tested-by: Judy Hsiao <judyhsiao@chromium.org>
Auto-Submit: Judy Hsiao <judyhsiao@chromium.org>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
2020-06-28 06:22:36 +00:00
Daniel Verkamp
0130b08077 docker: upgrade to Debian Buster (current stable)
We were previously building the Docker image on top of Debian Stretch,
which is now the oldstable distribution.  Upgrade to Buster to get newer
versions of various host packages; in particular, this gets us a newer
libc.

BUG=None
TEST=docker/build_crosvm_base.sh && docker/wrapped_smoke_test.sh

Change-Id: Ie9b92d7e053239234cc79936c9a2804560bba18a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2267689
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2020-06-27 22:51:54 +00:00
Daniel Verkamp
1c365a78c1 Cargo.lock: replace io_jail with minijail
Update the Cargo.lock file by running `cargo build` to match the latest
changes to Cargo.toml.

BUG=None
TEST=kokoro

Change-Id: I7e30c03fe1713c6da4042539f6579b5f6b29f92f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2270766
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2020-06-27 20:11:54 +00:00
Dylan Reid
81a87845b0 devices: queue: Add async descriptor fetching
Allow `Queue` to return descriptors asynchronously.

Asynchronous descriptors can be used by devices to replace their poll
loops with async functions.

TEST=cargo test.

Change-Id: I93ba4612ccf2f8ba8e77458fd5474cada705a9b6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2167692
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
2020-06-26 18:22:10 +00:00
Dylan Reid
57c667e07a cros_async: Convert FD executor to be more similar to uring
Convert the FD executor to have a more similar interface to the
uring_executor. This has two benefits.

1) This allows a single wrapper `PollOrRing` to be used. It will select
uring or fd transparent to the user, allowing users to get the benefits
of uring when available without changing their code.

2) Having the `PendingWaker` and Registered source manage FD lifetime
removes the need for custom drop implementations for each Future. This
simplifies things so much there is no longer need for the async_core
crate which is removed.

Change-Id: Ic6c84c4e668cbfe5eddeb75129b34d77f66b096d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2227087
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
2020-06-26 18:22:10 +00:00
Dylan Reid
c6478e6d99 cros_async: Add uring futures
Add futures to be used with the uring executor.

Change-Id: I92813e01cfbfe9b24e1d86ef2ec64254b4dc3248
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2227086
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
2020-06-26 18:22:08 +00:00
Allen Webb
f3024c8976 io_jail: Remove now that the code lives in aosp/external/minijail
io_jail has been migrated to aosp/external/minijail/rust/minijail.
This removes the crosvm copy and updates the references to use the new
location.

BUG=chromium:1096175
TEST=cargo test

Cq-Depend: chromium:2254418
Change-Id: I29d5c6178b6faf5e52671cfbe6fc7e51f0d21dd2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2254298
Tested-by: Allen Webb <allenwebb@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Allen Webb <allenwebb@google.com>
2020-06-26 17:27:44 +00:00
Lepton Wu
436296b1f0 secomp: Allow sched_yield for video device.
libvda depends on libchrome and libchrome call sched_yield
in NeedsLazyInstance sometimes.

BUG=b:159855961
TEST=manual - keep running `android -c reboot` on hatch-arc-r

Change-Id: I39afb77541c6d129ff84a776644c5cb68687ec82
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2269339
Commit-Queue: Lepton Wu <lepton@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Tested-by: Lepton Wu <lepton@chromium.org>
Auto-Submit: Lepton Wu <lepton@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2020-06-26 11:35:33 +00:00
Chirantan Ekbote
dc82c819f6 devices: fs: Implement FS_IOC_FSSETXATTR
Needed by arcvm.

BUG=b:159297591
TEST=run a test program that calls the ioctl

Change-Id: I1f8c17fa2b2457f5a9e73045c3dbee3440eb943d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2265932
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2020-06-26 09:10:32 +00:00
Chirantan Ekbote
d8447077f0 devices: fs: Fix linkat impl
Using AT_EMPTY_PATH with linkat requires the caller to have
CAP_DAC_READ_SEARCH in the init user namespace.  Since the fs device
isn't going to have this when run in a sandbox, switch to using
/proc/self/fd with AT_SYMLINK_FOLLOW instead, which is documented in the
manpage as an alternative to AT_EMPTY_PATH.

BUG=b:159861594
TEST=`touch foo; ln foo bar` succeeds

Change-Id: I944d80d955742d653e36d245024adc48cf77d77e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2265933
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2020-06-26 06:23:50 +00:00
Colin Downs-Razouk
b865569893 devices: irqchip: updated ioapic implementation
Modified ioapic implementation for the hypervisor abstraction layer.
This implementation has the same functionality and tests as the existing
one, but accepts a vec of resample_events instead of a GsiRelay. It also
takes a list of irqfds instead of creating them itself.

This will be used by the KvmSplitIrqChip, and will eventualy be modified
again to support an ApicBus when we want to support a UserspaceIrqChip.

Bug: chromium:1077058
Test: cargo test -p hypervisor -p devices
Change-Id: I306724266511a7975a25a34955651ea6f53e1c4c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2255303
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Colin Downs-Razouk <colindr@google.com>
2020-06-25 18:15:30 +00:00
Colin Downs-Razouk
6583fa8d6a devices: irqchip: updated pic implementation
Copied and slightly modified pic implementation in the irqchip
submodule. It uses the PicState defined in the hypervisor crate and has
a register_resample_events function instead of a register_relay
function.

Some function signatures have been slightly changed to take &self and
&mut self where before they would take a PicState. This was done so
that the Pic struct itself would be the only object that needs access
to the resample_events rather than each PicState needing it's own copy
or clone.

This will later be used by the the KvmSplitIrqChip.

Test: cargo test -p devices -p hypervisor
Bug: chromium:1077058
Change-Id: Ia15ea1800b4339d3ad38d88d8ec6ace8ca5ea67a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2255302
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Colin Downs-Razouk <colindr@google.com>
2020-06-25 18:15:24 +00:00
Steven Richman
07a0706829 hypervisor: add vcpu new and run
Vcpus are created on the Vm object, instead of with Vcpu::new.  Vm keeps
a copy of the Hypervisor to support create_vcpu.  Otherwise the methods
are the same as the kvm crate.

BUG=chromium:1077058
TEST=cargo test

Change-Id: I6fbd0e5fb5d81d4362a259e85eb392d8edbfff1f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2247366
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Steven Richman <srichman@google.com>
2020-06-25 14:38:18 +00:00
Andrew Walbran
f836c8edde Update x86 and x86_64 syscalls to Linux v5.6-rc5, avoiding duplicates.
There were some duplicate enum values for x86 which caused build
failure. Updating the names to match the Linux table fixes this.

Also updated awk command in comment to produce matching output.

BUG=None
TEST=cd syscall_defines; cargo build && cargo build --target i686-unknown-linux-gnu

Change-Id: I99032352332281566f8e8322fadec73ca916d31d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2260597
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Andrew Walbran <qwandor@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Andrew Walbran <qwandor@google.com>
2020-06-25 14:34:32 +00:00
Andrew Walbran
bf654c1753 Fix path to minijail-sys.
This was broken by
https://android-review.googlesource.com/c/platform/external/minijail/+/1341614

BUG=chromium:1096175
TEST=cargo test

Change-Id: I5e991a199166ecbe5add10484ac16bcaf13fe6ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2260596
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Allen Webb <allenwebb@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Andrew Walbran <qwandor@google.com>
2020-06-25 14:34:30 +00:00
Lepton Wu
42a5d13124 seccomp: gpu: Allow PR_GET_NAME for prctl
MALI GPU driver calls this for printing debug information. Just
enable it since it could help debug.

BUG=None
TEST=manual - Run ARCVM on kukui with debug build of mali driver

Change-Id: If65121520071a1df9b8ba932272428cbac844984
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2262176
Tested-by: Lepton Wu <lepton@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Lepton Wu <lepton@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Lepton Wu <lepton@chromium.org>
2020-06-25 10:33:59 +00:00
Steven Richman
c328f65054 hypervisor: add Vm capabilities
Vm capability checking has been split into two functions: one for a
small set of hypervisor-agnostic caps, and one for hypervisor-specific
u32 constants to support the plugin.

BUG=chromium:1077058
TEST=cargo test -p hypervisor

Change-Id: I17fb6804f0fa7114f39c5016da430afa75179919
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2202848
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Steven Richman <srichman@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2020-06-24 19:59:00 +00:00
Chirantan Ekbote
da69086e9f rand_ish: Generate random string from SimpleRng
Devices may not have access to /dev/urandom so refactor the random
string generation code so that it can also be used by SimpleRng.  Also
implement Iterator for SimpleRng to make the string generator
implementation easier.

BUG=b:152806644,b:159285544
TEST=unit tests

Change-Id: I245c90dc44cfa53a7e12343925b1e04a5df55255
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2260252
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2020-06-24 06:44:56 +00:00
Daniel Verkamp
708e3a63b9 Cargo.lock: update libc to 0.2.65
This matches the version of libc in the Chrome OS tree (dev-rust/libc).

Fixes non-Portage builds due to a change in the type of S_ISGID:
457b0f9902

Previously this would fail compilation with an error about "no
implementation for `u32 & i32`".

Updated with:

  cargo update -p libc --precise 0.2.65

BUG=None
TEST=bin/clippy

Change-Id: Ibe3043162a5af7c69168ec61fee3f4cdc35044e8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2258621
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2020-06-23 08:27:47 +00:00
Daniel Verkamp
4c64fa7c6f io_uring: allow alignment-changing casts of mmap
uring.rs wraps the kernel io_uring interfaces that provide C-style raw
pointers, which requires casting a *u8 into other types with stricter
alignment requirements.  All of these casts are based on the base mmap()
pointer (which is always page aligned) or offsets within an mmap
provided by the kernel, so we can assume they are safe to cast to the
relevant more-aligned types.

Fixes clippy warnings of the form:

  casting from `*mut u8` to a more-strictly-aligned pointer (`*const
  std::sync::atomic::AtomicU32`) (1 < 4 bytes)

BUG=None
TEST=bin/clippy

Change-Id: Ibef32bb8529d34ece79f089992ad8bd880c5030b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2253068
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2020-06-22 21:10:14 +00:00
Daniel Verkamp
635f90cd83 cros_async: ignore dead_code warnings for now
Since the call sites for some of these functions are not checked in yet,
add a blanket #![allow(dead_code)] to the relevant files.  These should
be removed as soon as the users are committed to avoid other unused code
slipping through later.

BUG=None
TEST=bin/clippy

Change-Id: Id11ad91542eb7fa60979dae76301a4c9ce0701ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2253067
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2020-06-22 21:10:13 +00:00
Daniel Verkamp
1064c5b58e cros_async: clarify add_future return value
Move the Ok(()) return value to a separate expression.

uring_executor::add_future returns (), so this is effectively the same,
but clippy complains about the previous form:

  error: passing a unit value to a function

BUG=None
TEST=bin/clippy

Change-Id: I8a05ae340568fa4ce94b35f9bf3dbd426a83219e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2253066
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2020-06-22 21:10:13 +00:00
Daniel Verkamp
af787af9bc io_uring: drop unnecessary 'static in const
clippy warns about the redundant 'static lifetime, which is implied for
const.

BUG=None
TEST=bin/clippy

Change-Id: I1d4dca90de359857ec947e12ae47858785d8867c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2253065
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2020-06-22 21:10:10 +00:00
Chirantan Ekbote
5d6a17f4b2 devices: fs: Enable posix_acl support
Advertise that we support posix acls in the response to the init
message.  Since the VM does access checks before sending the request to
the server, having this disabled meant that the VM was rejecting
requests that should have been allowed to succeed.

BUG=b:159285544
TEST=touch test
     setfacl -m u:crosvm:rw test
     su -s /bin/bash -c 'echo hello > test' crosvm
     cat test # check that it contains "hello"

Change-Id: I047b590e4caf0f2883b3f6198b9bc071e9e40a93
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2253494
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: Chirantan Ekbote <chirantan@chromium.org>
2020-06-21 20:33:09 +00:00
Chirantan Ekbote
91dc84471f devices: fs: Respect setgid bit on directories
The switch to 2 stage mkdir + create broke setgid bit handling on
directories.  When this bit is set in a directory all inodes in that
directory should be created with the gid of that directory rather than
the gid of the process that made the call.

BUG=b:152806644
TEST=Set the sgid bit on a directory and verify that new files and
     directories inherit the directory's group rather than the group of
     the process that created them.

Change-Id: Iafce9fbb4281b2dc84e052e0a703745dde4b817b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2253493
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: Chirantan Ekbote <chirantan@chromium.org>
2020-06-21 20:33:08 +00:00
Chirantan Ekbote
ad356fb327 devices: fs: Ignore umask
We don't set FUSE_DONT_MASK so the guest kernel will apply the umask
to the mode before sending the request.  Just pass it on unmodified.

BUG=b:152806644
TEST=vm.Virtiofs

Change-Id: Id0c138e9ccc3a361a2772ac144f1d3413b545d99
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2253492
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Tested-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2020-06-21 20:33:07 +00:00