Skip to content
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

fs/poll: Fix poll_notify for CONFIG_BUILD_KERNEL #8072

Merged
merged 1 commit into from
Jan 10, 2023

Conversation

pussuw
Copy link
Contributor

@pussuw pussuw commented Jan 10, 2023

Summary

With flat addressing the user pollfd list is given directly to the drivers that perform the notification. This is fine when the addressing is flat, as there is no ambiguity on who gets notified and the fds memory is always mapped.

For kernel mode with MMU this does not work. The notification must be done via a temporary buffer allocated from kernel memory.

Thus, create a copy of the user fds and pass the copy to the drivers. Afterwards copy the output events back to the user.

Impact

Fixes poll() for CONFIG_BUILD_KERNEL

Testing

icicle:knsh and in house risc-v target using CONFIG_BUILD_KERNEL

With flat addressing the user pollfd list is given directly to the
drivers that perform the notification. This is fine when the addressing
is flat, as there is no ambiguity on who gets notified and the fds memory
is always mapped.

For kernel mode with MMU this does not work. The notification must be done
via a temporary buffer allocated from kernel memory.

Thus, create a copy of the user fds and pass the copy to the drivers.
Afterwards copy the output events back to the user.
@xiaoxiang781216 xiaoxiang781216 merged commit f730cf8 into apache:master Jan 10, 2023
@pussuw pussuw deleted the fix_fs_poll branch January 10, 2023 18:54
@@ -441,6 +441,7 @@ int file_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup)

int poll(FAR struct pollfd *fds, nfds_t nfds, int timeout)
{
struct pollfd *kfds;
Copy link
Contributor

Choose a reason for hiding this comment

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

FAR is missing here

pussuw added a commit to tiiuae/nuttx that referenced this pull request Jan 11, 2023
xiaoxiang781216 pushed a commit that referenced this pull request Jan 11, 2023
chenzhihong007 pushed a commit to hpmicro/nuttx that referenced this pull request Mar 8, 2023
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.

3 participants