As it turns out trim_end_matching() does not do what I expected (namely
trim the string when it encounters matching substring) but rather
expects to remove exactly matching suffix, so it actually fails to
remove comments. Let's switch to using splitn() that does what I want.
BUG=b:144454617
TEST=Run Plugin VM
Change-Id: Ibe8cd14d9d3c14ff99dd9abfa8f286e452d96913
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1975095
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Dmitry Torokhov <dtor@chromium.org>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
This display isn't typically used when the virt-wl device is
available and it can lead to hung fds during plug/unplug with
external displays and docks.
BUG=chromium:1027379, chromium:1027447
TEST=
Tested five times each on R79-12607.47.0 sarien:
=> without patch --> CPU usage goes to 100% after unplug
=> with patch --> CPU usages remains normal
Change-Id: Iea57f05002acc661f36b180e9e88c37b1f1b9047
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1977100
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
FailEntry indicates an arch-specific failure to enter a VM. Treat this as
fatal to the vcpu.
Pass the u64 hardware failure reason from the kvm_run struct up to the client.
BUG=chromium:1036009
TEST=crosvm on hatch nested VM dies immediately instead of infinite looping
Change-Id: Iecb279b5b08ae1edc085717dce65e3ca46cbd30e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1977221
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Commit-Queue: Stephen Barber <smbarber@chromium.org>
Let's allow shorthand notation in the form of:
--plugin-mount=<src>[:[<dst>][:<writable>]]
--plugin-gid-map=<inner>[:[<outer>][:<count>]]
so that we can invoke crosvm as
crosvm ... --plugin-mount=/bin --plugin-mount=/dev/log::true \
--plugin-gid-map=123 --plugin-gid-map=567::5
as repeating the data for both src and destination muddies the waters
and is prone to errors.
BUG=None
TEST=cargo test
Change-Id: I6f0a075ea3b27d4ec3dcf88698069930c158e759
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1967786
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
igd stolen memory isn't a standard pci resource, so guest couldn't
access it. Once guest i915 driver see its size is zero, i915 won't use
it. Here sotlen memory's size register PciCfg 0x51 is forced to zero.
BUG=chromium:992270
TEST=crosvm run --vfio=/sys/devices/pci0000:00/0000:00:02.0, pass
through host igd into linux guest. The physical local display lightup and show linux desktop.
Change-Id: I1a0a6edda5d92d32307ea8025ef96677ca62c125
Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1688368
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
List of bind-mounts and gid maps can be quite long, so let's allow
listing them in text files, when convenient.
BUG=b:144454617
TEST=Run Plugin VM
Change-Id: I1218dab5a7e87b9f1ba44de6828da890fddb99fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1967785
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
In order to support specifying list of bind-mounts and gid maps options
via files, factor out the parsing code.
BUG=b:144454617
TEST=Run Plugin VM
Change-Id: I772116cd77827ef722559e9fce450235fdbf6478
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1967784
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
Support TSC deadline mode of LAPIC timer, this can potentially increase
the precision of guest timer.
BUG=None
TEST=launch linux guest and run `lscpu`, tsc_deadline_timer is present
in the output.
Change-Id: I7adc87827a51ba8d1866ebee201759f2769ba664
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1951429
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Zhuocheng Ding <zhuocheng.ding@intel.corp-partner.google.com>
Other users will want to set flags on FDs. Particularly asynchronous
code that wants to set FDs as non-blocking. Add a helper that handles
fetching and or-ing in the given flags so users don't have to handle
that themselves.
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Change-Id: Iabe438fbbb1ec305f693dbe1348930ef153edcf4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1955044
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Fix the build of block_fuzzer after "devices: block: add block_size
option for disks".
It might be nice to generate the block size from the random fuzz data,
but that would complicate things (we'd have to handle failure of
Block::new due to invalid sizes), so let's leave that as a future
improvement for now and just use a block_size of 512 to match previous
behavior.
BUG=chromium:942700
TEST=`USE='asan fuzzer' emerge-nami crosvm`
Change-Id: Ia16ef6a57fc8ce4407f8ec9dda0e708302916c4c
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1962535
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Could be used by virtio-fs and virtio-gpu.
(cherry picked from crrev.com/c/1493014)
[took out PCI portions and modified commit message -- @gsingh]
BUG=chromium:924405
TEST=build and run
Change-Id: I47fd4482aa7c11e08bfb4f6c990221ae7a11a11d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1963333
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
According to ac97 spec, warm reset is specified to no-op when the device
is running. We should ignore it while the device is recording audio as
well.
BUG=chromium:1026538
TEST=Build
Change-Id: I64be922149c90be9a7a8669ef6d56591e6de632b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1960058
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
Create a function move_to_next_buffer which handles incrementing civ and
piv properly.
Set the PICB register when that function is called, not when we read a
guest buffer.
BUG=chromium:968724
TEST=playback on-device
Change-Id: Ib384efceeac4be0e056c20591d93fe32b7305db6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1954207
Reviewed-by: Fletcher Woodruff <fletcherw@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Fletcher Woodruff <fletcherw@chromium.org>
Tested-by: Fletcher Woodruff <fletcherw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
This allows overriding the default logical block size (512 bytes) with
other values, such as 4096 for 4K block size disks.
BUG=chromium:942700
TEST=crosvm run -r vm_rootfs,block_size=4096 vm_kernel
TEST=verify block size with lsblk --output-all
Change-Id: Ia6db05f369a76557a2afb8b48b5cc2b66cf84b01
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1954220
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Add a new type `RunnableVcpu` for a vcpu that is bound to a thread. This
adds type safety to ensure that vcpus are only ever run on one thread
because RunnableVcpu can't `Send`. It also ensures multiple vcpus can't
run on the same thread.
Change-Id: Ia50dc127bc7a4ea4ce3ca99ef1062edbcaa912d0
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1898909
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
The PIT implementation has the assumption that addresses are I/O port
numbers, so we should use full address mode. i8042 is also changed to
full address mode to avoid the conflict on port 0x61.
BUG=chromium:908689
TEST=None
Change-Id: Ibbb851e3a46ac7fc71576990a1618196de92e33c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1945794
Commit-Queue: Zhuocheng Ding <zhuocheng.ding@intel.corp-partner.google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Interrupt polarity is ignored by kvm since 3.15, and the irqfd interface
does not support polarity. We should not consider polarity either.
BUG=chromium:908689
TEST=Unit tests in file. Integration testing is blocked on rest of
split-irqchip being implemented.
Change-Id: Ibae23b81274f867bbf56009854611628dbb4c154
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1945793
Commit-Queue: Zhuocheng Ding <zhuocheng.ding@intel.corp-partner.google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
This change enables Cuttlefish to run with a user specified display size on top
of virtio gpu accelerated graphics rendering.
This change makes the width and height an argument/flag and adds the necessary
plumbing to pass this width and height through the gpu backend.
BUG=b:134086390
TEST=built crosvm and booted cuttlefish locally
Change-Id: Idabf7ef083b2377e3ebf3b50dd0296f4bf7e8ddc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1927872
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Jason Macnak <natsu@google.com>
Add support for FS_IOC_{GET,SET}_ENCRYPTION_POLICY. Unfortunately,
since the I/O direction is encoded backwards in the ioctl definitions,
these will only work with on a kernel that's compiled with a patch to
mark them as unrestricted FUSE ioctls.
BUG=b:136127632
TEST=Compile and run the vfs_crypto.c program on a virtio-fs mount
inside a VM
Change-Id: I124c5a943111b453dd44921a079a2baa1036dfd4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1952570
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
When all refblocks are consumed, the loop looking for the first free
cluster would access the element at refcounts[refcounts.len()], which is
out of bounds. Modify the free cluster search loop to check that the
index is in bounds before accessing it.
BUG=chromium:1030751
TEST=qcow_fuzzer
Change-Id: Ib2384b9cf1edeaadb99be5fc67c27a55c03fc6e9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1953766
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Don't use /proc/sys/fs/file-max when setting the max open file limit for
the virtio-fs device. This will fail when the value is larger than the
hard limit set for the crosvm process, unless it also has CAP_SYS_ADMIN
in the initial namespace.
Instead, just use the hard limit as returned by `prlimit64`. Increasing
the soft limit up to the hard limit is allowed even for completely
unprivileged processes. It is up to the process that spawned crosvm to
ensure that the hard limit is high enough that the virtio-fs server will
not run out of fds.
BUG=b:142344095
TEST=Start a termina VM with a virtio-fs device after applying
CL:1939193
Change-Id: I4fb4c33ffe6378ed3109fddcb0fc2bf3da850252
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1957767
Tested-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
... to allow for specifying either '--gpu' to get default params or
'--gpu=width=800,height=600,egl,surfaceless' to get custom params.
Note: this introduces some potential ambiguity if the flag_or_value
argument is the last arg specified before a positional argument.
For example, 'crosvm run --gpu something' could either be parsed
as a single value ('--gpu=something') or a flag and a positional
argument ('--gpu' and 'something'). This change currently expects
that the functor passed to set_arguments() will return an error
on '--gpu=something' in order to resolve the disambiguity.
BUG=b:134086390
TEST=built crosvm and booted cuttlefish locally
Change-Id: Ib9be604af82583a39d7bd0a403e2168ef7350389
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1929603
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
The interrupt_evt/interrupt_resample_evt/queue_evts were move to activate
so the reset method has to return them back (although there is no virtio
device implemented the reset method yet).
Instead of move, another way is just clone these EventFds so that they
don't need needed to be returned.
The advantage of doing this can avoid changing every virtio device reset
method (again, currently there is no virtio device implemented the reset
method yet, but this method is going to used when needs to support the
reset of a virtio device) for returning them, which can simplify the code.
And reset method just needs to take care their own specific resources.
The disadvantage is that, the clone of an EventFd is try_clone which might
return error code (although this shouldn't happen). If in such case, the virtio
device won't be activated.
BUG=None
TEST=launch crosvm guest with virtio devices(rng/balloon/blk/net).
Change-Id: I6e55782c3ecc46bfa878aff24b85a58a7ed66365
Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1925682
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Instant::Now() is called from buffer_completed in ac97_bus_master.rs
sometimes, so we need this. It seems we've already added this to
arm. I guess that code path is only triggered on "slow" devices, that's
why we missed it here in the first place.
BUG=b:139318078
TEST=manual - Run betty-arcvm-pi board under qemu.
Change-Id: I45395eea4d69942c4e9577a39c8074888b4f637c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1954222
Tested-by: Lepton Wu <lepton@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Lepton Wu <lepton@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Commit-Queue: Lepton Wu <lepton@chromium.org>
Replace the unchecked conversion with a try_from() rather than just
truncating without warning. This gives a more useful error message when
a >4GB guest memory size is requested on a 32-bit platform.
BUG=chromium:1028747
TEST=`crosvm run -m $((5 * 1024)) ...` on kevin
Change-Id: Ib1fcf4019eefdc9ee8f93a5307802e6d6d43d01c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1937552
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
On systems where usize is 32 bits wide (e.g. 32-bit arm), the
calculation of memory_size in bytes based on the -m configuration option
in megabytes would silently overflow when the resulting value was wider
than 32 bits.
Change the shift that converts megabytes to bytes into a checked_mul so
that a suitable error is produced if the size overflows.
Additionally, change the cfg.memory type to u64 instead of usize; this
is representing a size in megabytes, so its maximum value isn't related
to the size of an object in memory anyway, and this avoids the need for
a cast in the memory_size calculation. Requesting a memory size larger
than the crosvm process can map will still result in an error at a later
stage in guest startup.
BUG=chromium:1028747
TEST=`crosvm run -m $((5 * 1024)) ...` on kevin
Change-Id: I8fef7070bab4dafff70ed54738b26d0bb7632150
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1937551
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
if device bar is mappable, map bar's gpa to hpa in EPT, guest vcpu
could access this bar directly through EPT without trapping. This
could improve performance.
vm.add_mmio_memory could help do this, here vfio_pci send
RegisterMmapMemory request through vm_control socket to do this.
BUG=chromium:992270
TEST=none
Change-Id: I3b4274372f7dcd32e18084d55f037b6fe45ed422
Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1581147
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
The implementations of FileReadWriteVolatile and FileReadWriteAtVolatile
for SharedMemory are never used; SharedMemory is typically accessed as a
memory mapping, not as a writable/readable file-like object. Remove the
implementation of these traits for SharedMemory to simplify porting to
other platforms where SharedMemory may not necessarily be backed by a
file-like object.
BUG=None
TEST=./build_test.py
Change-Id: I9c1e46ad2d3299b8676fad33151cde7c4b1c7b8e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1937555
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Two virtio descriptor_utils tests were using SharedMemory to stand in
for I/o targets with a fixed size; replace these with File to avoid
needing the FileReadWriteVolatile impl for SharedMemory, which isn't
used anywhere else in the crosvm code base.
This slightly changes the behavior under test in the reader_failing_io
test, since it was previously using the SharedMemory seal functionality
to make the region ungrowable; this is an unusual corner case, and (as
mentioned in the comment that was previously at the end of the test) it
is testing implementation details of write() on shared memory on Linux.
Instead, just use a read-only file so that write() to it will fail and
cause the same observable result.
BUG=None
TEST=./build_test.py
Change-Id: I6d62cd70791f1dec625b750ecd01cc51e307f971
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1939783
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
The gettid syscall is used in some corners of glibc and it is a fairly
harmless syscall (we already give getpid), so this change moves it to
the common policy.
TEST=None
BUG=chromium:996938
Change-Id: I129644273f2f02fe917255c7157c48b99c329045
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1952565
Tested-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Zach Reizner <zachr@chromium.org>
All virtio devices can use the same generic calculation for number of
MSI-X vectors required: number of queues plus one for configuration
changes. Move this calculation to the VirtioPciDevice implementation
and remove the Option to unconditionally enable MSI-X support for all
PCI virtio devices.
BUG=chromium:854765
TEST=Verify all virtio interrupts in /proc/interrupts are PCI-MSI
Change-Id: I5905ab52840e7617b0b342ec6ca3f75dccd16e4d
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1925169
Reviewed-by: Zide Chen <zide.chen@intel.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
PlaybackError and CaptureError encode the same error cases. Combine the
two into one Error type, AudioError.
BUG=None
TEST=builds
Change-Id: I44259227d67a0284c9a11c4aafd86fafe1006f8b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1925727
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Fletcher Woodruff <fletcherw@chromium.org>
The code in the doc comment didn't compile, fix the missing command.
Ignore the snippet because it depends on arch::__IncompleteArrayField,
and getting it to compile isn't worth adding a crate dependency.
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Change-Id: Ibaee50d0d44fbfb9ca2862b1dda220a0a1e5696b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1944097
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
The virtio-fs device opens a lot of fds and needs to have a pretty high
open file limit. In order for this to be successful on Chrome OS, the
parent process (concierge) also needs to have a very high open file
limit. This unfortunately has the side-effect of raising the open file
limit for _all_ crosvm devices.
Deal with this by setting the open file limit back down to a reasonable
value (1024) for all devices that use `create_base_minijail`. This was
the value of the open file limit for concierge before the increase.
BUG=b:142344095
TEST=Check /proc/<pid>/limits for various crosvm device processes and
see that they have the proper value for "Max open files".
Change-Id: I87e3fe62fe22e68bff5ba5b60d85d39060a111dd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1939527
Tested-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
This new trait allows DiskFile implementors to provide the length of the
file directly rather than using SeekFrom::End with seek().
BUG=None
TEST=./build_test
TEST=Boot Termina in crosvm
Change-Id: I9447ebb43dbd5fbb32a3a6b6d2fc969b9406cdbc
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1913961
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
This eliminates an extra seek per guest write zeroes request.
Additionally, it allows us to stop depending on the file cursor and pass
the offset directly, making multi-queue implementation easier.
BUG=chromium:858815
TEST=Boot Termina in crosvm
Change-Id: I8b15a39752a1b68597a2b1e1fd72382a484a3cb2
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1913521
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Replace the implementation of File write_zeroes with one that uses
fallocate() with the FALLOC_FL_ZERO_RANGE flag instead of
FALLOC_FL_PUNCH_HOLE. This means it will keep space allocated for the
zeroed region instead of deallocating it. The PunchHole trait is
available for this purpose instead, and the virtio-blk implementation
already relies on these two traits for their differing behaviors.
BUG=chromium:858815
TEST=cargo test -p sys_util write_zeroes
Change-Id: I69ab06037f72dc219e6ea9409654f97eeaba32c3
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1913520
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Add a variant of WriteZeroes that allows the caller to specify the
offset explicitly instead of using the file's cursor. This gets rid of
one of the last bits of shared state between disk file users, which will
help in implementing multi-queue support.
Additionally, modify the WriteZeroes trait to use a generic
implementation based on WriteZeroesAt + Seek when possible.
BUG=chromium:858815
TEST=Boot Termina in crosvm
Change-Id: If710159771aeeb55f4f7746dd4354b6c042144e8
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1913519
When vfio pass-through is enabled, guest will be very slow. The root
casue is gfn is uncachable in EPT.
From the comments in kernel vmx_get_mt_mask(vcpu, gfn, is_mmio)
function, EPT memory type with VT-d, VT-d without snooping control
feature: can't guarantee the result, try to trust guest through
kvm_mtrr_get_guest_memory_type(vcpu, gfn).
But crosvm doesn't set mtrr, so host kernel will set uncachable for all
gfn in ept.
This patch set the default cache type as WB, and set mmio cache type as
UC, so the guest ram is WB.
BUG=chromium:992270
TEST=crosvm --vfio /sys/devices/pci0000:00/0000:00:02.0, pass through
host igd into linux guest, the guest runs smoothly and guest desktop
could be shown on physical local display.
Change-Id: I151aae7835910cfbc9e38464ee901e5da281de1e
Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1813458
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
The libminijail API defines rlim_t as an alias for rlim64_t. Change the
FFI bindings to use rlim64_t.
BUG=none
TEST=`tast run kevin vm.Virtiofs`
Change-Id: I21ece499bcef187b358574bca0918b39f5971586
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1933612
Tested-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
This change also includes stubs for the wayland and x11 impls.
TEST=compiles
BUG=chromium:1023975
Change-Id: Ia2bcb5c2ed75ea47071dd77e149e60901a56595c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1930407
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
The EventDevice is a data structure that allows a generic gpu display to
send and receive input events in evdev's format to a generic input
device, such as virtio-input.
BUG=chromium:1023975
TEST=None
Change-Id: Ic663cc8c7a3031aee929e09620c5430c27a25190
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1930406
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>