Skip to content

Commit 4f243e1

Browse files
vineetgarcxxkent
authored andcommitted
ARCv3: fix mmap
In 64-bit regime, glibc passes the actual offset in mmap, and not the page index (due to historical size_t limitations). core kernel mmap deals with page indexes only so need to convert before calling core. Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
1 parent 879036b commit 4f243e1

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

arch/arc/include/uapi/asm/unistd.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@
3030
#define __ARCH_WANT_STAT64
3131
#endif
3232

33-
#ifdef __LP64__
34-
#define sys_mmap sys_mmap_pgoff
35-
#else
36-
#define sys_mmap2 sys_mmap_pgoff
37-
#endif
38-
3933
#include <asm-generic/unistd.h>
4034

4135
#define NR_syscalls __NR_syscalls

arch/arc/kernel/sys.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,33 @@
55
#include <linux/unistd.h>
66

77
#include <asm/syscalls.h>
8+
#include <asm/syscall.h>
89

910
#define sys_clone sys_clone_wrapper
1011
#define sys_clone3 sys_clone3_wrapper
1112

13+
#ifdef CONFIG_64BIT
14+
SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len,
15+
unsigned long, prot, unsigned long, flags,
16+
unsigned long, fd, off_t, off)
17+
{
18+
if (offset_in_page(off) != 0)
19+
return -EINVAL;
20+
21+
return ksys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
22+
}
23+
#else
24+
SYSCALL_DEFINE6(mmap2, unsigned long, addr, unsigned long, len,
25+
unsigned long, prot, unsigned long, flags,
26+
unsigned long, fd, unsigned long, off)
27+
{
28+
if (offset_in_page(off) != 0)
29+
return -EINVAL;
30+
31+
return ksys_mmap_pgoff(addr, len, prot, flags, fd, off);
32+
}
33+
#endif
34+
1235
#undef __SYSCALL
1336
#define __SYSCALL(nr, call) [nr] = (call),
1437

arch/arc/mm/mmap.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
7171
info.low_limit = mm->mmap_base;
7272
info.high_limit = TASK_SIZE;
7373
info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
74+
#ifndef CONFIG_64BIT
7475
info.align_offset = pgoff << PAGE_SHIFT;
76+
#endif
7577
return vm_unmapped_area(&info);
7678
}

0 commit comments

Comments
 (0)