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; --- 975 unchanged lines hidden (view full) --- 984} 985 986 987/// Target mmap() handler. 988/// 989/// We don't really handle mmap(). If the target is mmaping an 990/// anonymous region or /dev/zero, we can get away with doing basically 991/// nothing (since memory is initialized to zero and the simulator |
992/// doesn't really check addresses anyway). 993/// |
994template <class OS> 995SyscallReturn 996mmapFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc) 997{ 998 int index = 0; 999 Addr start = p->getSyscallArg(tc, index); 1000 uint64_t length = p->getSyscallArg(tc, index); 1001 index++; // int prot = p->getSyscallArg(tc, index); 1002 int flags = p->getSyscallArg(tc, index); |
1003 int tgt_fd = p->getSyscallArg(tc, index); |
1004 // int offset = p->getSyscallArg(tc, index); 1005 |
1006 if (!(flags & OS::TGT_MAP_ANONYMOUS)) { 1007 Process::FdMap *fd_map = p->sim_fd_obj(tgt_fd); 1008 if (!fd_map || fd_map->fd < 0) { 1009 warn("mmap failing: target fd %d is not valid\n", tgt_fd); 1010 return -EBADF; 1011 } |
1012 |
1013 if (fd_map->filename != "/dev/zero") { 1014 // This is very likely broken, but leave a warning here 1015 // (rather than panic) in case /dev/zero is known by 1016 // another name on some platform 1017 warn("allowing mmap of file %s; mmap not supported on files" 1018 " other than /dev/zero\n", fd_map->filename); 1019 } 1020 } 1021 |
1022 if ((start % TheISA::VMPageSize) != 0 || 1023 (length % TheISA::VMPageSize) != 0) { 1024 warn("mmap failing: arguments not page-aligned: " 1025 "start 0x%x length 0x%x", 1026 start, length); 1027 return -EINVAL; 1028 } 1029 --- 7 unchanged lines hidden (view full) --- 1037 start = p->mmap_end - length; 1038 p->mmap_end = start; 1039 } else { 1040 start = p->mmap_end; 1041 p->mmap_end += length; 1042 } 1043 p->pTable->allocate(start, length); 1044 |
1045 return start; 1046} 1047 1048/// Target getrlimit() handler. 1049template <class OS> 1050SyscallReturn 1051getrlimitFunc(SyscallDesc *desc, int callnum, LiveProcess *process, 1052 ThreadContext *tc) --- 187 unchanged lines hidden --- |