This is an automated email from the ASF dual-hosted git repository.

jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 538aa8cbbcc6cb4dad48fd6187a63978046ce51d
Author: raiden00pl <[email protected]>
AuthorDate: Mon Aug 24 08:56:37 2026 +0200

    arch/x86_64: fix AP initial stack alignment
    
    The AP boot path masked RSP with ~XCPTCONTEXT_SIZE, which just clears
    whichever bits happen to be set in the size (0x340 -> mask 0xfffffcbf).
    That drops RSP by an arbitrary amount and only guarantees 16-byte
    alignment, while the XSAVE area in the context needs 64.
    
    Mask with ~(XCPTCONTEXT_ALIGN - 1) instead.
    
    Signed-off-by: raiden00pl <[email protected]>
    Assisted-by: Claude Code
---
 arch/x86_64/src/intel64/intel64_head.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86_64/src/intel64/intel64_head.S 
b/arch/x86_64/src/intel64/intel64_head.S
index b9cc9639d3c..333640c200e 100644
--- a/arch/x86_64/src/intel64/intel64_head.S
+++ b/arch/x86_64/src/intel64/intel64_head.S
@@ -420,7 +420,7 @@ ap_start:
 
        /* Move initial RSP below IDLE TCB regs */
        sub     $XCPTCONTEXT_SIZE, %rsp
-       and     $(~XCPTCONTEXT_SIZE), %rsp
+       and     $(~(XCPTCONTEXT_ALIGN - 1)), %rsp
 
        /* Jump to ap_start routine */
        movabs  $x86_64_ap_boot,   %rbx

Reply via email to