|
@@ -10,6 +10,8 @@
|
|
|
|
|
|
//#define SIGNAL_DEBUG
|
|
//#define SIGNAL_DEBUG
|
|
|
|
|
|
|
|
+static FPUState s_clean_fpu_state;
|
|
|
|
+
|
|
u16 thread_specific_selector()
|
|
u16 thread_specific_selector()
|
|
{
|
|
{
|
|
static u16 selector;
|
|
static u16 selector;
|
|
@@ -55,7 +57,7 @@ Thread::Thread(Process& process)
|
|
dbgprintf("Thread{%p}: New thread TID=%u in %s(%u)\n", this, m_tid, process.name().characters(), process.pid());
|
|
dbgprintf("Thread{%p}: New thread TID=%u in %s(%u)\n", this, m_tid, process.name().characters(), process.pid());
|
|
set_default_signal_dispositions();
|
|
set_default_signal_dispositions();
|
|
m_fpu_state = (FPUState*)kmalloc_aligned(sizeof(FPUState), 16);
|
|
m_fpu_state = (FPUState*)kmalloc_aligned(sizeof(FPUState), 16);
|
|
- memset(m_fpu_state, 0, sizeof(FPUState));
|
|
|
|
|
|
+ memcpy(m_fpu_state, &s_clean_fpu_state, sizeof(FPUState));
|
|
memset(&m_tss, 0, sizeof(m_tss));
|
|
memset(&m_tss, 0, sizeof(m_tss));
|
|
|
|
|
|
// Only IF is set when a process boots.
|
|
// Only IF is set when a process boots.
|
|
@@ -119,9 +121,6 @@ Thread::~Thread()
|
|
thread_table().remove(this);
|
|
thread_table().remove(this);
|
|
}
|
|
}
|
|
|
|
|
|
- if (g_last_fpu_thread == this)
|
|
|
|
- g_last_fpu_thread = nullptr;
|
|
|
|
-
|
|
|
|
if (selector())
|
|
if (selector())
|
|
gdt_free_entry(selector());
|
|
gdt_free_entry(selector());
|
|
|
|
|
|
@@ -625,8 +624,7 @@ u32 Thread::make_userspace_stack_for_main_thread(Vector<String> arguments, Vecto
|
|
}
|
|
}
|
|
env[environment.size()] = nullptr;
|
|
env[environment.size()] = nullptr;
|
|
|
|
|
|
- auto push_on_new_stack = [&new_esp](u32 value)
|
|
|
|
- {
|
|
|
|
|
|
+ auto push_on_new_stack = [&new_esp](u32 value) {
|
|
new_esp -= 4;
|
|
new_esp -= 4;
|
|
u32* stack_ptr = (u32*)new_esp;
|
|
u32* stack_ptr = (u32*)new_esp;
|
|
*stack_ptr = value;
|
|
*stack_ptr = value;
|
|
@@ -646,7 +644,6 @@ Thread* Thread::clone(Process& process)
|
|
memcpy(clone->m_signal_action_data, m_signal_action_data, sizeof(m_signal_action_data));
|
|
memcpy(clone->m_signal_action_data, m_signal_action_data, sizeof(m_signal_action_data));
|
|
clone->m_signal_mask = m_signal_mask;
|
|
clone->m_signal_mask = m_signal_mask;
|
|
memcpy(clone->m_fpu_state, m_fpu_state, sizeof(FPUState));
|
|
memcpy(clone->m_fpu_state, m_fpu_state, sizeof(FPUState));
|
|
- clone->m_has_used_fpu = m_has_used_fpu;
|
|
|
|
clone->m_thread_specific_data = m_thread_specific_data;
|
|
clone->m_thread_specific_data = m_thread_specific_data;
|
|
return clone;
|
|
return clone;
|
|
}
|
|
}
|
|
@@ -654,6 +651,9 @@ Thread* Thread::clone(Process& process)
|
|
void Thread::initialize()
|
|
void Thread::initialize()
|
|
{
|
|
{
|
|
Scheduler::initialize();
|
|
Scheduler::initialize();
|
|
|
|
+ asm volatile("fninit");
|
|
|
|
+ asm volatile("fxsave %0"
|
|
|
|
+ : "=m"(s_clean_fpu_state));
|
|
}
|
|
}
|
|
|
|
|
|
Vector<Thread*> Thread::all_threads()
|
|
Vector<Thread*> Thread::all_threads()
|