Skip to content

!syscalls: add portUnregister syscall#750

Open
julianuziemblo wants to merge 2 commits intomasterfrom
julianuziemblo/port-unregister
Open

!syscalls: add portUnregister syscall#750
julianuziemblo wants to merge 2 commits intomasterfrom
julianuziemblo/port-unregister

Conversation

@julianuziemblo
Copy link
Contributor

@julianuziemblo julianuziemblo commented Mar 16, 2026

The functionality is there but was previously unused. Its useful with new remove_dev() userspace function that will call it if there's no filesystem.

Description

Motivation and Context

Depends-On: libphoenix:julianuziemblo/remove_dev

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (refactoring, style fixes, git/CI config, submodule management, no code logic changes)

How Has This Been Tested?

  • Already covered by automatic testing.
  • New test added: (add PR link here).
  • Tested by hand on: armv7m7-imxrt117x-evk

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing linter checks and tests passed.
  • My changes generate no new compilation warnings for any of the targets.

Special treatment

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new portUnregister syscall, making previously existing kernel functionality accessible to userspace. This change is crucial for enabling more dynamic device management, specifically for scenarios where devices need to be removed and their associated ports unregistered, such as with the remove_dev() userspace function.

Highlights

  • New portUnregister syscall: Exposed the portUnregister functionality as a new syscall, allowing userspace to unregister ports. This is particularly useful for new device removal mechanisms.
Changelog
  • include/syscalls.h
    • Added portUnregister to the list of available syscall IDs.
  • syscalls.c
    • Implemented the syscalls_portUnregister function, which retrieves the port name from the user stack and calls the proc_portUnregister kernel function.
Activity
  • Pull request created by julianuziemblo.
  • Identified as a breaking change.
  • Tested manually on armv7m7-imxrt117x-evk.
  • Depends on libphoenix:julianuziemblo/remove_dev.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new portUnregister syscall. The implementation contains a critical bug where it reads an argument from an incorrect stack offset, which would cause it to fail. I've provided a fix for this. Additionally, I've pointed out a security vulnerability related to handling strings from userspace and a design issue with the function's return type that prevents error handling. Addressing these would significantly improve the robustness and security of the new syscall.

@github-actions
Copy link

github-actions bot commented Mar 16, 2026

Unit Test Results

9 553 tests  ±0   8 961 ✅ ±0   52m 45s ⏱️ -1s
  591 suites ±0     592 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit d575864. ± Comparison against base commit cbfa5d0.

♻️ This comment has been updated with latest results.

@julianuziemblo julianuziemblo force-pushed the julianuziemblo/port-unregister branch from 3b9ca46 to 32fc1e8 Compare March 16, 2026 16:59
@nalajcie
Copy link
Member

please use the same branch name for related changes in different repos - that way you won't need to use Depends-On and it will look sane for the developer checking-out your change locally if needed.

@julianuziemblo
Copy link
Contributor Author

please use the same branch name for related changes in different repos - that way you won't need to use Depends-On and it will look sane for the developer checking-out your change locally if needed.

Agreed, but these changes are related only one way, same branch names might have been confusing. Next time I'll try to find a matching one tho.

agkaminski
agkaminski previously approved these changes Mar 17, 2026
Copy link
Member

@agkaminski agkaminski left a comment

Choose a reason for hiding this comment

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

Not that sure it will work well, have no problem with addition of syscall

@julianuziemblo
Copy link
Contributor Author

Not that sure it will work well, has no problem with addition of syscall

I'll add some tests before merging

@nalajcie
Copy link
Member

not sure but at https://github.com/phoenix-rtos/phoenix-rtos-kernel/blob/master/proc/name.c#L140 it should probably be entry->next instead of NULL?

I'm also not sure about generic approach - if we would like for the servers to be restartable - it would be better to have the same port number as the previous instance, so actually re-reading port from the dev and reclaiming it might be a better approach (clients doesn't need to re-lookup). Might not matter that much if we switch the message API to explicit open/close connection.

@julianuziemblo julianuziemblo force-pushed the julianuziemblo/port-unregister branch 2 times, most recently from b32730a to 23fba5a Compare March 17, 2026 11:10
The functionality is there, but was previously unused.
It can now be useful wit new `remove_dev()` userspace
function that will cal it if there's no filesystem.

YT: RTOS-1254
@julianuziemblo julianuziemblo force-pushed the julianuziemblo/port-unregister branch from 23fba5a to 228941d Compare March 17, 2026 11:28
@julianuziemblo julianuziemblo force-pushed the julianuziemblo/port-unregister branch from 228941d to d575864 Compare March 17, 2026 11:37
Copy link
Member

@agkaminski agkaminski left a comment

Choose a reason for hiding this comment

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

I guess usage of len deeper is TODO (what if I lie about len when executing the syscall)?

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.

4 participants