All of the linux-ppc64x Syscall functions return the contents of R4 as syscall return r2.
#42178 previously ran into issues because system calls were getting inconsistent r2 values. The short-term workaround there was to ignore r2 for AllThreadsSyscall, with the assumption that some syscalls may use r2.
On further investigation, it looks like that is not true.
The system call entrypoint I find a bit difficult to follow, as it is unclear exactly what function pointers are loaded by __LOAD_HANDLER, but not seeing lots of assembly implementations, I assume these are the C system call implementations.
syscall_exit_prepare seems pretty clear that it only expects to use R3 for the return value.
Thus my conclusion is that R4 is never a syscall return value and our syscall implementations should change to unconditionally returning 0 for r2.
Anyone know if I missed something that should keep R4 in use?
R4 is clobbered upon return from a syscall. Only R3 and CR0SO convey status on PPC64 via SYSCALL. Storing a consistent value of 0 to r2 seems much more reasonable than what is done now.
dmitshur
added
NeedsFix
The path to resolution is known, but the work has not been done.
and removed
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
labels
Mar 7, 2022
All of the linux-ppc64x Syscall functions return the contents of R4 as syscall return r2.
#42178 previously ran into issues because system calls were getting inconsistent r2 values. The short-term workaround there was to ignore r2 for AllThreadsSyscall, with the assumption that some syscalls may use r2.
On further investigation, it looks like that is not true.
The Linux ppc64 system call ABI documentation lists only R3 as a return value, with R4 getting clobbered.
The system call entrypoint I find a bit difficult to follow, as it is unclear exactly what function pointers are loaded by
__LOAD_HANDLER
, but not seeing lots of assembly implementations, I assume these are the C system call implementations.syscall_exit_prepare seems pretty clear that it only expects to use R3 for the return value.
Thus my conclusion is that R4 is never a syscall return value and our syscall implementations should change to unconditionally returning 0 for r2.
Anyone know if I missed something that should keep R4 in use?
cc @minux @cherrymui @aclements @AndrewGMorgan @laboger
The text was updated successfully, but these errors were encountered: