summaryrefslogtreecommitdiff
path: root/Kernel/Process.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-02-03 03:56:08 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-02-03 03:56:08 +0100
commit333aa1646c1a2e1694399b84dce8a1b3fbe1b027 (patch)
tree19c8c27a666196ebddcacdf50143add2d202f979 /Kernel/Process.cpp
parent2a093ada33083c2cb4f90426e925a15a63cdfd80 (diff)
downloadserenity-333aa1646c1a2e1694399b84dce8a1b3fbe1b027.zip
Kernel: Increase default userspace stack size to 64 kilobytes.
Diffstat (limited to 'Kernel/Process.cpp')
-rw-r--r--Kernel/Process.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index 652f1a9d80..c5987d60bc 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -27,7 +27,8 @@
#define SIGNAL_DEBUG
#define MAX_PROCESS_GIDS 32
-static const dword default_stack_size = 16384;
+static const dword default_kernel_stack_size = 16384;
+static const dword default_userspace_stack_size = 65536;
static pid_t next_pid;
InlineLinkedList<Process>* g_processes;
@@ -287,6 +288,8 @@ pid_t Process::sys$fork(RegisterDump& regs)
int Process::do_exec(const String& path, Vector<String>&& arguments, Vector<String>&& environment)
{
+ ASSERT(is_ring3());
+
auto parts = path.split('/');
if (parts.is_empty())
return -ENOENT;
@@ -400,9 +403,9 @@ int Process::do_exec(const String& path, Vector<String>&& arguments, Vector<Stri
m_tss.gs = 0x23;
m_tss.ss = 0x23;
m_tss.cr3 = page_directory().cr3();
- m_stack_region = allocate_region(LinearAddress(), default_stack_size, "stack");
+ m_stack_region = allocate_region(LinearAddress(), default_userspace_stack_size, "stack");
ASSERT(m_stack_region);
- m_stack_top3 = m_stack_region->laddr().offset(default_stack_size).get();
+ m_stack_top3 = m_stack_region->laddr().offset(default_userspace_stack_size).get();
m_tss.esp = m_stack_top3;
m_tss.ss0 = 0x10;
m_tss.esp0 = old_esp0;
@@ -670,24 +673,24 @@ Process::Process(String&& name, uid_t uid, gid_t gid, pid_t ppid, RingLevel ring
if (is_ring0()) {
// FIXME: This memory is leaked.
// But uh, there's also no kernel process termination, so I guess it's not technically leaked...
- dword stack_bottom = (dword)kmalloc_eternal(default_stack_size);
- m_stack_top0 = (stack_bottom + default_stack_size) & 0xffffff8;
+ dword stack_bottom = (dword)kmalloc_eternal(default_kernel_stack_size);
+ m_stack_top0 = (stack_bottom + default_kernel_stack_size) & 0xffffff8;
m_tss.esp = m_stack_top0;
} else {
if (fork_parent) {
m_stack_top3 = fork_parent->m_stack_top3;
} else {
- auto* region = allocate_region(LinearAddress(), default_stack_size, "stack");
+ auto* region = allocate_region(LinearAddress(), default_userspace_stack_size, "stack");
ASSERT(region);
- m_stack_top3 = region->laddr().offset(default_stack_size).get();
+ m_stack_top3 = region->laddr().offset(default_userspace_stack_size).get();
m_tss.esp = m_stack_top3;
}
}
if (is_ring3()) {
// Ring3 processes need a separate stack for Ring0.
- m_kernel_stack = kmalloc(default_stack_size);
- m_stack_top0 = ((dword)m_kernel_stack + default_stack_size) & 0xffffff8;
+ m_kernel_stack = kmalloc(default_kernel_stack_size);
+ m_stack_top0 = ((dword)m_kernel_stack + default_kernel_stack_size) & 0xffffff8;
m_tss.ss0 = 0x10;
m_tss.esp0 = m_stack_top0;
}
@@ -830,15 +833,15 @@ bool Process::dispatch_signal(byte signal)
if (interrupting_in_kernel) {
if (!m_signal_stack_user_region) {
- m_signal_stack_user_region = allocate_region(LinearAddress(), default_stack_size, "signal stack (user)");
+ m_signal_stack_user_region = allocate_region(LinearAddress(), default_userspace_stack_size, "signal stack (user)");
ASSERT(m_signal_stack_user_region);
- m_signal_stack_kernel_region = allocate_region(LinearAddress(), default_stack_size, "signal stack (kernel)");
+ m_signal_stack_kernel_region = allocate_region(LinearAddress(), default_userspace_stack_size, "signal stack (kernel)");
ASSERT(m_signal_stack_user_region);
}
m_tss.ss = 0x23;
- m_tss.esp = m_signal_stack_user_region->laddr().offset(default_stack_size).get() & 0xfffffff8;
+ m_tss.esp = m_signal_stack_user_region->laddr().offset(default_userspace_stack_size).get() & 0xfffffff8;
m_tss.ss0 = 0x10;
- m_tss.esp0 = m_signal_stack_kernel_region->laddr().offset(default_stack_size).get() & 0xfffffff8;
+ m_tss.esp0 = m_signal_stack_kernel_region->laddr().offset(default_userspace_stack_size).get() & 0xfffffff8;
push_value_on_stack(ret_eflags);
push_value_on_stack(ret_cs);
push_value_on_stack(ret_eip);