syscall_emul.hh (8600:b0d7c64ada19) syscall_emul.hh (8601:af28085882dc)
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 663 unchanged lines hidden (view full) ---

672 (new_length % TheISA::VMPageSize != 0)) {
673 warn("mremap failing: arguments not page aligned");
674 return -EINVAL;
675 }
676
677 if (new_length > old_length) {
678 if ((start + old_length) == process->mmap_end) {
679 uint64_t diff = new_length - old_length;
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 663 unchanged lines hidden (view full) ---

672 (new_length % TheISA::VMPageSize != 0)) {
673 warn("mremap failing: arguments not page aligned");
674 return -EINVAL;
675 }
676
677 if (new_length > old_length) {
678 if ((start + old_length) == process->mmap_end) {
679 uint64_t diff = new_length - old_length;
680 process->pTable->allocate(process->mmap_end, diff);
680 process->allocateMem(process->mmap_end, diff);
681 process->mmap_end += diff;
682 return start;
683 } else {
684 // sys/mman.h defined MREMAP_MAYMOVE
685 if (!(flags & 1)) {
686 warn("can't remap here and MREMAP_MAYMOVE flag not set\n");
687 return -ENOMEM;
688 } else {
689 process->pTable->remap(start, old_length, process->mmap_end);
690 warn("mremapping to totally new vaddr %08p-%08p, adding %d\n",
691 process->mmap_end, process->mmap_end + new_length, new_length);
692 start = process->mmap_end;
693 // add on the remaining unallocated pages
681 process->mmap_end += diff;
682 return start;
683 } else {
684 // sys/mman.h defined MREMAP_MAYMOVE
685 if (!(flags & 1)) {
686 warn("can't remap here and MREMAP_MAYMOVE flag not set\n");
687 return -ENOMEM;
688 } else {
689 process->pTable->remap(start, old_length, process->mmap_end);
690 warn("mremapping to totally new vaddr %08p-%08p, adding %d\n",
691 process->mmap_end, process->mmap_end + new_length, new_length);
692 start = process->mmap_end;
693 // add on the remaining unallocated pages
694 process->pTable->allocate(start + old_length, new_length - old_length);
694 process->allocateMem(start + old_length,
695 new_length - old_length);
695 process->mmap_end += new_length;
696 warn("returning %08p as start\n", start);
697 return start;
698 }
699 }
700 } else {
696 process->mmap_end += new_length;
697 warn("returning %08p as start\n", start);
698 return start;
699 }
700 }
701 } else {
701 process->pTable->deallocate(start + new_length, old_length -
702 new_length);
702 process->pTable->unmap(start + new_length, old_length - new_length);
703 return start;
704 }
705}
706
707/// Target stat() handler.
708template <class OS>
709SyscallReturn
710statFunc(SyscallDesc *desc, int callnum, LiveProcess *process,

--- 349 unchanged lines hidden (view full) ---

1060 start = p->mmap_end - length;
1061 p->mmap_end = start;
1062 } else {
1063 start = p->mmap_end;
1064 p->mmap_end += length;
1065 }
1066 }
1067
703 return start;
704 }
705}
706
707/// Target stat() handler.
708template <class OS>
709SyscallReturn
710statFunc(SyscallDesc *desc, int callnum, LiveProcess *process,

--- 349 unchanged lines hidden (view full) ---

1060 start = p->mmap_end - length;
1061 p->mmap_end = start;
1062 } else {
1063 start = p->mmap_end;
1064 p->mmap_end += length;
1065 }
1066 }
1067
1068 p->pTable->allocate(start, length, clobber);
1068 p->allocateMem(start, length, clobber);
1069
1070 return start;
1071}
1072
1073/// Target getrlimit() handler.
1074template <class OS>
1075SyscallReturn
1076getrlimitFunc(SyscallDesc *desc, int callnum, LiveProcess *process,

--- 188 unchanged lines hidden ---
1069
1070 return start;
1071}
1072
1073/// Target getrlimit() handler.
1074template <class OS>
1075SyscallReturn
1076getrlimitFunc(SyscallDesc *desc, int callnum, LiveProcess *process,

--- 188 unchanged lines hidden ---