summary refs log tree commit diff
path: root/x86_64/src
diff options
context:
space:
mode:
authorDylan Reid <dgreid@chromium.org>2018-08-08 16:11:09 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-08-09 02:21:31 -0700
commit2dd78797d76245a45cc34a841150a170a0a22557 (patch)
treea0c66f74d5c0b9b6dad462befc5a5c9d72cead27 /x86_64/src
parentebd56813e189de4a2d2bad2699bc07b56e580035 (diff)
downloadcrosvm-2dd78797d76245a45cc34a841150a170a0a22557.tar
crosvm-2dd78797d76245a45cc34a841150a170a0a22557.tar.gz
crosvm-2dd78797d76245a45cc34a841150a170a0a22557.tar.bz2
crosvm-2dd78797d76245a45cc34a841150a170a0a22557.tar.lz
crosvm-2dd78797d76245a45cc34a841150a170a0a22557.tar.xz
crosvm-2dd78797d76245a45cc34a841150a170a0a22557.tar.zst
crosvm-2dd78797d76245a45cc34a841150a170a0a22557.zip
x86_64: Don't allocate addrs in the 32 bit gap
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>
Diffstat (limited to 'x86_64/src')
-rw-r--r--x86_64/src/lib.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/x86_64/src/lib.rs b/x86_64/src/lib.rs
index f78632d..32f9a0c 100644
--- a/x86_64/src/lib.rs
+++ b/x86_64/src/lib.rs
@@ -305,10 +305,11 @@ impl arch::LinuxArch for X8664arch {
     ///
     /// * `mem_size` - the size in bytes of physical ram for the guest
     fn get_base_dev_pfn(mem_size: u64) -> u64 {
-        // Put device memory at nearest 2MB boundary after physical memory
+        // Put device memory at a 2MB boundary after physical memory or 4gb, whichever is greater.
         const MB: u64 = 1024 * 1024;
+        const GB: u64 = 1024 * MB;
         let mem_size_round_2mb = (mem_size + 2*MB - 1) / (2*MB) * (2*MB);
-        mem_size_round_2mb / sys_util::pagesize() as u64
+        std::cmp::max(mem_size_round_2mb, 4 * GB) / sys_util::pagesize() as u64
     }
 
     /// This returns a minimal kernel command for this architecture