summaryrefslogtreecommitdiff
path: root/tools/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2024-01-09 17:14:32 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2024-01-09 17:14:32 -0800
commit5d09f61e505a614250df24a0f7e646802e40fc87 (patch)
tree430e7c78065becc3220bcceceaee98cf08104df0 /tools/include
parenta7e4c6cf5bbbd8fea2be1cef0540e5cf107c43c2 (diff)
parentd543d9ddf593b1f4cb1d57d9ac0ad279fe18adaf (diff)
Merge tag 'linux_kselftest-nolibc-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
Pull nolibc updates from Shuah Khan: - 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 * tag 'linux_kselftest-nolibc-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: (22 commits) selftests/nolibc: disable coredump via setrlimit tools/nolibc: add support for getrlimit/setrlimit tools/nolibc: drop custom definition of struct rusage tools/nolibc: drop duplicated testcase ioctl_tiocinq tools/nolibc: annotate va_list printf formats selftests/nolibc: make result alignment more robust tools/nolibc: mips: add support for PIC selftests/nolibc: run-tests.sh: enable testing via qemu-user selftests/nolibc: introduce QEMU_ARCH_USER selftests/nolibc: fix testcase status alignment selftests/nolibc: add configuration for mipso32be selftests/nolibc: extraconfig support selftests/nolibc: explicitly specify ABI for MIPS selftests/nolibc: use XARCH for MIPS tools/nolibc: move MIPS ABI validation into arch-mips.h tools/nolibc: error out on unsupported architecture selftests/nolibc: add script to run testsuite selftests/nolibc: support out-of-tree builds selftests/nolibc: anchor paths in $(srcdir) if possible selftests/nolibc: use EFI -bios for LoongArch qemu ...
Diffstat (limited to 'tools/include')
-rw-r--r--tools/include/nolibc/arch-mips.h11
-rw-r--r--tools/include/nolibc/arch.h4
-rw-r--r--tools/include/nolibc/stdio.h4
-rw-r--r--tools/include/nolibc/sys.h38
-rw-r--r--tools/include/nolibc/types.h25
5 files changed, 55 insertions, 27 deletions
diff --git a/tools/include/nolibc/arch-mips.h b/tools/include/nolibc/arch-mips.h
index 4ab6fa54beee..62cc50ef3288 100644
--- a/tools/include/nolibc/arch-mips.h
+++ b/tools/include/nolibc/arch-mips.h
@@ -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 */
diff --git a/tools/include/nolibc/arch.h b/tools/include/nolibc/arch.h
index e276fb0680af..c8f4e5d3add9 100644
--- a/tools/include/nolibc/arch.h
+++ b/tools/include/nolibc/arch.h
@@ -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 */
diff --git a/tools/include/nolibc/stdio.h b/tools/include/nolibc/stdio.h
index d7ef43973916..16cd4d807251 100644
--- a/tools/include/nolibc/stdio.h
+++ b/tools/include/nolibc/stdio.h
@@ -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);
diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h
index 2f359cb03d10..dda9dffd1d74 100644
--- a/tools/include/nolibc/sys.h
+++ b/tools/include/nolibc/sys.h
@@ -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"
@@ -899,6 +900,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);
*/
diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h
index 8cfc4c860fa4..b26a5d0c417c 100644
--- a/tools/include/nolibc/types.h
+++ b/tools/include/nolibc/types.h
@@ -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.
*/