Skip to content

Add configUSE_TASK_FPU_SUPPORT to AARCH64 port #1048

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 5 commits into from
May 8, 2024
Merged

Conversation

StefanBalt
Copy link
Contributor

Description

NEON SIMD is required by standard AARCH64 and its registers are frequently utilized by standard functions such as memcpy(). This means that even simple tasks that do not use any floating point arithmetics may still alter the contents of the FPU registers.

For this reason it makes sense to add support for configUSE_TASK_FPU_SUPPORT to be able to enforce FPU register saving and restoring globally.

Without configUSE_TASK_FPU_SUPPORT it is not possible to enforce this for some library tasks.

This pull request partially fixes this issue:
https://forums.freertos.org/t/zynq-ultrascale-mpsoc-task-floating-point-corruption/9121

For a full fix portASM.S also needs to be adapted to save/restore all FPU registers at interrupt entry/exit.
Maybe I will find time to contribute this in another pull request.

Checklist:

  • I have tested my changes. No regression in existing tests. (stack consumption and timing will get worse)
  • I have modified and/or added unit-tests to cover the code changes in this Pull Request.

Related Issue

My colleague did already something similar for the ARM Cortex R5 port: GH-584

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

NEON SIMD is required by standard AARCH64 and its registers are
frequently utilized by standard functions such as memcpy().
This means that even simple tasks that do not use any floating point
arithmetics may still alter the contents of the FPU registers.

For this reason it makes sense to add support for
configUSE_TASK_FPU_SUPPORT to be able to enforce FPU register saving and
restoring globally.

The implementation was largely adopted from the ARM_CA9 port. However,
the FPU registers must be placed on the stack before the critical
nesting count to match the AARCH64 portASM.S.
@StefanBalt StefanBalt requested a review from a team as a code owner May 2, 2024 16:51
n9wxu
n9wxu previously approved these changes May 7, 2024
chinglee-iot
chinglee-iot previously approved these changes May 7, 2024
@aggarg aggarg requested a review from chinglee-iot May 7, 2024 18:02
aggarg and others added 2 commits May 8, 2024 14:54
Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
@aggarg aggarg dismissed stale reviews from chinglee-iot and n9wxu via aaf9b00 May 8, 2024 10:06
Copy link

sonarqubecloud bot commented May 8, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@aggarg aggarg merged commit 55eceb2 into FreeRTOS:main May 8, 2024
16 checks passed
@aggarg
Copy link
Member

aggarg commented May 8, 2024

@StefanBalt Thank you for your contribution.

schilkp pushed a commit to schilkp/FreeRTOS-Kernel that referenced this pull request May 17, 2024
* Add configUSE_TASK_FPU_SUPPORT to AARCH64 port

NEON SIMD is required by standard AARCH64 and its registers are
frequently utilized by standard functions such as memcpy().
This means that even simple tasks that do not use any floating point
arithmetics may still alter the contents of the FPU registers.

For this reason it makes sense to add support for
configUSE_TASK_FPU_SUPPORT to be able to enforce FPU register saving and
restoring globally.

The implementation was largely adopted from the ARM_CA9 port. However,
the FPU registers must be placed on the stack before the critical
nesting count to match the AARCH64 portASM.S.
MinghuanLian pushed a commit to nxp-mcuxpresso/FreeRTOS-Kernel that referenced this pull request Nov 28, 2024
This is a direct backport of upstream commit [1] for aarch64 (legacy operation port)
done under [2]
The same code can be applied on the aarch SRE port to be able to enable FPU context
saving on all tasks context switch to mitigate GCC optimization to use SIMD registers
for copy.

[1] "55eceb22: Add configUSE_TASK_FPU_SUPPORT to AARCH64 port (FreeRTOS#1048)"
[2] FreeRTOS#1048

Signed-off-by: Marouen Ghodhbane <marouen.ghodhbane@nxp.com>
asellaminxp pushed a commit to nxp-mcuxpresso/FreeRTOS-Kernel that referenced this pull request Nov 28, 2024
This is a direct backport of upstream commit [1] for aarch64 (legacy operation port)
done under [2]
The same code can be applied on the aarch SRE port to be able to enable FPU context
saving on all tasks context switch to mitigate GCC optimization to use SIMD registers
for copy.

[1] "55eceb22: Add configUSE_TASK_FPU_SUPPORT to AARCH64 port (FreeRTOS#1048)"
[2] FreeRTOS#1048

Signed-off-by: Marouen Ghodhbane <marouen.ghodhbane@nxp.com>
asellaminxp pushed a commit to nxp-mcuxpresso/FreeRTOS-Kernel that referenced this pull request Jan 22, 2025
This is a direct backport of upstream commit [1] for aarch64 (legacy operation port)
done under [2]
The same code can be applied on the aarch SRE port to be able to enable FPU context
saving on all tasks context switch to mitigate GCC optimization to use SIMD registers
for copy.

[1] "55eceb22: Add configUSE_TASK_FPU_SUPPORT to AARCH64 port (FreeRTOS#1048)"
[2] FreeRTOS#1048

Signed-off-by: Marouen Ghodhbane <marouen.ghodhbane@nxp.com>
asellaminxp pushed a commit to nxp-mcuxpresso/FreeRTOS-Kernel that referenced this pull request Jan 22, 2025
This is a direct backport of upstream commit [1] for aarch64 (legacy operation port)
done under [2]
The same code can be applied on the aarch SRE port to be able to enable FPU context
saving on all tasks context switch to mitigate GCC optimization to use SIMD registers
for copy.

[1] "55eceb22: Add configUSE_TASK_FPU_SUPPORT to AARCH64 port (FreeRTOS#1048)"
[2] FreeRTOS#1048

Signed-off-by: Marouen Ghodhbane <marouen.ghodhbane@nxp.com>
archigup pushed a commit that referenced this pull request Jan 23, 2025
This is a direct backport of upstream commit [1] for aarch64 (legacy operation port)
done under [2]
The same code can be applied on the aarch SRE port to be able to enable FPU context
saving on all tasks context switch to mitigate GCC optimization to use SIMD registers
for copy.

[1] "55eceb22: Add configUSE_TASK_FPU_SUPPORT to AARCH64 port (#1048)"
[2] #1048

Signed-off-by: Marouen Ghodhbane <marouen.ghodhbane@nxp.com>
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.

5 participants