summary refs log tree commit diff
path: root/x86_64/src
Commit message (Collapse)AuthorAge
* 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>
* x86_64: improve documentation for cpuid vendorMike Frysinger2018-03-21
| | | | | | | | | | | | BUG=None TEST=None Change-Id: Id274c361d10be00d5d7279765a2e90ad5ecb4112 Reviewed-on: https://chromium-review.googlesource.com/974314 Commit-Ready: Mike Frysinger <vapier@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm: create a LinuxArch trait and use it for x86Sonny Rao2018-03-15
| | | | | | | | | | | | | | | | | | | | | This creates a trait that different architectures can implement to support running Linux VMs. In the implementation on X86 we remove some error and return errors from lower-level modules as appropriate. These modules now implement the Error trait so we can get meaningful descriptions without an extra error from the calling function. This still keeps all the ifdefs in linux.rs for now until we have another implementation to use for ARM. BUG=chromium:797868 TEST=./build_test passes on all architectures TEST=crosvm runs on caroline Change-Id: If24bcc83e25f9127d6aea68f9272e639296aad8b Reviewed-on: https://chromium-review.googlesource.com/952368 Commit-Ready: Sonny Rao <sonnyrao@chromium.org> Tested-by: Sonny Rao <sonnyrao@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* x86_64: implement error traitSonny Rao2018-03-14
| | | | | | | | | | | | | | This is useful for describing errors that we pass up. BUG=chromium:797868 TEST=build_tests passes on all architectures TEST=crosvm runs on caroline Change-Id: Ied456015e74830d3f1f465fca1151682c9148eb5 Reviewed-on: https://chromium-review.googlesource.com/961603 Commit-Ready: Sonny Rao <sonnyrao@chromium.org> Tested-by: Sonny Rao <sonnyrao@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm: move x86_64 arch specific stuff into the x86_64 crateSonny Rao2018-03-02
| | | | | | | | | | | | | | | | | This is in preparation to make different architectures implement a trait, but for now it's just moving code out of linux.rs and into x86_64 trait. A few new functions were required which will become part of the trait interface. There's still a lot of ugly ifdefs everywhere that should go away in subsequent CLs. BUG=chromium:797868 TEST=./build_test TEST=run crosvm on caroline Change-Id: Ifc95d4eb84f64ebacb4481a172524d94dc96b7bb Signed-off-by: Sonny Rao <sonnyrao@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/942084 Reviewed-by: Zach Reizner <zachr@chromium.org>
* x86_64: implement error trait for sub-modules in x86_64 crateSonny Rao2018-02-27
| | | | | | | | | | | | | | | | | Implement the std::error::Error Trait for Error types within the x86_64 crate. We will make use of these implementations later on when we are using the architecture Trait to pass architecture-specific errors up with meaningful descriptions. BUG=chromium:797868 TEST=./build_test passes on all architectures TEST=crosvm runs on caroline Change-Id: I7a30db69437990608e3a0f5e6e3a200ef6c2d0c3 Reviewed-on: https://chromium-review.googlesource.com/932976 Commit-Ready: Sonny Rao <sonnyrao@chromium.org> Tested-by: Sonny Rao <sonnyrao@chromium.org> Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
* kvm: do not pass max number of cpuid entries in get_supported_cpuid()Dmitry Torokhov2018-02-27
| | | | | | | | | | | | | | It does not make sense to have users of the API limit number of cpuid entries retrieved. Just have KVM select reasonable upper limit and return the true number. TEST=cargo test --features plugin; cargo test -p kvm BUG=chromium:800626 Change-Id: I8ab7e8d901bc408d17c23bfe798d89f921488673 Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/933242 Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm: disable reliance on support of 1GB pagesSlava Malyugin2018-02-26
| | | | | | | | | | | | | | | | | | The initalization code in crosvm used two-level page table in long mode, with last entry covering 1GB. This assumed presence of 1GB pages support ('pdpe1gb' in /proc/cpuinfo). Some CPUs don't have it. BUG=none TEST=reproduced bug on Celeron N3150 (Braswell), verified VM boots on it with fix Change-Id: I6014c7ea236d8daf95e9f09b68beb7935a267aa3 Reviewed-on: https://chromium-review.googlesource.com/936323 Commit-Ready: Slava Malyugin <slavamn@chromium.org> Tested-by: Slava Malyugin <slavamn@chromium.org> Reviewed-by: Slava Malyugin <slavamn@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* crosvm: change GuestAddress to always be a u64Sonny Rao2018-02-01
| | | | | | | | | | | | | | | We want to be able to run 64-bit ARM kernels using a 32-bit version of crosvm, to make it more consistent use a u64 to represent GuestAddress. BUG=chromium:797868 TEST=./build_test passes on all architectures TEST=crosvm runs on caroline Change-Id: I43bf993592caf46891e3e5e05258ab70b6bf3045 Signed-off-by: Sonny Rao <sonnyrao@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/896398 Reviewed-by: Dylan Reid <dgreid@chromium.org>
* x85: mptable: Move the mptable to the end of base RAMDylan Reid2017-11-21
| | | | | | | | | | | Recent Linux kernel's fail to start if the mptable is at the start of RAM (address 0x00). Avoid putting the mptable there so that crosvm can boot 4.14+ kernels. The kernel scans the last kilobyte of RAM after the first, move the mptable there. Change-Id: Ia00f49e7a4cbd0fb3719c21b757e8fdca65584e8 Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/780045
* mptable: Fix range check and unit testsDylan Reid2017-11-17
| | | | | | | | | | | | The table grew with the addition of the 16 mpc_intsrc structures. Correct the `compute_mp_size` function, the end check, and add a unit test for the not having enough memory. Change-Id: I1ff268629a47a422f50aefef9d6aa95121b94d59 Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/777710 Reviewed-by: Slava Malyugin <slavamn@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm: fix MPTable, enable apicSlava Malyugin2017-11-15
| | | | | | | | | | | | | | The mptable inherited from kvmtool had some missing pieces. On top of that, crosvm does not use KVM_SET_GSI_ROUTING. The addresses makes mptable match the default routing in host kernel and removes "noapic". TEST=cargo build (--release). tatl boot tested on 4.4.0 and 4.4.9 Change-Id: Ibc55abf245cd9d8fca601da204d5a189321c09c7 Reviewed-on: https://chromium-review.googlesource.com/772820 Commit-Ready: Slava Malyugin <slavamn@google.com> Tested-by: Slava Malyugin <slavamn@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* Fix new warning with rust 1.21Dylan Reid2017-10-13
| | | | | | | | | | | Mutable references being declared mutable themselves is unnecessary and now generates a warning. Change-Id: I29c7652fb86e17a8eda21efc728dd09b726c304f Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/717733 Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* Limit types that can be read from guest memoryDylan Reid2017-06-27
| | | | | | | | | | | | | | | | | | | | Not all types are safe to read from guest memory. Any type with a reference or pointer will be initialized to random bits that don't refer to a valid address. This can cause dangling pointer and general unsafe behavior. To fix this, limit types that can be read with read_obj to those that implement the unsafe trait `DataInit`. Provide implementations of `DataInit` for intrinsic types that are obviously safe to initialize with random data. Implement the needed traits for bootparam types as they are read from the kernel image directly. Change-Id: I1040f5bc1b2fc4c58c87d8a2ce3f618edcf6f9b1 Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/540750 Reviewed-by: Zach Reizner <zachr@chromium.org>
* x86_64: Remove extra closure args and double-derefsDylan Reid2017-05-29
| | | | | | | | | | | | | A few places were passing a reference to a reference, which just gets compiled out anyways. Some other places where passing `|e| ErrorName(e)` as a closure when just `ErrorName` would be more succinct. Change-Id: Ic097a81b956ef82b29fc1a15196c245bee61c251 Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/510782 Reviewed-by: Zach Reizner <zachr@chromium.org>
* x86_64: add multi-cpu setup supportZach Reizner2017-05-25
| | | | | | | | | | | | | | | | This change includes support for setting up the Intel MP Spec v1.4 table necessary for emulating multiprocessor x86 systems. BUG=None TEST=cargo test Change-Id: I02ffce49dc9eecfc98f56e5bc6ac009b3e680e27 Reviewed-on: https://chromium-review.googlesource.com/514349 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Tested-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* sys_util: Add guest_memoryDylan Reid2017-05-25
| | | | | | | | | | | | | | Add a module for accessing guest memory. This module will replace all the slices that are used to access it currently as those slices aren't valid because the memory is volatile and a volatile slice doesn't exist in rust. Modify the existing users so they no longer depend on the deprecated slice access. Change-Id: Ic0e86dacf66f68bd88ed9cc197cb14e45ada891d Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/509919
* x86_64: Add x86_64 setup codeDylan Reid2017-05-12
| | | | | | | | | Change-Id: Ibdf83f8efcc92bf1f45ed9a5f95117fd9ae3ad5a Reviewed-on: https://chromium-review.googlesource.com/483868 Commit-Ready: Dylan Reid <dgreid@chromium.org> Tested-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* x86_64: Add bootparams.rsDylan Reid2017-05-11
created from bindgen bootparams.h then run rustfmt Change-Id: I46fde6aefefb13db5f5bd79378eb17598cf890ec Reviewed-on: https://chromium-review.googlesource.com/490908 Commit-Ready: Dylan Reid <dgreid@chromium.org> Tested-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>