diff options
author | Andrew Waterman <waterman@cs.berkeley.edu> | 2015-05-28 15:34:13 -0700 |
---|---|---|
committer | Andrew Waterman <waterman@cs.berkeley.edu> | 2015-05-28 15:35:27 -0700 |
commit | 835d03d2160be9ee50ba5fd892554ef62fcb13b8 (patch) | |
tree | dbab432ec00dd3b8397ea5fecba136fa4d4ab23d | |
parent | b2251a985c46fb0399d154557937cd5535f6f1af (diff) | |
download | pk-835d03d2160be9ee50ba5fd892554ef62fcb13b8.zip pk-835d03d2160be9ee50ba5fd892554ef62fcb13b8.tar.gz pk-835d03d2160be9ee50ba5fd892554ef62fcb13b8.tar.bz2 |
"Fix" mremap bug by returning -ENOSYS
mremap was badly broken, and maybe it's not worth the time to fix it.
glibc still seems to work ok, because the malloc implementation handles
mremap failure gracefully (though at a performance cost).
-rw-r--r-- | pk/vm.c | 30 |
1 files changed, 1 insertions, 29 deletions
@@ -330,37 +330,9 @@ uintptr_t do_brk(size_t addr) return addr; } -uintptr_t __do_mremap(uintptr_t addr, size_t old_size, size_t new_size, int flags) -{ - for (size_t i = 0; i < MAX_VMR; i++) - { - if (vmrs[i].refcnt && addr == vmrs[i].addr && old_size == vmrs[i].length) - { - size_t old_npage = (vmrs[i].length-1)/RISCV_PGSIZE+1; - size_t new_npage = (new_size-1)/RISCV_PGSIZE+1; - if (new_size < old_size) - __do_munmap(addr + new_size, old_size - new_size); - else if (new_size > old_size) - __do_mmap(addr + old_size, new_size - old_size, vmrs[i].prot, 0, - vmrs[i].file, vmrs[i].offset + new_size - old_size); - __vmr_decref(&vmrs[i], old_npage - new_npage); - return addr; - } - } - return -1; -} - uintptr_t do_mremap(uintptr_t addr, size_t old_size, size_t new_size, int flags) { - if (((addr | old_size | new_size) & (RISCV_PGSIZE-1)) || - (flags & MREMAP_FIXED)) - return -EINVAL; - - spinlock_lock(&vm_lock); - uintptr_t res = __do_mremap(addr, old_size, new_size, flags); - spinlock_unlock(&vm_lock); - - return res; + return -ENOSYS; } uintptr_t do_mprotect(uintptr_t addr, size_t length, int prot) |