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

Generate linux syscall constants #1759

Closed
wants to merge 4 commits into from

Conversation

mahkoh
Copy link

@mahkoh mahkoh commented May 12, 2020

Tl;dr: Many syscall constants were missing so I've written a small script that generates the constants from kernel sources.

As a first step I've reduced the duplication between glibc and musl by creating a new sibling module which is supposed to contain kernel structures and constants. There are many of those that could be moved out of the libc modules but for now I've only moved the syscall constants.

This violates the bottom-up design of the library but this design is not suitable for a system with multiple libcs because a significant part of their surface will be identical reexports of kernel structures and constants.

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @JohnTitor (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

... except for hexagon which seems to have something odd going on with
syscall numbers >1000.

Also do not test the validity of the values because libc is regularly
missing newer syscall numbers.

For those archs which use the newer unified asm-generic/unistd.h numbers
we generate too many constants because

    a) some syscalls are optional
    b) we cannot perform the necessary tests without significant effort.

This is not too problematic because the worst that can happen is ENOSYS
which also happens when newer syscalls are executed on older kernels.
@JohnTitor
Copy link
Member

Hey, thanks for the PR! But this is a major change to our process, so I think we need to discuss it before reviewing.

@mahkoh
Copy link
Author

mahkoh commented May 13, 2020

Just to be clear: The syscalls are generated manually and not during the build. So the process stays the same unless you want to add new syscalls which you should then do by using the script.

@mahkoh
Copy link
Author

mahkoh commented May 26, 2020

@JohnTitor What's the status of this?

@JohnTitor
Copy link
Member

That's great that we could cover many syscalls here but I'm reluctant to this because this will affect too many targets at once.

@mahkoh
Copy link
Author

mahkoh commented May 27, 2020

Adding new linux syscall numbers affects all linux targets. This is your objection?

@bors
Copy link
Contributor

bors commented Jul 2, 2020

☔ The latest upstream changes (presumably #1805) made this pull request unmergeable. Please resolve the merge conflicts.

@mahkoh
Copy link
Author

mahkoh commented Oct 11, 2020

@JohnTitor Can I assume that this PR will stay in limbo indefinitely? You've said that it needs to be "discussed" but I've seen no such discussion nor any concerns raised beyond "it affects all linux targets". Please close the PR if you have no interest in the changes.

@JohnTitor
Copy link
Member

Sorry for my absence! So, as I said this would affect the targets broadly, and I concerned that this may introduce some inconsistencies. Since the current workflow is fine to maintain, I'm going to close this.
If you still want to add such a change, you could open an issue to make a decision at first.
Thanks for contributing anyway!

@JohnTitor JohnTitor closed this Oct 15, 2020
@kpcyrd
Copy link
Contributor

kpcyrd commented Oct 15, 2020

In case this is getting revived, the script I'm using to generate the syscall list for the syscallz crate is located here: https://github.com/kpcyrd/syscallz-rs/blob/main/gen.py

This is lightly tested on the major debian architectures: https://buildd.debian.org/status/package.php?p=rust-syscallz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants