Fix nonexistent sync_file_range2
syscall bug in aarch64,loongarch64 and riscv*
#55
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 usingsync_file_range2
instead ofsync_file_range
.Because of registers alignment, on a few architectures,
sync_file_range2
swaps the argument order to avoid requiring 7 arguments instead ofsync_file_range
. After my investigation, only 32-bit ARM1, SH2, PowerPC3, CSKY4 and Hexagon5 usesync_file_range2
. Specifically,arm_sync_file_range
is aliased tosync_file_range
on 32-bit ARM1.For aarch64, this architectures use
sync_file_range
actually. However, ARMv8 has a compatibility mode calledaarch32
, which will let 32bit ARM programs running on aarch64 machines. So there is aunistd32.h
syscall compat header inarch/arm64
6. It also havesync_file_range2
syscall name, aliased toarm_sync_file_range
.For other architectures which use
unistd.h
for syscalls definition, we should filter outsync_file_range2
if not defined. That follows their definitions in Linux kernel.Footnotes
https://github.com/torvalds/linux/blob/176000734ee2978121fde22a954eb1eabb204329/arch/arm/tools/syscall.tbl#L359 ↩ ↩2
https://github.com/torvalds/linux/blob/30766f1105d6d2459c3b9fe34a3e52b637a72950/arch/sh/kernel/syscalls/syscall.tbl#L398 ↩
https://github.com/torvalds/linux/blob/b1e31c134a8ab2e8f5fd62323b6b45a950ac704d/arch/powerpc/kernel/syscalls/syscall.tbl#L401 ↩
https://github.com/torvalds/linux/blob/f840cab63efe802638bf536221deecfbf3f569ed/arch/csky/include/uapi/asm/unistd.h#L5 ↩
https://github.com/torvalds/linux/blob/36d69c29759ec2299c1537e292a466eab3824087/arch/hexagon/include/uapi/asm/unistd.h ↩
https://github.com/torvalds/linux/blob/7fe33e9f662c0a2f5110be4afff0a24e0c123540/arch/arm64/include/asm/unistd32.h#L7 ↩