microblaze: Use the correct select syscall (BZ #28883)

Message ID 20220216141638.477808-1-adhemerval.zanella@linaro.org
State Committed
Headers
Series microblaze: Use the correct select syscall (BZ #28883) |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent
dj/TryBot-32bit success Build for i686

Commit Message

Adhemerval Zanella Netto Feb. 16, 2022, 2:16 p.m. UTC
  On Microblaze only __NR_newselect is implemented, even though kernel
advertise __NR_select on asm/unistd.h.  Instead of adding an ad-hoc
logic on select.c, change the __NR_select of microblaze by overwritting
with fixup-asm-unistd.h.
---
 .../unix/sysv/linux/microblaze/arch-syscall.h |  2 +-
 .../sysv/linux/microblaze/fixup-asm-unistd.h  | 26 +++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)
 create mode 100644 sysdeps/unix/sysv/linux/microblaze/fixup-asm-unistd.h
  

Comments

Andreas Schwab Feb. 16, 2022, 3:15 p.m. UTC | #1
On Feb 16 2022, Adhemerval Zanella via Libc-alpha wrote:

> On Microblaze only __NR_newselect is implemented, even though kernel
> advertise __NR_select on asm/unistd.h.  Instead of adding an ad-hoc
> logic on select.c, change the __NR_select of microblaze by overwritting
> with fixup-asm-unistd.h.

Microblaze is the only architecture that undefines __ASSUME_PSELECT (for
very old kernels), so it is the only one to actually trigger that
fallback in select.c.  I think that fallback could just be changed to
use _newselect instead.
  
Mark Hatle Feb. 16, 2022, 3:48 p.m. UTC | #2
The other option would be to remove the non-__assume_pselect path, and simply 
require all systems to have pselect.  (This would require microblaze to move to 
kernel 3.15 minimum, which may be reasonable behavior.)

(It has been a long time since Xilinx has shipped a kernel older then 3.15, so 
it would be down to specific users trying to hold onto an older kernel.)

--Mark

On 2/16/22 9:15 AM, Andreas Schwab wrote:
> On Feb 16 2022, Adhemerval Zanella via Libc-alpha wrote:
> 
>> On Microblaze only __NR_newselect is implemented, even though kernel
>> advertise __NR_select on asm/unistd.h.  Instead of adding an ad-hoc
>> logic on select.c, change the __NR_select of microblaze by overwritting
>> with fixup-asm-unistd.h.
> 
> Microblaze is the only architecture that undefines __ASSUME_PSELECT (for
> very old kernels), so it is the only one to actually trigger that
> fallback in select.c.  I think that fallback could just be changed to
> use _newselect instead.
>
  
Adhemerval Zanella Netto Feb. 16, 2022, 4:46 p.m. UTC | #3
On 16/02/2022 12:15, Andreas Schwab wrote:
> On Feb 16 2022, Adhemerval Zanella via Libc-alpha wrote:
> 
>> On Microblaze only __NR_newselect is implemented, even though kernel
>> advertise __NR_select on asm/unistd.h.  Instead of adding an ad-hoc
>> logic on select.c, change the __NR_select of microblaze by overwritting
>> with fixup-asm-unistd.h.
> 
> Microblaze is the only architecture that undefines __ASSUME_PSELECT (for
> very old kernels), so it is the only one to actually trigger that
> fallback in select.c.  I think that fallback could just be changed to
> use _newselect instead.
> 

I would simpler indeed, I will update the patch.
  
Adhemerval Zanella Netto Feb. 16, 2022, 4:49 p.m. UTC | #4
On 16/02/2022 12:48, Mark Hatle wrote:
> The other option would be to remove the non-__assume_pselect path, and simply require all systems to have pselect.  (This would require microblaze to move to kernel 3.15 minimum, which may be reasonable behavior.)
> 
> (It has been a long time since Xilinx has shipped a kernel older then 3.15, so it would be down to specific users trying to hold onto an older kernel.)

I don't have a strong preference, we usually tie the minimum kernel version to
the LTS support one for the architecture.  Also, bumping the minimum kernel
version is usually done when there is room for code cleanups (which seems
minimal for this case).

> 
> --Mark
> 
> On 2/16/22 9:15 AM, Andreas Schwab wrote:
>> On Feb 16 2022, Adhemerval Zanella via Libc-alpha wrote:
>>
>>> On Microblaze only __NR_newselect is implemented, even though kernel
>>> advertise __NR_select on asm/unistd.h.  Instead of adding an ad-hoc
>>> logic on select.c, change the __NR_select of microblaze by overwritting
>>> with fixup-asm-unistd.h.
>>
>> Microblaze is the only architecture that undefines __ASSUME_PSELECT (for
>> very old kernels), so it is the only one to actually trigger that
>> fallback in select.c.  I think that fallback could just be changed to
>> use _newselect instead.
>>
  

Patch

diff --git a/sysdeps/unix/sysv/linux/microblaze/arch-syscall.h b/sysdeps/unix/sysv/linux/microblaze/arch-syscall.h
index 6e10c3661d..06c0575325 100644
--- a/sysdeps/unix/sysv/linux/microblaze/arch-syscall.h
+++ b/sysdeps/unix/sysv/linux/microblaze/arch-syscall.h
@@ -313,7 +313,7 @@ 
 #define __NR_sched_setscheduler 156
 #define __NR_sched_yield 158
 #define __NR_seccomp 384
-#define __NR_select 82
+#define __NR_select 142
 #define __NR_semctl 328
 #define __NR_semget 329
 #define __NR_semop 330
diff --git a/sysdeps/unix/sysv/linux/microblaze/fixup-asm-unistd.h b/sysdeps/unix/sysv/linux/microblaze/fixup-asm-unistd.h
new file mode 100644
index 0000000000..bbb82c4588
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/microblaze/fixup-asm-unistd.h
@@ -0,0 +1,26 @@ 
+/* Regularize <asm/unistd.h> definitions.  Microblaze version.
+   Copyright (C) 2022 Free Software Foundation, Inc.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+/* Microblaze does not implement __NR_select, besides kernel advertise
+   it.  Also, make it failproof if kernel decides to remove the bogus
+   __NR_select definition.  */
+#ifdef __NR_select
+# undef __NR_select
+#endif
+#ifndef __NR_select
+# define __NR_select __NR__newselect
+#endif