diff -r e6347e559e8f src/sim/syscall_emul.hh --- a/src/sim/syscall_emul.hh Tue Feb 19 12:57:47 2013 -0500 +++ b/src/sim/syscall_emul.hh Fri Feb 22 11:42:58 2013 -0600 @@ -753,8 +753,10 @@ uint64_t new_length = process->getSyscallArg(tc, index); uint64_t flags = process->getSyscallArg(tc, index); - if ((start % TheISA::VMPageSize != 0) || - (new_length % TheISA::VMPageSize != 0)) { + new_length += (TheISA::VMPageSize - 1); + new_length &= ~(TheISA::VMPageSize - 1); + + if ((start % TheISA::VMPageSize != 0)) { warn("mremap failing: arguments not page aligned"); return -EINVAL; } @@ -1086,7 +1088,7 @@ index++; // int prot = p->getSyscallArg(tc, index); int flags = p->getSyscallArg(tc, index); int tgt_fd = p->getSyscallArg(tc, index); - // int offset = p->getSyscallArg(tc, index); + int offset = p->getSyscallArg(tc, index); if (length > 0x100000000ULL) warn("mmap length argument %#x is unreasonably large.\n", length); @@ -1107,11 +1109,14 @@ } } + length += (TheISA::VMPageSize - 1); + length &= ~(TheISA::VMPageSize - 1); + if ((start % TheISA::VMPageSize) != 0 || - (length % TheISA::VMPageSize) != 0) { + (offset % TheISA::VMPageSize) != 0) { warn("mmap failing: arguments not page-aligned: " - "start 0x%x length 0x%x", - start, length); + "start 0x%x offset 0x%x", + start, offset); return -EINVAL; }