Skip to content

Move ELF loading into context of new task#1153

Open
joergroedel wants to merge 7 commits into
coconut-svsm:mainfrom
joergroedel:task-exec
Open

Move ELF loading into context of new task#1153
joergroedel wants to merge 7 commits into
coconut-svsm:mainfrom
joergroedel:task-exec

Conversation

@joergroedel

Copy link
Copy Markdown
Member

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.

Comment thread kernel/src/task/exec.rs
Comment thread kernel/src/task/exec.rs
Comment thread kernel/src/task/exec.rs
Comment thread kernel/src/task/tasks.rs Outdated
Comment thread kernel/src/task/tasks.rs Outdated
Comment thread kernel/src/task/tasks.rs Outdated
Comment thread kernel/src/task/tasks.rs Outdated
Comment thread kernel/src/cpu/shadow_stack.rs Outdated
Comment thread kernel/src/task/tasks.rs Outdated
Comment thread kernel/src/task/tasks.rs Outdated
Comment thread kernel/src/task/tasks.rs
Comment thread kernel/src/task/tasks.rs
@joergroedel joergroedel force-pushed the task-exec branch 2 times, most recently from 3751ce2 to c35e7fb Compare July 8, 2026 15:44
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>
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.

3 participants