syscall_emul.hh (10485:5aa65300f44f) syscall_emul.hh (10486:9b848f3813c5)
1/*
2 * Copyright (c) 2012-2013 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

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

826 uint64_t flags = process->getSyscallArg(tc, index);
827 uint64_t provided_address = 0;
828 bool use_provided_address = flags & OS::TGT_MREMAP_FIXED;
829
830 if (use_provided_address)
831 provided_address = process->getSyscallArg(tc, index);
832
833 if ((start % TheISA::PageBytes != 0) ||
1/*
2 * Copyright (c) 2012-2013 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

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

826 uint64_t flags = process->getSyscallArg(tc, index);
827 uint64_t provided_address = 0;
828 bool use_provided_address = flags & OS::TGT_MREMAP_FIXED;
829
830 if (use_provided_address)
831 provided_address = process->getSyscallArg(tc, index);
832
833 if ((start % TheISA::PageBytes != 0) ||
834 (new_length % TheISA::PageBytes != 0) ||
835 (provided_address % TheISA::PageBytes != 0)) {
836 warn("mremap failing: arguments not page aligned");
837 return -EINVAL;
838 }
839
834 (provided_address % TheISA::PageBytes != 0)) {
835 warn("mremap failing: arguments not page aligned");
836 return -EINVAL;
837 }
838
839 new_length = roundUp(new_length, TheISA::PageBytes);
840
840 if (new_length > old_length) {
841 if ((start + old_length) == process->mmap_end &&
842 (!use_provided_address || provided_address == start)) {
843 uint64_t diff = new_length - old_length;
844 process->allocateMem(process->mmap_end, diff);
845 process->mmap_end += diff;
846 return start;
847 } else {

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

1208mmapFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
1209{
1210 int index = 0;
1211 Addr start = p->getSyscallArg(tc, index);
1212 uint64_t length = p->getSyscallArg(tc, index);
1213 index++; // int prot = p->getSyscallArg(tc, index);
1214 int flags = p->getSyscallArg(tc, index);
1215 int tgt_fd = p->getSyscallArg(tc, index);
841 if (new_length > old_length) {
842 if ((start + old_length) == process->mmap_end &&
843 (!use_provided_address || provided_address == start)) {
844 uint64_t diff = new_length - old_length;
845 process->allocateMem(process->mmap_end, diff);
846 process->mmap_end += diff;
847 return start;
848 } else {

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

1209mmapFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
1210{
1211 int index = 0;
1212 Addr start = p->getSyscallArg(tc, index);
1213 uint64_t length = p->getSyscallArg(tc, index);
1214 index++; // int prot = p->getSyscallArg(tc, index);
1215 int flags = p->getSyscallArg(tc, index);
1216 int tgt_fd = p->getSyscallArg(tc, index);
1216 // int offset = p->getSyscallArg(tc, index);
1217 int offset = p->getSyscallArg(tc, index);
1217
1218 if (length > 0x100000000ULL)
1219 warn("mmap length argument %#x is unreasonably large.\n", length);
1220
1221 if (!(flags & OS::TGT_MAP_ANONYMOUS)) {
1222 Process::FdMap *fd_map = p->sim_fd_obj(tgt_fd);
1223 if (!fd_map || fd_map->fd < 0) {
1224 warn("mmap failing: target fd %d is not valid\n", tgt_fd);

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

1229 // This is very likely broken, but leave a warning here
1230 // (rather than panic) in case /dev/zero is known by
1231 // another name on some platform
1232 warn("allowing mmap of file %s; mmap not supported on files"
1233 " other than /dev/zero\n", fd_map->filename);
1234 }
1235 }
1236
1218
1219 if (length > 0x100000000ULL)
1220 warn("mmap length argument %#x is unreasonably large.\n", length);
1221
1222 if (!(flags & OS::TGT_MAP_ANONYMOUS)) {
1223 Process::FdMap *fd_map = p->sim_fd_obj(tgt_fd);
1224 if (!fd_map || fd_map->fd < 0) {
1225 warn("mmap failing: target fd %d is not valid\n", tgt_fd);

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

1230 // This is very likely broken, but leave a warning here
1231 // (rather than panic) in case /dev/zero is known by
1232 // another name on some platform
1233 warn("allowing mmap of file %s; mmap not supported on files"
1234 " other than /dev/zero\n", fd_map->filename);
1235 }
1236 }
1237
1238 length = roundUp(length, TheISA::PageBytes);
1239
1237 if ((start % TheISA::PageBytes) != 0 ||
1240 if ((start % TheISA::PageBytes) != 0 ||
1238 (length % TheISA::PageBytes) != 0) {
1241 (offset % TheISA::PageBytes) != 0) {
1239 warn("mmap failing: arguments not page-aligned: "
1242 warn("mmap failing: arguments not page-aligned: "
1240 "start 0x%x length 0x%x",
1241 start, length);
1243 "start 0x%x offset 0x%x",
1244 start, offset);
1242 return -EINVAL;
1243 }
1244
1245 // are we ok with clobbering existing mappings? only set this to
1246 // true if the user has been warned.
1247 bool clobber = false;
1248
1249 // try to use the caller-provided address if there is one

--- 228 unchanged lines hidden ---
1245 return -EINVAL;
1246 }
1247
1248 // are we ok with clobbering existing mappings? only set this to
1249 // true if the user has been warned.
1250 bool clobber = false;
1251
1252 // try to use the caller-provided address if there is one

--- 228 unchanged lines hidden ---