System call select on R4600
After trace system, found this problem is from scall_o32.S line 161 in 2.4.26 kernel.
bltz t0, bad_stack # -> sp is bad
If stack address larger than 0x7fffffff, branch will take, and that's why I got "-4142" errno on select system call even parameters in stack are correct. I tried to remove this line and seems "select" works fine.
-----Original message-----
From:Ralf Baechle <[email protected]>
To:Macleod <[email protected]>
Cc:[email protected]
Date:Sun, 22 Aug 2004 14:14:36 +0200
Subject:Re: System call select on R4600
Quoted 6 lines · Macleod
My problem is "select" system call always return -1 and errno is -4142, but
sys_selecthas never been called. Think, it has some problem on handling system call. Because if I changeSYS(sys_select, 5)to 4 arguments,sys_selectwill be executed.
Thanks!
This is a bug which was fixed a while ago. I assume your application is picking up a bad definition from an old kernel header package or so. Still doing syscalls directly is a fragily; better avoid and use your libc's select(3).
Ralf
Quoted 9 lines · Macleod
After trace system, found this problem is from
scall_o32.Sline 161 in 2.4.26 kernel.bltz t0,
bad_stack# -> sp is badIf stack address larger than
0x7fffffff, branch will take, and that's why I got "-4142" errno on select system call even parameters in stack are correct. I tried to remove this line and seems "select" works fine.
Oh yes, I forgot on this one :-) It's intentional; making all syscalls work from kernel mode would add some overhead. Possible solutions:
- move to 64-bit kernels; the 64-bit syscall interface happens to support upto 8 arguments for syscalls from kernel mode.
- move your module or parts of it to userspace. Something that's using select suspiciously looks like something that shouldn't be in the kernel.
- use the proper kernel APIs. Kernel programming isn't user space programming.
Ralf