This is an archive of the discontinued LLVM Phabricator instance.

[mips] Implement GetWriteFlag() for mips
ClosedPublic

Authored by mstojanovic on Apr 18 2018, 6:10 AM.

Details

Summary

The read/write flag is set by manually decoding the instruction that caused the exception. It is implemented this way because the the cause register which contains the needed flag was removed from the signal context structure which the user handler receives from the kernel.

Diff Detail

Repository
rL LLVM

Event Timeline

mstojanovic created this revision.Apr 18 2018, 6:10 AM
sdardis added inline comments.Apr 19 2018, 2:28 AM
lib/sanitizer_common/sanitizer_linux.cc
1741–1742 ↗(On Diff #142922)

Use uint32_t here.

1753 ↗(On Diff #142922)

You need to add s(w|d)(l|r) under an #ifdef __mips_isa_rev < 6 clause.

1763 ↗(On Diff #142922)

You need to add l(w|d)(l|r) under an #ifdef __mips_isa_rev < 6 clause.

1763 ↗(On Diff #142922)

You may also want to add lwpc and lwupc to this list as well, but they are only for MIPSR6.

test/sanitizer_common/TestCases/Posix/illegal_read_test.cc
11 ↗(On Diff #142922)

Add:

return 0;

here.

test/sanitizer_common/TestCases/Posix/illegal_write_test.cc
10 ↗(On Diff #142922)

Add:

return 0;

here.

sdardis requested changes to this revision.Apr 19 2018, 3:41 AM
This revision now requires changes to proceed.Apr 19 2018, 3:41 AM

Comments addressed.

sdardis requested changes to this revision.Apr 24 2018, 4:53 AM
sdardis added inline comments.
lib/sanitizer_common/sanitizer_linux.cc
1739 ↗(On Diff #143073)

This should be:

__mips__

not __mips64 as asan can be built for MIPS32.

1744 ↗(On Diff #143073)

This should be (uint32_t *) not (long *).

1747 ↗(On Diff #143073)

FIXME: Add support for FPU, microMIPS, DSP, MSA memory instructions.

This revision now requires changes to proceed.Apr 24 2018, 4:53 AM
mstojanovic marked 6 inline comments as done.

Fixed macro and types, added a comment.

sdardis accepted this revision.Apr 25 2018, 4:43 AM

LGTM. Keep on eye on the buildbots when you commit this in case there are sanitizer implementations can't distinguish between illegal reads and writes.

This revision is now accepted and ready to land.Apr 25 2018, 4:43 AM
This revision was automatically updated to reflect the committed changes.