mmap: Round up map size by pagesize when specified MAP_HUGETLB

To match the behavior of Linux.

Change-Id: I7bcc2cb3c1e678ffc28f6b825c7a55032441dded
This commit is contained in:
Ken Sato
2019-09-25 22:19:57 +09:00
committed by Masamichi Takagi
parent edd3ea0103
commit 37ea770f8c
2 changed files with 6 additions and 2 deletions

View File

@ -1934,7 +1934,7 @@ SYSCALL_DECLARE(mmap)
;
const uintptr_t addr0 = ihk_mc_syscall_arg0(ctx);
const size_t len0 = ihk_mc_syscall_arg1(ctx);
size_t len0 = ihk_mc_syscall_arg1(ctx);
const int prot = ihk_mc_syscall_arg2(ctx);
const int flags0 = ihk_mc_syscall_arg3(ctx);
const int fd = ihk_mc_syscall_arg4(ctx);
@ -1993,6 +1993,8 @@ SYSCALL_DECLARE(mmap)
goto out;
}
pgsize = (size_t)1 << ((flags >> MAP_HUGE_SHIFT) & 0x3F);
/* Round-up map length by pagesize */
len0 = ALIGN(len0, pgsize);
if (rusage_check_overmap(len0,
(flags >> MAP_HUGE_SHIFT) & 0x3F)) {

View File

@ -1668,7 +1668,7 @@ SYSCALL_DECLARE(mmap)
;
const uintptr_t addr0 = ihk_mc_syscall_arg0(ctx);
const size_t len0 = ihk_mc_syscall_arg1(ctx);
size_t len0 = ihk_mc_syscall_arg1(ctx);
const int prot = ihk_mc_syscall_arg2(ctx);
const int flags0 = ihk_mc_syscall_arg3(ctx);
const int fd = ihk_mc_syscall_arg4(ctx);
@ -1725,6 +1725,8 @@ SYSCALL_DECLARE(mmap)
}
pgsize = (size_t)1 << ((flags >> MAP_HUGE_SHIFT) & 0x3F);
/* Round-up map length by pagesize */
len0 = ALIGN(len0, pgsize);
if (rusage_check_overmap(len0,
(flags >> MAP_HUGE_SHIFT) & 0x3F)) {