From 92e66345eed4ccd9be0f7f4447cb3031bc856ea0 Mon Sep 17 00:00:00 2001 From: Mark Hatle Date: Tue, 8 Feb 2022 20:36:33 -0800 Subject: meta-microblaze: Fix glibc issues related to select/pselect *) Select syscall is not implemented on microblaze, newselect should be used instead, but commit 4c3df0eba5e8fe98f0de917ade9b2ebba6951c5f from glibc removed this behavior. Presumably by accident. *) When the code path that doesn't use select, but instead uses pselect32 is used, microblaze provides it's own implementation but this implementation is only available when ASSUME_PSELECT is disabled. We need to fallback to the default Linux implementation. Signed-off-by: Mark Hatle --- ...Add-missing-implementation-when-__ASSUME_.patch | 61 ++++++++++++++++++++++ .../glibc/files/select-use-newselect-syscall.patch | 50 ++++++++++++++++++ .../recipes-core/glibc/glibc_2.34.bbappend | 4 ++ .../recipes-core/glibc/microblaze-glibc.inc | 7 +++ 4 files changed, 122 insertions(+) create mode 100644 meta-microblaze/recipes-core/glibc/files/0001-microblaze-Add-missing-implementation-when-__ASSUME_.patch create mode 100644 meta-microblaze/recipes-core/glibc/files/select-use-newselect-syscall.patch create mode 100644 meta-microblaze/recipes-core/glibc/glibc_2.34.bbappend create mode 100644 meta-microblaze/recipes-core/glibc/microblaze-glibc.inc (limited to 'meta-microblaze/recipes-core') diff --git a/meta-microblaze/recipes-core/glibc/files/0001-microblaze-Add-missing-implementation-when-__ASSUME_.patch b/meta-microblaze/recipes-core/glibc/files/0001-microblaze-Add-missing-implementation-when-__ASSUME_.patch new file mode 100644 index 00000000..5c0dc42a --- /dev/null +++ b/meta-microblaze/recipes-core/glibc/files/0001-microblaze-Add-missing-implementation-when-__ASSUME_.patch @@ -0,0 +1,61 @@ +From c75aa9246a8cfc814d99cf5f58229177bd69fc4f Mon Sep 17 00:00:00 2001 +From: Thomas Petazzoni +Date: Tue, 28 Dec 2021 09:09:49 -0300 +Subject: [PATCH] microblaze: Add missing implementation when + !__ASSUME_TIME64_SYSCALLS + +In commit a92f4e6299fe0e3cb6f77e79de00817aece501ce ("linux: Add time64 +pselect support"), a Microblaze specific implementation of +__pselect32() was added to cover the case of kernels < 3.15 which lack +the pselect6 system call. + +This new file sysdeps/unix/sysv/linux/microblaze/pselect32.c takes +precedence over the default implementation +sysdeps/unix/sysv/linux/pselect32.c. + +However sysdeps/unix/sysv/linux/pselect32.c provides an implementation +of __pselect32() which is needed when __ASSUME_TIME64_SYSCALLS is not +defined. On Microblaze, which is a 32-bit architecture, +__ASSUME_TIME64_SYSCALLS is only true for kernels >= 5.1. + +Due to sysdeps/unix/sysv/linux/microblaze/pselect32.c taking +precedence over sysdeps/unix/sysv/linux/pselect32.c, it means that +when we are with a kernel >= 3.15 but < 5.1, we need a __pselect32() +implementation, but sysdeps/unix/sysv/linux/microblaze/pselect32.c +doesn't provide it, and sysdeps/unix/sysv/linux/pselect32.c which +would provide it is not compiled in. + +This causes the following build failure on Microblaze with for example +Linux kernel headers 4.9: + +[...]/build/libc_pic.os: in function `__pselect64': +(.text+0x120b44): undefined reference to `__pselect32' +collect2: error: ld returned 1 exit status + +Upstream-Status: Backport [https://sourceware.org/git/?p=glibc.git;a=commit;h=c75aa9246a8cfc814d99cf5f58229177bd69fc4f] + +Signed-off-by: Thomas Petazzoni +Reviewed-by: Adhemerval Zanella +Signed-off-by: Mark Hatle +--- + sysdeps/unix/sysv/linux/microblaze/pselect32.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/sysdeps/unix/sysv/linux/microblaze/pselect32.c b/sysdeps/unix/sysv/linux/microblaze/pselect32.c +index 70b7b52a48..dd9d56ba29 100644 +--- a/sysdeps/unix/sysv/linux/microblaze/pselect32.c ++++ b/sysdeps/unix/sysv/linux/microblaze/pselect32.c +@@ -22,7 +22,9 @@ + #include + #include + +-#ifndef __ASSUME_PSELECT ++#ifndef __ASSUME_TIME64_SYSCALL ++#include ++#elif !defined __ASSUME_PSELECT + int + __pselect32 (int nfds, fd_set *readfds, fd_set *writefds, + fd_set *exceptfds, const struct __timespec64 *timeout, +-- +2.17.1 + diff --git a/meta-microblaze/recipes-core/glibc/files/select-use-newselect-syscall.patch b/meta-microblaze/recipes-core/glibc/files/select-use-newselect-syscall.patch new file mode 100644 index 00000000..04231f0a --- /dev/null +++ b/meta-microblaze/recipes-core/glibc/files/select-use-newselect-syscall.patch @@ -0,0 +1,50 @@ +Restore newselect syscall override of select syscall + +Commit 4c3df0eba5e8fe98f0de917ade9b2ebba6951c5f removed the check and override +of select syscall with newselect if newselect was defined. + +This code path, using select instead of pselect is only executed when +ASSUME_PSELECT is not enabled. This happens on microblaze when the +kernel version is set below 3.15. + +On Microblaze select is not implemented, only newselect is. So this automatic +conversion from select to newselect syscall is expected. The original +implementation of the select to newselect syscall was part of: + + commit 26f28fd73d20df8847d93f88b6e2a7bd3bd9bf51 + Author: Adhemerval Zanella + Date: Fri Nov 18 14:27:03 2016 -0200 + + Consolidate Linux select implementation + + This patch consolidates the select Linux syscall implementation on + sysdeps/unix/sysv/linux/select.c. The changes are: + + 1. Remove select from auto-generation syscalls.list on the architecture + that uses __NR_select. + 2. Remove generic implementation add a default one that handle all + current cases (with the expection of alpha) + The new default implementation will either use __NR_select if + available of fallback to __NR_pselect6 otherwise. + 3. Add a alpha outlier implementation which requires old compatibility + symbols. + +Upstream-Status: Submitted [https://sourceware.org/bugzilla/show_bug.cgi?id=28883] + +Signed-off-by: Mark Hatle + +diff --git a/sysdeps/unix/sysv/linux/select.c b/sysdeps/unix/sysv/linux/select.c +index da25b4b4cfe..0f4c67aa29e 100644 +--- a/sysdeps/unix/sysv/linux/select.c ++++ b/sysdeps/unix/sysv/linux/select.c +@@ -101,6 +116,10 @@ __select64 (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, + TIMESPEC_TO_TIMEVAL (timeout, pts32); + return r; + # else ++# ifdef __NR__newselect ++# undef __NR_select ++# define __NR_select __NR__newselect ++# endif + struct timeval tv32, *ptv32 = NULL; + if (pts64 != NULL) + { diff --git a/meta-microblaze/recipes-core/glibc/glibc_2.34.bbappend b/meta-microblaze/recipes-core/glibc/glibc_2.34.bbappend new file mode 100644 index 00000000..ab93a9b5 --- /dev/null +++ b/meta-microblaze/recipes-core/glibc/glibc_2.34.bbappend @@ -0,0 +1,4 @@ +MB_INC_FILE = "" +MB_INC_FILE:microblaze = "microblaze-glibc.inc" + +require ${MB_INC_FILE} diff --git a/meta-microblaze/recipes-core/glibc/microblaze-glibc.inc b/meta-microblaze/recipes-core/glibc/microblaze-glibc.inc new file mode 100644 index 00000000..f7820f24 --- /dev/null +++ b/meta-microblaze/recipes-core/glibc/microblaze-glibc.inc @@ -0,0 +1,7 @@ +# Workaround for microblaze being unable to boot +FILESEXTRAPATHS:append:microblaze := ":${THISDIR}/files" + +SRC_URI:append:microblaze = " \ + file://select-use-newselect-syscall.patch \ + file://0001-microblaze-Add-missing-implementation-when-__ASSUME_.patch \ +" -- cgit v1.2.3-54-g00ecf