Commit graph

1613 commits

Author SHA1 Message Date
Dylan Reid
becca3722d io_uring: handle EBUSY from uring_enter
enter can fail if there are too many pending ops. This will return
EBUSY. The user will have to handle some completions before trying
again. Only count sqes as submitted by resetting self.added when enter
returns success.

The number of sqes must also be guarded if too many are added before the
kernel can update the head pointer.

TEST=added ebusy unit test

Change-Id: I0c20677f1332732aab09f025e110eca0c2a42500
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2296699
Tested-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2020-07-17 15:06:15 +00:00
Daniel Verkamp
05b13d0eff kvm: return removed memory region
When a memory region is added to the guest, ownership is passed to the
Vm object.  However, it was not possible to get the memory region back
when removing it from the Vm.  Update the return type of
remove_memory_region so that the original boxed memory region can be
returned to the caller.

BUG=None
TEST=cargo test -p kvm

Change-Id: Ie39a57e0c037ed25a603865cb3dce1af1478e143
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2300840
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Zach Reizner <zachr@chromium.org>
2020-07-17 11:16:42 +00:00
Daniel Verkamp
f4f8f86873 Fix new clippy warnings from Rust 1.45.0
Fix a few instances of and_then(Ok(...)) in syslog:
https://rust-lang.github.io/rust-clippy/master/index.html#bind_instead_of_map

And an unused (overwritten) variable assignment in the argument tests.

BUG=None
TEST=docker/wrapped_smoke_test.sh

Change-Id: Id59b1749fd7eba1fe7dfeb7938ecbbc9d0f9aa6a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2303275
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2020-07-17 06:49:30 +00:00
Dylan Reid
eef1c93fdc uring/async: Add fsync and fallocate
These will be needed by by block.
Note that support for uring fallocate was added in 5.6. The users will
have to handle falling back to synchronous calls if fallocate returns
EINVAL.

BUG=901139
TEST=added fallocate unit tests

Change-Id: I51d635adcf0bb4dd55c5bfe50719f2fde2b88e49
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2274996
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
2020-07-17 06:13:17 +00:00
Dylan Reid
bae84398e5 sys_util: Move set_errno to the only place it's used
Move the OS specific errno handling to the handle_eintr test code which
is the only place that uses it.

The function was already only compiled for test code and the ifdefs have
started to spread with the added android support. Moving the code to the
test that uses it makes it more obvious that it is test-only code.

TEST=cargo test passes

Change-Id: I9fea1bb30052c0edc41c9609e2698221daefa580
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2296828
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Andrew Walbran <qwandor@google.com>
Tested-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
2020-07-17 00:50:43 +00:00
Lepton Wu
ff7796372b seccomp: x86_64: Allow fstat for video device
libvda depends minigbm, on amdgpu, minigbm calls dri_init
to check GPU type. dri_init calls drmGetRenderDeviceNameFromFd
in libdrm which calls fstat.

BUG=b:161376212
TEST=manual - Run arcvm on grunt

Change-Id: I3dcb723711030d25e85cf3cac4cc7c66e0e2077f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2301439
Commit-Queue: Lepton Wu <lepton@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: Lepton Wu <lepton@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Lepton Wu <lepton@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2020-07-17 00:48:12 +00:00
Colin Downs-Razouk
e00cd6826c devices: irqchip: kvm: route and event issues
Fixes for several bugs found in the KvmKernelIrqChip and the
KvmSplitIrqChip that were found while testing the hypervisor abstraction
layer integration:
  - Fixed determination of which routes are MSI routes when setting
  routes in KVM.
  - Fixed issue with setting conflicting routes.
  - Updated service_irq_event to read the associated EventFd that
  triggered the irq event, and updated the documentation. Also updated
  KvmKernelIrqChip's implementation to simply print an error because
  that function should never be called on KvmKernelIrqChip.
  - Fixed a bug with add_vcpu in both KvmKernelIrqChip and
  KvmSplitIrqChip.

BUG=chromium:1077058
TEST=added a new test, ran devices tests, ran a VM with abstraction
  integration changes with both irqchips

Change-Id: I255fbe498f6586d90cb196ff173a574a2cae0453
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2300843
Reviewed-by: Udam Saini <udam@google.com>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Colin Downs-Razouk <colindr@google.com>
2020-07-16 21:13:28 +00:00
Andrew Scull
1590e6fb3e Add feature flag for audio.
This will allow it to be disabled for Protected KVM usecases on Android.

BUG=b:158290206
TEST=cargo test

Change-Id: Ibddd8a98c42bb0847aba804f5e33df29feedd783
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2292372
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Andrew Walbran <qwandor@google.com>
2020-07-16 17:57:55 +00:00
Andrew Walbran
67448289e5 Use platform abstraction around libc::__errno_location.
It has a different name on Android.

BUG=b:158290206
TEST=cargo test

Change-Id: I424d0ddf24c008a06570c709354c7c2dd9395738
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2294865
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Andrew Walbran <qwandor@google.com>
2020-07-16 13:34:19 +00:00
Colin Downs-Razouk
fe368791f8 devices: irqchip: KvmSplitIrqChip impl
Implementation of a KVM split irqchip. KVM's "split irqchip"
functionality only works for x86/x86_64 so this is implemented in the
kvm/x86_64.rs sub-module. The chip has a userspace Pic, Ioapic, and Pit.

This change necessitated a couple modifications to the irqchip traits:
  - The create_pit function has been removed, and it's now implied that
  the creation of the irqchip handles the creation of the pit.
  - A finalize_devices function has been added. This function will need
  to be called on the irqchip after all devices have been setup. The
  purpose of finalize_devices is to allow the irqchip to register any
  userspace devices with the io_bus or mmio_bus, and for the irqchip to
  supply any necessary EventFds to these devices.
  - A service_irq_event function has been added. This function works a
  lot like the service_irq function, except it's specifically designed
  to work the same way an IRQFD works: it first asserts then immediately
  deasserts the line. If a resamplefd is associated with the irq line,
  the deassert doesn't happen immediately, but happens when an EOI
  occurs for a vector associated with the line. The service_irq function
  will still exist for unittests.
  - A process_delayed_irq_events function has been added. There
  is a case where a deadlock can occur if the main thread blocks on
  locking the ioapic in order to service an irq event, while a vcpu
  thread holding the ioapic lock waits on the main thread to process the
  addition of a MSI route. So the irqchip delays the servicing of irq
  events if it finds a locked ioapic, and the
  process_delayed_irq_events function should be called regularly
  by the main thread in order to re-try servicing any delayed irq events.

Bug: chromium:1077058
Test: split irqchip runs all available x86-specific irqchip tests.
  Also added some tests specific for the split irqchip. Ran these tests
  and cargo test -p hypervisor -p devices

Change-Id: I14866645b86b3bf318440051069ff165e2cf9d88
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2290192
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Colin Downs-Razouk <colindr@google.com>
2020-07-16 00:45:31 +00:00
Nicholas Verne
71e73d847e crosvm: Support UnixDatagram sockets for serial output.
BUG=chromium:1053847
TEST=Listen to the socket from VmLogForwarder, observer messages
forwarded into separate output file.

Change-Id: Ia472e34b78db599e91f63e72a13bf8539d0d6312
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2287077
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Nicholas Verne <nverne@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Nicholas Verne <nverne@chromium.org>
Auto-Submit: Nicholas Verne <nverne@chromium.org>
2020-07-16 00:05:19 +00:00
Gurchetan Singh
7b652a3011 devices: gpu: send back map response
To validate caching from the host.

BUG=chromium:924405
TEST=compile and test

Change-Id: I3292c938df442d1162ad994103ba3fd7e6f2f16c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2160032
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2020-07-15 23:54:19 +00:00
Victor Hsieh
fe863ad1bc p9: fix lcreate to respect the open mode
lcreate is not just used for creat(2), but open(2) as well. So it is
possible that the read/write mode is specified manually.

BUG=chromium:1105484
TEST=Run the test program in the bug. Read returns 0 like on other
     filesystem.

Change-Id: I4fb642deb09831f00d3bd83e973e8a42c54ec5d6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2297228
Tested-by: Victor Hsieh <victorhsieh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Auto-Submit: Victor Hsieh <victorhsieh@chromium.org>
Commit-Queue: Victor Hsieh <victorhsieh@chromium.org>
2020-07-15 22:15:14 +00:00
Andrew Walbran
e43468f066 sys_util: Add IoctlNr type, as different platforms use different types.
In particular, Android targets use c_int whereas normal Linux targets
use c_ulong. An ioctl number should always fit in 16 bits, so casting
from c_uint (as bindgen uses for the constants) to either other type
should be safe.

BUG=b:158290206
TEST=cargo test

Change-Id: I3d808ba9a5588a75c029a299e3609d97e328e3cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2288229
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Andrew Walbran <qwandor@google.com>
Commit-Queue: Andrew Walbran <qwandor@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2020-07-15 19:10:23 +00:00
Ram Muthiah
d7c1591e54 x86_64 configure_vcpu handles image type
Regardless of what image type crosvm is running, it must set the cpuid
since the cpuid is not set by software. This missing setting was
preventing uboot from jumping to the 64 bit kernel since it thought
the cpu was not long mode capable.

BUG=b:153027511
TEST=Booted cuttlefish with and without uboot

Change-Id: Ib8902b324532daf2a0e8ff462603207ff0c64bad
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2298171
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Ram Muthiah <rammuthiah@google.com>
2020-07-15 16:36:16 +00:00
Chirantan Ekbote
906b43c5c9 cros_async: Make raw waker Send + Sync
std::task::Waker unconditionally implements Send + Sync so the raw waker
that we provide also must implement those traits.  Switch to using an
Arc<AtomicBool>.

This also fixes an inconsistency where the waker was defined to be an
Rc<Cell<bool>> but all the vtable functions were treating as an
Rc<AtomicBool>.

To reduce the vtable boilerplate use the ArcWake trait from the futures
crate.

BUG=none
TEST=unit tests

Change-Id: I3870e4d7f6ce0de9f6ac3313a2f4474ae29018b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2287079
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2020-07-15 09:28:23 +00:00
Zach Reizner
f62b22c7bf upgrade rust and rustup version used in Docker
This change also fixes a warning with the drm repo URL being redirected.

The warning about detached HEADs while building the crosvm-base image is
supressed.

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

Change-Id: Ia0d39717769d53ec43bf120b2100dd7b9fa9acfb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2295844
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Zach Reizner <zachr@chromium.org>
2020-07-14 21:14:36 +00:00
Daniel Verkamp
dbf8f9ca0e docker: track minijail in checkout_commits.env
Since the minijail Rust wrapper API can change in incompatible ways
(such as the recent 0.2.0 version bump), track the minijail commit like
other external repositories in checkout_commits.env.

BUG=chromium:1105157
TEST=docker/build_crosvm_base.sh && docker/wrapped_smoke_test.sh

Change-Id: I7dd12327e924806374bae951dd31128726d92099
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2295842
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2020-07-14 21:14:35 +00:00
Andrew Walbran
10d3955d56 Update version of minijail in Cargo.lock.
BUG=b:158290206
BUG=1105157
TEST=cargo test

Cq-Depend: chromium:2296099
Change-Id: I21c0164d9d116f36ac751eb6ae713423a884aa34
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2292370
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2020-07-14 21:14:33 +00:00
Daniel Verkamp
0114c4b312 readme: add a note about clippy
Mention the bin/clippy script in the Code Health section.

BUG=None
TEST=read the readme

Change-Id: Idb55affd5240a85ae434b54360a418e8ef1d40c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2296504
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
2020-07-14 17:29:57 +00:00
Andrew Walbran
fb0e6d9d6a p9: Use std::os::unix rather than std::os::linux.
This will call out to the appropriate platform, so that it works on
Android as well.

BUG=b:158290206
TEST=cargo test

Change-Id: I081a5515340f450a4b8605d5ec9c275e7fa4970b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2294866
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Commit-Queue: Andrew Walbran <qwandor@google.com>
2020-07-14 10:49:15 +00:00
Andrew Walbran
945b980e1a kvm: Fix typos.
BUG=None
TEST=cargo test

Change-Id: Id731f8087b391319329eca1f59bee906f3046bdd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2283337
Commit-Queue: Zach Reizner <zachr@chromium.org>
Auto-Submit: Andrew Walbran <qwandor@google.com>
Tested-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2020-07-13 17:50:28 +00:00
Andrew Walbran
5b1655cc66 gpu_renderer: sys_util::debug is only used on x86_64.
Including it on other architectures causes an unused symbol error.

BUG=b:158290206
TEST=cargo test

Change-Id: If47cc3618c2aaa789fc0c7c7c26ed0e3e0bda621
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2283336
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Andrew Walbran <qwandor@google.com>
2020-07-11 15:05:42 +00:00
Andrew Walbran
f50bab643c rlim64_t doesn't exist on Android, use u64.
rlim64_t is defined as u64 in the 'Linux' version of the libc crate for
all architectures, so this shouldn't change current behaviour.

BUG=b:158290206
TEST=cargo test

Change-Id: Ie04a212c0dadcfc3010f13a058064ff75c7835a5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2283335
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Andrew Walbran <qwandor@google.com>
2020-07-11 15:05:40 +00:00
Gurchetan Singh
2ced42be12 devices: gpu: src: v2 to blob
- Use upstream's preferred nomenclature
- Move to create blob to 2D hypercall group

BUG=chromium:924405
TEST=compile and test

Change-Id: I8676cd5d24e80009266c7bbf8c4b8d734b932672
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2160031
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2020-07-10 22:26:54 +00:00
Kaiyi Li
6c52a2e0c8 gpu_renderer: add vulkan flag for gfxstream
Add a gpu argument to control whether vulkan support should be enabled
for gfxstream backend. Default to enabled.

BUG=None
TEST=launch_cvd

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