Move set_tss_stack call to switch_to

This commit is contained in:
bjorn3
2024-02-25 20:10:49 +01:00
parent 96f1a14115
commit 24187b5f80
3 changed files with 8 additions and 6 deletions
+4
View File
@@ -129,6 +129,10 @@ pub unsafe fn empty_cr3() -> rmm::PhysicalAddress {
/// Switch to the next context by restoring its stack and registers
pub unsafe fn switch_to(prev: &mut super::Context, next: &mut super::Context) {
if let Some(ref stack) = next.kstack {
crate::gdt::set_tss_stack(stack.as_ptr() as usize + stack.len());
}
core::arch::asm!("
fxsave [{prev_fx}]
fxrstor [{next_fx}]
+4
View File
@@ -143,6 +143,10 @@ pub unsafe fn empty_cr3() -> rmm::PhysicalAddress {
/// Switch to the next context by restoring its stack and registers
pub unsafe fn switch_to(prev: &mut super::Context, next: &mut super::Context) {
if let Some(ref stack) = next.kstack {
crate::gdt::set_tss_stack(stack.as_ptr() as usize + stack.len());
}
core::arch::asm!(
alternative2!(
feature1: "xsaveopt",
-6
View File
@@ -198,12 +198,6 @@ pub unsafe fn switch() -> bool {
next_context.cpu_id = Some(cpu_id);
next_context.switch_time = switch_time;
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
{
if let Some(ref stack) = next_context.kstack {
crate::gdt::set_tss_stack(stack.as_ptr() as usize + stack.len());
}
}
let percpu = PercpuBlock::current();
percpu.switch_internals.context_id.set(next_context.id);