Skip to content

Commit

Permalink
task/schedule: Launch elf tasks at CPL-3
Browse files Browse the repository at this point in the history
In order to provide separation between loadable modules and
between a module and the kernel, loadable modules should be
executed at CPL-3 and use a syscall interface to interact with the
SVSM kernel.

This commit simply changes the creation of tasks from ELF files
from using kernel tasks to user-mode tasks running at CPL-3.

Signed-off-by: Roy Hopkins <rhopkins@suse.de>
  • Loading branch information
roy-hopkins committed Nov 22, 2023
1 parent d1b3e5a commit f38c886
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/task/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ pub fn create_task_for_module(
flags: u16,
affinity: Option<u32>,
) -> Result<(), SvsmError> {
let mut task = Task::create(module.entry_point(), 0, flags)?;
let mut task = Task::user_create(module.entry_point(), 0, flags)?;
task.set_affinity(affinity);
task.set_on_switch_hook(Some(task_switch_hook));

Expand Down
8 changes: 6 additions & 2 deletions src/task/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl From<TaskError> for SvsmError {

#[derive(Clone, Copy, Debug)]
struct UserParams {
entry_point: usize,
entry_point: extern "C" fn(u64),
param: u64,
}

Expand Down Expand Up @@ -281,7 +281,11 @@ impl Task {
Ok(task)
}

pub fn user_create(entry: usize, param: u64, flags: u16) -> Result<Box<Task>, SvsmError> {
pub fn user_create(
entry: extern "C" fn(u64),
param: u64,
flags: u16,
) -> Result<Box<Task>, SvsmError> {
// Launch via the user-mode entry point
let entry_param = Box::new(UserParams {
entry_point: entry,
Expand Down

0 comments on commit f38c886

Please sign in to comment.