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

task/schedule: Free init stack during first context switch #593

Merged
merged 2 commits into from
Jan 22, 2025

Conversation

peterfang
Copy link
Contributor

init_stack is now completely unused by the BSP and stops being used by any CPU after switching to the idle task in schedule_init(). Free up these memory pages during context switching. Since a Rust function is called for this purpose, make sure callee-saved registers are used for switch_context's input arguments.

Using stack_base + STACK_TOTAL_SIZE is not the correct way to derive a
VMKernelStack's top-of-stack address because there are unmapped guard
pages on both ends of the stack. Use the output of
VMKernelStack::top_of_stack() instead during context switches.

Fixes: a448d45 ("schedule: switch to special stack during context switches")
Signed-off-by: Peter Fang <[email protected]>
init_stack is now completely unused by the BSP and stops being used by
any CPU after switching to the idle task in schedule_init(). Free up
these memory pages during context switching. Since a Rust function is
called for this purpose, make sure callee-saved registers are used for
switch_context's input arguments.

Signed-off-by: Peter Fang <[email protected]>
Copy link
Member

@joergroedel joergroedel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good to me, thanks.

@joergroedel joergroedel merged commit 5cd227c into coconut-svsm:main Jan 22, 2025
4 checks passed
@peterfang peterfang deleted the free-init-stack branch January 22, 2025 11:03
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.

2 participants