From 8039c6cacb5f4627b6085cda1e5c8db8ef70b9d6 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Sun, 13 Nov 2016 17:52:34 -0800 Subject: For RV32, mmap offset is in 4 KiB increments --- pk/syscall.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pk/syscall.c b/pk/syscall.c index c5f650c..e6b2454 100644 --- a/pk/syscall.c +++ b/pk/syscall.c @@ -320,8 +320,12 @@ int sys_getuid() uintptr_t sys_mmap(uintptr_t addr, size_t length, int prot, int flags, int fd, off_t offset) { - uintptr_t ret = do_mmap(addr, length, prot, flags, fd, offset); - return ret; +#ifdef __riscv32 + if (offset != (offset << 12 >> 12)) + return -ENXIO; + offset <<= 12; +#endif + return do_mmap(addr, length, prot, flags, fd, offset); } int sys_munmap(uintptr_t addr, size_t length) -- cgit v1.1