mirror of
https://github.com/RGBCube/serenity
synced 2025-07-02 23:42:13 +00:00
Kernel: Don't leak an FPU state buffer for every spawned thread
We were leaking 512 bytes of kmalloc memory for every new thread. This patch fixes that, and also makes sure to zero out the FPU state buffer after allocating it, and finally also makes the LogStream operator<< for Thread look a little bit nicer. :^)
This commit is contained in:
parent
517e78a7e2
commit
40beb4c5c0
2 changed files with 7 additions and 5 deletions
|
@ -50,6 +50,7 @@ Thread::Thread(Process& process)
|
|||
dbgprintf("Thread{%p}: New thread TID=%u in %s(%u)\n", this, m_tid, process.name().characters(), process.pid());
|
||||
set_default_signal_dispositions();
|
||||
m_fpu_state = (FPUState*)kmalloc_aligned(sizeof(FPUState), 16);
|
||||
memset(m_fpu_state, 0, sizeof(FPUState));
|
||||
memset(&m_tss, 0, sizeof(m_tss));
|
||||
|
||||
// Only IF is set when a process boots.
|
||||
|
@ -564,7 +565,6 @@ Thread* Thread::clone(Process& process)
|
|||
auto* clone = new Thread(process);
|
||||
memcpy(clone->m_signal_action_data, m_signal_action_data, sizeof(m_signal_action_data));
|
||||
clone->m_signal_mask = m_signal_mask;
|
||||
clone->m_fpu_state = (FPUState*)kmalloc_aligned(sizeof(FPUState), 16);
|
||||
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;
|
||||
|
@ -658,3 +658,8 @@ void Thread::make_thread_specific_region(Badge<Process>)
|
|||
if (process().m_master_tls_size)
|
||||
memcpy(thread_local_storage, process().m_master_tls_region->vaddr().as_ptr(), process().m_master_tls_size);
|
||||
}
|
||||
|
||||
const LogStream& operator<<(const LogStream& stream, const Thread& value)
|
||||
{
|
||||
return stream << value.process().name() << "(" << value.pid() << ":" << value.tid() << ")";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue