diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 6163f1a0d1..4bcfaf7894 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -1029,9 +1029,9 @@ static int mmap_reserve_or_unmap(abi_ulong start, abi_ulong len) void *host_start; int prot; - last = start + len - 1; + last = ROUND_UP(start + len, TARGET_PAGE_SIZE) - 1; real_start = start & -host_page_size; - real_last = ROUND_UP(last, host_page_size) - 1; + real_last = ROUND_UP(last + 1, host_page_size) - 1; /* * If guest pages remain on the first or last host pages,