summary refs log tree commit diff
path: root/x86_64
Commit message (Collapse)AuthorAge
...
* edition: Eliminate blocks superseded by NLLDavid Tolnay2019-04-17
| | | | | | | | | | | | | | | | | | | | Before the new borrow checker in the 2018 edition, we sometimes used to have to manually insert curly braced blocks to limit the scope of borrows. These are no longer needed. Details in: https://doc.rust-lang.org/edition-guide/rust-2018/ownership-and-lifetimes/non-lexical-lifetimes.html TEST=cargo check --all-features TEST=local kokoro Change-Id: I59f9f98dcc03c8790c53e080a527ad9b68c8d6f3 Reviewed-on: https://chromium-review.googlesource.com/1568075 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* clippy: Switch to tool attributes for suppressing lintsDavid Tolnay2019-04-15
| | | | | | | | | | | | | | | | | | | | | | | Tool attributes were stabilized in Rust 1.31: https://blog.rust-lang.org/2018/12/06/Rust-1.31-and-rust-2018.html#tool-lints Before: #[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment)] After: #[allow(clippy::cast_ptr_alignment)] TEST=cargo check --all-features Change-Id: If2f1511f6231d60578b5e0d5bd4210a68eb08caf Reviewed-on: https://chromium-review.googlesource.com/1566651 Commit-Ready: David Tolnay <dtolnay@chromium.org> Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>
* edition: Remove extern crate linesDavid Tolnay2019-04-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Rust 2018 edition, `extern crate` is no longer required for importing from other crates. Instead of writing: extern crate dep; use dep::Thing; we write: use dep::Thing; In this approach, macros are imported individually from the declaring crate rather than through #[macro_use]. Before: #[macro_use] extern crate sys_util; After: use sys_util::{debug, error}; The only place that `extern crate` continues to be required is in importing the compiler's proc_macro API into a procedural macro crate. This will hopefully be fixed in a future Rust release. extern crate proc_macro; TEST=cargo check TEST=cargo check --all-features TEST=cargo check --target aarch64-unknown-linux-gnu TEST=local kokoro Change-Id: I0b43768c0d81f2a250b1959fb97ba35cbac56293 Reviewed-on: https://chromium-review.googlesource.com/1565302 Commit-Ready: David Tolnay <dtolnay@chromium.org> Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>
* lints: Enforce sorted order for enum variantsDavid Tolnay2019-04-13
| | | | | | | | | | | | | | | | | | | | | | | | | To avoid wasting time re-sorting these things (CL:1492612). https://docs.rs/remain Disclaimer: I wrote the macro. This CL adds #[sorted] attributes to those Error enums that seemed to have made some effort to be in sorted order. TEST=cargo check TEST=cargo check --all-features TEST=cargo check --target aarch64-unknown-linux-gnu TEST=emerge-nami crosvm TEST=local kokoro CQ-DEPEND=CL:1524247 Change-Id: I89685ced05e2f149fa189ca509bc14c70aebb531 Reviewed-on: https://chromium-review.googlesource.com/1515998 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>
* main: add --cpu-affinity option to pin VCPUsDaniel Verkamp2019-04-09
| | | | | | | | | | | | | | | | | | This allows setting the affinity of the VCPU threads to specific host CPUs. Note that each individual CPU has its affinity set to the full set of CPUs specified, so the host kernel may still reschedule VCPU threads on whichever host CPUs it sees fit (within the specified set). BUG=chromium:909793 TEST=build_test Change-Id: I09b893901caf91368b64f5329a6e9f39027fef23 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1554865 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* cargo: Sort all dependency lists in Cargo.tomlDavid Tolnay2019-04-09
| | | | | | | | | | | | | | | This may help reduce cases of conflicts between independent CLs each appending a dependency at the bottom of the list, of which I hit two today rebasing some of my open CLs. TEST=cargo check --all-features Change-Id: Ief10bb004cc7b44b107dc3841ce36c6b23632aed Reviewed-on: https://chromium-review.googlesource.com/1557172 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* edition: Use dyn syntax for trait objectsDavid Tolnay2019-04-08
| | | | | | | | | | | | | | | | | | | | | Found by running: `cargo rustc -- -D bare_trait_objects` Bare trait objects like `&Trait` and `Box<Trait>` are soft-deprecated in 2018 edition and will start warning at some point. As part of this, I replaced `Box<Trait + 'static>` with `Box<dyn Trait>` because the 'static bound is implied for boxed trait objects. TEST=cargo check --all-features TEST=cargo check --target aarch64-unknown-linux-gnu TEST=local kokoro Change-Id: I41c4f13530bece8a34a8ed1c1afd7035b8f86f19 Reviewed-on: https://chromium-review.googlesource.com/1513059 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>
* edition: Update x86_64 crate to 2018 editionDavid Tolnay2019-04-07
| | | | | | | | | | | | | | | | | | Separated out of CL:1513058 to make it possible to land parts individually while the affected crate has no other significant CLs pending. This avoids repeatedly introducing non-textual conflicts with new code that adds `use` statements. TEST=cargo check TEST=cargo check --all-features TEST=cargo check --target aarch64-unknown-linux-gnu Change-Id: Iec5cc762f38f18196a6147473ac093f474b00794 Reviewed-on: https://chromium-review.googlesource.com/1520075 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>
* crosvm: add memfd for GuestMemoryDaniel Prilik2019-03-25
| | | | | | | | | | | | | | | | | Building off CL:1290293 Instead of having a seperate GuestMemoryManager, this adds SharedMemory as a Arc'd member of GuestMemory. This is nice since it removes the need to plumb the Manager struct throughout the codebase. BUG=chromium:936567 TEST=cargo test -p sys_util Change-Id: I6fa5d73f7e0db495c2803a040479818445660345 Reviewed-on: https://chromium-review.googlesource.com/1493013 Commit-Ready: Daniel Prilik <prilik@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* Move split_irqchip_common to devices/.Miriam Zimmerman2019-03-20
| | | | | | | | | | | | | | | Previously, code in devices/ couldn't use split_irqchip_common, since x86_64/ already has a dependency on devices/. TEST=Built. BUG=chromium:908689 Change-Id: I481514ae6bbd68e47feecc6f364ca8f4fd798e67 Reviewed-on: https://chromium-review.googlesource.com/1526762 Commit-Ready: Miriam Zimmerman <mutexlox@chromium.org> Tested-by: Miriam Zimmerman <mutexlox@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>
* bitfield: Support BitFieldSpecifier for enumsDavid Tolnay2019-03-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, the getter and setter functions generated for a bitfield struct by #[bitfield] all operated on primitive types like bool, u8, u16 etc. This CL adds support for getters and setters defined in terms of user-defined enums. We make an enum bitfield-compatible by adding #[bitfield]. The number of variants must be a power of 2. #[bitfield] enum TwoBits { Zero = 0b00, One = 0b01, Two = 0b10, Three = 0b11, } And then it may be used to specify a field in a bitfield struct. #[bitfield] struct Struct { prefix: BitField1, two_bits: TwoBits, suffix: BitField5, } The generated getters and setters for this struct would have the following signatures: impl Struct { fn get_prefix(&self) -> u8; fn set_prefix(&mut self, val: u8); fn get_two_bits(&self) -> TwoBits; fn set_two_bits(&mut self, val: TwoBits); fn get_suffix(&self) -> u8; fn set_suffix(&mut self, val: u8); } TEST=`cargo test` the bit_field and bit_field_derive crates TEST=`cargo check` crosvm Change-Id: Ibc8923e2877fda6ae8da5767731edcb68721a434 Reviewed-on: https://chromium-review.googlesource.com/1519686 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>
* edition: Update absolute paths to 2018 styleDavid Tolnay2019-03-13
| | | | | | | | | | | | | | | | | | | | | | | | | | This is an easy step toward adopting 2018 edition eventually, and will make any future CL that sets `edition = "2018"` this much smaller. The module system changes in Rust 2018 are described here: https://doc.rust-lang.org/edition-guide/rust-2018/module-system/path-clarity.html Generated by running: cargo fix --edition --all in each workspace, followed by bin/fmt. TEST=cargo check TEST=cargo check --all-features TEST=cargo check --target aarch64-unknown-linux-gnu Change-Id: I000ab5e69d69aa222c272fae899464bbaf65f6d8 Reviewed-on: https://chromium-review.googlesource.com/1513054 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>
* Add common types and constants for split IRQ chip.Miriam Zimmerman2019-03-13
| | | | | | | | | | | | | | | These will come in handy for reducing code duplication and simplifying PIC/IOAPIC/PIT/interrupt routing code. TEST=Built BUG=chromium:908689 Change-Id: I696e9f51231a8e39640f1fd0af055b48048bc134 Reviewed-on: https://chromium-review.googlesource.com/1518557 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Miriam Zimmerman <mutexlox@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>
* arch: Replace Box<dyn Error> with error enumDavid Tolnay2019-03-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Avoiding Box<dyn Error> makes it less likely that we display errors with insufficient context by accident. Many of the errors touched in this CL already had helpful message written! But those corresponding enum variants were never being instantiated, and that bug was masked by Box<dyn Error>. For example see the Error::LoadCmdline and Error::LoadKernel. pub enum Error { LoadCmdline(kernel_loader::Error), ... } Before this CL: // Bug: boxes the underlying error without adding LoadCmdline kernel_loader::load_cmdline(...)?; After this CL: kernel_loader::load_cmdline(...).map_err(Error::LoadCmdline)?; TEST=cargo check TEST=cargo check --all-features TEST=cargo check --target aarch64-unknown-linux-gnu Change-Id: I7c0cff843c2211565226b9dfb4142ad6b7fa15ac Reviewed-on: https://chromium-review.googlesource.com/1502112 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* linux: use panic=-1 to reboot immediately on panicDaniel Verkamp2019-03-05
| | | | | | | | | | | | | | | | | | | | This changes the default Linux kernel command line from panic=1 (reboot one second after panic) to panic=-1 (reboot immediately on panic). The kernel should not normally panic; this is just to improve quality of life for developer workflows, such as running bash as init and exiting the shell to shut down the VM. BUG=None TEST=crosvm run -r vm_rootfs.img -p init=/bin/bash vm_kernel; exit shell Change-Id: I7c9084ccf1786cd4455fd748512078e02fdb17fa Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1500872 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* error: Consistently use Display instead of error description()David Tolnay2019-03-02
| | | | | | | | | | | | | | | | The description method is deprecated and its signature forces less helpful error messages than what Display can provide. BUG=none TEST=cargo check --all-features TEST=cargo check --target aarch64-unknown-linux-gnu Change-Id: I27fc99d59d0ef457c5273dc53e4c563ef439c2c0 Reviewed-on: https://chromium-review.googlesource.com/1497735 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* linux: rename function of device creationJianxun Zhang2019-03-01
| | | | | | | | | | | | | | | | | Rename functions and parameters that had 'virtio' in their names because we also create non-virtio devices like audio. BUG=none TEST=emerge-eve crosvm and deploy it to the device, verify some of devices are still created at /sys/bus/virtio/devices/ Change-Id: I3ea75159a865e5f00ecef349725b3c12f94afaca Signed-off-by: Jianxun Zhang <jianxun.zhang@intel.com> Reviewed-on: https://chromium-review.googlesource.com/1480739 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* linux: add support for loading an initrdDaniel Verkamp2019-02-07
| | | | | | | | | | | | | | Based on Linux boot protocol references: - x86: Documentation/x86/boot.txt - arm: Documentation/devicetree/bindings/chosen.txt BUG=None TEST=Boot Alpine Linux netboot initrd on x86_64 and aarch64 Change-Id: If4730765638f0a0b8bb8f63203c98e4765a354ee Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1407221 Tested-by: kokoro <noreply+kokoro@google.com>
* x86_64: return fdt size from create_fdt()Daniel Verkamp2019-02-07
| | | | | | | | | | | | | | | | | | This will allow placement of the initrd after the end of the device tree blob in the next patch. This also moves the load of the fdt into setup_system_memory() so that the position of the initrd can be calculated (in the next patch) before calling configure_system(). BUG=None TEST=Boot Termina on x86-64 Change-Id: I6dcfce3aa48ae0932157a40fa28ea9fb384263c8 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1443634 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* Add logic to set up PIT (guarded by flag).Miriam Zimmerman2019-02-06
| | | | | | | | | | | | BUG=chromium:908689 TEST=None Change-Id: I625bab235f740d1d2ae256de61a25d560025b751 Reviewed-on: https://chromium-review.googlesource.com/1444501 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Miriam Zimmerman <mutexlox@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm: x86_64 guest support for android device-treeTristan Muntsinger2019-01-28
| | | | | | | | | | | | | | | | This device tree is derived from the Android fstab file which is provided via command line flag. BUG=chromium:922737 TEST=None CQ-DEPEND=CL:1415390 CQ-DEPEND=CL:1415270 Change-Id: Idd007c844f84cab3ff37be16a718f14e5f630312 Reviewed-on: https://chromium-review.googlesource.com/1370058 Commit-Ready: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* crosvm: add debug labels to devices for improved SIGCHLD logsZach Reizner2019-01-26
| | | | | | | | | | | | | | | | | | | Each device (Bus, Pci, Proxy, etc), gets a debug label associated with it. When a child is spawned, the debug label for it is stored in a map with the child's pid as the key. If a SIGCHLD is handled, this map is used to print a more helpful message about exactly which child died. BUG=None TEST=run with sandboxing and a faulty child device check logs for message about child died the child should have a debug label Change-Id: I61fbbee0a8e701249533a7a3a6a1ad48840f12e5 Reviewed-on: https://chromium-review.googlesource.com/1432835 Commit-Ready: Chih-Yang Hsia <paulhsia@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* crosvm: Support cros-rust version crosvm ebuildpaulhsia2019-01-22
| | | | | | | | | | | | | | | | | | | | | | | To support eclass migration for crosvm ebuild from crate to cros-rust. This CL need to be built with cros-rust version crosvm ebuild. - Upgrage crate cc from 1.0.15 to 1.0.25. - Change local tempdir version from 0.3.5 to 0.3.7 for ebuild integration. - Remove 9s directory since it's moved to platform2. BUG=chromium:781398 BUG=chromium:907520 TEST=Run $ FEATURES=test emerge-eve crosvm in a clean chroot CQ-DEPEND=CL:1421303 Change-Id: Iab615b555a51f8020e5efae1cc40ac6b54ea87f2 Reviewed-on: https://chromium-review.googlesource.com/1421237 Commit-Ready: Chih-Yang Hsia <paulhsia@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Chih-Yang Hsia <paulhsia@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* toolchain: Update to Rust 1.31.0David Tolnay2018-12-13
| | | | | | | | | | | | | | | | | | We updated the production toolchain from 1.30 to 1.31 in CL:1366446. This CL does the same upgrade for the local developer toolchain and Kokoro. The relevant changes are in rust-toolchain and kokoro/Dockerfile. The rest are from rustfmt. TEST=cargo fmt --all -- --check TEST=as described in kokoro/README.md Change-Id: I3b4913f3e237baa36c664b4953be360c09efffd4 Reviewed-on: https://chromium-review.googlesource.com/1374376 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* sync: Mutex type with methods that panic instead of return errorDavid Tolnay2018-12-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL adds a crate `sync` containing a type sync::Mutex which wraps the standard library Mutex and mirrors the same methods, except that they panic where the standard library would return a PoisonError. This API codifies our error handling strategy around poisoned mutexes in crosvm. - Crosvm releases are built with panic=abort so poisoning never occurs. A panic while a mutex is held (or ever) takes down the entire process. Thus we would like for code not to have to consider the possibility of poison. - We could ask developers to always write `.lock().unwrap()` on a standard library mutex. However, we would like to stigmatize the use of unwrap. It is confusing to permit unwrap but only on mutex lock results. During code review it may not always be obvious whether a particular unwrap is unwrapping a mutex lock result or a different error that should be handled in a more principled way. Developers should feel free to use sync::Mutex anywhere in crosvm that they would otherwise be using std::sync::Mutex. TEST=boot linux Change-Id: I9727b6f8fee439edb4a8d52cf19d59acf04d990f Reviewed-on: https://chromium-review.googlesource.com/1359923 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* lint: Resolve the easier clippy lintsDavid Tolnay2018-12-03
| | | | | | | | | | | | | | | | | | | | Hopefully the changes are self-explanatory and uncontroversial. This eliminates much of the noise from `cargo clippy` and, for my purposes, gives me a reasonable way to use it as a tool when writing and reviewing code. Here is the Clippy invocation I was using: cargo +nightly clippy -- -W clippy::correctness -A renamed_and_removed_lints -Aclippy::{blacklisted_name,borrowed_box,cast_lossless,cast_ptr_alignment,enum_variant_names,identity_op,if_same_then_else,mut_from_ref,needless_pass_by_value,new_without_default,new_without_default_derive,or_fun_call,ptr_arg,should_implement_trait,single_match,too_many_arguments,trivially_copy_pass_by_ref,unreadable_literal,unsafe_vector_initialization,useless_transmute} TEST=cargo check --features wl-dmabuf,gpu,usb-emulation TEST=boot linux Change-Id: I55eb1b4a72beb2f762480e3333a921909314a0a2 Reviewed-on: https://chromium-review.googlesource.com/1356911 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* Revert "mptable: mark PCI interrupts as edge triggered"Daniel Verkamp2018-10-29
| | | | | | | | | | | | | | | | | | | | Legacy PCI interrupts should be level triggered, not edge triggered. The reverted change was done as part of a series of patches during debugging of virtio-pci differences from virtio-mmio, but this was not the actual root cause of the problems. BUG=None TEST=Boot crosvm on x86-64 and verify virtio devices still work This reverts commit 9357ceab6ac207498fc2cff4be70aa6975e9c79f. Change-Id: If1bf6e48d63fe352f0b914f5bdb2e346ab210369 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1297840 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* devices: make PCI work in --disable-sandbox modeDaniel Verkamp2018-10-19
| | | | | | | | | | | | | Make the Minijail part of the PCI device tuple optional so that an empty jail is not created for --disable-sandbox. BUG=None TEST=Boot crosvm in both --multiprocess and --disable-sandbox modes Change-Id: Ibb3f2dbf33ca19910ee7448ea823b2772e09ecc5 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1290289 Reviewed-by: Dylan Reid <dgreid@chromium.org>
* Revert "Revert "linux: Convert all virtio devices to PCI""Daniel Verkamp2018-10-12
| | | | | | | | | | | | | | This reverts commit c8986f14a8dd9f256d6faed55996d955b50ff923. Re-land the virtio PCI conversion after the preceding fixes. BUG=chromium:854766 TEST=Boot crosvm on nami and kevin Change-Id: I3699e3ed1a45cecc99c51e352d0cf0c32bc4116f Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1265862 Reviewed-by: Dylan Reid <dgreid@chromium.org>
* mptable: mark PCI interrupts as edge triggeredDaniel Verkamp2018-10-10
| | | | | | | | | | BUG=chromium:854766 TEST=Boot crosvm on an x86_64 platform (nami) Change-Id: Id55975a443a54e8b9c25616cd842507c57802af0 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1265047 Reviewed-by: Dylan Reid <dgreid@chromium.org>
* cargo fmt all source codeZach Reizner2018-10-09
| | | | | | | | | | | | | | Now that cargo fmt has landed, run it over everything at once to bring rust source to the standard formatting. TEST=cargo test BUG=None Change-Id: Ic95a48725e5a40dcbd33ba6d5aef2bd01e91865b Reviewed-on: https://chromium-review.googlesource.com/1259287 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* Revert "linux: Convert all virtio devices to PCI"Daniel Verkamp2018-10-04
| | | | | | | | | | | | | | | This reverts commit d635acbaf348c0863bc05b8f889b2fa5f8156aaa. This commit seems to be responsible for introducing hung tasks in tests, so let's revert it for now to get the tests green and debug it offline. BUG=chromium:891806 TEST=None Change-Id: I83504058baeae00909d9fb4f4bb704a144a0dfaf Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1259408 Reviewed-by: Dylan Reid <dgreid@chromium.org>
* linux: Convert all virtio devices to PCIDaniel Verkamp2018-10-02
| | | | | | | | | | | | | Change the main create_virtio_devs() function to create virtio devices using the PCI transport rather than MMIO. BUG=chromium:854766 TEST=Boot crosvm and verify that all virtio devices still work Change-Id: I9a6e60b21edea1e5ac2b3ae5c91793d45cf5063a Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1241541 Reviewed-by: Dylan Reid <dgreid@chromium.org>
* x86_64: increase size of MMIO rangeDaniel Verkamp2018-10-01
| | | | | | | | | | | VirtioPci uses 0x4000 bytes of MMIO space per device, so the existing allocation of 0x10000 was only enough for 4 devices; extend the MMIO region to allow for more devices. Change-Id: I0cc44edacc5f435510ab8ae9b38a925a0ee5d008 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1240654 Reviewed-by: Dylan Reid <dgreid@chromium.org>
* devices: pci: refactor config access mechanismDaniel Verkamp2018-10-01
| | | | | | | | | | | | The current PciRoot is only workable for the legacy I/O port 0xCF8 access mechanism; factor out the config access mechanism part of PciRoot into PciConfigIo so that we can add a MMIO-based access mechanism for ARM. Change-Id: I87756b0ab31070d8717c76d419957bf5ea5d75ad Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1241539 Reviewed-by: Dylan Reid <dgreid@chromium.org>
* devices: pci: fix registration of PCI IRQsDylan Reid2018-10-01
| | | | | | | | | | | MPTABLE needs the PCI device number, not the IRQ; modify the information passed via pci_irqs so that it contains a (device index, interrupt pin) tuple. Change-Id: Ia1dcb478cdab6654087925093ef9d1204edb21c9 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1237362 Reviewed-by: Dylan Reid <dgreid@chromium.org>
* devices: pci: add ioeventfds to PciDevice traitDylan Reid2018-10-01
| | | | | | | | | | | | VirtioDevices and potentially others need to register ioeventfds that will be triggered when guests write to certain addresses. Allow PciDevices to return an array of ioeventfds that the VM can install. Change-Id: I2524c4e8c04f75a8d7868cac998304aecbb29c40 Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1237360 Commit-Ready: Daniel Verkamp <dverkamp@chromium.org> Tested-by: Daniel Verkamp <dverkamp@chromium.org>
* move pci root creation to archDylan Reid2018-10-01
| | | | | | | | | | passing everything in to the pci code is getting annoying. Instead build it up in arch which already has access to all the needed resources. Change-Id: If42f994443c4f11152fca8da16f27fa4cd80580d Reviewed-on: https://chromium-review.googlesource.com/1237357 Commit-Ready: Daniel Verkamp <dverkamp@chromium.org> Tested-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* Arch: Big refactor and add an empty PCI busDylan Reid2018-09-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When setting up IO, accept an optional PciRoot device to put on the IO bus. For aarch64, it's currently ignored. For x86_64, it will be added at 0xcf8. break up mmio device creation and registration Moving forward registration will be handled by the architecture specific code. However, creation will be handled by the common code. To make that easier split up the two steps so a list of devices is created, then each is registered later. Start moving to a model where the configuration generates a set of components that are passed to the architecture. The architecture will crate a VM from the components. Break up the big run_config function and move architecture specific parts to the various architectures. This doesn't refactor the function calls each architecture makes, but moves the setup flow in to the arch impls so that they can diverge in the future. Change-Id: I5b10d092896606796dc0c9afc5e34a1b288b867b Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1099860 Commit-Ready: Daniel Verkamp <dverkamp@chromium.org> Tested-by: Daniel Verkamp <dverkamp@chromium.org>
* x86_64: Don't allocate addrs in the 32 bit gapDylan Reid2018-08-09
| | | | | | | | | | | | | | | Device allocations have to skip the gap so they don't collide with things like the APIC. BUG=863490 TEST=Resize a gedit window on APL for a minute and make sure there isn't a crash. Change-Id: Ia8185bcdbb6c18e13d02be317ae4d48c73288661 Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1168400 Reviewed-by: Sonny Rao <sonnyrao@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* x86_64: Enable pci on the command line.Dylan Reid2018-07-31
| | | | | | | Change-Id: I73f77dfbd1d76ed94e6ae9645fa7c0a6fab0337a Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1085250 Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
* mptable: Add ability to allocate pci interruptsDylan Reid2018-07-23
| | | | | | | | | | | PCI devices will require interrupts, allow this by passing a vector of IRQs to the mptable so the guest kernel can find the IRQs. Change-Id: I9fa8a2ed0a34089e631441570521082ffde9c4ef Reviewed-on: https://chromium-review.googlesource.com/1072578 Commit-Ready: Dylan Reid <dgreid@chromium.org> Tested-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* devices: proxy - Add support for proxying PciDevicesDylan Reid2018-07-18
| | | | | | | | | | | | | | | | | | PCI adds a configuration space to the existing memory mapped IO supported by BusDevices. Add the ability to set configuration space as optional to the BusDevice trait so that ProxyDevice can be shared. PCI devices can have more than one memory mapped region. Expand the bus so that it has the ability to pass an absolute address instead of an offset. This will allow the PCI device to know which BAR is being written to. Change-Id: I055cd516c49a74316a9547df471290f05d865b0a Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1103663 Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
* Move gpu allocator to resourcesDylan Reid2018-07-09
| | | | | | | | | | Combine GPU buffer allocation with the system resource allocator making life easier as only one allocator needs to get passed to the execute function. Change-Id: I199eb0fd6b99b629aaec1ae3295e8a1942da5309 Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1099856
* x86_64: fill cache info in cpuid, stop spoofing CPU vendor idSlava Malyugin2018-07-09
| | | | | | | | | | | | | | | | | | | | | | | | | The fix passes through cache-related CPU entries 2, 4, 0x80000005 and 0x80000006 similar to how QEMU does it. Note passing this cpuid info itself is not sufficient unless CPU vendor is something Linux kernel recognizes. Therefore, I am removing cute spoofing of the vendor id, allowing host value to pass through. I believe it is generally a bad idea to spoof vendor id as lots of kernel and user space code gets confused and may take unoptimized paths. The corollary is that removing the spoofing may have unintended consequences correctness- and performance-wise. I would appreciate recommendation on additional testing. BUG=chromium:859678 TEST=lscpu in Guest, 'cargo test' Change-Id: I6963b00d9eecf49fb4578bcc75ad744c3099f045 Reviewed-on: https://chromium-review.googlesource.com/1125529 Commit-Ready: Slava Malyugin <slavamn@chromium.org> Tested-by: Slava Malyugin <slavamn@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* Remove the device manager and use the new resource allocatorDylan Reid2018-06-29
| | | | | | | | | | | | | | | | | Allow IRQs to be assigned before creating device manager. For PCI, we need to add devices with interrupts before MMIO setup. Add the ability to tell the architecture device manager about IRQs that we have stolen. There was only one function in device_manager and all of its state is now delegated to the resource allocator, remove it. Change-Id: I9afa0e3081a20cb024551ef18ae34fe76a1ef39d Reviewed-on: https://chromium-review.googlesource.com/1089720 Commit-Ready: Dylan Reid <dgreid@chromium.org> Tested-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
* crosvm: aarch64: get kernel's preferred target type for vcpusSonny Rao2018-04-03
| | | | | | | | | | | | | | | | | | | | This fixes an issue on kevin where if we start on a little core, the kernel doesn't like the generic ARMv8 target cpu type for some reason. To fix this we must query the preferred type from the vm device first and supply that to the vcpu init ioctl. We need to change the signature of the configure_vcpu method to pass in the vm object even though we aren't using it on x86. BUG=chromium:797868 TEST=./build_test passes on all architectures TEST=crosvm runs on kevin Change-Id: I460cb9db62a8805bb88f838956aa4f1c69183961 Reviewed-on: https://chromium-review.googlesource.com/982996 Commit-Ready: Sonny Rao <sonnyrao@chromium.org> Tested-by: Sonny Rao <sonnyrao@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* x86_64: Set EFER.LMADylan Reid2018-03-29
| | | | | | | | | | We were setting LME (Long Mode Enabled) but not LMA (Long Mode Active). New kernels have a check in the kvm code that disallows this brokenness. Change-Id: Ic8950c8748ead81201223c19404fdd2c8d80f7dc Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/985733 Reviewed-by: Zach Reizner <zachr@chromium.org>
* x86_64: use project name in cpuid vendorMike Frysinger2018-03-22
| | | | | | | | | | | | | The official name is "crosvm", not "CrOSVM". BUG=None TEST=None Change-Id: I21f200d8224c9a8fee53011a63ff4ad165128904 Reviewed-on: https://chromium-review.googlesource.com/976941 Commit-Ready: Mike Frysinger <vapier@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org>
* x86_64: Add separate error for getting sregsDylan Reid2018-03-22
| | | | | | | | | | | | Re-using the set error could cause confusion. BUG=none TEST=none Change-Id: I47445b28946484028bf96cff9ee0bc8c89b6f3e5 Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/974741 Reviewed-by: Zach Reizner <zachr@chromium.org>