Skip to content

[compiler-rt][ARM] Add missing PACBTI support to assembly aeabi functions #142400

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

Merged
merged 4 commits into from
Jun 10, 2025

Conversation

vhscampos
Copy link
Member

@vhscampos vhscampos commented Jun 2, 2025

Some of the aeabi functions were missing PACBTI support. The lack of it resulted in exceptions at runtime if the running environment had PAC and/or BTI enabled.

This patch adds this support. This involves the addition of PACBTI instructions, depending on whether each of these features is enabled, plus the saving and restoring of the PAC code that resides in r12. Some of the common code has been put in preprocessor macros to reduce duplication, but not all, especially since some register saving and restoring is very specific to each context.

…ions

Some of the aeabi functions were missing PACBTI support. The lack of it
resulted in exceptions at runtime if the running environment had PAC
and/or BTI enabled.

This patch adds this support.
Copy link
Collaborator

@smithp35 smithp35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I've understood the rtabi correctly I think we're not allowed to corrupt r0 in the 3-way comparison routines, which it looks like we're doing in a couple of cases.

The rest looks good to me. There could be a case for adding some closing comments to the #else and #endif as nested ones can be awkward to figure out. Although in this case they are always the innermost ones.

The other possibility I thought about was to have a macro that conditionally expanded to , r12 or nothing depending on whether PAC was being used. That could be used in the save list for push, however I don't think there's any precedent for that in compiler-rt so it's probably not a good idea.

@vhscampos
Copy link
Member Author

The other possibility I thought about was to have a macro that conditionally expanded to , r12 or nothing depending on whether PAC was being used. That could be used in the save list for push, however I don't think there's any precedent for that in compiler-rt so it's probably not a good idea.

I also thought of that, however the register list argument for push and pop must be in order, therefore r12 has to come before lr. As far as I could tell, this kind of maneuvering is not possible with the preprocessor machinery.

@vhscampos vhscampos requested a review from smithp35 June 6, 2025 13:36
Copy link
Collaborator

@smithp35 smithp35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update. I think I've spotted a way to get closer to the original code, but I could have missed something.

Copy link
Collaborator

@smithp35 smithp35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks for the updates. I don't have any more comments.

@vhscampos vhscampos merged commit a59a8ae into llvm:main Jun 10, 2025
7 checks passed
@vhscampos vhscampos deleted the aeabi-pacbti branch June 10, 2025 09:20
rorth pushed a commit to rorth/llvm-project that referenced this pull request Jun 11, 2025
…ions (llvm#142400)

Some of the aeabi functions were missing PACBTI support. The lack of it
resulted in exceptions at runtime if the running environment had PAC
and/or BTI enabled.

This patch adds this support. This involves the addition of PACBTI
instructions, depending on whether each of these features is enabled,
plus the saving and restoring of the PAC code that resides in r12. Some
of the common code has been put in preprocessor macros to reduce
duplication, but not all, especially since some register saving and
restoring is very specific to each context.
tomtor pushed a commit to tomtor/llvm-project that referenced this pull request Jun 14, 2025
…ions (llvm#142400)

Some of the aeabi functions were missing PACBTI support. The lack of it
resulted in exceptions at runtime if the running environment had PAC
and/or BTI enabled.

This patch adds this support. This involves the addition of PACBTI
instructions, depending on whether each of these features is enabled,
plus the saving and restoring of the PAC code that resides in r12. Some
of the common code has been put in preprocessor macros to reduce
duplication, but not all, especially since some register saving and
restoring is very specific to each context.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants