-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests: socketpair: fix userspace thread permissions #25271
tests: socketpair: fix userspace thread permissions #25271
Conversation
All checks are passing now. Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages. |
Realized yesterday that I was reinventing the work queue. Should probably use one of those instead of manually doing it with a thread, stack, k_thread_suspend() / k_thread_resume(). Made a huge difference. I think only one of the tests is hanging atm, so will need to debug that a bit. |
99.88% of tests passing but a page fault on qemu_x86. Any pointers on how to get rid of that?
|
Paging Dr. @andrewboie |
I think my assumption was that a thread's stack was fair game from zephyr kernel space was wrong - at least on x86. I guess I need to use a |
Were you going to post the contents of the error message? A page fault means you accessed memory improperly in some way. What is going on at the PC value (EIP) when the fault happens? Have you attached a debugger and gotten a stack trace? |
error message:
backtrace:
Originally I thought maybe the issue was the user thread accessing the static "struct ctx" that I have in Trying to follow along with tests/kernel/workq/work_queue_api/src/main.c .. |
Aha - |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some minor comments otherwise LGTM
Testing seems to be kind of slow. Here is the output of sanitycheck on my machine locally.
|
@pfalcon @jukkar @andrewboie - anyone able to approve? |
Commit message:
My usual comment would be that the changes to subsys/net/lib/sockets/socketpair.c are substantial enough to go in a separate commit and not piggy-back on a commit, which patches tests, with a fineprint "Also, ..." at the end. |
@pfalcon and @andrewboie would very much appreciate a review for this one |
I really think your changes for is_nonblock synchronization need to be in a separate commit. You should not keep adding unrelated stuff to the same commit. Ultimately the networking team needs to approve this. The changes to support user mode look fine. |
There was a possible race condition between sock_is_nonblock() and k_sem_take() in spair_read() and spair_write() that was mitigated. Also clarified some of the conditional branching in those functions. Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
Kernel objects were being directly accessed without previously calling k_thread_access_grant(). This change allows each test that requires an asynchronous event to send it to a common work queue with correct permissions. Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
Split into 2 commits. Ok to merge, @pfalcon @jukkar @andrewboie? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
user mode changes look OK.
no opinion on the race condition change.
Kernel objects were being directly accessed without previously calling k_thread_access_grant().
This change allows each test that requires an asynchronous event to send it to a common work queue with correct permissions given to the userspace thread.
Also, clarified some conditions in subsys/net/lib/sockets/socketpair.c and added / reordered some calls to respect whether semaphores were held / object were valid.
Fixes #25270