summaryrefslogtreecommitdiff
path: root/tools/include/nolibc/arch-s390.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2023-08-29 05:03:24 +0300
committerLinus Torvalds <torvalds@linux-foundation.org>2023-08-29 05:03:24 +0300
commit1c59d383390f970b891b503b7f79b63a02db2ec5 (patch)
treed8f965dd0deac6bcc28a4022b51b772129ebdad6 /tools/include/nolibc/arch-s390.h
parent815c24a085dd8ab9bb7381e455afdb3f9c260e38 (diff)
parent556fb7131e03b0283672fb40f6dc2d151752aaa7 (diff)
downloadlinux-1c59d383390f970b891b503b7f79b63a02db2ec5.tar.xz
Merge tag 'linux-kselftest-nolibc-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
Pull nolibc updates from Shuah Khan: "Nolibc: - improved portability by removing build errors with -ENOSYS - added syscall6() on MIPS to support pselect6() and mmap() - added setvbuf(), rmdir(), pipe(), pipe2() - add support for ppc/ppc64 - environ is no longer optional - fixed frame pointer issues at -O0 - dropped sys_stat() in favor of sys_statx() - centralized _start_c() to remove lots of asm code - switched size_t to __SIZE_TYPE__ Selftests: - improved status reporting (success/warning/failure counts, path to log file) - various code cleanups (indent, unused variables, ...) - more consistent test numbering - enabled compiler warnings - dropped unreliable chmod_net test - improved reliability (create /dev/zero & /tmp, rely less on /proc) - new tests (brk/sbrk/mmap/munmap) - improved compatibility with musl - new run-nolibc-test target to build and run natively - new run-libc-test target to build and run against native libc - made the cmdline parser more reliable against boolean arguments - dropped dependency on memfd for vfprintf() test - nolibc-test is no longer stripped - added support for extending ARCH via XARCH Other: - add Thomas as co-maintainer" * tag 'linux-kselftest-nolibc-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: (103 commits) tools/nolibc: avoid undesired casts in the __sysret() macro tools/nolibc: keep brk(), sbrk(), mmap() away from __sysret() tools/nolibc: silence ppc64 compile warnings selftests/nolibc: libc-test: use HOSTCC instead of CC tools/nolibc: stackprotector.h: make __stack_chk_init static selftests/nolibc: allow report with existing test log selftests/nolibc: add test support for ppc64 selftests/nolibc: add test support for ppc64le selftests/nolibc: add test support for ppc selftests/nolibc: add XARCH and ARCH mapping support tools/nolibc: add support for powerpc64 tools/nolibc: add support for powerpc MAINTAINERS: nolibc: add myself as co-maintainer selftests/nolibc: enable compiler warnings selftests/nolibc: don't strip nolibc-test selftests/nolibc: prevent out of bounds access in expect_vfprintf selftests/nolibc: use correct return type for read() and write() selftests/nolibc: avoid sign-compare warnings selftests/nolibc: avoid unused parameter warnings selftests/nolibc: make functions static if possible ...
Diffstat (limited to 'tools/include/nolibc/arch-s390.h')
-rw-r--r--tools/include/nolibc/arch-s390.h77
1 files changed, 13 insertions, 64 deletions
diff --git a/tools/include/nolibc/arch-s390.h b/tools/include/nolibc/arch-s390.h
index 516dff5bff8b..5d60fd43f883 100644
--- a/tools/include/nolibc/arch-s390.h
+++ b/tools/include/nolibc/arch-s390.h
@@ -9,31 +9,7 @@
#include <asm/unistd.h>
#include "compiler.h"
-
-/* The struct returned by the stat() syscall, equivalent to stat64(). The
- * syscall returns 116 bytes and stops in the middle of __unused.
- */
-
-struct sys_stat_struct {
- unsigned long st_dev;
- unsigned long st_ino;
- unsigned long st_nlink;
- unsigned int st_mode;
- unsigned int st_uid;
- unsigned int st_gid;
- unsigned int __pad1;
- unsigned long st_rdev;
- unsigned long st_size;
- unsigned long st_atime;
- unsigned long st_atime_nsec;
- unsigned long st_mtime;
- unsigned long st_mtime_nsec;
- unsigned long st_ctime;
- unsigned long st_ctime_nsec;
- unsigned long st_blksize;
- long st_blocks;
- unsigned long __unused[3];
-};
+#include "crt.h"
/* Syscalls for s390:
* - registers are 64-bit
@@ -52,7 +28,7 @@ struct sys_stat_struct {
register long _num __asm__ ("1") = (num); \
register long _rc __asm__ ("2"); \
\
- __asm__ volatile ( \
+ __asm__ volatile ( \
"svc 0\n" \
: "=d"(_rc) \
: "d"(_num) \
@@ -66,7 +42,7 @@ struct sys_stat_struct {
register long _num __asm__ ("1") = (num); \
register long _arg1 __asm__ ("2") = (long)(arg1); \
\
- __asm__ volatile ( \
+ __asm__ volatile ( \
"svc 0\n" \
: "+d"(_arg1) \
: "d"(_num) \
@@ -81,7 +57,7 @@ struct sys_stat_struct {
register long _arg1 __asm__ ("2") = (long)(arg1); \
register long _arg2 __asm__ ("3") = (long)(arg2); \
\
- __asm__ volatile ( \
+ __asm__ volatile ( \
"svc 0\n" \
: "+d"(_arg1) \
: "d"(_arg2), "d"(_num) \
@@ -97,7 +73,7 @@ struct sys_stat_struct {
register long _arg2 __asm__ ("3") = (long)(arg2); \
register long _arg3 __asm__ ("4") = (long)(arg3); \
\
- __asm__ volatile ( \
+ __asm__ volatile ( \
"svc 0\n" \
: "+d"(_arg1) \
: "d"(_arg2), "d"(_arg3), "d"(_num) \
@@ -114,7 +90,7 @@ struct sys_stat_struct {
register long _arg3 __asm__ ("4") = (long)(arg3); \
register long _arg4 __asm__ ("5") = (long)(arg4); \
\
- __asm__ volatile ( \
+ __asm__ volatile ( \
"svc 0\n" \
: "+d"(_arg1) \
: "d"(_arg2), "d"(_arg3), "d"(_arg4), "d"(_num) \
@@ -132,7 +108,7 @@ struct sys_stat_struct {
register long _arg4 __asm__ ("5") = (long)(arg4); \
register long _arg5 __asm__ ("6") = (long)(arg5); \
\
- __asm__ volatile ( \
+ __asm__ volatile ( \
"svc 0\n" \
: "+d"(_arg1) \
: "d"(_arg2), "d"(_arg3), "d"(_arg4), "d"(_arg5), \
@@ -152,7 +128,7 @@ struct sys_stat_struct {
register long _arg5 __asm__ ("6") = (long)(arg5); \
register long _arg6 __asm__ ("7") = (long)(arg6); \
\
- __asm__ volatile ( \
+ __asm__ volatile ( \
"svc 0\n" \
: "+d"(_arg1) \
: "d"(_arg2), "d"(_arg3), "d"(_arg4), "d"(_arg5), \
@@ -162,41 +138,14 @@ struct sys_stat_struct {
_arg1; \
})
-char **environ __attribute__((weak));
-const unsigned long *_auxv __attribute__((weak));
-
/* startup code */
-void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) __no_stack_protector _start(void)
+void __attribute__((weak, noreturn, optimize("Os", "omit-frame-pointer"))) __no_stack_protector _start(void)
{
__asm__ volatile (
- "lg %r2,0(%r15)\n" /* argument count */
- "la %r3,8(%r15)\n" /* argument pointers */
-
- "xgr %r0,%r0\n" /* r0 will be our NULL value */
- /* search for envp */
- "lgr %r4,%r3\n" /* start at argv */
- "0:\n"
- "clg %r0,0(%r4)\n" /* entry zero? */
- "la %r4,8(%r4)\n" /* advance pointer */
- "jnz 0b\n" /* no -> test next pointer */
- /* yes -> r4 now contains start of envp */
- "larl %r1,environ\n"
- "stg %r4,0(%r1)\n"
-
- /* search for auxv */
- "lgr %r5,%r4\n" /* start at envp */
- "1:\n"
- "clg %r0,0(%r5)\n" /* entry zero? */
- "la %r5,8(%r5)\n" /* advance pointer */
- "jnz 1b\n" /* no -> test next pointer */
- "larl %r1,_auxv\n" /* yes -> store value in _auxv */
- "stg %r5,0(%r1)\n"
-
- "aghi %r15,-160\n" /* allocate new stackframe */
- "xc 0(8,%r15),0(%r15)\n" /* clear backchain */
- "brasl %r14,main\n" /* ret value of main is arg to exit */
- "lghi %r1,1\n" /* __NR_exit */
- "svc 0\n"
+ "lgr %r2, %r15\n" /* save stack pointer to %r2, as arg1 of _start_c */
+ "aghi %r15, -160\n" /* allocate new stackframe */
+ "xc 0(8,%r15), 0(%r15)\n" /* clear backchain */
+ "brasl %r14, _start_c\n" /* transfer to c runtime */
);
__builtin_unreachable();
}