Skip to content
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

Remove init stack #611

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

peterfang
Copy link
Contributor

Commit 676e741 introduced the side effect of breaking the stack unwinder because init_stack no longer exists after the first context switch in schedule_init(). This commit fixes that by completely removing init_stack:

  • BSP is not impacted because it never uses init_stack and uses bsp_stack instead
  • AP now uses context_switch_stack as its initial stack because this stack was originally designed to be used only when switching between tasks

Also, improve the stack unwinder by allowing it to dump the stack while running in the initial stack and detecting stack misalignment.

Commit 676e741 introduced the side
effect of breaking the stack unwinder because init_stack no longer
exists after the first context switch in schedule_init(). This commit
fixes that by completely removing init_stack:

- BSP is not impacted because it never uses init_stack and uses
  bsp_stack instead
- AP now uses context_switch_stack as its initial stack because this
  stack was originally designed to be used only when switching between
  tasks

In both cases, IRQs requiring a stack can safely occur during context
switching because these stacks are accessible after switching to the
first task's page table.

Let the stack unwinder inspect context_switch_stack instead of
init_stack. This stack will always exist as long as its PerCpu is in
use.

Fixes: 676e741 ("task/schedule: Free init stack during first context switch")
Signed-off-by: Peter Fang <[email protected]>
Record the initial stack in PerCpu's current_stack field. This allows
the stack unwinder to properly dump the stack when executing in the
initial stack. Also, explicitly mark the bottom stack frame in the
initial stack using RBP = 0 so that the stack unwinder knows when to
stop.

Signed-off-by: Peter Fang <[email protected]>
The x86-64 ABI requires 16b-aligned stack frames. Detect misaligned
stack frames in the stack unwinder and mark them with a pound sign ('#')
when printing a stack.

Signed-off-by: Peter Fang <[email protected]>
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.

1 participant