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

Add syscall functions #116

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

newpavlov
Copy link

@newpavlov newpavlov commented May 2, 2024

Draft for resolving bytecodealliance/rustix#1055

If the outlined approach is acceptable, I will port the remaining arches and tweak the gen crate.

I am not sure what to do with x86. Duplicating the vDSO stuff looks a bit too heavy, while using int 0x80 would be too inefficient. We could use the GS register with 0x10 offset, but IIUC it relies on C runtime, which may not be present in some rare cases and the offset may not be stable across platforms. After cursory reading it looks like we could use the sysenter instruction, it's performance should be comparable to vDSO, but I wonder why it was not used in the rustix crate.

@sunfishcode
Copy link
Owner

The sysenter instruction isn't available in 32-bit mode on all x86 CPUs. Linux's vDSO knows how to pick between the sysenter, syscall, and int 0x80 instructions depending on the CPU architecture. This is another reason why I wouldn't want raw syscall knowledge to spread around to general-purpose crates.

As I mentioned in my comment in bytecodealliance/rustix#1055, I would prefer not to take the approach in this PR.

@newpavlov
Copy link
Author

The sysenter instruction isn't available in 32-bit mode on all x86 CPUs

Are these CPUs supported by Rust in the first place?

@sunfishcode
Copy link
Owner

Looking at this page, the choice of sysenter vs. syscall still depends on whether the kernel is 32-bit or 64-bit. My understanding is that Rust's i686 target is expected to work on either kind of kernel.

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.

None yet

2 participants