kernel: Make sure the stack is 16-byte aligned on program startup

This is required by the System V ABI and fixes some movaps-related GPFs in ndisasm.
This commit is contained in:
apio 2023-06-19 10:41:32 +02:00
parent 795b0ca8d4
commit ae01a31104
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 3 additions and 2 deletions

View File

@ -1,6 +1,7 @@
#include "thread/ThreadImage.h"
#include "memory/MemoryManager.h"
#include "thread/Thread.h"
#include <luna/Alignment.h>
#include <luna/CString.h>
static constexpr usize DEFAULT_USER_STACK_PAGES = 6;
@ -122,7 +123,7 @@ void ThreadImage::apply(Thread* thread)
thread->kernel_stack = m_kernel_stack;
thread->stack = m_user_stack;
thread->set_sp(m_sp);
thread->set_sp(align_down<16>(m_sp));
thread->directory = m_directory;

View File

@ -6,5 +6,5 @@ Stack::Stack(u64 base, usize bytes) : m_base(base), m_bytes(bytes)
u64 Stack::top() const
{
return (m_base + m_bytes) - sizeof(void*);
return (m_base + m_bytes) - 16;
}