sim: mmap: correct behavior for fixed address
authorMichael Adler <Michael.Adler@intel.com>
Mon, 20 Oct 2014 21:45:08 +0000 (16:45 -0500)
committerMichael Adler <Michael.Adler@intel.com>
Mon, 20 Oct 2014 21:45:08 +0000 (16:45 -0500)
Change mmap fixed address request to return an error if the mapping is
impossible due to conflict instead of what I believe used to be silent
corruption.

Committed by: Nilay Vaish <nilay@cs.wisc.edu>

src/sim/syscall_emul.hh

index a106a1939bb83b093f1815163c5ecfd00a6859f5..034a7043b656e79b5f49695709dfbcc85f584d5b 100644 (file)
@@ -1256,10 +1256,8 @@ mmapFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
             // whether we clobber them or not depends on whether the caller
             // specified MAP_FIXED
             if (flags & OS::TGT_MAP_FIXED) {
-                // MAP_FIXED specified: clobber existing mappings
-                warn("mmap: MAP_FIXED at 0x%x overwrites existing mappings\n",
-                     start);
-                clobber = true;
+                // MAP_FIXED specified: map attempt fails
+                return -EINVAL;
             } else {
                 // MAP_FIXED not specified: ignore suggested start address
                 warn("mmap: ignoring suggested map address 0x%x\n", start);