Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drreg-test fails with non-default stolen register #2072

Open
egrimley opened this issue Nov 17, 2016 · 3 comments
Open

drreg-test fails with non-default stolen register #2072

egrimley opened this issue Nov 17, 2016 · 3 comments

Comments

@egrimley
Copy link
Contributor

This only seems to be a problem on AArch64, not 32-bit ARM.

bin64/drrun -steal_reg 28 -c suite/tests/bin/libclient.drreg-test.dll.so -- suite/tests/bin/client.drreg-test

works, but

bin64/drrun -steal_reg 27 -c suite/tests/bin/libclient.drreg-test.dll.so -- suite/tests/bin/client.drreg-test

fails (at translate.c:770).

Note that https://codereview.appspot.com/316900043/ removes one hardwired reference to X28, but the bug is not fixed by that commit and there don't seem to be any other similar references, so it might be something more subtle.

@egrimley
Copy link
Contributor Author

Interestingly, although my recursive grepping didn't reveal any hardwired references to X28, there do seem to be a couple of hardwired references to DR_REG_R10, in translate.c and instr_shared.c. That might be relevant, though there could also be some kind of AArch64-specific fragment prefix or veneer or whatever that is not correctly handled by translation.

@egrimley
Copy link
Contributor Author

It works with most values for steal_reg, but it fails when the stolen register is X19, X25 or X27. Why those values? Because those are the values to be found in the register fields of 0xf36d19, which is the "udf" instruction used in drreg-test.c!

So I could make the problem go away by choosing a different unallocated encoding, or by getting the decoder to recognise certain unallocated encodings, but I suspect there may be a bug in DynamoRIO with the handling of a fault on an instruction that really does access the stolen register...

@egrimley
Copy link
Contributor Author

Yes, it looks as though the problem can be reproduced on AArch32 as follows:

Replace ".word 0xe7f000f0 /* udf */" with "swp r10, r10, [r0]", then run drreg-test on ARMv8 hardware, without kernel emulation of SWP, so that SWP causes a SIGILL. Then the test fails in the same way as it fails on AArch64. But you can make it pass by specifying "-steal_reg 9" or "-steal_reg 11".

So there seems to be a non-AArch64-specific bug in the handling of faults on instructions that access the stolen register, and this bug has nothing to do with the two references to DR_REG_R10 mentioned above (which might constitute a separate bug).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants