Index: lib/msan/msan.h =================================================================== --- lib/msan/msan.h +++ lib/msan/msan.h @@ -42,15 +42,28 @@ #if SANITIZER_LINUX && defined(__mips64) -// Everything is above 0x00e000000000. +// MIPS64 maps: +// - 0x0100000000-0x0200000000: Program own segments +// - 0xa000000000-0xc000000000: PIE program segments +// - 0xe000000000-0xffffffffff: libraries segments. const MappingDesc kMemoryLayout[] = { - {0x000000000000ULL, 0x00a000000000ULL, MappingDesc::INVALID, "invalid"}, - {0x00a000000000ULL, 0x00c000000000ULL, MappingDesc::SHADOW, "shadow"}, - {0x00c000000000ULL, 0x00e000000000ULL, MappingDesc::ORIGIN, "origin"}, - {0x00e000000000ULL, 0x010000000000ULL, MappingDesc::APP, "app"}}; - -#define MEM_TO_SHADOW(mem) (((uptr)(mem)) & ~0x4000000000ULL) -#define SHADOW_TO_ORIGIN(shadow) (((uptr)(shadow)) + 0x002000000000) + {0x000000000000ULL, 0x000100000000ULL, MappingDesc::INVALID, "invalid"}, + {0x000100000000ULL, 0x000200000000ULL, MappingDesc::APP, "app-1"}, + {0x000200000000ULL, 0x002100000000ULL, MappingDesc::INVALID, "invalid"}, + {0x002100000000ULL, 0x002200000000ULL, MappingDesc::SHADOW, "shadow-1"}, + {0x002200000000ULL, 0x003100000000ULL, MappingDesc::INVALID, "invalid"}, + {0x003100000000ULL, 0x003200000000ULL, MappingDesc::ORIGIN, "origin-1"}, + {0x003200000000ULL, 0x008000000000ULL, MappingDesc::INVALID, "invalid"}, + {0x008000000000ULL, 0x009000000000ULL, MappingDesc::SHADOW, "shadow-2"}, + {0x009000000000ULL, 0x00a000000000ULL, MappingDesc::ORIGIN, "origin-2"}, + {0x00a000000000ULL, 0x00b000000000ULL, MappingDesc::APP, "app-2"}, + {0x00b000000000ULL, 0x00d000000000ULL, MappingDesc::INVALID, "invalid"}, + {0x00d000000000ULL, 0x00e000000000ULL, MappingDesc::SHADOW, "shadow-3"}, + {0x00e000000000ULL, 0x00f000000000ULL, MappingDesc::ORIGIN, "origin-3"}, + {0x00f000000000ULL, 0x00ffffffffffULL, MappingDesc::APP, "app-3"}}; + +#define MEM_TO_SHADOW(mem) (((uptr)(mem)) ^ 0x2000000000ULL) +#define SHADOW_TO_ORIGIN(shadow) (((uptr)(shadow)) + 0x1000000000ULL) #elif SANITIZER_LINUX && defined(__aarch64__) Index: test/msan/mmap.cc =================================================================== --- test/msan/mmap.cc +++ test/msan/mmap.cc @@ -19,7 +19,9 @@ (addr >= 0x510000000000ULL && addr < 0x600000000000ULL) || (addr >= 0x700000000000ULL && addr < 0x800000000000ULL); #elif defined(__mips64) - return addr >= 0x00e000000000ULL; + return (addr >= 0x000100000000ULL || addr >= 0x000200000000ULL) || + (addr >= 0x00a000000000ULL && addr <= 0x00b000000000ULL) || + addr >= 0x00f000000000ULL; #elif defined(__powerpc64__) return addr < 0x000100000000ULL || addr >= 0x300000000000ULL; #elif defined(__aarch64__) Index: test/msan/strlen_of_shadow.cc =================================================================== --- test/msan/strlen_of_shadow.cc +++ test/msan/strlen_of_shadow.cc @@ -14,7 +14,7 @@ #if defined(__x86_64__) return (char *)((uintptr_t)p ^ 0x500000000000ULL); #elif defined (__mips64) - return (char *)((uintptr_t)p & ~0x4000000000ULL); + return (char *)((uintptr_t)p ^ 0x2000000000ULL); #elif defined(__powerpc64__) #define LINEARIZE_MEM(mem) \ (((uintptr_t)(mem) & ~0x200000000000ULL) ^ 0x100000000000ULL)