-#ifdef DEBUG_MMAP
- {
- printf("mmap: start=0x" TARGET_FMT_lx
- " len=0x" TARGET_FMT_lx " prot=%c%c%c flags=",
- start, len,
- prot & PROT_READ ? 'r' : '-',
- prot & PROT_WRITE ? 'w' : '-',
- prot & PROT_EXEC ? 'x' : '-');
- if (flags & MAP_FIXED)
- printf("MAP_FIXED ");
- if (flags & MAP_ANON)
- printf("MAP_ANON ");
- switch (flags & TARGET_BSD_MAP_FLAGMASK) {
- case MAP_PRIVATE:
- printf("MAP_PRIVATE ");
- break;
- case MAP_SHARED:
- printf("MAP_SHARED ");
- break;
- default:
- printf("[MAP_FLAGMASK=0x%x] ", flags & TARGET_BSD_MAP_FLAGMASK);
- break;
- }
- printf("fd=%d offset=" TARGET_FMT_lx "\n", fd, offset);
+ if (qemu_loglevel_mask(CPU_LOG_PAGE)) {
+ qemu_log("mmap: start=0x" TARGET_ABI_FMT_lx
+ " len=0x" TARGET_ABI_FMT_lx " prot=%c%c%c flags=",
+ start, len,
+ prot & PROT_READ ? 'r' : '-',
+ prot & PROT_WRITE ? 'w' : '-',
+ prot & PROT_EXEC ? 'x' : '-');
+ if (flags & MAP_ALIGNMENT_MASK) {
+ qemu_log("MAP_ALIGNED(%u) ",
+ (flags & MAP_ALIGNMENT_MASK) >> MAP_ALIGNMENT_SHIFT);
+ }
+ if (flags & MAP_GUARD) {
+ qemu_log("MAP_GUARD ");
+ }
+ if (flags & MAP_FIXED) {
+ qemu_log("MAP_FIXED ");
+ }
+ if (flags & MAP_ANON) {
+ qemu_log("MAP_ANON ");
+ }
+ if (flags & MAP_EXCL) {
+ qemu_log("MAP_EXCL ");
+ }
+ if (flags & MAP_PRIVATE) {
+ qemu_log("MAP_PRIVATE ");
+ }
+ if (flags & MAP_SHARED) {
+ qemu_log("MAP_SHARED ");
+ }
+ if (flags & MAP_NOCORE) {
+ qemu_log("MAP_NOCORE ");
+ }
+ if (flags & MAP_STACK) {
+ qemu_log("MAP_STACK ");
+ }
+ qemu_log("fd=%d offset=0x%lx\n", fd, offset);
+ }
+
+ if ((flags & MAP_ANON) && fd != -1) {
+ errno = EINVAL;
+ goto fail;
+ }
+ if (flags & MAP_STACK) {
+ if ((fd != -1) || ((prot & (PROT_READ | PROT_WRITE)) !=
+ (PROT_READ | PROT_WRITE))) {
+ errno = EINVAL;
+ goto fail;
+ }
+ }
+ if ((flags & MAP_GUARD) && (prot != PROT_NONE || fd != -1 ||
+ offset != 0 || (flags & (MAP_SHARED | MAP_PRIVATE |
+ /* MAP_PREFAULT | */ /* MAP_PREFAULT not in mman.h */
+ MAP_PREFAULT_READ | MAP_ANON | MAP_STACK)) != 0)) {
+ errno = EINVAL;
+ goto fail;