pwmgen: prevent GCC from emitting SSE in base-thread function#3896
Open
grandixximo wants to merge 1 commit intoLinuxCNC:masterfrom
Open
pwmgen: prevent GCC from emitting SSE in base-thread function#3896grandixximo wants to merge 1 commit intoLinuxCNC:masterfrom
grandixximo wants to merge 1 commit intoLinuxCNC:masterfrom
Conversation
make_pulses() is exported with uses_fp=0 for the base-thread, but GCC
optimizes struct zeroing into SSE instructions (pxor/movups on XMM
registers). Since RTAI skips FPU/SSE save/restore for non-FP threads,
this silently corrupts XMM state of whatever Linux process was running,
causing heap corruption, segfaults, and hard crashes.
Add __attribute__((target("general-regs-only"))) to make_pulses() to
force GCC to use only general-purpose registers.
Confirmed via objdump that the compiled function contains zero SSE
instructions after this change. Tested on RTAI 5.4.280 with the
etch-servo parport config which previously crashed reliably.
See: LinuxCNC#3895
Collaborator
|
Is this fix still needed, or are we going for the meta-fix? |
Author
|
I can work on ripping out non-FP in the weekend, this will not be needed once that is done, it is just a quick fix, if anyone wants to run RTAI with pwmgen in the meantime, Though I doubt there is anyone else but me testing this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
make_pulses() is exported with uses_fp=0 for the base-thread, but GCC optimizes struct zeroing into SSE instructions (pxor/movups on XMM registers). Since RTAI skips FPU/SSE save/restore for non-FP threads, this silently corrupts XMM state of whatever Linux process was running, causing heap corruption, segfaults, and hard crashes.
Add attribute((target("general-regs-only"))) to make_pulses() to force GCC to use only general-purpose registers.
Confirmed via objdump that the compiled function contains zero SSE instructions after this change. Tested on RTAI 5.4.280 with the etch-servo parport config which previously crashed reliably.
See: #3895