Skip to content

Commit

Permalink
Merge pull request #484 from msft-jlange/task_flags
Browse files Browse the repository at this point in the history
task: create new tasks with interrupts disabled
  • Loading branch information
joergroedel authored Oct 15, 2024
2 parents 3d26c7f + bf964e2 commit 9870390
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions kernel/src/task/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use core::sync::atomic::{AtomicU32, Ordering};

use crate::address::{Address, VirtAddr};
use crate::cpu::idt::svsm::return_new_task;
use crate::cpu::msr::read_flags;
use crate::cpu::percpu::PerCpu;
use crate::cpu::X86ExceptionContext;
use crate::cpu::{irqs_enable, X86GeneralRegs};
Expand Down Expand Up @@ -351,8 +350,11 @@ impl Task {
.try_into()
.unwrap();
let task_context = stack_ptr.offset(-tc_offset).cast::<TaskContext>();
// flags
(*task_context).flags = read_flags();
// The processor flags must always be in a default state, unrelated
// to the flags of the caller. In particular, interrupts must be
// disabled because the task switch code expects to execute a new
// task with interrupts disabled.
(*task_context).flags = 2;
// ret_addr
(*task_context).regs.rdi = entry as *const () as usize;
(*task_context).ret_addr = run_kernel_task as *const () as u64;
Expand Down

0 comments on commit 9870390

Please sign in to comment.