The first patch in the series fixes a major think-o in the sparc port. The 64 and 32-bit constants were reversed. Fixing these are required to avoid a build error in later patches.
For the actual problem, introduce a guest_start_len_valid macro similar to the existing h2g_valid macro, where we compare the address range against TARGET_VIRT_ADDR_SPACE_BITS (or ULONG_MAX, depending on the host). Use this in 3 places in the linux-user memory handling functions, and also in the generic page_check_range. In the later case, also remove a mis-conception that I had that page_check_range was already bounds checked -- these values come directly from a guest syscall and so can contain any random errant values. r~ Richard Henderson (7): target-sparc: Fix TARGET_{PHYS,VIRT}_ADDR_SPACE_BITS. Add guest_start_len_valid function. linux-user: Use guest_start_len_valid in msync. linux-user: Use guest_start_len_valid in mremap. linux-user: Use guest_start_len_valid in mmap. Fix zero-length write(2). Use guest_start_len_valid in page_check_range. cpu-all.h | 10 ++++++++ exec.c | 12 +++------ linux-user/mmap.c | 65 +++++++++++++++++++++++++++------------------------ target-sparc/cpu.h | 12 ++++---- 4 files changed, 54 insertions(+), 45 deletions(-)