From: Warner Losh <imp@FreeBSD.org>
Update the reserved base based on what platform we're on, as well as the
start of the mmap range. Update routines that find va ranges to interact
with the reserved ranges as well as properly align the mapping (this is
especially important for targets whose page size does not match the
host's). Loop where appropriate when the initial address space offered
by mmap does not meet the contraints.
Signed-off-by: Mikaƫl Urankar <mikael.urankar@gmail.com>
Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
bsd-user/main.c | 23 ++-
bsd-user/mmap.c | 372 ++++++++++++++++++++++++++++++++++++++++--------
bsd-user/qemu.h | 5 +-
3 files changed, 335 insertions(+), 65 deletions(-)
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 93ef9298b8..36852604f8 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -49,12 +49,29 @@
#include "target_arch_cpu.h"
int singlestep;
-unsigned long mmap_min_addr;
uintptr_t guest_base;
static const char *cpu_model;
static const char *cpu_type;
bool have_guest_base;
+#if (TARGET_LONG_BITS == 32) && (HOST_LONG_BITS == 64)
+/*
+ * When running 32-on-64 we should make sure we can fit all of the possible
+ * guest address space into a contiguous chunk of virtual host memory.
+ *
+ * This way we will never overlap with our own libraries or binaries or stack
+ * or anything else that QEMU maps.
+ */
+# ifdef TARGET_MIPS
+/* MIPS only supports 31 bits of virtual address space for user space */
+unsigned long reserved_va = 0x77000000;
+# elif defined(TARGET_PPC64)
+unsigned long reserved_va = 0xfffff000;
+# else
+unsigned long reserved_va = 0xf7000000;
+# endif
+#else
unsigned long reserved_va;
+#endif