nxsem_wait_irq with MMU
- Dominant language
- C
- Stars
- 4k
- Forks
- 1.7k
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 237
Description
I have encountered a little issue with semaphores, and nxsem_wait_irq which is used to wake the process waiting for a sempahore and do other cleanup i.e. handle priority inheritance etc.
The issue arises when nxsem_wait_irq is called from ISR or from the signal dispatch logic; while it works like a charm with flat addressing, it fails when virtual memory is in use.
The issue obviously is that sem_t is userspace data, and if the current task is not the one holding / waiting for the semaphore, the clean up fails due to wrong mappings.
Now, the solution might be as simple as changing the mappings temporarily to the semaphore holder's mappings, but this to me seems like quite a heavy operation. At least the TLB is lost, maybe with other side effects as well.
So I created this issue to open discussion about the subject. Is this a more generic problem (affecting more than just the semaphore API), needing a generic solution ? Has anyone ever thought of this issue and how to fix it ? Maybe coming up with a solution but no time to implement it ? If so I'll be more than happy to do the fix and test it.
Regardless, I will present a patch (and reference this issue there) where the mappings are just swapped because that works and is a way to fix the issue. The issue is easier to grasp this way I think.
Contributor guide
Assessment
This issue has not been assessed yet.