From 14f24e1465edc44b9b4d89fbbea66e06088154e1 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Wed, 10 Mar 2010 15:39:07 -0800 Subject: 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 --- linux-user/main.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'linux-user/main.c') 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. -- cgit v1.2.3-55-g7522