The KVM docs say
If setting an MSR fails, ..., it stops processing the MSR list and
returns the number of MSRs that have been set successfully.
So, a return value of zero really means the operation completely failed.
Change-Id: Ic98cdb02513ff86e22fb6b048e7ceb2d6b7e554a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4500732
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Allow running riscv unit tests only. This required filtering out some
workspace projects that can't yet build on riscv because the backing
packages aren't installed. Aside from that and passing the new
`--no-default-features` flag to `run_tests`, this is mostly copy/paste
of aarch64 support.
TEST=./tools/run_tests -p riscv64 --no-default-features
TEST=./tools/presubmit unit_tests
Change-Id: If0f74f1bb6eb42e1fe24ad31f4c1aa06f7822f8c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4500729
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Adds the ability to specify no-default-features to run_tests and have it
passed along to cargo. This will be useful when adding riscv as a new
architecture that doesn't yet support the default feature set.
Change-Id: I4692a02f4c47c3c66a03d7f44e3273360fad6be9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4500728
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Add the qemu package needed for running riscv64 unit tests.
qemu-riscv64-static needs this ld-linux-riscv64-lp64d.so.1 in just the
right place and because of how riscv64 cross tools are installed it
doesn't land there automatically. Copy it over.
Similarly to find riscv libraries when running qemu-riscv64-static, the
risv libraries need to live at /usr/lib/'arch' so copy the 35MB of libs
over for riscv. This isn't pretty, but is temporary and my attempts to
set LD_PREFIX variables caused other problems such as breaking virtiofs'
passthrough tests.
TEST=run qemu-riscv64-static from the dev_container
Change-Id: I34ad32877f160f7fb7a3272344f6024ef1630841
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4500727
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Allows building with --no-default-features without warnings.
TEST=cargo build --no-default-features
Change-Id: I660c68f77d01e314751cc08938ffdac2d8492005
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4501093
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
The `merge_commands` test depends on the `config-file` features. Only
build it when `config-file` is enabled. Fixes a build failure when
running tests with `--no-default-features`
TEST=cd src; cargo nextest run --no-default-features
Change-Id: I00222c5aa25b7d030176222ea8dcd0ebca72eb2e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4501092
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Riscv doesn't implement `create_irq_chip` so match the guard here in the
test to the one in `Vm::create_irq_chip`. That includes aarch64 although
it doesn't appear to be used outside of tests except on x86_64.
Change-Id: I7a2705ec896f92861325a40cd02a51b5eac9b801
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4501090
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
These tests require initialization of the syslogger via
`openlog_and_get_socket` which requires no other threads in the
process to prevent conflicting file descriptors.
BUG=b:280331266
TEST=run_tests --dut=host
TEST=cargo test -p base --test syslog
TEST=cargo test -p base --lib
Change-Id: I3d83ecb80770d94914fc23b2d5760c7a54f6380f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4499660
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
This is a refactoring with no functionality change. The common.py
file is split up so we will be able to use the parts that have no
third party dependencies separately.
For now, keep common.py and re-export everything, so we do not
introduce issues in other tools.
BUG=b:267499599
TEST=presubmit
Change-Id: Idf6d45bd90f5cf448fb9dd88df540af3da0f7f88
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4482141
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
These macros are no longer necessary, as we can replace them with const
fn implementations instead.
BUG=None
TEST=tools/dev_container tools/presubmit
Change-Id: If64cfa8fe08f113ead7236d11bb5a8b0fd51c290
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4484512
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Similar to prior work upstream, we've added the ability to flush IRQs to
the guest LAPICs. This helps us snapshot the guest because we are
guaranteed no events are pending inside CrosVM itself.
BUG=b:269653760
TEST=ran crosvm downstream & verified shutdown was clean.
Change-Id: I0fe42d8a963969edb390a8a432b7f39ae39af882
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4439031
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Richard Zhang <rizhang@google.com>
system_api bindings have been regenerated with protobuf 3.2; this should
be okay to land before the full ChromeOS system_api migration, since
crosvm always uses its own copy of the bindings rather than the ones
provided by the dev-rust/system_api package.
The protoc-rust crate is replaced with protobuf_codegen in 3.x.
BUG=b:277243607
BUG=b:279834784
TEST=tools/dev_container tools/presubmit
Change-Id: I6aad45ded2639d7506a7238800584bebab196455
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4405309
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Add simple serialization/deserialization to StubPciDevice through the
traits provided by serde by adding the snapshot() and restore()
implementations to this struct's Suspendable implementation. The
requested_address and assigned_address fields were left out of the
snapshot since they are only configurable during VM creation.
Also add a test case for validation.
BUG=b:266622321
TEST=cargo build && ./tools/run_tests
Change-Id: I8d640452ee7db7263f1ecb185041dabb50ac46fc
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4451466
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Elie Kheirallah <khei@google.com>
Commit-Queue: Jesus Sanchez-Palencia <jesussanp@google.com>
MSRs are specific to x86/x86-64; add the appropriate cfg checks and
remove the MsrHandlers stubs from aarch64 and riscv64.
Change-Id: I94f0b5b4b9f75fecdc8e03c569f89a70b7f9f647
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4482135
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Some type parameters in <> were being mis-parsed as HTML tags.
BUG=b:276487055
TEST=tools/cargo-doc # with rust 1.68.2
Change-Id: Iaa9ec6cf94a6084cfdf323bb04c643396a320889
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4485758
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Always enable interactive mode when a tty is present. This allows
commands to receive SIGINT.
Otherwise, still allocate a pseudo tty to enable proper console
output.
BUG=b:275613273
TEST=dev_container presubmit - then CTRL-C
Change-Id: I7fb5c6897404f7d3e9f70755c237da0fd8b82c41
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4475490
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
The import of hypervisor::CpuConfigX86_64 was removed, but the
non-default whpx feature still needs it.
BUG=b:277957421
TEST=cargo build --target=x86_64-pc-windows-gnu --features=whpx
Fixes: 1aff211998 ("arch: use cfg_if to clean up hypervisor *Arch types")
Change-Id: I300b6c8c6dee36f75109a6adca9840a9f4da3ab2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4481153
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
Add cast to support Android. Libc Android has different types for some
variables than Libc Linux. This leads to casts required. Added skips on
clippy for these casts as they would be redundant on a platform while
required on another.
The same change is also applied to fuse:.
BUG=N/A
Test=presubmit
Change-Id: I994af922cf3ccc56438f2642fef9af91f6af5118
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4485518
Commit-Queue: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
To prevent accidentally ACPI FACP overwriting similar to one described
in the b:279563028 add unit test which will catch such bugs in the
future.
BUG=b:279563028
TEST=tools/run_tests
Change-Id: Ie1dac4460b1ce7c9186835dbbbaa3f6001fabaa1
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4482091
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Grzegorz Jaszczyk <jaszczyk@google.com>
According to ACPI specification the RTC's DAY_ALRM, MON_ALRM and CENTURY
are all 8-bits values. Fix the related register sizes in order to
prevent other ACPI FADT fields overwriting happen e.g. in
x86_64/src/acpi.rs:
facp.write(FADT_FIELD_RTC_CENTURY, devices::cmos::RTC_REG_CENTURY);
While introducing this change, convert other RTC_REG* consts to u8.
This commit fixes CL:4364558 which accidentally causes some other ACPI FADT
overwriting e.g. FADT FLAGS which introduced regression in borealis project.
BUG=b:279563028
TEST=Run borealis VM and make sure that rendering issues after
suspend/resume cycle are gone.
Change-Id: I159ba16616f0eb08b5fc562e88d2887836815c44
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4477066
Commit-Queue: Grzegorz Jaszczyk <jaszczyk@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This lets us use the common arg parsing infrastructure, and it should
work on Windows (as opposed to the previous bash script).
BUG=b:267672683
TEST=tools/cargo-doc
TEST=tools/cargo-doc --target-dir=/tmp/crosvm-doc
Change-Id: Ib56f4d28965d32ea01a9aa55d7840edfb71f3d59
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4483471
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Both single and multi process did not have realtime priority, due to us
dropping the multimedia trick handle in set_audio_thread_priority where
we should be holding it until the thread is finished.
BUG=b:276698085
TEST=Process explorer -> properties -> threads -> base priority
increases from 8 to 24
Change-Id: Ia9199f4816e087046b8718e85c60abc9479ec0f3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4416757
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Idan Raiter <idanr@google.com>
This is a new major version, and requires some code changes.
Change-Id: I294ce3604aad6e6dc5f50e33246b690e883c1e36
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4481294
Auto-Submit: Andrew Walbran <qwandor@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
This was implicitly tested before, but seems worth an explicit test.
Change-Id: I0d31051a8422d61f91938fc5975f230346bbce65
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4478450
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Also use the arch definitions in the main crosvm crate to avoid
duplicating the cfg checks.
BUG=None
TEST=tools/dev_container tools/presubmit
Change-Id: Ia92b2840b0f6c8f0daa25f4b2b185ef7ef372860
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4477764
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Summary: DescriptorChain now reads the full chain when it is created.
Previously, DescriptorChain worked more like an iterator, returning one
descriptor at a time. This meant that DescriptorChain::checked_new()
returning Ok(...) did not guarantee the whole chain was valid, so
callers - in particular, Reader::new() and Writer::new() - had to be
fallible so they could report errors.
With the new API, DescriptorChain::new() reads the whole chain of
descriptors before returning, validating the required properties that
were previously deferred to Reader/Writer creation errors. This means
that Reader::new() and Writer::new() can now be infallible, which
eliminates error cases all over virtio device code.
Since the Reader::new() and Writer::new() function signatures are
changing anyway, take the opportunity to remove the redundant
GuestMemory parameter to those functions; DescriptorChain already holds
a reference to the GuestMemory.
The internal structure of DescriptorChain has been modified in
preparation for supporting packed virtqueues (in addition to the current
split virtqueues). The queue-type-specific code has been factored into a
separate trait implementation (DescriptorChainIter) so it is separate
from the high-level descriptor chain validation logic and IOMMU
translation.
BUG=None
TEST=tools/dev_container tools/presubmit
Change-Id: I48fd44b7f3e8b509dcb3683864a3f9621c744c4c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4391797
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Maciek Swiech <drmasquatch@google.com>
The presbumit tool takes care of truncating results in a readable
way. And we can see full output when things fail, and in CI logs.
BUG=b:279641456
TEST=presubmit --no-delta
Change-Id: I347dc938fd07f265d4adb641e2f2818cd37e7db2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4481511
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
This seems to only generate bindings for ImmDisableIME(), which is
unused in upstream crosvm and also seems to be available without running
a build step now.
BUG=b:277957421
TEST=tools/dev_container tools/presubmit
Change-Id: Ic5a996eb9d8c7d7c65e2138fe92e8ea335cac76f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4477411
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Because bullseye's cross packages for riscv64 are broken, libcap needs to
be manually built and installed, and pkg-config needs a hacky define to
allow minijail to find it. Other than that, it's very similar to the
other architectures.
Change-Id: I903f7ccd2ccbd94168ba09b425fd649458fdee70
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4460942
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Allows running crosvm on riscv64 devices.
Tested on a qemu host with `-machine virt,aia=aplic-imsic,aia-guests=4`
Change-Id: I9b369718bcb438f043e3342f1866c56fc4983304
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4460941
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Instead of unconditionally depending on these dependencies only include
them for riscv64 builds. This will fix a build breakage on the windows
builders.
Thanks to denniskempin and dverkamp for suggesting this fix.
Change-Id: I035dc23cd0b58f63a3bcb3b8f883aba97d56492d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4477776
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Match version available in Debian.
BUG=b:265082456
TEST=build
Change-Id: I8fc3b65fb8bb6cc3f7e512921d96c8cbbc4291b5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4364561
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>