forked from Bananymous/banan-os
Kernel: Add offset for interrupt stack in Scheduler::yield()
This allows accessing (garbage) sp and ss in interrupt stack.
This commit is contained in:
parent
c95a271821
commit
9e073e9fa0
|
@ -115,11 +115,7 @@ namespace Kernel
|
||||||
if (thread->state() == Thread::State::NotStarted)
|
if (thread->state() == Thread::State::NotStarted)
|
||||||
thread->m_state = Thread::State::Executing;
|
thread->m_state = Thread::State::Executing;
|
||||||
|
|
||||||
ASSERT(thread->interrupt_stack().ip);
|
|
||||||
ASSERT(thread->interrupt_stack().sp);
|
|
||||||
|
|
||||||
Processor::gdt().set_tss_stack(thread->kernel_stack_top());
|
Processor::gdt().set_tss_stack(thread->kernel_stack_top());
|
||||||
|
|
||||||
Processor::get_interrupt_stack() = thread->interrupt_stack();
|
Processor::get_interrupt_stack() = thread->interrupt_stack();
|
||||||
Processor::get_interrupt_registers() = thread->interrupt_registers();
|
Processor::get_interrupt_registers() = thread->interrupt_registers();
|
||||||
}
|
}
|
||||||
|
@ -149,7 +145,9 @@ namespace Kernel
|
||||||
"movq %[load_sp], %%rsp;"
|
"movq %[load_sp], %%rsp;"
|
||||||
"int %[ipi];"
|
"int %[ipi];"
|
||||||
"movq %%rcx, %%rsp;"
|
"movq %%rcx, %%rsp;"
|
||||||
:: [load_sp]"r"(Processor::current_stack_top()),
|
// NOTE: This is offset by 2 pointers since interrupt without PL change
|
||||||
|
// does not push SP and SS. This allows accessing "whole" interrupt stack.
|
||||||
|
:: [load_sp]"r"(Processor::current_stack_top() - 2 * sizeof(uintptr_t)),
|
||||||
[ipi]"i"(IRQ_VECTOR_BASE + IRQ_IPI)
|
[ipi]"i"(IRQ_VECTOR_BASE + IRQ_IPI)
|
||||||
: "memory", "rcx"
|
: "memory", "rcx"
|
||||||
);
|
);
|
||||||
|
@ -159,7 +157,9 @@ namespace Kernel
|
||||||
"movl %[load_sp], %%esp;"
|
"movl %[load_sp], %%esp;"
|
||||||
"int %[ipi];"
|
"int %[ipi];"
|
||||||
"movl %%ecx, %%esp;"
|
"movl %%ecx, %%esp;"
|
||||||
:: [load_sp]"r"(Processor::current_stack_top()),
|
// NOTE: This is offset by 2 pointers since interrupt without PL change
|
||||||
|
// does not push SP and SS. This allows accessing "whole" interrupt stack.
|
||||||
|
:: [load_sp]"r"(Processor::current_stack_top() - 2 * sizeof(uintptr_t)),
|
||||||
[ipi]"i"(IRQ_VECTOR_BASE + IRQ_IPI)
|
[ipi]"i"(IRQ_VECTOR_BASE + IRQ_IPI)
|
||||||
: "memory", "ecx"
|
: "memory", "ecx"
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue