Commit graph

10 commits

Author SHA1 Message Date
Dylan Reid
fedb675ed5 x85: mptable: Move the mptable to the end of base RAM
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
2017-11-21 15:58:40 -08:00
Dylan Reid
5327d059a2 mptable: Fix range check and unit tests
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>
2017-11-17 20:18:24 -08:00
Slava Malyugin
15ac873218 crosvm: fix MPTable, enable apic
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>
2017-11-15 20:21:05 -08:00
Dylan Reid
70a8290514 Fix new warning with rust 1.21
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>
2017-10-13 14:45:07 -07:00
Dylan Reid
0584fe9fb2 Limit types that can be read from guest memory
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>
2017-06-27 00:20:33 -07:00
Dylan Reid
b2ae5fabd3 x86_64: Remove extra closure args and double-derefs
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>
2017-05-29 21:49:05 -07:00
Zach Reizner
664bbcb970 x86_64: add multi-cpu setup support
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>
2017-05-25 22:51:15 -07:00
Dylan Reid
d4eaa4056f sys_util: Add guest_memory
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
2017-05-25 22:51:14 -07:00
Dylan Reid
67030be903 x86_64: Add x86_64 setup code
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>
2017-05-12 20:58:07 -07:00
Dylan Reid
abd3707450 x86_64: Add bootparams.rs
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>
2017-05-11 22:27:38 -07:00