Skip to contentSkip to conversation

nolibc changes for Linux 6.8-rc1

GIT PULL Merged Shuah Khan 2 participants 2 messages Jan 9, 2024 – Jan 10, 2024

Subsystems (2)
lore
Share & tools
lore

Shuah Khan

author maintainer
#0 lore raw

Hi Linus,

Please pull the nolibc update for Linux 6.8-rc1.

This nolibc update for Linux 6.8-rc1 consists of:

* Support for PIC mode on MIPS.
* Support for getrlimit()/setrlimit().
* Replace some custom declarations with UAPI includes.
* A new script "run-tests.sh" to run the testsuite over different architectures and configurations.
* A few non-functional code cleanups.
* Minor improvements to nolibc-test, primarily to support the test script.

There are no urgent fixes available at this time.

diff is attached. Build and nolibc tests were run on next.

thanks,
-- Shuah

----------------------------------------------------------------
The following changes since commit b85ea95d086471afb4ad062012a4d73cd328fa86:

Linux 6.7-rc1 (2023-11-12 16:19:07 -0800)

are available in the Git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest tags/linux_kselftest-nolibc-6.8-rc1

for you to fetch changes up to d543d9ddf593b1f4cb1d57d9ac0ad279fe18adaf:

selftests/nolibc: disable coredump via setrlimit (2023-12-11 22:38:37 +0100)

----------------------------------------------------------------
linux_kselftest-nolibc-6.8-rc1

This nolibc update for Linux 6.8-rc1 consists of:

* Support for PIC mode on MIPS.
* Support for getrlimit()/setrlimit().
* Replace some custom declarations with UAPI includes.
* A new script "run-tests.sh" to run the testsuite over different architectures and configurations.
* A few non-functional code cleanups.
* Minor improvements to nolibc-test, primarily to support the test script.

There are no urgent fixes available at this time.

----------------------------------------------------------------
Mark Brown (1):
tools/nolibc: Use linux/wait.h rather than duplicating it

Thomas Weißschuh (21):
selftests/nolibc: don't hang on config input selftests/nolibc: use EFI -bios for LoongArch qemu selftests/nolibc: anchor paths in $(srcdir) if possible selftests/nolibc: support out-of-tree builds selftests/nolibc: add script to run testsuite tools/nolibc: error out on unsupported architecture tools/nolibc: move MIPS ABI validation into arch-mips.h selftests/nolibc: use XARCH for MIPS selftests/nolibc: explicitly specify ABI for MIPS selftests/nolibc: extraconfig support selftests/nolibc: add configuration for mipso32be selftests/nolibc: fix testcase status alignment selftests/nolibc: introduce QEMU_ARCH_USER selftests/nolibc: run-tests.sh: enable testing via qemu-user tools/nolibc: mips: add support for PIC selftests/nolibc: make result alignment more robust tools/nolibc: annotate va_list printf formats tools/nolibc: drop duplicated testcase ioctl_tiocinq tools/nolibc: drop custom definition of struct rusage tools/nolibc: add support for getrlimit/setrlimit selftests/nolibc: disable coredump via setrlimit

 tools/include/nolibc/arch-mips.h             |  11 +-
 tools/include/nolibc/arch.h                  |   4 +-
 tools/include/nolibc/stdio.h                 |   4 +-
 tools/include/nolibc/sys.h                   |  38 ++++++
 tools/include/nolibc/types.h                 |  25 +---
 tools/testing/selftests/nolibc/.gitignore    |   1 +
 tools/testing/selftests/nolibc/Makefile      |  65 ++++++++---
 tools/testing/selftests/nolibc/nolibc-test.c |  51 ++++++--
 tools/testing/selftests/nolibc/run-tests.sh  | 169 +++++++++++++++++++++++++++
 9 files changed, 318 insertions(+), 50 deletions(-)
 create mode 100755 tools/testing/selftests/nolibc/run-tests.sh

----------------------------------------------------------------

tools/include/nolibc/arch-mips.h +10 -1
index 4ab6fa54beee..62cc50ef3288 100644
@@ -10,6 +10,10 @@
 #include "compiler.h"
 #include "crt.h"
 
+#if !defined(_ABIO32)
+#error Unsupported MIPS ABI
+#endif
+
 /* Syscalls for MIPS ABI O32 :
  *   - WARNING! there's always a delayed slot!
  *   - WARNING again, the syntax is different, registers take a '$' and numbers
@@ -180,8 +184,13 @@ void __attribute__((weak, noreturn, optimize("Os", "omit-frame-pointer"))) __no_
 	__asm__ volatile (
 		".set push\n"
 		".set noreorder\n"
-		".option pic0\n"
+		"bal 1f\n"               /* prime $ra for .cpload                            */
+		"nop\n"
+		"1:\n"
+		".cpload $ra\n"
 		"move  $a0, $sp\n"       /* save stack pointer to $a0, as arg1 of _start_c */
+		"addiu $sp, $sp, -4\n"   /* space for .cprestore to store $gp              */
+		".cprestore 0\n"
 		"li    $t0, -8\n"
 		"and   $sp, $sp, $t0\n"  /* $sp must be 8-byte aligned                     */
 		"addiu $sp, $sp, -16\n"  /* the callee expects to save a0..a3 there        */
tools/include/nolibc/arch.h +3 -1
index e276fb0680af..c8f4e5d3add9 100644
@@ -23,7 +23,7 @@
 #include "arch-arm.h"
 #elif defined(__aarch64__)
 #include "arch-aarch64.h"
-#elif defined(__mips__) && defined(_ABIO32)
+#elif defined(__mips__)
 #include "arch-mips.h"
 #elif defined(__powerpc__)
 #include "arch-powerpc.h"
@@ -33,6 +33,8 @@
 #include "arch-s390.h"
 #elif defined(__loongarch__)
 #include "arch-loongarch.h"
+#else
+#error Unsupported Architecture
 #endif
 
 #endif /* _NOLIBC_ARCH_H */
tools/include/nolibc/stdio.h +2 -2
index d7ef43973916..16cd4d807251 100644
@@ -212,7 +212,7 @@ char *fgets(char *s, int size, FILE *stream)
  *  - %s
  *  - unknown modifiers are ignored.
  */
-static __attribute__((unused))
+static __attribute__((unused, format(printf, 2, 0)))
 int vfprintf(FILE *stream, const char *fmt, va_list args)
 {
 	char escape, lpref, c;
@@ -318,7 +318,7 @@ int vfprintf(FILE *stream, const char *fmt, va_list args)
 	return written;
 }
 
-static __attribute__((unused))
+static __attribute__((unused, format(printf, 1, 0)))
 int vprintf(const char *fmt, va_list args)
 {
 	return vfprintf(stdout, fmt, args);
tools/include/nolibc/sys.h +38 -0
index 2f359cb03d10..dda9dffd1d74 100644
@@ -21,6 +21,7 @@
 #include <linux/fcntl.h> /* for O_* and AT_* */
 #include <linux/stat.h>  /* for statx() */
 #include <linux/prctl.h>
+#include <linux/resource.h>
 
 #include "arch.h"
 #include "errno.h"
@@ -898,6 +899,43 @@ int reboot(int cmd)
 }
 
 
+/*
+ * int getrlimit(int resource, struct rlimit *rlim);
+ * int setrlimit(int resource, const struct rlimit *rlim);
+ */
+
+static __attribute__((unused))
+int sys_prlimit64(pid_t pid, int resource,
+		  const struct rlimit64 *new_limit, struct rlimit64 *old_limit)
+{
+	return my_syscall4(__NR_prlimit64, pid, resource, new_limit, old_limit);
+}
+
+static __attribute__((unused))
+int getrlimit(int resource, struct rlimit *rlim)
+{
+	struct rlimit64 rlim64;
+	int ret;
+
+	ret = __sysret(sys_prlimit64(0, resource, NULL, &rlim64));
+	rlim->rlim_cur = rlim64.rlim_cur;
+	rlim->rlim_max = rlim64.rlim_max;
+
+	return ret;
+}
+
+static __attribute__((unused))
+int setrlimit(int resource, const struct rlimit *rlim)
+{
+	struct rlimit64 rlim64 = {
+		.rlim_cur = rlim->rlim_cur,
+		.rlim_max = rlim->rlim_max,
+	};
+
+	return __sysret(sys_prlimit64(0, resource, &rlim64, NULL));
+}
+
+
 /*
  * int sched_yield(void);
  */
tools/include/nolibc/types.h +2 -23
index 8cfc4c860fa4..b26a5d0c417c 100644
@@ -12,6 +12,8 @@
 #include <linux/reboot.h> /* for LINUX_REBOOT_* */
 #include <linux/stat.h>
 #include <linux/time.h>
+#include <linux/wait.h>
+#include <linux/resource.h>
 
 
 /* Only the generic macros and types may be defined here. The arch-specific
@@ -108,9 +110,6 @@
 #define WTERMSIG(status)    ((status) & 0x7f)
 #define WIFSIGNALED(status) ((status) - 1 < 0xff)
 
-/* waitpid() flags */
-#define WNOHANG      1
-
 /* standard exit() codes */
 #define EXIT_SUCCESS 0
 #define EXIT_FAILURE 1
@@ -180,26 +179,6 @@ struct linux_dirent64 {
 	char           d_name[];
 };
 
-/* needed by wait4() */
-struct rusage {
-	struct timeval ru_utime;
-	struct timeval ru_stime;
-	long   ru_maxrss;
-	long   ru_ixrss;
-	long   ru_idrss;
-	long   ru_isrss;
-	long   ru_minflt;
-	long   ru_majflt;
-	long   ru_nswap;
-	long   ru_inblock;
-	long   ru_oublock;
-	long   ru_msgsnd;
-	long   ru_msgrcv;
-	long   ru_nsignals;
-	long   ru_nvcsw;
-	long   ru_nivcsw;
-};
-
 /* The format of the struct as returned by the libc to the application, which
  * significantly differs from the format returned by the stat() syscall flavours.
  */
tools/testing/selftests/nolibc/.gitignore +1 -0
index 5119f9f7afd2..35d247a0d5bd 100644
@@ -3,4 +3,5 @@
 /libc-test
 /nolibc-test
 /run.out
+/run.out.*
 /sysroot/
tools/testing/selftests/nolibc/Makefile +50 -15

184 lines not on this page · raw message

tools/testing/selftests/nolibc/nolibc-test.c +43 -8

105 lines not on this page · raw message

tools/testing/selftests/nolibc/run-tests.sh new file +169 -0

169 lines not on this page · raw message

merge bot Merged
#1 lore raw
The pull request you sent on Mon, 8 Jan 2024 17:41:31 -0700:

The pull request you sent on Mon, 8 Jan 2024 17:41:31 -0700:

Quoted 1 line

git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest tags/linux_kselftest-nolibc-6.8-rc1

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/5d09f61e505a614250df24a0f7e646802e40fc87

Thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html