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

Fix nonexistent sync_file_range2 syscall bug in aarch64,loongarch64 and riscv* #55

Merged
merged 1 commit into from
Sep 20, 2024

Conversation

Fearyncess
Copy link
Contributor

This PR will fix sync_file_range2 corruption in codes.

During these days, I have discovered a bug in syscall-gen. It has mistakenly marked some architectures using sync_file_range2 instead of sync_file_range.

Because of registers alignment, on a few architectures, sync_file_range2 swaps the argument order to avoid requiring 7 arguments instead of sync_file_range. After my investigation, only 32-bit ARM1, SH2, PowerPC3, CSKY4 and Hexagon5 use sync_file_range2. Specifically, arm_sync_file_range is aliased to sync_file_range on 32-bit ARM1.

For aarch64, this architectures use sync_file_range actually. However, ARMv8 has a compatibility mode called aarch32, which will let 32bit ARM programs running on aarch64 machines. So there is a unistd32.h syscall compat header in arch/arm646. It also have sync_file_range2 syscall name, aliased to arm_sync_file_range.

For other architectures which use unistd.h for syscalls definition, we should filter out sync_file_range2 if not defined. That follows their definitions in Linux kernel.

Footnotes

  1. https://github.com/torvalds/linux/blob/176000734ee2978121fde22a954eb1eabb204329/arch/arm/tools/syscall.tbl#L359 2

  2. https://github.com/torvalds/linux/blob/30766f1105d6d2459c3b9fe34a3e52b637a72950/arch/sh/kernel/syscalls/syscall.tbl#L398

  3. https://github.com/torvalds/linux/blob/b1e31c134a8ab2e8f5fd62323b6b45a950ac704d/arch/powerpc/kernel/syscalls/syscall.tbl#L401

  4. https://github.com/torvalds/linux/blob/f840cab63efe802638bf536221deecfbf3f569ed/arch/csky/include/uapi/asm/unistd.h#L5

  5. https://github.com/torvalds/linux/blob/36d69c29759ec2299c1537e292a466eab3824087/arch/hexagon/include/uapi/asm/unistd.h

  6. https://github.com/torvalds/linux/blob/7fe33e9f662c0a2f5110be4afff0a24e0c123540/arch/arm64/include/asm/unistd32.h#L7

@jasonwhite jasonwhite merged commit 92624de into jasonwhite:main Sep 20, 2024
23 of 26 checks passed
@jasonwhite
Copy link
Owner

Thanks! Looks good.

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.

2 participants