arch/arm/include/arm*/irq.h: fix FPU context layout guard macro#18824
Merged
xiaoxiang781216 merged 1 commit intoapache:masterfrom Apr 30, 2026
Merged
Conversation
The register index layout for D16-D31 and FPU_CONTEXT_REGS was guarded
by CONFIG_ARM_HAVE_DPFPU32 (hardware capability) in three header files,
but all save/restore code in the corresponding .S files gates on
CONFIG_ARM_DPFPU32 (software enable).
These two macros are distinct:
CONFIG_ARM_HAVE_DPFPU32 - set by chip via 'select'; means hardware
has D16-D31 registers
CONFIG_ARM_DPFPU32 - user-selectable; means software has chosen
to use D16-D31 (requires hardware support)
When ARM_HAVE_DPFPU32=y and ARM_DPFPU32=n, the header defined
REG_FPSCR at offset 64 and FPU_CONTEXT_REGS=65, while the assembly
only saved S0-S31+FPSCR (33 words), placing FPSCR at offset 32.
This mismatch causes incorrect register access and wrong xcptcontext
sizing.
Signed-off-by: yaojiaqi <yaojiaqi@lixiang.com>
xiaoxiang781216
approved these changes
Apr 30, 2026
jerpelea
approved these changes
Apr 30, 2026
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.
Summary
The register index layout for D16–D31 and
FPU_CONTEXT_REGSwas guarded byCONFIG_ARM_HAVE_DPFPU32(hardware capability) in three header files, but all save/restore code in the corresponding.Sfiles gates onCONFIG_ARM_DPFPU32(software enable).These two macros are distinct:
CONFIG_ARM_HAVE_DPFPU32— set by the chip viaselect; indicates thehardware has D16–D31 registers.
CONFIG_ARM_DPFPU32— user-selectable; means the software has chosen touse D16–D31 (requires hardware support).
When
ARM_HAVE_DPFPU32=yandARM_DPFPU32=n, the header definedREG_FPSCRat offset 64 andFPU_CONTEXT_REGS=65, while the assembly only saved S0–S31 + FPSCR (33 words), placing FPSCR at offset 32. This mismatch causes incorrect register access and wrongxcptcontextsizing.Fix all three affected headers to use
CONFIG_ARM_DPFPU32, matching the actual save/restore behavior in the assembly code.All save/restore sites (
arm_vectors.S,arm_saveusercontext.S,arm_tcbinfo.c) consistently gate onCONFIG_ARM_DPFPU32across all three architectures (ARMv8-R, ARMv7-R, ARMv7-A). The threeirq.hheaders were the only outliers usingCONFIG_ARM_HAVE_DPFPU32. The three irq.h headers were the only outliers usingCONFIG_ARM_HAVE_DPFPU32, making this a clear consistency fix::Impact
Any ARMv8-R, ARMv7-R, or ARMv7-A platform that has hardware support for 32 double-precision FPU registers (
ARM_HAVE_DPFPU32=y) but has not enabled the software use of D16–D31 (ARM_DPFPU32=n) is affected. In this configuration the FPU context layout in the header disagrees with what the assembly actually saves, leading to corrupted register restores and incorrect stack sizing, which typically manifests as a boot failure or crash at the first context switch involving FPU state.Testing
Target: Private ARMv8-R Cortex-R52 platform with
CONFIG_ARM_HAVE_DPFPU32=yandCONFIG_ARM_DPFPU32=n(hardware has D16–D31 but software use of the upper bank is isabled).
Before the fix: the system fails to boot when
CONFIG_ARM_DPFPU32=n.After the fix: the system boots normally and the
ostestapplication completes without errors.