When we detect a VCPU stall we propagate the watchdog reboot error code
to the event tube. The newly added error code WATCHDOG_REBOOT = 36 is
returned from the crovm process.
Bug: 245900797
Test: manual testing, build and Virtualization apk on a device
Signed-off-by: Sebastian Ene <sebastianene@google.com>
Change-Id: Ib1ce97de911784b33d130d40536be26813edc3d7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3936647
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
The path does not belong to crosvm and should not, for example, be
revealed to UnlinkUnixSeqpacketListener which would try to remove it.
TEST=cargo test, added a new unit test
BUG=b:251742702
Change-Id: I6e81623b76d62961c774010e1dafcf73ffca6471
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3941684
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Keir Fraser <keirf@google.com>
The platform event types are now private, and their methods are exposed
through the base Event type, so remove that comment that triggers a
warning with `cargo doc`.
TEST=`cargo doc` does not warn about this line.
Change-Id: I4577a194582dddaa2536541247807fc4cd1eea06
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3932438
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
This isn't necessary, but it does aid readbility in my opinion.
BUG=b:231344063
TEST=cargo build && ./tools/dev_container ./tools/run_tests --target=host --build-target=mingw64 --build-only
Change-Id: Id486d66773a15f1a544f717aab508d5006be3553
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3864026
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
The existing file descriptor must refer to a listening socket.
TEST=cargo test, added a new unit test
BUG=b:238931628
Change-Id: Ia6bd5d6d30af69fb4b5fa00865f5528f19f569d9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3932714
Commit-Queue: Keir Fraser <keirf@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Make it official that setting a Timer's interval to 0 is the same as
setting it to None, meaning it will not be periodic. Fixed the windows
timer to behave this way again, and updated Timer docstring.
Also updated APIC timer to use None for interval which is clearer.
Bug: b:248612697
Test: tested with UserspaceIrqChip in dynamic tick mode
Change-Id: I57713c3ace345a8c64b9219a8e60f36c54a9481c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3925006
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Colin Downs-Razouk <colindr@google.com>
An existing file descriptor is specified by a path of the form
/proc/self/fd/<fd>. In this case crosvm will use this existing
listener socket directly, rather than trying to create a fresh one at
the specified path location.
This is useful for sandboxing crosvm in an environment in which it is
unable to create new filesystem entries.
BUG=b:238931628
TEST=Tested downstream
Change-Id: Ic6b24196bbe01960aedfe3f00ec69fd799e6ba91
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3928022
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Keir Fraser <keirf@google.com>
Windows' SetWaitableTimer function takes a period argument that is in
milliseconds. If it's set to 0 then the timer will not be periodic. If
the reset function is called with a period that is <1ms but not None, we
should set the period to 1ms which is the best we can do.
Bug: b:248612697
Test: ran kernel with HZ=1000 on Windows, verified PIT works
Change-Id: Ie908205a455c818bad5b246da54b504eb9ce7b27
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3926198
Commit-Queue: Colin Downs-Razouk <colindr@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
This feature is only available on ChromeOS and should live in
the downstream ChromeOS repository.
Note: This change should be reverted with the next ChromeOS merge.
BUG=b:244618505
TEST=None
Change-Id: I33d4e6c5feb4178ebf7cd946ea654dbd20291653
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3907532
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Virglrenderer must not unmap from any thread other than the virtio-gpu
thread because virglrenderer is not thread-safe and EGL requires that
only one thread own a context concurrently.
For the VirglRenderer RutabagaComponent, we can unmap directly from the
virtio-gpu thread. In fact, we can greatly simplify the use of
ExternalMapping if we eliminate the associated map/unmap callbacks for
all RutabagaComponents.
Now VirtioGpu is responsible for ensuring that the map/unmap occurs and
is registered/unregistered. Also, the shared `map_request:
Arc<Mutex<ExternalMapping>>` spanning the KVM and virtio-gpu threads is
no longer necessary.
BUG=b:244626679
TEST=OpenGL and Vulkan gameplay with sandboxing disabled
TEST=OpenGL and Vulkan gameplay on ChromeOS with sandboxing
Change-Id: I4acaf4aabff3891536ca0439221cfbd021dba123
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3888602
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Ryan Neph <ryanneph@google.com>
This search/replace updates all copyright notices to drop the
"All rights reserved", Use "ChromiumOS" instead of "Chromium OS"
and drops the trailing dots.
This fulfills the request from legal and unifies our notices.
./tools/health-check has been updated to only accept this style.
BUG=b:246579983
TEST=./tools/health-check
Change-Id: I87a80701dc651f1baf4820e5cc42469d7c5f5bf7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3894243
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Remove the _bytes_read variable, since it is not needed. It was also
misnamed since we are writing, not reading, data.
Fixes a Rust 1.62 clippy lint:
error: this let-binding has unit value
BUG=b:243677117
TEST=tools/clippy # with Rust 1.62
Change-Id: I53f7b675f8e95c94ab127e500127a9153166a906
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3854968
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Behavior should be exactly the same.
- Use `CpuSet::new()` directly instead of duplicating its code
- Use the `syscall!()` macro for error handling
TEST=./tools/presubmit
BUG=None
Change-Id: I371e9a113914db7ffdecbf4bf8770be157368569
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3858174
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Auto-Submit: Christian Blichmann <cblichmann@google.com>
Reviewed-by: Christian Blichmann <cblichmann@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
If we can't create a PlatformSyslog instance (for example, if /dev/log
is not available on a minimal Linux system without a traditional init),
warn the user and continue executing instead of failing.
BUG=b:242103548
TEST=Run crosvm inside minimal VM with no init
Change-Id: I4d81da396125331ef7ad335e57b37645b6546980
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3842814
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Abhishek Bhardwaj <abhishekbh@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Ensure that openlog_and_get_socket() is only called once by storing its
result in a OnceCell. This fixes logging initialization when the syslog
State structure was constructed more than once, causing the log fd to be
invalidated and breaking sandboxed startup.
BUG=b:242103548
TEST=Start crosvm on Linux with sandbox enabled (default mode)
Change-Id: I663a7e918b81f4c23415a28cfcc2c72f6b4a51d8
Fixes: 7dbdc73063 ("base & src: allow multiple log inits.")
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3842813
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
With the migration to env_logger, we lost the ability to initialize
logging multiple times. This meant that we had to wait until we had
parsed CLI args and knew exactly what we wanted our logging spec to be,
which meant that it would sometimes be too late to log startup errors.
This CL modifies the logging facade to be modifiable on the fly, albeit
with some restrictions, to obviate the problem.
The syslog API has been modified as follows:
syslog::early_init: initializes stderr logging, can be called only once
per process. Called as the first function in main.
syslog::init/init_with: can be called after early_init to modify the
parameters used by the logging system. Can be called only once per
process. Will be called roughly after argument parsing or bootstrapping
is complete.
The fundamental change to enable this was in the logging facade. Now,
the facade passes all logging operations to a static, mutex protected
struct. This way, the facade never changes, but we can modify the
struct whenever we wish.
BUG=b:242103548
TEST=tested downstream
Change-Id: I76bc1bb275c81a69aadc7f03a80b94c297f47781
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3834294
Commit-Queue: Noah Gold <nkgold@google.com>
Tested-by: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Crashes of rust executables have a generic signature since the user
crash collector is not able to compute a reasonable signature for them.
This custom panic hook allows passing a signature derived from PanicInfo
to the crash collector.
BUG=b:234093439
TEST=See crrev.com/c/3834930 and crrev.com/c/3836804
Change-Id: Ida7f655d3a2463e8a42602d8e32588195a0ce36b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3842808
Commit-Queue: Paramjit Oberoi <psoberoi@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Paramjit Oberoi <psoberoi@google.com>
This CL migrates Tube from directly using a UnixSeqpacket to instead use
a StreamChannel backed by UnixSeqpackets. This CL also migrates users of
the old Tube::new(UnixSeqpacket) function to its renamed counterpart.
Tests are added for new functionality.
This CL enforces that the StreamChannel used by the Tube is backed by a
UnixSeqpacket because the reading and writing behavior of a UnixStream
is different, and it cannot guarantee the same multi-process
concurrent-writers behavior that a UnixSeqpacket can. This is because
the UnixStream does not send data as packets and the size cannot be
queried, so two underlyig writes are required for each Tube write: one
to send a header indicating message size, and one for the actual content
of the sent data. These can be interleaved during concurrent writes,
causing corruption of the Tube's data.
This CL makes the Windows and Unix API closer to each other, with some
differences remaining or added, including Tube::new_from_unix_seqpacket
existing in Unix but necessarily not Windows.
This migration (Tube from UnixSeqpacket to Stream) is intended to move
the Unix Tube API closer to the Windows API, with the eventual goal of
creating a platform-agnostic API for Tube.
Bug: b:231641496
Change-Id: I2422e76b7efa5a20bc40a8d194f5f8390dc71438
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3818253
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: Clarissa Garvey <clarissagarvey@chromium.org>
Commit-Queue: Clarissa Garvey <clarissagarvey@chromium.org>
This CL is one of two CLs in a series that migrate the Unix Tube from
using UnixSeqpackets directly to instead use StreamChannels backed by
UnixSeqpackets. This CL adds some pass-through functions to
StreamChannel that are needed by Tube in the follow-up CL, as well as
a new function to create a StreamChannel directly from a UnixSeqpacket.
Additionally, a test is added for the new constructor-like function.
This migration (Tube from UnixSeqpacket to Stream) is intended to move
the Unix Tube API closer to the Windows API, with the eventual goal of
creating a platform-agnostic API for Tube.
Bug: b:231641496
Change-Id: I8d7da6a0e64d38d8f9833ae8e62ec7a2c4cfda5c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3818249
Tested-by: Clarissa Garvey <clarissagarvey@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
The test isn't unix specific anymore, so we ought to move it to
base/src/syslog.rs, however, when moved, it fails with an "Illegal Seek"
error when run in the presubmit (but not in `cargo test`). The cause is
unclear.
BUG=b:228881485
TEST=./tools/dev_container ./tools/presubmit
Change-Id: I76e6595007a3b59f6bbd5a4afae42f911686f3e3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3817974
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Frederick Mayle <fmayle@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
This CL adds tests for Unix Tube: a test for the platform-specific
Tube::new function, and a serialization/deserialization test that
existed previously in Windows and now is shared between platforms.
Bug: b:231641496
Change-Id: Iabbc15f847b995affd0bfd5b304fd70d34b171b5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3794509
Tested-by: Clarissa Garvey <clarissagarvey@chromium.org>
Commit-Queue: Clarissa Garvey <clarissagarvey@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
This introduces slirp support. On windows, net is enabled only if slirp
is enabled.
BUG=b:213149155
TEST=presubmit
Change-Id: I77f0121ab4545350345c4f42f67b51186279c44c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3787269
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
We already depend on chrono elsewhere, so we might as well use it rather
than rolling our own unsafe wrapper around gmtime_r.
BUG=None
TEST=tools/presubmit --all
Change-Id: I46e4a75ca74f8a02875814f6cb21031db58e1e3a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3795009
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
bionic (the android libc) doesn't have shm_open or shm_unlink.
TEST=presubmit
BUG=b:228881485
Change-Id: Ic0df86387a1110835b1e53a68d249fa3d55803ab
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3803896
Reviewed-by: Devin Moore <devinmoore@google.com>
Auto-Submit: Frederick Mayle <fmayle@google.com>
Tested-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
- Remove trailing ::{self} on all use statements
- Remove any resulting single-level use statements (e.g. use libc;)
- Reformat with `tools/fmt --nightly`
BUG=b:239937122
TEST=tools/dev_container tools/presubmit --all
Change-Id: I8afd1b0458ca6d08d9b41a24583f7d4148597ccb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3798973
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Prior to this CL, the StreamChannel in base/src/sys/unix had no tests
for FramingMode::Message. This CL adds a test for that framing mode.
Bug: b:231641496
Change-Id: I75e13709d558258eca838c3190aaf0237e39513b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3793688
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Clarissa Garvey <clarissagarvey@chromium.org>
Tested-by: Clarissa Garvey <clarissagarvey@chromium.org>
By default, KSM is disabled by the kernel. This is harmless if KSM
is disabled, and only causes merging if the user manually enabled
the feature on their kernel. If enabled, significant memory saving
can occur, at the cost of CPU cycles and a reduction in privacy.
Bug: 1346340
Change-Id: I838cdda97ea8d335b1953dd6775311958069898c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3780870
Reviewed-by: David Manouchehri <david@davidmanouchehri.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Closing one of the deltas in base crate.
BUG=b:213146388
TEST=presubmit
Change-Id: Ibac36d1ad9b1b6387ec74e8b59ccb38319903655
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3793691
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
crosvm is switching the import style to use one import per line.
While more verbose, this will greatly reduce the occurence of merge
conflicts going forward.
Note: This is using a nightly feature of rustfmt. So it's a one-off
re-format only. We are considering adding a nightly toolchain to
enable the feature permanently.
BUG=b:239937122
TEST=CQ
Change-Id: Id2dd4dbdc0adfc4f8f3dd1d09da1daafa2a39992
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3784345
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
The crosvm run --syslog-tag argument was accepted, but it did not do
anything after the argh refactor. Tweak the LogConfig setup so the
default tag is "crosvm" and can be overriden by the --syslog-tag option.
BUG=None
TEST=crosvm run --syslog-tag="TESTVM" ... # observe tag in syslog
Change-Id: I7cd83b0623ac725c59a1dc1fcc4f8952e749e00a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3764041
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
We recently started to map VVU device registers into the process address
space, but accessed them like regular memory. This is dangerous as the
compiler can reorder and optimize these accesses.
Add new `write_obj_volatile` and `read_obj_volatile` ops to
`MemoryMapping` that are designed to perform such I/O accesses and use
them where appropriate.
BUG=b:238282334
BUG=b:237647217
TEST=VVU console device can be created from Linux.
Change-Id: I40f30acfd358248d4f9d0c00d5cd708eabae047d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3762971
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Move MemoryMapping's implementations of write/read_slice, write/read_obj
and get_slice as well as the definition of the MappedRegion from the
platform module into the base mmap module, since these definitions were
strictly identical between Windows and Linux. This removes quite a bit
of duplicated code.
In the process, some tests need to be adapted in order to work with the
common MemoryMapping type instead of the platform one, as the above
mentioned methods become unavailable on the platform type.
BUG=b:213153157
TEST=./tools/dev_container ./tools/run_tests --target=host
TEST=./tools/dev_container ./tools/run_tests --target=host --build-target=mingw64
TEST=cargo test -p base --doc
Change-Id: I20e6f47c3c4763b63eae707a527a084b229cd951
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3762970
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Windows and Unix now use identical code for their Protection
implementation, the only difference being the value of their PROT_*
constants. Make the contants part of the platform and use these from the
common mmap module to avoid duplicated code.
BUG=None
TEST=./tools/dev_container ./tools/run_tests --target=host
TEST=./tools/dev_container ./tools/run_tests --target=host --build-target=mingw64
Change-Id: I95f2769e868f32ae70de8159ac4fbb481c4ef467
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3762969
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
This state is invalid for Windows, and we can easily avoid using it
altogether.
BUG=None
TEST=./tools/dev_container ./tools/run_tests
TEST=./tools/dev_container ./tools/run_tests --target=host --build-target=mingw64
Change-Id: Id5aba0498f9c19df0d95e86aea04fbe8a4023707
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3762968
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
The Windows and Unix Protection struct are extremely close, with the
only difference being how they internally represent their state. Make
the Windows implementation adopt the same storage type as the Unix one
so we can merge them.
BUG=None
TEST=./tools/dev_container ./tools/run_tests --target=host --build-target=mingw64
Change-Id: Idb47243e7d2003d7eb499e683993dba2419e8841
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3762967
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
If a core is offline, we will not be able to set the cpu affinity to
that core. The TSC calibration code attempts to determine the TSC offset
of all cores. Determining which cores are online requires parsing the
contents of /sys/devices/system/cpu/online on linux, and it's not clear
how to do it on Windows. Instead, the calibration code will treat errors
when calling set_cpu_affinity as legitimate reasons for a core to be
offline, and will exclude that core from the offset information in the
TscState. This will prevent the TSC sync mitigation logic from setting
any vpu's affinity to that core.
This also changes how number_of_logical_cores is implemented on linux,
to count the number of configured cores instead of the number of online
cores, which seems more correct.
BUG=b:230372694
TEST=added a new unittest, also ran unittests with an offline core
Change-Id: I12c187a7ca1dd06e25b396eaeae542628fdf563c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3764280
Tested-by: Colin Downs-Razouk <colindr@google.com>
Commit-Queue: Colin Downs-Razouk <colindr@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
We've had multiple silent bugs stemming from the current double-init
behavior of the logging system. To prevent that from happening for the
fourth time, this CL makes all subsequent logging inits panic. This way,
it will be much harder to commit code that won't work. Details:
* Current behavior: only the first init applies logging configuration.
The subsequent inits will silently do nothing, and discard the
supplied settings. These settings could be important things like
setting the log file, whether to echo to stderr, etc.
* New behavior: after the first call to init, any subseqent call will
panic.
NOTE: If this CL breaks a downstream project, there is very likely
a bug in that project which may be causing logs from crosvm to be
lost. Please fix that bug, or revert this CL in the downstream project
temporarily.
In this CL, we discovered that openlog_and_get_socket (used in linux
syslog) mutates global state. In tests, this manifested as a failure.
For this CL, we've chosen to preserve the behavior of only re-creating
State (and by extension, PlatformSyslog) when there is no STATE
currently set. (This behavior is nice for other reasons since it keeps
us from performing unnecessary operations when a no-op is possible.)
BUG=b:238680255
TEST=presubmit & tested downstream by verifying log files were written.
Also ran example_simple & verified it didn't panic.
Change-Id: Iad64c1b52b917e63d14a42cbbd1739ef94107fae
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3756274
Commit-Queue: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Change http://crrev.com/c/3737406 removed the custom permission enum for
IOMMU, but did not update the related Windows code. This results in a
build error that was not caught because the Windows builder was
temporarily deactivated.
BUG=b:237620529
TEST=./tools/dev_container ./tools/run_tests --target=host --build-target=mingw64
Change-Id: Id57eb0d0836fe0c61ff578752d5c5eb8941f37b0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3758169
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: David Stevens <stevensd@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Clock now has a single now() function that returns a std::time::Instant
rather than wrapping an Instant itself.
FakeClock provides the same now() API, except the Instant it reports is
only advanced when test code calls add_ns(). FakeClock continues to
provide the add_event() and add_ns() APIs used by tests.
The only functional difference is that the epoch used by FakeClock is
now whatever moment in (real) time it is created, rather than a fixed
timestamp, but this should not change the results of the tests. The only
way to observe the contents of an Instant is by comparing it to other
Instants, which should all be derived from the Clock/FakeClock now()
API.
BUG=None
TEST=cargo test -p base -- --test-threads=1
TEST=cargo test -p devices
Change-Id: I9a0ed8d252f213d85dba3dfbbcd1182e2db981f0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3736922
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
The previous configuration made us pull in three different versions of
rand, and depending on "*" is a recipe for API incompatibility.
crosvm-fuzz needs to match its rand version to the rand_core used in
common/cros_fuzz, so that will be upgraded separately.
BUG=b:236978141
TEST=cargo build
TEST=emerge-hatch crosvm
Change-Id: I655ed3f156e4ac43afa3122596f62e9caa43b4f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3722184
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
The original Pit code encoded the start value of a timer into the
count_load_time field as a number of nanoseconds since the start of
the host's monotonic time value. Instead, we can use the PitCounter's
creation_time as the epoch. This makes the math look a bit more sensible
and removes the use of the non-portable clock_gettime() function.
Before
======
get_channel_state():
count_load_time = get_monotonic_time() - start.elapsed()
=== count_load_time = now() - (now() - start)
=== count_load_time = start
set_channel_state():
start = now() - (get_monotonic_time() - count_load_time)
=== start = now() - now() + count_load_time
=== start = count_load_time
After
=====
get_channel_state():
count_load_time = start - creation_time
set_channel_state():
start = creation_time + count_load_time
BUG=chromium:908689
BUG=b:213149155
TEST=cargo test -p devices pit
TEST=tools/run_tests --target=host --arch=win64
Change-Id: I5468d1d964a04b1ce96979ed583b729d139e1005
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3723804
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>