Skip to content

fix: spinlock alignement issue in aarch64 causing so3 to crash#142

Merged
AndreCostaaa merged 6 commits intomainfrom
141-spinlock-alignement-issue-in-aarch64-causing-so3-to-crash
Apr 4, 2025
Merged

fix: spinlock alignement issue in aarch64 causing so3 to crash#142
AndreCostaaa merged 6 commits intomainfrom
141-spinlock-alignement-issue-in-aarch64-causing-so3-to-crash

Conversation

@AndreCostaaa
Copy link
Copy Markdown
Contributor

This PR aims to fix #141

I first tried to make the lock inside spinlock_t a uint64_t and reordering the mutex arguments but that didn't work. I believe the problem is within the pcb_t struct which causes the misalignment.
I tried putting the __attribute__((aligned(8))) inside the pcb_t structure but that didn't help.

So, I took it a step further and decided to put pcb mutex list in the heap so we can align it by calling as we control how the memory is aligned in the heap

I also took the liberty to:

  1. Decrease the amount of mutexes per pcb
  2. Make the mutex_lock/unlock syscalls more robust by actually checking the mutex id instead of just indexing inside the list

Comment thread so3/kernel/syscalls.c
@@ -218,11 +218,11 @@ long syscall_handle(syscall_args_t *a)
* Mainly used for debugging purposes (kernel mutex validation) at the moment ... */

case SYSCALL_MUTEX_LOCK:
Copy link
Copy Markdown
Contributor

@daniel-rossier daniel-rossier Mar 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm. bad naming of arguments -> please use syscall_args instead of a

@daniel-rossier
Copy link
Copy Markdown
Contributor

daniel-rossier commented Mar 31, 2025

So, the do_mutex_lock() takes an id as argument instead of the lock. How is it managed? How is the link between the mutex and the ID handled?
[UPDATE] We leave as it is today since we will have a clean implementation of mutex as soon as we are able to support the full MUSL library.

@AndreCostaaa
Copy link
Copy Markdown
Contributor Author

AndreCostaaa commented Apr 1, 2025

Sounds reasonable. Will revert the change :)

@AndreCostaaa AndreCostaaa force-pushed the 141-spinlock-alignement-issue-in-aarch64-causing-so3-to-crash branch from fb76d88 to d6b2e65 Compare April 1, 2025 08:29
@AndreCostaaa AndreCostaaa merged commit 344a981 into main Apr 4, 2025
11 checks passed
@AndreCostaaa AndreCostaaa deleted the 141-spinlock-alignement-issue-in-aarch64-causing-so3-to-crash branch April 4, 2025 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

spinlock alignement issue in aarch64 causing so3 to crash

2 participants