This PR fixes a stack corruption bug caused by bad thread stack initialization. I discovered that the synchronization bug I was chasing was a stack corruption bug. Essentially the aarch64 thread stack initialization code simply sets the stack pointer to the end of the stack instead of the base. This is a problem since on aarch64 the stack is full descending and grows towards lower addresses. This did not cause any immediate issues when the system ran with a few threads.
However, when running the kernel tests ,the synchronization tests (mutex/condvar) failed. This is because those tests create many threads which cause execution of code to overwrite the stack of other threads. Now that the threads stacks are initialized correctly, the tests test_condvar and test_mutex pass. According to those test, there are no synchronization bugs ;)
There are still a few tests that the aarch64 version of the kernel does not pass. Those bugs will be fixed in future PRs.
This PR fixes a stack corruption bug caused by bad thread stack initialization. I discovered that the synchronization bug I was chasing was a stack corruption bug. Essentially the aarch64 thread stack initialization code simply sets the stack pointer to the end of the stack instead of the base. This is a problem since on aarch64 the stack is full descending and grows towards lower addresses. This did not cause any immediate issues when the system ran with a few threads.
However, when running the kernel tests ,the synchronization tests (mutex/condvar) failed. This is because those tests create many threads which cause execution of code to overwrite the stack of other threads. Now that the threads stacks are initialized correctly, the tests
test_condvar
andtest_mutex
pass. According to those test, there are no synchronization bugs ;)There are still a few tests that the aarch64 version of the kernel does not pass. Those bugs will be fixed in future PRs.