summaryrefslogtreecommitdiff
path: root/linux-user/main.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@twiddle.net>2010-03-10 15:39:07 -0800
committerPaul Brook <paul@codesourcery.com>2010-03-12 16:29:18 +0000
commit14f24e1465edc44b9b4d89fbbea66e06088154e1 (patch)
treea4d7af58d82337b45a4566a5c3f7d3d15b18a584 /linux-user/main.c
parent7bc7b099dfa38a856b1bc892c0f9f3d6fe28e170 (diff)
downloadqemu-14f24e1465edc44b9b4d89fbbea66e06088154e1.tar.gz
linux-user: Fix mmap_find_vma returning invalid addresses.
Don't return addresses that aren't properly aligned for the guest, e.g. when the guest has a larger page size than the host. Don't return addresses that are outside the virtual address space for the target, by paying proper attention to the h2g/g2h macros. At the same time, place the default mapping base for 64-bit guests (on 64-bit hosts) outside the low 4G. Consistently interpret mmap_next_start in the guest address space. Signed-off-by: Richard Henderson <rth@twiddle.net>
Diffstat (limited to 'linux-user/main.c')
-rw-r--r--linux-user/main.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/linux-user/main.c b/linux-user/main.c
index eeae22e2bf..4614e3c9f9 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -39,8 +39,8 @@
char *exec_path;
int singlestep;
-#if defined(CONFIG_USE_GUEST_BASE)
unsigned long mmap_min_addr;
+#if defined(CONFIG_USE_GUEST_BASE)
unsigned long guest_base;
int have_guest_base;
#endif
@@ -2812,16 +2812,14 @@ int main(int argc, char **argv, char **envp)
* proper page alignment for guest_base.
*/
guest_base = HOST_PAGE_ALIGN(guest_base);
+#endif /* CONFIG_USE_GUEST_BASE */
/*
* Read in mmap_min_addr kernel parameter. This value is used
* When loading the ELF image to determine whether guest_base
- * is needed.
- *
- * When user has explicitly set the quest base, we skip this
- * test.
+ * is needed. It is also used in mmap_find_vma.
*/
- if (!have_guest_base) {
+ {
FILE *fp;
if ((fp = fopen("/proc/sys/vm/mmap_min_addr", "r")) != NULL) {
@@ -2833,7 +2831,6 @@ int main(int argc, char **argv, char **envp)
fclose(fp);
}
}
-#endif /* CONFIG_USE_GUEST_BASE */
/*
* Prepare copy of argv vector for target.