summaryrefslogtreecommitdiff
path: root/Kernel/Thread.cpp
diff options
context:
space:
mode:
authorDrew Stratford <drewstratford@outlook.com>2019-09-04 14:31:38 +1200
committerAndreas Kling <awesomekling@gmail.com>2019-09-05 16:37:09 +0200
commit259a1d56b04809690716fe0576fad9ea12782ce9 (patch)
treeaaa41d51efd7e97e35feb21ba01911572800cadb /Kernel/Thread.cpp
parentbf43d94a2f0fc761158b0049e97fb69d8d273c8c (diff)
downloadserenity-259a1d56b04809690716fe0576fad9ea12782ce9.zip
Thread: added member m_kernel_stack_top.
This value stores the top of a threads kernel_stack.
Diffstat (limited to 'Kernel/Thread.cpp')
-rw-r--r--Kernel/Thread.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp
index c90a796805..f9061c5930 100644
--- a/Kernel/Thread.cpp
+++ b/Kernel/Thread.cpp
@@ -57,14 +57,16 @@ Thread::Thread(Process& process)
// FIXME: This memory is leaked.
// But uh, there's also no kernel process termination, so I guess it's not technically leaked...
m_kernel_stack_base = (u32)kmalloc_eternal(default_kernel_stack_size);
- m_tss.esp = (m_kernel_stack_base + default_kernel_stack_size) & 0xfffffff8u;
+ m_kernel_stack_top = (m_kernel_stack_base + default_kernel_stack_size) & 0xfffffff8u;
+ m_tss.esp = m_kernel_stack_top;
} else {
// Ring3 processes need a separate stack for Ring0.
m_kernel_stack_region = MM.allocate_kernel_region(default_kernel_stack_size, String::format("Kernel Stack (Thread %d)", m_tid));
m_kernel_stack_base = m_kernel_stack_region->vaddr().get();
+ m_kernel_stack_top = m_kernel_stack_region->vaddr().offset(default_kernel_stack_size).get() & 0xfffffff8u;
m_tss.ss0 = 0x10;
- m_tss.esp0 = m_kernel_stack_region->vaddr().offset(default_kernel_stack_size).get() & 0xfffffff8u;
+ m_tss.esp0 = m_kernel_stack_top;
}
// HACK: Ring2 SS in the TSS is the current PID.