summary refs log tree commit diff
path: root/x86_64
Commit message (Collapse)AuthorAge
* move MemoryParams to devicesAlyssa Ross2020-06-15
|
* hacky working out-of-process virtio_wlAlyssa Ross2020-06-15
|
* arch: add public API for creating GuestMemoryAlyssa Ross2020-06-15
| | | | | | | | | | | | | For inter-guest communication, other processes need to be able to access guest memory, without creating a VM. GuestMemory, with its list of memory regions, can't derive MsgOnSocket. This means that GuestMemory structs can't (easily) be shared over a socket. However, all that is required to create a GuestMemory is a size, and on x86_64, a boolean has_bios field. The architecture differences can be encapsulated in a struct. It can be opaque outside of architecture-specific crates, so the rest of the code can remain architecture-independent.
* acpi: support user provided ACPI SDTs.Tomasz Jeznach2020-06-01
| | | | | | | | | | | | | | | Enable support for user provided ACPI tables with supplementary system description. Argument --acpi-table shall point to exsting file or pseudo-file with valid ACPI table content. BUG=None TEST=boot Linux kernel with generated SSDT tables. Change-Id: I8eac21da070dcc325884ed888cc7bcb01bc086ce Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2212501 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: Tomasz Jeznach <tjeznach@chromium.org> Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
* Make VolatileSlice ABI-compatible with iovecChirantan Ekbote2020-05-25
| | | | | | | | | | | | | | | | | | | | | | Change VolatileSlice so that it is ABI-compatible with iovec. This allows us to directly pass in a VolatileSlice for a C function that expects an iovec without having to create temporaries that convert from one to the other. Also change all the parameters from u64 to usize. It's not possible to address more memory than fits into a usize so having u64 here didn't really provide much benefit and led to a lot of tedious casting back and forth all over the place. BUG=none TEST=unit tests Cq-Depend: chromium:2206621 Change-Id: I258f9123c603d9a4c6c5e2d4d10eb4aedf74466d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2203998 Tested-by: Chirantan Ekbote <chirantan@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
* acpi: refactor the ACPI PM deviceChuanxiao Dong2020-05-11
| | | | | | | | | | | | | | | | | | Add the AML support to generate the S1 table instead of hard coding. Also use the IO allocater to allocate the IO resouce for ACPI PM. BUG=None TEST=boot crosvm by command "crosvm run -s crosvm.sock -m 4096 --cpus 4 --rwdisk rootfs.img -p "root=/dev/vda rootfstype=ext4" vmlinux". Check the S1 capability by "#echo standby > /sys/power/state" from guest side. Linux guest is suspended. And resume linux guest by "#crosvm resume crosvm.sock" from host side. Change-Id: I75b484c44db05f98d49557ba694a1531b57871c1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2119571 Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com>
* pci: refactor FDT/MPTABLE creation to use PciAddress.Tomasz Jeznach2020-05-05
| | | | | | | | | | | | | | | | | Simple refactor of FDT and MPTables generation to use PCI device addressing and allow declatation of non-zero PCI bus ids for x86 architectures. It also allows non sequential IRQ allocation for PCI devices. BUG=None TEST=build_test & tast run crostini.Sanity Change-Id: I6cc31ce412199a732499b2d8d18d99f08d765690 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2175739 Tested-by: Tomasz Jeznach <tjeznach@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
* Remove unnecessary parentheses in constsDaniel Verkamp2020-04-26
| | | | | | | | | | | | | Fix clippy "error: unnecessary parentheses around assigned value." BUG=None TEST=bin/clippy Change-Id: I31e61c770c62d7ff2ca8525bf754bd615e24c349 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2163204 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* Remove redundant single-component importsDaniel Verkamp2020-04-26
| | | | | | | | | | | | | Fix clippy 1.43.0 clippy::single-component-path-imports warnings. BUG=None TEST=bin/clippy Change-Id: I3f4f54138bedce16dc1ca937bb8bc00a94594f69 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2163203 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* arch, main: add virtio-console parsing and creationDaniel Verkamp2020-04-23
| | | | | | | | | | | | | | | | | | | | | | This allows the creation of virtio-console devices using the new hardware=virtio-console parameter to the --serial option. Also add support for the serial earlycon option, which allows using virtio-console as the main console device with a traditional serial device as the early console. This allows logging during early boot before PCI device discovery (when virtio-console devices are set up). BUG=chromium:1059924 TEST=crosvm run -r vm_rootfs.img \ --serial hardware=serial,type=stdout,console=false,earlycon=true \ --serial hardware=virtio-console,type=stdout,console=true,stdin=true \ vm_kernel Change-Id: Iff48800272b154d49b1da00f3914799089268afe Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2127322 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* arch, devices: move serial creation to archDaniel Verkamp2020-04-23
| | | | | | | | | | | | | | | | | | | | | Split the serial code into two parts: - Configuration and setup: arch/src/serial.rs - Serial device emulation: devices/src/serial.rs No change in functionality - this is just preparation for generalizing the command line parsing/setup code so that it can be used with virtio console devices as well. BUG=chromium:1059924 TEST=emerge-nami crosvm TEST=emerge-kevin crosvm Change-Id: I0aaf9dd6f8096eac4a17077ab5bf569f57d64ff5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2127319 Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* ACPI: enable ACPI from command lineChuanxiao Dong2020-03-19
| | | | | | | | | | | | | | | | | | | | | | Previously the "acpi=off" in cmdline has disabled the ACPI for the guest kernel. With removing the "acpi=off", the ACPI will be enabled for the guest kernel by default. With acpi enabled, the SCI irq will be needed by the ACPI core driver. Register the SCI irq in MP table so that it can use IO-APIC routing. The reason to have "pci=noacpi" is that, in the current DSDT there is only suspend capability, so PCI scan still need to be done by the traditional way. BUG=chromium:1018674 TEST=Linux guest is able to boot up with the virtio devices functional. Also able to see the S1 capability from kernel dmesg. Change-Id: Id54e788f4aa4c944fac5e3fa1c92b76865dd5021 Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2078967 Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* Fix warnings added in rust 1.42Dylan Reid2020-03-17
| | | | | | | | | | | | | | | | rustc now warns about return statements that have an extra set of parenthesis. Remove such instances so that the code is warning free. TEST=cargo build completes without warnings Change-Id: I55148f8aceca8ba90f6bead2b6929e2c843351aa Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2104767 Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Dylan Reid <dgreid@chromium.org>
* crosvm: Add plumbing for split-irqchip interruptsZhuocheng Ding2020-03-05
| | | | | | | | | | | | | | | Devices use irqfd to inject interrupts, we listen to them in the main thread and activate userspace pic/ioapic accordingly. BUG=chromium:908689 TEST=lanuch linux guest with `--split-irqchip` flag Change-Id: If30d17ce7ec9e26dba782c89cc1b9b2ff897a70d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1945798 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Zhuocheng Ding <zhuocheng.ding@intel.corp-partner.google.com>
* Add logic to setup PIC/IOAPIC.Zhuocheng Ding2020-03-05
| | | | | | | | | | | | | TODO: Route irqfd to PIC/IOAPIC to make them fully work. BUG=chromium:908689 TEST=None Change-Id: I301287b1cf32cfccffce6c52ebbb5e123931178e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1945796 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Zhuocheng Ding <zhuocheng.ding@intel.corp-partner.google.com>
* acpi: add S1 capability in DSDTChuanxiao Dong2020-02-28
| | | | | | | | | | | | | | | | | | | | S1 is a sleep state which is lighter than S3, but enough to put the devices into the suspended state. With this DSDT, the guest kernel is able to see the S1 capability and to put the VM into virtual S1. During the virtual S1, guest kernel will call each suspend callbacks of the devices driver to put the devices into the suspend state, including the pass through device. BUG=chromium:1018674 TEST=boot linux guest with ACPI enabled, and able to see "shallow" by "cat /sys/power/mem_sleep", which means the S1 Change-Id: I232609f6f2474895fd9ec4046d88236c413e51af Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2035353 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
* acpi: allocate sci_irq instead of use fixed numberChuanxiao Dong2020-02-28
| | | | | | | | | | | | | | | | sci_irq can be allocated so not to use the fixed number 9. Actually this irq is not used for injecting any event but the Linux guest OS requires to see meaning value from the FADP table. So just fill it to satisfy. BUG=chromium:1018674 TEST=None Change-Id: If3ea3bb2844fc7fc1c24a577b7098d2a3e6f1c7f Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2035352 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
* x86_64: generate ACPI tablesChuanxiao Dong2020-02-28
| | | | | | | | | | | | | | | | | | | | | | | | Add acpi_rsdp_addr in boot_params to allow crosvm to pass a physicall address of RSDP to the Linux guest kernel, so that the linux guest kernel can parse the constructed ACPI tables and enable the ACPI. Although there is ACPI tables but as we still have "acpi=off" in command line parameter, there is still no ACPI in guest kernel. The ACPI construction refers to the implementation of the Cloud-hypervisor commit: - arch: x86_64: Generate basic ACPI tables BUG=chromium:1018674 TEST=None Change-Id: Ibcb2ae98c43da8ef8c07a07eda9213f61570d14c Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2035351 Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
* x86_64: use __cpuid intrinsicDaniel Verkamp2020-02-22
| | | | | | | | | | | | | | | | | | | | | | Use the Rust __cpuid and __cpuid_count intrinsics to replace the C implementation in host_cpuid.c. These are defined in core, but they are also re-exported in std, despite being undocumented there due to technical reasons: https://github.com/rust-lang/rust/pull/57808#issuecomment-457390549 Use the std version for consistency (we don't currently use anything from core anywhere else in crosvm). BUG=None TEST=cargo test -p x86_64 TEST=Boot crosvm on x86_64 Change-Id: Ic7a1094d1b804304a2944f8ee1fe55c5e2db23e9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2067159 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* devices: IOAPIC: implement interrupt routingZhuocheng Ding2020-02-21
| | | | | | | | | | | | | | This change implements MSI routing and injection, so that service_irq can actually inject an interrupt into guest. BUG=chromium:908689 TEST=Unit tests in file. Change-Id: I2db4f00f569db56f5765c707faaa87c64fd3da9f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1945795 Reviewed-by: Stephen Barber <smbarber@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Zhuocheng Ding <zhuocheng.ding@intel.corp-partner.google.com>
* acpipm: implement suspend and resume mechanismChuanxiao Dong2020-02-19
| | | | | | | | | | | | | | | | | | | For suspend request from VM, will write suspend event and notify crosvm main process to pause VCPUs. For resume request, it is not from VM itself but by the resume command through crosvm socket. Resume request will notify the PM device to fill its wakeup registers with wakeup event so that when VCPUs start to run, VM can know there is wakeup from outside. BUG=chromium:1018674 TEST=cargo test -p devices Change-Id: I4724ffee10150065a62bf520076c16cbc70b7749 Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2035169 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
* devices: add acpi device emulation code in devicesChuanxiao Dong2020-02-17
| | | | | | | | | | | | | | Add ACPI PM resource emulation code in devices, so that it can support the ACPI PM requestion from guest OS. BUG=chromium:1018674 TEST=cargo test -p devices Change-Id: I7b82b1c3a6f609136e493b55420b947afd1d5cfc Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2035168 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
* crosvm: pstore works for ARCVM on x86_64Kansho Nishida2020-02-03
| | | | | | | | | | | | | | | | Adds support for pstore on ARCVM on x86_64. The backend file of the buffer will be passed via argument of the crosvm. BUG=b:144962428 TEST=kernel crash on eve-arcvm, check /sys/fs/pstore/console-ramoops-0 Launch crostini manually on eve-arcvm Change-Id: I29492ac7a9067aa2ae23eb03fbb942ab7dd3aa8d Signed-off-by: Kansho Nishida <kansho@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1973391 Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Kansho Nishida <kansho@chromium.org>
* x86_64: fix warning on 1.40Dylan Reid2020-01-12
| | | | | | | | | | | The extra parens crept back in during a recent refactoring. Change-Id: Iaba13ddea9b7bada09f6079db7e7f8133cbfc896 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1994726 Reviewed-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Dylan Reid <dgreid@chromium.org> Tested-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* devices: remove user_command from proxy deviceZach Reizner2020-01-09
| | | | | | | | | | | | | | | | | | The only device that used user_command was Serial. This change makes Serial device use a thread to read from its input instead of using user_command. BUG=chromium:1033787 TEST=./build_test run crosvm with stdio serial with and without sandbox Change-Id: Ia0f2ee83d94ad2fee3f1f4f89aa734b976e33507 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1966435 Tested-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Zach Reizner <zachr@chromium.org> Auto-Submit: Zach Reizner <zachr@chromium.org>
* devices: fix warning about extra parensDylan Reid2019-12-23
| | | | | | | | | | | rust 1.40 has a new warning when there are extra parens, soRemove them. Change-Id: Ibb565cac41ba8d72879f4cb8b949f2be30e55167 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1978140 Reviewed-by: Stephen Barber <smbarber@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Dylan Reid <dgreid@chromium.org>
* x86_64: add tsc_deadline_timer supportZhuocheng Ding2019-12-13
| | | | | | | | | | | | | | | Support TSC deadline mode of LAPIC timer, this can potentially increase the precision of guest timer. BUG=None TEST=launch linux guest and run `lscpu`, tsc_deadline_timer is present in the output. Change-Id: I7adc87827a51ba8d1866ebee201759f2769ba664 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1951429 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Zhuocheng Ding <zhuocheng.ding@intel.corp-partner.google.com>
* crosvm: PIT: use full address and avoid conflictZhuocheng Ding2019-12-10
| | | | | | | | | | | | | | | | The PIT implementation has the assumption that addresses are I/O port numbers, so we should use full address mode. i8042 is also changed to full address mode to avoid the conflict on port 0x61. BUG=chromium:908689 TEST=None Change-Id: Ibbb851e3a46ac7fc71576990a1618196de92e33c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1945794 Commit-Queue: Zhuocheng Ding <zhuocheng.ding@intel.corp-partner.google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* Setup vcpu's MTRRXiong Zhang2019-11-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | When vfio pass-through is enabled, guest will be very slow. The root casue is gfn is uncachable in EPT. From the comments in kernel vmx_get_mt_mask(vcpu, gfn, is_mmio) function, EPT memory type with VT-d, VT-d without snooping control feature: can't guarantee the result, try to trust guest through kvm_mtrr_get_guest_memory_type(vcpu, gfn). But crosvm doesn't set mtrr, so host kernel will set uncachable for all gfn in ept. This patch set the default cache type as WB, and set mmio cache type as UC, so the guest ram is WB. BUG=chromium:992270 TEST=crosvm --vfio /sys/devices/pci0000:00/0000:00:02.0, pass through host igd into linux guest, the guest runs smoothly and guest desktop could be shown on physical local display. Change-Id: I151aae7835910cfbc9e38464ee901e5da281de1e Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1813458 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* x86_64: fix the incorrect parameter for disabling ACPIChuanxiao Dong2019-11-22
| | | | | | | | | | | | | | noacpi is not used by the current guest linux kernel to disable ACPI. Instead, acpi=off is the right parameter to be used. BUG=chromium:1026497 TEST=launch crosvm linux guest and ACPI is disabled Change-Id: I9c9001146abb57ea9dbc078ee6188b8c60cb056e Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1925999 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* Vfio: Suitably allocate bar for vfio deviceXiong Zhang2019-11-11
| | | | | | | | | | | | | Use 64bit flag in vfio device's bar to get correct mmio allocator. BUG=chromium:992270 TEST=none Change-Id: I8f3dab48eb6dc0b92071803aa3526cadda8034c7 Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1581143 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* resource: Rename device memory to mmioXiong Zhang2019-11-10
| | | | | | | | | | | | | | Since unified allocator is used to allocate mmio, this patch remove the device memory name, and rename device to mmio. BUG=chromium:992270 TEST=this patch doesn't change function, run build_test Change-Id: I234b0db4b3c5de8cfee372ace5212a980564d0c7 Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1895234 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* arch: replace is_some + unwrap with `if let`Daniel Verkamp2019-11-08
| | | | | | | | | | | BUG=None TEST=emerge-kevin crosvm Change-Id: I78aa9f4fb4fb46de3394bb9bc2fa5a53e210fa0b Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1896085 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* x86_64: Correct the start address of device memoryXiong Zhang2019-11-05
| | | | | | | | | | | | | | | | | | | When guest ram >= 4G, as mmio hole exists in ram GuestMemory, GuestMemory->end_addr() is larger than memsize, if memsize is used as start address of device memory, device memory will overlap with Guest ram. This patch use GuestMemory->end_addr() as the start address of device memory. BUG=None TEST=Boot vm with guest memory above 4G, and enable vGPU, and run vGPU benchmark. Change-Id: Ifc28f3a022cb0a179d16fee4056016a192f2acbd Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1895232 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* x86_64: Correct guest ram memory region layoutXiong Zhang2019-11-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When guest boot with -m 4096, guest e820 is: BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable BIOS-e820: [mem 0x0000000000200000-0x00000000cfffffff] usable so guest usable ram is 3.25G which is smaller than specified 4G. 3.25G~4G is assigned to pci device as mmio, this range should be relocated to 4G above like 4G to 4.75G. So guest could see the full 4G usable ram. With this patch, guest e820 is: BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable BIOS-e820: [mem 0x0000000000200000-0x00000000cfffffff] usable BIOS-e820: [mem 0x0000000100000000-0x000000012fffffff] usable The guest could use 4G ram equal to specified 4G. Then mmio hole exists in guest ram's regions, GuestMemory's end_addr is larger than the memsize. end_addr couldn't be used to judge an address in a guest memory or not We should iterate all the regions to avoid the address in the hole; end_addr couldn't be used for checked_offset() also, it may faill into mmio hole. BUG=none TEST=build_test; Boot vm with different guest memory size, and check vm's e820 table Change-Id: I2cd7c3223173ab635041875b9d8b49c2800c8dab Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1895231 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* devices: jail serial deviceZach Reizner2019-10-10
| | | | | | | | | | | | | | | | | | This change plumbs the jail throughout the arch specific device creation process. It also adds a custom callback support for the ProxyDevice so that the main process can interrupt the child serial process when it has incoming bytes. TEST=crosvm run BUG=None Change-Id: I6af7d2cb0acbba9bf42eaeeb294cee2bce4a1f36 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1752589 Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Zach Reizner <zachr@chromium.org> Commit-Queue: Zach Reizner <zachr@chromium.org>
* x86_64: replace byteorder with {to,from}_le_bytes()Daniel Verkamp2019-08-26
| | | | | | | | | | | BUG=None TEST=./build_test Change-Id: Ic7873c6b70d9a0e9f34b7a2977845552144934ea Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1761152 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm: virtio-pmem deviceJakub Staron2019-06-05
| | | | | | | | | | | | | | | | | | | | Adds support for virtio-pmem device as an alternative for virtio-blk. Exposing disk image to guest as virtio-blk device results in both guest and host independently caching the disk I/O. Using virtio-pmem device allows to mount disk image as direct access (DAX) in the guest and thus bypass the guest cache. This will reduce memory foodprint of the VMs. BUG=None TEST=cargo test TEST=Boot patched termina kernel in crosvm; mount virtio-pmem device as DAX and run xfstests. Change-Id: I935fc8fc7527f79e5169f07ec7927e4ea4fa6027 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1605517 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org> Commit-Queue: Jakub Staroń <jstaron@google.com>
* eliminate mut from non-mut referencesZach Reizner2019-06-04
| | | | | | | | | | | | | | | | | | | | | | | This manifested itself in a couple places that were turning shared memory buffers into slices for the purposes of passing these slices to `Read` and `Write` trait methods. However, this required the removal of the methods that took `Read` and `Write` instances. This was a convenient interface but impossible to implement safely because making slices from raw pointers without enforcing safety guarantees causes undefined behaviour in Rust. It turns out lots of code in crosvm was using these interfaces indirectly, which explains why this CL touches so much. TEST=crosvm run BUG=chromium:938767 Change-Id: I4ff40c98da6ed08a4a42f4c31f0717f81b1c5863 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1636685 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Zach Reizner <zachr@chromium.org>
* Initial BIOS support.Cody Schuffelen2019-05-31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The --bios argument is added as an alternative to the kernel positional argument. The BIOS runs in unreal mode (16-bit cs selector set to the end of 32-bit address space), which matches the default state KVM puts the segment and data registers into. Example usage: Build u-boot with "make qemu-x86_defconfig && make" Run crosvm with "crosvm_wrapper.sh run --bios=u-boot.rom" This produces the following message: """ U-Boot 2019.01-00017-gdc76aabe6a-dirty (May 21 2019 - 12:17:02 -0700) CPU: DRAM: 16 MiB unable to get online cpu number: -19 Warning: MP init failure Model: QEMU x86 (I440FX) Net: No ethernet found. error: can't find etc/table-loader Hit any key to stop autoboot: 0 => """ At this point the u-boot shell works with stdin/stdout, but virtual disks passed with --rwdisk weren't immediately visible from running "virtio scan" and "virtio info". This change puts the bios loading together with the linux kernel loading code since there is a lot of overlap in functionality. Bug: b/133358982 Test: ./crosvm_wrapper.sh run --mem=4097 --bios=u-boot.rom Change-Id: I65b0e1044233af662a642c592d35b106217f3c13 Reviewed-on: https://chromium-review.googlesource.com/1622648 Commit-Ready: Daniel Verkamp <dverkamp@chromium.org> Tested-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* x86_64: regenerate bootparam bindings without unionsZach Reizner2019-05-23
| | | | | | | | | | | | TEST=crosvm run still works BUG=chromium:761517 Change-Id: I6e95dde573febb5e498107b84b574373d1685c9a Reviewed-on: https://chromium-review.googlesource.com/1625947 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* devices: cmos: report memory size in CMOSDaniel Verkamp2019-05-23
| | | | | | | | | | | | | | | This matches the QEMU CMOS implementation and is used by BIOSes to determine the valid memory regions to add to the e820 map. BUG=b:133358982 TEST=Boot u-boot qemu build; observe memory size Change-Id: I27956bc05738b5dd5b84240d5137cb06846aaab9 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1625330 Tested-by: kokoro <noreply+kokoro@google.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* smbios: fix clippy warningsDaniel Verkamp2019-05-22
| | | | | | | | | | | | | | | | | Resolve a couple of minor clippy warnings: - const implies static lifetime, so it can be omitted - dereference bytes of str instead of clone() BUG=None TEST=bin/clippy TEST=cargo build; boot vm_kernel+vm_rootfs.img Change-Id: I29ff9bf7fdecd64286c2199e8e45c21103de9ce1 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1618284 Tested-by: kokoro <noreply+kokoro@google.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* x86_64: load initrd at max addressDaniel Verkamp2019-05-20
| | | | | | | | | | | | | | | | | This matches behavior of other bootloaders (grub2, iPXE), and the kernel seems to be relying on this; decompression of the initrd fails if the initrd is loaded right after the kernel as before, but succeeds if loaded at the maximum address. BUG=None TEST=Boot Debian kernel + initrd on workstation Change-Id: If7712efb05f55ef413a419dfe276ed3f68c335b7 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1616989 Tested-by: kokoro <noreply+kokoro@google.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* crosvm: add cmdline flags for configuring serial outputs in guest machineTrent Begin2019-05-15
| | | | | | | | | | | | | | | | This change allows an output to be set for each serial device for a guest machine (stdout, syslog, or sink). BUG=chromium:953983 TEST=FEATURES=test emerge-sarien crosvm; cd sys_util; cargo test; ./build_test; manual testing on x86_64 and aarch_64 Change-Id: I9e7fcb0b296c0f8a5aa8d54b1a74ae801f6badc8 Reviewed-on: https://chromium-review.googlesource.com/1572813 Commit-Ready: Trent Begin <tbegin@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Trent Begin <tbegin@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* x86_64: support loading bzImage kernelsDaniel Verkamp2019-05-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | The current kernel loader expects an extracted ELF kernel; this adds complexity to the build and test process for the guest kernel, since the normal output of a Linux kernel build is a bzImage-format kernel. bzImage also supports compressed kernels, which are smaller on disk and potentially quicker to load, depending on disk and CPU speed. Add support for loading of bzImage-format kernels, and use the 64-bit boot protocol as described in the official Linux/x86 boot protocol: https://www.kernel.org/doc/Documentation/x86/boot.txt The existing ELF loader is kept for compatibility with shipping kernel images; if a kernel image doesn't have the ELF signature, it is passed to the bzImage loader as a fallback. BUG=None TEST=Boot bzImage and extracted ELF kernels on x86-64 Change-Id: I90be4cd597d15bc89e63f0f6cbc781c5c8c2eaeb Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1609969 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* Add Android fstab support to aarch64, based on x86_64 versionGreg Hartman2019-05-02
| | | | | | | | | | | Test: cargo test on x86_64 and aarch64, boot on aarch64 Change-Id: I29fb269abedaaca4168581aa7f92d413d51e9232 Reviewed-on: https://chromium-review.googlesource.com/1585279 Commit-Ready: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Greg Hartman <ghartman@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Greg Hartman <ghartman@google.com>
* crosvm: Fix misleading field name in VmComponents struct.Jakub Staron2019-04-29
| | | | | | | | | | | | | | | Renames field memory_mb to memory_size. All usages of this field treat it as a memory size in bytes, not megabytes. BUG=None TEST=cargo check TEST=cargo check --package aarch64 --target aarch64-unknown-linux-gnu Change-Id: I7b1aefe4f0b612d5eeb2987dc2a0fce6db0dd228 Reviewed-on: https://chromium-review.googlesource.com/1585617 Commit-Ready: Jakub Staroń <jstaron@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm: add license blurb to all filesStephen Barber2019-04-24
| | | | | | | | | | | | | | A few files were missing license blurbs at the top, so update them all to include them. BUG=none TEST=none Change-Id: Ida101be2e5c255b8cffeb15f5b93f63bfd1b130b Reviewed-on: https://chromium-review.googlesource.com/1577900 Commit-Ready: Stephen Barber <smbarber@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* Add rudimentary support for SMBIOS 3.0.Philipp Kern2019-04-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SMBIOS allows to pass down system information from the BIOS to the OS. Its information is used on Linux to construct modalias entries for the system in order to facilite module autoloading on specific hardware. Adding it also allows package management software to target specific packages when crosvm is used as the hypervisor (e.g. to pre-install the helper daemons or a special vTPM driver). This change has only been tested with Linux and implements the bare minimum necessary to make a crosvm hypervisor detectable through DMI data. As such it also skips over some required structures like BIOS information that do not technically apply. The result is a hodgepodge of standards: SMBIOS 3.0 provides a convenient 64-bit entrypoint that we implement. However the structures are cut short to SMBIOS 2.0 standards as most of the fields are skipped. Linux deals just fine with this, although some of the dmi/id files in sysfs will be empty as a result. The resulting modalias looks like this: dmi:bvncrosvm:bvr0:bd:svnChromiumOS:pncrosvm:pvr: The kernel prints this as part of startup: SMBIOS 3.2.0 present. DMI: ChromiumOS crosvm, BIOS 0 And for oops/panic: Hardware name: ChromiumOS crosvm, BIOS 0 dmidecode's view on the tables (which uses its own parser): Getting SMBIOS data from sysfs. SMBIOS 3.2.0 present. Table at 0x000F0018. Handle 0x0001, DMI type 0, 20 bytes BIOS Information Vendor: crosvm Version: 0 Release Date: Not Specified ROM Size: 64 kB Characteristics: PCI is supported System is a virtual machine Handle 0x0002, DMI type 1, 27 bytes System Information Manufacturer: ChromiumOS Product Name: crosvm Version: Not Specified Serial Number: Not Specified UUID: Not Settable Wake-up Type: Reserved SKU Number: Not Specified Family: Not Specified TEST=cargo test Change-Id: Ie27105711a9bc14941d387b720da350349dff265 Reviewed-on: https://chromium-review.googlesource.com/1571565 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: Daniel Verkamp <dverkamp@chromium.org>