Move ELF loading into context of new task#1153
Open
joergroedel wants to merge 7 commits into
Open
Conversation
luigix25
reviewed
Jul 3, 2026
00xc
reviewed
Jul 6, 2026
3751ce2 to
c35e7fb
Compare
Initialize the kernel-stack of a new user-mode task using one structure and initialize it in one place. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Initialize the stack of a new kernel task from a single structure to make it more similar to user-task stack initialization. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Check at compile time whether the stack-frame after ret_addr is 16b-aligned. Also consolidate the check for kernel and user tasks. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
The initialization routines for user- and kernel-tasks basically do the same thing, except that they use different context structures for each case. Consolidate the common parts in allocate_stack_common() and make that function generic. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
User-tasks use a different launch path than kernel-tasks. Kernel-tasks go directly to a Rust function on the `ret` in `switch_context` while for user-tasks the `ret`-target is an assembly function which calls the `setup_user_task()` helper and then goes into the `iret` path. This causes some fraction in how the initial stack layouts of both task types are set up, so consolidate this to be more similar in both cases. Kernel- and User thread now use a common thread entry in assembly code, which unifies the initial thread setup. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
When loading a user ELF binary for execution the COCONUT kernel created a new Task object and mapped the ELF sections into the new tasks user-VMR. This all happened from the context of the old task. This behavior is problematic as it creates unnecessary complexity for cases when the kernel needs to write values into the user address space. Fix this behavior by moving the actual ELF loading into the context of the new task. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Make the shadow stack initialization more readable by introducing an initializer struct with push semantics. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
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.
Cleanup the task setup and launch process and move loading of the ELF file for a user-space process into the context of the user-mode task.