We can require the ID field to be present in all the arch specific
structs, then we don't need an extra layer.
Change-Id: Icbbf0ec5b99fd6816863a611a538e67def09d87f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4385864
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Elie Kheirallah <khei@google.com>
This CL adds BAR reprogramming support to a VirtioPciDevice. A tube for
handling ioevent register requests is added. The requests are handled
similarly to existing VmMemoryRequests.
Test: Presubmit tests. Hotplugged virtio device without VM memory
allocation functions after guest OS gives the memory.
Bug: 271204121
Change-Id: Ia0d421d8cd461eeee8f402256d0c7620c507f0e9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4311103
Reviewed-by: Ningyuan Wang <ningyuan@google.com>
Commit-Queue: Ningyuan Wang <ningyuan@google.com>
Reviewed-by: Zihan Chen <zihanchen@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
"crosvm swap trim <socket_path>" command for trimming 2 types of pages
in the staging memory before swapping out to reduce the disk I/O.
* clean pages
* zero pages
The doc comment of TrimContext explains the page types.
BUG=b:265592787
TEST=cargo test -p swap
Change-Id: I5c33149f7d0bfd712f07fd11eb9aa07c1a8b0e7a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4357224
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
The base crate has some nifty abstractions but also
pulls in things like minijail, audio_streams and
various random items.
This prevents true cross-platform interoperatibility,
which requires the ability to upload to crates.io
with relative ease.
This change removes the base crate. The replacement
strategy is two fold:
- For things like SafeDescriptor which don't have
adequate solutions on crates.io, just copy it
internally. I think SafeDescriptor in particular --
since it works on bot Windows/Linux should probably
be made into a separate crate long-term since it is
generically valuable. Similarly for the Event and
WaitContext APIs. For now, live with the duplication.
- Otherwise, the nix crate does most of the Linux
specific items.
The cross-domain context type has a lot of dependencies
on Linux sockets / epoll. This is refactored to look more
like the Fuchsia solution, which uses std::sync::mspc
channels to connect to an utility Wayland FIDL library.
The rest of Rutabaga mostly relies just on SafeDescriptor
and the ability to clone it. rutabaga_gralloc allows
provides shared memory used via virtwl.
Another thing to call out is zerocopy is now strongly
versioned to the latest stable release on crates.io
I also got rid of #[cfg(feature = "virgl_renderer_next")]
on the renderer server fd, since it was complicating the
refactoring. SafeDescriptor works everywhere and adding
the #ifdef should be reserved for the lowest-levels of
platform specific code when possible.
Overall, this makes compiling on Fuchsia hosts much
simpler.
BUG=b:273555494
TEST= - run cross_domain context type, see Wayland apps
- note there is a previous bug in cross domain
when resizing windows, it occurs before this CL.
The reason seems to be raciness and can likely be fixed
gfxstream-like seqno.
- run gfxstream + virgl on Linux, verify everything works.
Change-Id: I7519f2b8ed0cd57c47980d4e76403057498cf064
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4353700
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
This is a reland of commit 42a437de5e
This change fixes a crash that occurs when no-rtc is set by properly
checking the Option that can contain the cmos's control tube, instead of
just calling unwrap. It also replaces an unwrap during cmos
initialization with proper error propagation.
Original change's description:
> devices: cmos: implement rtc alarm
>
> Implement CMOS alarm functionality. This allows guests to set rtc
> alarms, which is useful when putting a Linux guest into s2idle.
>
> This change allocates a dedicated interrupt for the goldfish battery,
> instead of reusing the sci irq. Sharing an irq line between a wakeup
> interrupt and a non-wakeup interrupt doesn't work well because the
> non-wakeup interrupt won't be delivered to its driver while the driver
> is suspended, which results in the irq being permanently asserted.
> Simply using a dedicated interrupt for the goldfish battery is much
> easier than adding suspend/resume support to the Linux driver.
>
> BUG=None
> TEST=cargo test -p devices cmos, manual tests w/rtcwake
>
> Change-Id: I757acc64b61e414d5d9df5a1fb4770943ef985bf
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4314184
> Reviewed-by: Elie Kheirallah <khei@google.com>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Commit-Queue: David Stevens <stevensd@chromium.org>
BUG=None
TEST=cargo test -p devices cmos, manual tests w/rtcwake and no-rtc
Change-Id: Iec73c0aa08b4f2081c3b7a824254723ea9da5365
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4364558
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
Auto-Submit: David Stevens <stevensd@chromium.org>
Add restore to Vcpu to restore VCPU state from snapshot.
Add kick_vcpu to kick a specific vcpu.
BUG=b:266515147
BUG=b:232437513
Test=crosvm run && crosvm snapshot take img_name socket
Change-Id: Ie09419fd50dcecd0226b2b716236d2c8196b58ec
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4260157
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Elie Kheirallah <khei@google.com>
Auto-Submit: Elie Kheirallah <khei@google.com>
Add snapshot to vCPU for x86 and x86_64 arch.
BUG=b:266515147
BUG=b:232437513
Test=crosvm run && crosvm snapshot take img_name socket
Change-Id: I65d059a7537c713e9ef6c1456a7aeae2b6bc4728
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4237759
Auto-Submit: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Elie Kheirallah <khei@google.com>
MsixConfig is now serializable. After deserialization, there is a new function
`restore_msix_all`, which will re-create the MSI-X vectors based on the
data that was deserialized. We could try to weave this into the actual
serde deserialization process, but that will likely be more hassle than
it is worth (it will also stop us from fixing up the msi control Tube on
restore, which we'll have to do in a future CL).
BUG=b:272137957
TEST=presubmit
Change-Id: I36fbc35a13fe11ae2f7c899431d2ef239ac00f90
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4337964
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
This CL renames some functions and variables introduced for PCI BAR
reprogramming to avoid confusion.
Test: presubmit tests.
Bug: b:271204121
Change-Id: I77aaca123a677b56da0b45ce78a54e84bec64a59
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4332623
Commit-Queue: Ningyuan Wang <ningyuan@google.com>
Reviewed-by: Hugo Benichi <hugobenichi@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Instead of wiring up a channel ahead of time, set one up on demand. This
significantly reduces the amount of plumbing required. We'll need more
VcpuControl cases in the near future that require responses like this
(e.g. vcpu snapshotting and restoring) and the extra plumbing for each
in unpalatable.
It isn't obvious what the performance difference is and we don't have a
relevant benchmark. None of the use cases are particularly performance
sensitive yet.
BUG=b:232437513
Change-Id: I96e720065275894ac0eb2965d5f707ec57b19c64
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4326945
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Elie Kheirallah <khei@google.com>
Upstreams blocking overlapped read/write commmands to base.
These funtions will be used by the broker to forward messages exchanged
between main and service.
Bug: 269191436
Test: none
Change-Id: I029e8c440bb6b8234fe2d1ca3b1dd5ddb408d814
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4329913
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
crrev.com/v/4237140 was reverted in crrev.com/c/4310064 due to the
generated header file not defining the RegisteredEvent type. along with
re-reverting the original cl (and corresponding bugfix cl) this patch
introduces a RegisteredEventFfi type which mirrors the original
RegisteredEvent type but should be exposed in the generated header file.
BUG=b:269609274
TEST=sidecar process (patch: crrev.com/c/4276642)
TEST=cargo build, header file inspection
Change-Id: I4a17163e36eb466a540a72d2bb4356419739c974
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4311831
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Maciek Swiech <drmasquatch@google.com>
This reverts commit 42a437de5e.
Reason for revert: This is crashing if no_rtc is set (http://go/bbid/8787052669966742145/test-results)
Original change's description:
> devices: cmos: implement rtc alarm
>
> Implement CMOS alarm functionality. This allows guests to set rtc
> alarms, which is useful when putting a Linux guest into s2idle.
>
> This change allocates a dedicated interrupt for the goldfish battery,
> instead of reusing the sci irq. Sharing an irq line between a wakeup
> interrupt and a non-wakeup interrupt doesn't work well because the
> non-wakeup interrupt won't be delivered to its driver while the driver
> is suspended, which results in the irq being permanently asserted.
> Simply using a dedicated interrupt for the goldfish battery is much
> easier than adding suspend/resume support to the Linux driver.
>
> BUG=None
> TEST=cargo test -p devices cmos, manual tests w/rtcwake
>
> Change-Id: I757acc64b61e414d5d9df5a1fb4770943ef985bf
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4314184
> Reviewed-by: Elie Kheirallah <khei@google.com>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Commit-Queue: David Stevens <stevensd@chromium.org>
Bug: None
Change-Id: I25737095f84ca0b56d94924a9d8ccb5fd42ff51c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4329909
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
This CL adds trait implementation for PciDevice to handle BAR
reprogramming. When BAR reprogramming is detected, the PciDevice checks
all ioevents needed, and requests ioevent registeration for events that
are in the changed domain. The requests are handled by instances of
PciDevice via the trait function ioevent_register_request.
Before the CL, ioevent re-registering is unhandled, and PciDevice is
broken without notification. After CL, an error message will appear, but
device still would not function as the added trait is not implemented.
Test: Presubmit Tests. Hotplugged virtio device triggers error
IoEventNotSupported as expected.
Bug: 271204121
Change-Id: Ibf4bc00cfdce24e508cd50b5009f148c5a49db30
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4310071
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Ningyuan Wang <ningyuan@google.com>
Implement CMOS alarm functionality. This allows guests to set rtc
alarms, which is useful when putting a Linux guest into s2idle.
This change allocates a dedicated interrupt for the goldfish battery,
instead of reusing the sci irq. Sharing an irq line between a wakeup
interrupt and a non-wakeup interrupt doesn't work well because the
non-wakeup interrupt won't be delivered to its driver while the driver
is suspended, which results in the irq being permanently asserted.
Simply using a dedicated interrupt for the goldfish battery is much
easier than adding suspend/resume support to the Linux driver.
BUG=None
TEST=cargo test -p devices cmos, manual tests w/rtcwake
Change-Id: I757acc64b61e414d5d9df5a1fb4770943ef985bf
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4314184
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
This reverts commit 2404c5ed44.
Reason for revert: This fails to build crosvm C interface and blocking ChromeOS CQ.
Original change's description:
> balloon: add event registration mechanism for sidecar processes.
>
> this patch introduces a mechanism for so-called 'sidecar processes' to
> register as event listeners, consuming events that are generated in
> various parts of crosvm. in this patch we focus on events that enable
> roziere cooperative ballooning, but lay the groundwork for a more
> general framework.
>
> the general idea is that a sidecar process would open a listening socket
> and register the path with crosvm for a specific event. crosvm will pass
> along a handle to a registered event tube to the appropriate device (or
> other internal component) which would then be responsible for passing
> along events. once events arrive back in the crosvm control loop, an
> attempt is made to dispatch the events to any registered sockets.
>
> BUG=b:269609274
> TEST=sidecar program that performs registration and receives events
>
> Change-Id: Iaff41aad8f862ed99a104c75623caaabc53e9e88
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4237140
> Commit-Queue: Maciek Swiech <drmasquatch@google.com>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Bug: b:269609274
Change-Id: I135e0d55bb296cf591548b7bd4feffc7ff9f3447
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4310064
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
To safely flush IRQs, we need devices to be asleep. This CL splits our
existing snapshot device control command into three: sleep, snapshot,
and wake. This way we can ensure the devices are sleeping while we flush
IRQs & snapshot the VCPUs (in the future).
BUG=b:269652620
TEST=./tools/dev_container e2e_tests/run --tests suspend_resume
Change-Id: I82a3f280c24378ea5d2a28a5cd4e3db49c9b78f2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4304243
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
https://crrev.com/c/4304741 broke these because the expected responses
are not `VmResponse::Ok`. There isn't good reason for them to have
custom types though, so I've moved them to `VmResponse::Ok` and added a
generic `VmResponse::ErrString` case to support stringy errors. Maybe
more stuff could be moved to `VmResponse::ErrString`, but I'm holding
off for now.
Change-Id: Ib5760217037ceb8718e36a77aeb300a4b0eb2a9f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4304683
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
The tube response should be deserialized as a `SnapshotControlResult`
instead of `()`.
Also, we want to flush IRQs before snapshotting the IRQ chip state, so
it should be done before sending the snapshot command. However, this
part is still not right because the devices aren't asleep.
Change-Id: I94245b23a5166ec231dd36020e55930a80e007cd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4304682
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
A command like `crosvm stop` could fail, but report an exit code of 0
with no error message.
Change-Id: I6491f8fcb755717999816d34d4a4eaf3964e1270
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4304741
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
this patch introduces a mechanism for so-called 'sidecar processes' to
register as event listeners, consuming events that are generated in
various parts of crosvm. in this patch we focus on events that enable
roziere cooperative ballooning, but lay the groundwork for a more
general framework.
the general idea is that a sidecar process would open a listening socket
and register the path with crosvm for a specific event. crosvm will pass
along a handle to a registered event tube to the appropriate device (or
other internal component) which would then be responsible for passing
along events. once events arrive back in the crosvm control loop, an
attempt is made to dispatch the events to any registered sockets.
BUG=b:269609274
TEST=sidecar program that performs registration and receives events
Change-Id: Iaff41aad8f862ed99a104c75623caaabc53e9e88
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4237140
Commit-Queue: Maciek Swiech <drmasquatch@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
The design sending SIGSTOP to the main process and the device processes
from the monitor process does not work with sandboxing the monitor
process because user namespace without pid namespace is not supported by
minijail.
This changes the design so that monitor process sends a message to the
main process, which is then responsible for guaranteeing that nothing
except the monitor process will access guest memory when vmm-swap is
being enabled. The main process does this by sending SIGSTOP to device
processes and suspending the vCPU threads. Although there are other
threads in the main process, none of them currently access guest memory.
The vmm-swap feature now does not support `--disable-sandbox`. It would
be possible to support it by sending `SIGSTOP` from the monitor process
to the main process. However there is no clear use case for vmm-swap
with `--disable-sandbox`, so the extra complexity is not worth it.
BUG=b:270248453
TEST=manual test
Change-Id: Ie24d5a5b5f8e6999d133beb9b4c3562e26427838
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4293656
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
The constant was for a max, not an expected loop value.
BUG=none
TEST=tools/clippy
Change-Id: I71a69612951b0f12f32e7d800d7a892e7f472371
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4299921
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
Just prior to taking a snapshot, we want to ensure that all pending IRQs
are flushed to LAPICs so that they can be safely saved & restored with a
snapshot. This CL wires the snapshot handler to the IRQ handler so that
the IRQs can be confirmed to be flushed.
BUG=b:269652620
TEST=./tools/dev_container e2e_tests/run --tests suspend_resume exercises this
code path, but does not directly test the changed behavior.
TEST=this fixes a race condition. Writing a test to reproduce that race
condition would just introduce a flakey test. When we have a cold boot
test (which we can't write yet because it depends future features), it
will flake on restoring LAPIC state *if* this CL has not fixed the race
condition properly. Thus, the testing strategy for this CL is to make
sure our cold boot test is run with *many* iterations to detect such
flakes (see b/270778349).
Change-Id: I2f326a7fdee9f21edda8402920661ef984943761
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4292623
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
Add unit test cases to test disk resize and device reset.
BUG=b:270280130
TEST=`cargo test -p devices`
Change-Id: Idac5e5e18ff520b6ae7d85ca9a6d5d103b114e78
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4272806
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Takaya Saeki <takayas@chromium.org>
do_while_vcpus_suspended() deeply depends on device snapshot feature.
It should be more generic.
The vmm-swap feature will need to execute enabling logic while vCPUs are
suspended.
BUG=b:270248453
TEST=cargo build
Change-Id: I4f1acb2cf9ad61ee0887c6c7bfa7f68ba1dfb3ed
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4279545
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Elie Kheirallah <khei@google.com>
Commit-Queue: Shin Kawamura <kawasin@google.com>
page fault logger is only for debugging purpose. It has a security
concern about exposing the trigger to enable the logger. The logger will
make the page fault handling slower and consumes disk resources.
Instead, the page fault logger is only enabled by compiler feature flag
like:
```
cargo build --features=swap,swap/log_page_fault
```
Opening a file on the monitor process is blocking the upcoming minijail
migration. Open the log file on the main process and pass the file
descriptor to the monitor process.
BUG=b:269372016
TEST=manual test
Change-Id: I5df2a32da7fb149680fa24617ffd905b2483108b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4253287
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
Allow devices to notice wakeup events supported by
VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY_WITH_WAKEUP.
BUG=b:241526471
TEST=Trigger a wakeup event and verify the output from `lspci`
Change-Id: Ie93780606fbfaa7efff853b6ff12314b3f54f276
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4048547
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Victor Ding <victording@chromium.org>
Commit-Queue: Victor Ding <victording@chromium.org>
Behavior difference: will now call `irq_chip.kick_halted_vcpus()` (which
is a noop for many irq chip impls).
Change-Id: I165393fe22e0c90b9d751ab2f04246e3e93fb414
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4149735
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Elie Kheirallah <khei@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
This splits the `crosvm swap enable` command, which pauses the whole
crosvm processes while it write all the active pages on the guest memory
into the swap file, into 2 commands.
On `crosvm swap enable` command, the monitor process just moves the
guest memroy to the staging memory while blocking the whole crosvm
processes with SIGSTOP.
On `crosvm swap out` command, the monitor process writes the active
pages in the staging memory to the swap file.
The page faults between `swap enable` and `swap out` are swapped in from
the staging memory.
By waiting some time before sending swap out request after enabling
vmm-swap, hot pages on the guest memory, which are frequently accessed,
are swapped in from the staging memory and we can reduce the TBW of the
swap file and reduce the latency of page faults for hot pages.
BUG=b:263830401
TEST=cargo test -p swap -p base
Change-Id: Ia83f5052cc0bd4d25089c6a6680e40a1fa1661c0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4134149
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
These should be written as ChromeOS and ChromiumOS (without the space)
to match the updated branding. The copyright headers were already
migrated to the new style (https://crrev.com/c/3894243), but there were
some more instances left over.
BUG=None
TEST=tools/cargo-doc
Change-Id: I8c76aea2eb33b2e370ab71ee9b5cc0a4cfd00585
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4129934
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Adding restore to crosvm
Adding restore in vm_control
Cleaning snapshot and restore to be in DeviceCommand (single point of
entry for modifying devices)
Bug=b🅱️232437513
Test=WIP
Change-Id: Id7d51cb5689bc1872aa0dbcbc9a8778e0d26130e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3936662
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Steven Moreland <smoreland@google.com>
Auto-Submit: Elie Kheirallah <khei@google.com>
Commit-Queue: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Add snapshot functionality in Bus.
Add thread to handle communication between VM cmdline and devices.
Add DeviceCommandControl in vm_control to handle device-specific
actions.
Bug=b:232437513
Test=cargo build && cargo run ...
Change-Id: If3795c9e1f12ab4cd34ab36cad8eae43d469a50a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3930627
Auto-Submit: Elie Kheirallah <khei@google.com>
Commit-Queue: Elie Kheirallah <khei@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Steven Moreland <smoreland@google.com>
The current syntax is:
--gpu-display horizontal-dpi=100,vertical-dpi=200
We would like to change that to:
--gpu-display dpi=[100,200]
We will keep the backward compatibility for now, but the caller
should not use both of syntax at the same time.
FixedGpuDisplayParameters is introduced for backward compatibility
support, and it will be removed once the old syntax is deprecated.
BUG=b:260101753
TEST=presubmit
Change-Id: I66a31c448ecc1eba60f6d1cbcbc753315c6c1df6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4049340
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Commit-Queue: Pujun Lun <lunpujun@google.com>
Handling page faults using userfaultfd for all the time after vmm-swap
is enabled originally has overhead. By disabling swapping, we can use
crosvm without the overhead when the crosvm become used heavily again.
This also refactor PageHandler and extract register logic to lib.rs.
BUG=b:215093219
TEST=cargo test -p swap
Change-Id: Id81d84ebe40067b4f19b212f6b81cbaf249c0c3c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4005474
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
The new command "crosvm swap log_pagefault <socket>" starts logging
page fault events. The log file "page_fault.log" will be located under
the swap directory.
Pagefault event log help up debugging the vmm-swap feature and
understand the memory usage of the guest os.
design document: go/tanooki-phase1-dd
BUG=b:253555760
TEST=manually tested. this is debug feature.
Change-Id: I13e36cef873cd83179032fe8a289c8df71384644
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3954806
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
Added new crosvm commands "crosvm swap enable" and "crosvm swap status".
swap crate exposes SwapController to control the vmm-swap feature.
When vmm-swap is enabled, all the pages on the GuestMemory are swapped
out to a file and are freed to give a lot of memory back to OS.
design document: go/tanooki-phase1-dd
BUG=b:215093219
TEST=manually tested
Change-Id: Ideb10b0119edd9f47b66c8ac61add21ac08181d4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3871758
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
As part of commit cadc84b32a the crosvm
suspend command has been extended to generating sleep button injection
in order to put VM in suspend state. Additionally the crosvm suspend
command completed after the guest entered proper power state.
Nevertheless in some circumstances above implementation caused issues.
E.g. when the guest with pass-through devices entered run-time device
suspension, triggering a subsequent system suspend request fails and
makes VM inaccessible. It is because before entering system suspension,
devices which entered device run-time suspension needs to be resumed.
Therefore in problematic scenario:
- VmRequest::Suspend was triggered and it resulted with blocking till
guest entered proper suspend state
- during VM suspension process some pci config write accesses are made,
which in some cases triggers write_msi_reg-> write_msi_capability->
add_msi_route, which underneath sends VmIrqRequest::AddMsiRoute
request
- above VmIrqRequest::AddMsiRoute request can't be satisfied since
VmRequest::Suspend made the run_control wait loop busy waiting and
preventing further requests to be processed
In order to fix the above issue, instead of busy waiting directly in the
run_control wait loop for suspend notification, spawn a new thread, which
will generate the acpi power button and start busy waiting for a
notification that the VM actually entered suspend state. This allows to
postpone sending response over the control tube indicating that the
'crosvm suspend ...' command completed and in the same time process
other Vm*Requests.
Mentioned postponement of 'crosvm suspend ..' completion is crucial
since the full system suspension needs to be blocked till VM actually
enters proper suspend state.
BUG=b:248462336
TEST=With a setup where some device is pass-through to the VM and
--force-s2idle flag is used: wait till pass-through device enters
run-time suspend state and trigger "crosvm suspend
/run/vm/vm.<hash>/crosvm.sock" followed by "crosvm resume ..". Also make
sure that full system suspension/resumption doesn't make VM inaccessible
anymore.
Change-Id: Ic23461a78a62d2116cf5674c71d89f4f86ad96c3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3944915
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Grzegorz Jaszczyk <jaszczyk@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
This CL contains a few fixes to needless_return which need approval from
someone familiar with the code. In two cases, the return was removed
from a function that returns a value, so it is considered safe because
if code is added later into the function, it will be clear that this is
removing an implicit return from the function. In the last case
(iommu.rs), the function has several error! macros that do not trigger
an early return, so it seems that it is okay to remove the last early
return.
BUG=b:157245930, chromium:908640
TEST=cargo clippy (no logical code changes)
Change-Id: I00685c9033499a92713eb591eadb5f90c29e761d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4014835
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Clarissa Garvey <clarissagarvey@chromium.org>
Reviewed-by: David Stevens <stevensd@chromium.org>