This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer] [asan] Use same shadow offset for aarch64
ClosedPublic

Authored by zatrazz on Oct 15 2015, 12:52 PM.

Details

Summary

Following a discussion in gcc maillist for the libsanitizer merge I am now
trying to remove the SANITIZER_AARCH64_VMA flags for aarch64 port.

This patch makes ASAN for aarch64 use the same shadow offset for all
currently supported VMAs (39 and 42 bits). The shadow offset is the
same of 39-bit (36). To make it work on 42-bit llvm instrumentation will
require a change [1] on how to generate the memory address.

No regression tests found in 39 and 42-bit VMA. I have not tested on
48-bit VMA due lack of available platforms (but it is on my radar).

[1] http://reviews.llvm.org/D13781

Diff Detail

Event Timeline

zatrazz updated this revision to Diff 37506.Oct 15 2015, 12:52 PM
zatrazz retitled this revision from to [sanitizer] [asan] Use same shadow offset for aarch64.
zatrazz updated this object.
zatrazz added reviewers: kcc, pcc, rengolin, samsonov, eugenis.
zatrazz added a subscriber: llvm-commits.
zatrazz updated this revision to Diff 37513.Oct 15 2015, 1:13 PM

Updated patch correcting the segments placement for 42-bit VMA.

eugenis added inline comments.Oct 19 2015, 11:09 AM
lib/sanitizer_common/sanitizer_platform.h
107–108

I'm pretty sure this won't work on 48 bit VMA.
Could you evaluate the cost of lifting the upper limit to 48? Last time I looked, this should only affect .bss size (so, no real RAM cost), and not really that much.

zatrazz added inline comments.Oct 22 2015, 9:31 AM
lib/sanitizer_common/sanitizer_platform.h
107–108

I won't, but I am also not sure if kAArch64_ShadowOffset64 = 1ULL << 36 will work correctly on 48-bit kernels. But it will check this out.

zatrazz added inline comments.Oct 30 2015, 1:06 PM
lib/sanitizer_common/sanitizer_platform.h
107–108

I did some analysis of the memory consumption difference about using 47 instead of 42 and the results look reasonable: with test/asan/TestCases/mmap_limit_mb.cc as base with some code to dump '/proc/self/statm' I see:

$ ./test_mem-{42,48} 2000 16

MMAP          42       48      Diff
Resident   21970    22110       140
          186924   187035       111
         1476712  1476841       129

So it seems an overhead not really dependent of total memory utilization for about 129-140 kb.

eugenis edited edge metadata.Nov 2 2015, 1:03 PM

Why is there a difference in resident memory?
I'd expect it to go to .bss.
This could be related to http://llvm.org/viewvc/llvm-project?rev=251717&view=rev

Why is there a difference in resident memory?
I'd expect it to go to .bss.
This could be related to http://llvm.org/viewvc/llvm-project?rev=251717&view=rev

I will recheck against master.

zatrazz updated this revision to Diff 39356.Nov 5 2015, 6:02 AM
zatrazz edited edge metadata.

Remove SANITIZER_AARCH64_VMA on LSAN.

Why is there a difference in resident memory?
I'd expect it to go to .bss.
This could be related to http://llvm.org/viewvc/llvm-project?rev=251717&view=rev

Master (r252155) looks better:

MMAP          42       48      Diff
Resident   12989    12988        -1
          128228   128227        -1
         1280210  1280224       +14

I did not dig into to find exactly from where the difference came from when total usage is 1280210.

eugenis accepted this revision.Nov 5 2015, 10:49 AM
eugenis edited edge metadata.

LGTM, thanks!

This revision is now accepted and ready to land.Nov 5 2015, 10:49 AM
zatrazz closed this revision.Nov 9 2015, 11:30 AM