Skip to content

arch/x86_64: support more than 4 CPU - #19947

Open
raiden00pl wants to merge 3 commits into
apache:masterfrom
raiden00pl:nuttx-intel64-smp-generalize
Open

arch/x86_64: support more than 4 CPU#19947
raiden00pl wants to merge 3 commits into
apache:masterfrom
raiden00pl:nuttx-intel64-smp-generalize

Conversation

@raiden00pl

Copy link
Copy Markdown
Member

Summary

  • arch/x86_64: fix AP initial stack alignment
  • arch/x86_64: generalize intel64 idle stacks
  • arch/x86_64: drop unused gap below the intel64 idle stacks

Impact

support more than 4 CPU for intel64

Testing

intel64 with 12 CPUs enabled

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 <raiden00@railab.me>
Assisted-by: Claude Code
intel64 port explicitly enumerates five idle-stack
addresses and rejects configurations with more than five CPUs.

Store the CPU0 stack top and calculate every CPU stack address
from its index.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
The idle stack area started at _ebss + CONFIG_IDLETHREAD_STACKSIZE *
CONFIG_SMP_NCPUS, so the first CONFIG_SMP_NCPUS stack slots after .bss
were never used - 16MiB on a 4-CPU configuration with a 4MiB idle
stack.  Start the area at _ebss and let the heap begin that much
earlier.

The -16 offset is kept: it is what places the AP initial RSP set up in
intel64_head.S below the xcp->regs block that up_cpu_idlestack()
reserves at the top of the same stack.  Without it both land on the
same 64-byte slot and the first context save corrupts the AP stack.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
@github-actions github-actions Bot added Arch: x86_64 Issues related to the x86_64 architecture Size: S The size of the change in this PR is small labels Aug 24, 2026
@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: x86_64 Issues related to the x86_64 architecture Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants