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

Add AArch64 support for restartable sequences #4316

Closed
derekbruening opened this issue Jun 4, 2020 · 4 comments · Fixed by #4858
Closed

Add AArch64 support for restartable sequences #4316

derekbruening opened this issue Jun 4, 2020 · 4 comments · Fixed by #4858

Comments

@derekbruening
Copy link
Contributor

This covers adding AArch64 support to bring it into parity with x86 for restartable sequence ("rseq") handling which was added as part of #2350.

@derekbruening
Copy link
Contributor Author

Rseq requries a Linux kernel version 4.18+. Both the TX1 and Jenkins are too old. I have an internal machine I am currently testing on, but for regression tests it would be best if the Jenkins machine actually had rseq support (the test will still gracefully pass by just doing nothing if rseq is not there). @AssadHashmi would it be possible to upgrade the Jenkins kernel to 4.18+ for rseq support?

@AssadHashmi
Copy link
Contributor

@derekbruening we will shortly be migrating the existing Jenkins to a newer machine: an Ampere Altra!
We would prefer to wait and do such work as part of that migration.
We don't have an accurate ETA yet but the request has been approved and provisioning will be scheduled shortly.
I'll contact them requesting kernel version >4.18.

@derekbruening
Copy link
Contributor Author

Thanks, sounds good.

derekbruening added a commit that referenced this issue Apr 15, 2021
Ports the linux.rseq test and its extensive inline assembly to
AArch64.  We use compiler-acquired C variable addresses prior to the
assembly sequences for simplicity.  This should be fine as there are
plenty of GPR's and DR handles inputs.

Tested natively and with forthcoming DR rseq mangling changes;
separated to keep diffs smaller.  These tests will be enabled in the
PR that adds DR handling.

Issue: #4316
derekbruening added a commit that referenced this issue Apr 15, 2021
Fixes a rank order violation at -loglevel 5 with rseq.
It is the same vmarea diagnostic issue seen with other vmarea lists.
It does not seem worth the complexity of adding rseq to the existing
high-loglevel test or adding a new one; tested manually on the
linux.rseq test.

Issue: #4736, #4316
derekbruening added a commit that referenced this issue Apr 15, 2021
Fixes a rank order violation at -loglevel 5 with rseq.
It is the same vmarea diagnostic issue seen with other vmarea lists.
It does not seem worth the complexity of adding rseq to the existing
high-loglevel test or adding a new one; tested manually on the
linux.rseq test.

Issue: #4736, #4316
derekbruening added a commit that referenced this issue Apr 15, 2021
Ports the linux.rseq test and its extensive inline assembly to
AArch64.  We use compiler-acquired C variable addresses prior to the
assembly sequences for simplicity.  This should be fine as there are
plenty of GPR's and DR handles inputs.

Tested natively and with forthcoming DR rseq mangling changes;
separated to keep diffs smaller.  These tests will be enabled in the
PR that adds DR handling.

Issue: #4316
derekbruening added a commit that referenced this issue Apr 15, 2021
Ports rseq mangling to AArch64.  This requires implementing
patch_mov_immed_arch() (done by leveraging existing raw encoding code
from exit stub support) and spilling extra scratch registers in
multiple places.

Expands translation support to cover the new mangling.  This includes
adding proper recognition of an mcontext base load, which was
incorrectly identified as an indirect branch target load on x86.

Ports the heuristic for finding the app's rseq TLS offset on attach
(when we did not see an rseq syscall) for AArch64 to look forward
instead of backward as on x86 where negative segment offsets are used.

Enables the rseq tests for AArch64.
Updates the rseq docs to state that AArch64 is supported.

One final step is to support stores with writeback, which are seen in
real rseq sequences.  That will be done separately.  This completes
porting the x86 support to AArch64.

Issue: #4316
derekbruening added a commit that referenced this issue Apr 16, 2021
Ports rseq mangling to AArch64.  This requires implementing
patch_mov_immed_arch() (done by leveraging existing raw encoding code
from exit stub support) and spilling extra scratch registers in
multiple places.

Expands translation support to cover the new mangling.  This includes
adding proper recognition of an mcontext base load, which was
incorrectly identified as an indirect branch target load on x86.

Ports the heuristic for finding the app's rseq TLS offset on attach
(when we did not see an rseq syscall) for AArch64 to look forward
instead of backward as on x86 where negative segment offsets are used.

Enables the rseq tests for AArch64.
Tested all 6 rseq tests manually on a machine with a newer kernel.
The Jenkins machine is too old and does not have rseq.
3 rseq tests do run on QEMU so those are enabled but until Jenkins is
upgraded we will not have perfect regression tests.

Updates the rseq docs to state that AArch64 is supported.
One final step is to support stores with writeback, which are seen in
real rseq sequences.  That will be done separately.  This completes
porting the x86 support to AArch64.

Issue: #4316
@derekbruening
Copy link
Contributor Author

I enabled 3 linux.rseq* tests under QEMU because they pass there, but on inspection QEMU is returning ENOSYS for rseq: so they are not testing full functionality.

derekbruening added a commit that referenced this issue Apr 16, 2021
Adds nop-ing of writeback stores inside rseq regions by replacing them
with adds to preserve the GPR changes but throw away the memory changes.

Updates the documentation.
Adds a test case.

Fixes #4316
derekbruening added a commit that referenced this issue Apr 16, 2021
Adds nop-ing of writeback stores inside rseq regions by replacing them
with adds to preserve the GPR changes but throw away the memory changes.

Updates the documentation.
Adds a test case.

Fixes #4316
derekbruening added a commit that referenced this issue Feb 11, 2022
Adds translation of the save of input registers to rseq sequences.

This fixes a hang on detach in the api.ir test on AArch64, which we
remove from the flaky list here.

Manually tested by running api.rseq 200x on the Jenkins machine.
Previously the test failed every single time there.

Issue: #4923, #4316, #4669
Fixes #4923
derekbruening added a commit that referenced this issue Feb 11, 2022
Adds translation of the save of input registers to rseq sequences.

This fixes a hang on detach in the api.ir test on AArch64, which we
remove from the flaky list here.

Manually tested by running api.rseq 200x on the Jenkins machine.
Previously the test failed every single time there.

Issue: #4923, #4316, #4669
Fixes #4923
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants