Skip to content

gh-125444: Fix illegal instruction for older Arm architectures #125574

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 2 commits into from
Oct 16, 2024

Conversation

diegorusso
Copy link
Contributor

@diegorusso diegorusso commented Oct 16, 2024

On Arm v5 it is not possible to get the thread ID via c13 register hence the illegal instruction. The c13 register started to provide thread ID since Arm v6K architecture variant. Other variants of Arm v6 (T2, Z and base) don’t provide the thread ID via c13. For the sake of simplicity we group v5 and v6 together and consider that instructions for Arm v7 only.

On Arm v5 it is not possible to get the thread ID via c13 register
hence the illegal instruction. The c13 register started to provide
thread ID since Arm v6K architecture variant. Other variants of
Arm v6 (T2, Z and base) don’t provide the thread ID via c13.
For the sake of simplicity we group v5 and v6 together and
consider that instructions for Arm v7 only.
@diegorusso
Copy link
Contributor Author

This has been tested by @rossburton by manually building CPython and testing it with software emulation.

With the 3.13 release:

 root@armv5:~# python3
 Illegal instruction

With this PR:

 root@armv5:~# python3
 Python 3.13.0 (main, Oct  7 2024, 05:02:14) [GCC 14.2.0] on linux
 Type "help", "copyright", "credits" or "license" for more information.
 >>>

Copy link
Contributor

@Zheaoli Zheaoli left a comment

Choose a reason for hiding this comment

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

Mostly LGTM, but may I ask should we define a new variable like __arm_7_or_new__ to keep the arch check have same code style? (BTW this is personal thought)

@diegorusso
Copy link
Contributor Author

Mostly LGTM, but may I ask should we define a new variable like __arm_7_or_new__ to keep the arch check have same code style? (BTW this is personal thought)

I would prefer to leave it as is to keep it "standard" as the rest of the macros used here. The code style is different but it is the standard way to use these macros.
Said that, if there is a strong argument to have a custom macro, I will do it.

@diegorusso
Copy link
Contributor Author

Also the aim is to upstream a similar fix to https://github.com/microsoft/mimalloc/ as well, so I would prefer not do to have a "localised" patch for CPython.

@diegorusso diegorusso added the needs backport to 3.13 bugs and security fixes label Oct 16, 2024
@colesbury colesbury merged commit feda9aa into python:main Oct 16, 2024
40 checks passed
@miss-islington-app
Copy link

Thanks @diegorusso for the PR, and @colesbury for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@colesbury
Copy link
Contributor

Hmmm... the backporting is going slowly.

@ambv ambv added needs backport to 3.13 bugs and security fixes and removed needs backport to 3.13 bugs and security fixes labels Oct 16, 2024
@miss-islington-app
Copy link

Thanks @diegorusso for the PR, and @colesbury for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 16, 2024
…ythonGH-125574)

On Arm v5 it is not possible to get the thread ID via c13 register
hence the illegal instruction. The c13 register started to provide
thread ID since Arm v6K architecture variant. Other variants of
Arm v6 (T2, Z and base) don’t provide the thread ID via c13.
For the sake of simplicity we group v5 and v6 together and
consider that instructions for Arm v7 only.
(cherry picked from commit feda9aa)

Co-authored-by: Diego Russo <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Oct 16, 2024

GH-125595 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Oct 16, 2024
colesbury pushed a commit that referenced this pull request Oct 16, 2024
…GH-125574) (GH-125595)

On Arm v5 it is not possible to get the thread ID via c13 register
hence the illegal instruction. The c13 register started to provide
thread ID since Arm v6K architecture variant. Other variants of
Arm v6 (T2, Z and base) don’t provide the thread ID via c13.
For the sake of simplicity we group v5 and v6 together and
consider that instructions for Arm v7 only.
(cherry picked from commit feda9aa)

Co-authored-by: Diego Russo <[email protected]>
@diegorusso diegorusso deleted the gh-125444 branch October 16, 2024 15:03
ebonnal pushed a commit to ebonnal/cpython that referenced this pull request Jan 12, 2025
…ython#125574)

On Arm v5 it is not possible to get the thread ID via c13 register
hence the illegal instruction. The c13 register started to provide
thread ID since Arm v6K architecture variant. Other variants of
Arm v6 (T2, Z and base) don’t provide the thread ID via c13.
For the sake of simplicity we group v5 and v6 together and
consider that instructions for Arm v7 only.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants