Skip to content

Commit dcfb3c0

Browse files
committed
Introduce raw syscall invocation wrappers
Unfortunately, syscall(3) provided by libc is too smart for some of our needs. * linux/raw_syscall.h: New file. * linux/aarch64/raw_syscall.h: Likewise. * linux/alpha/raw_syscall.h: Likewise. * linux/arc/raw_syscall.h: Likewise. * linux/arm/raw_syscall.h: Likewise. * linux/avr32/raw_syscall.h: Likewise. * linux/bfin/raw_syscall.h: Likewise. * linux/hppa/raw_syscall.h: Likewise. * linux/i386/raw_syscall.h: Likewise. * linux/ia64/raw_syscall.h: Likewise. * linux/m68k/raw_syscall.h: Likewise. * linux/metag/raw_syscall.h: Likewise. * linux/microblaze/raw_syscall.h: Likewise. * linux/mips/raw_syscall.h: Likewise. * linux/nios2/raw_syscall.h: Likewise. * linux/or1k/raw_syscall.h: Likewise. * linux/powerpc/raw_syscall.h: Likewise. * linux/powerpc64/raw_syscall.h: Likewise. * linux/riscv/raw_syscall.h: Likewise. * linux/s390/raw_syscall.h: Likewise. * linux/s390x/raw_syscall.h: Likewise. * linux/sh/raw_syscall.h: Likewise. * linux/sh64/raw_syscall.h: Likewise. * linux/sparc/raw_syscall.h: Likewise. * linux/sparc64/raw_syscall.h: Likewise. * linux/tile/raw_syscall.h: Likewise. * linux/x32/raw_syscall.h: Likewise. * linux/x86_64/raw_syscall.h: Likewise. * linux/xtensa/raw_syscall.h: Likewise. * Makefile.am (EXTRA_DIST): Add them.
1 parent 73edd44 commit dcfb3c0

File tree

30 files changed

+1274
-0
lines changed

30 files changed

+1274
-0
lines changed

Makefile.am

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ EXTRA_DIST = \
409409
linux/aarch64/ioctls_inc0.h \
410410
linux/aarch64/ioctls_inc1.h \
411411
linux/aarch64/nr_prefix.c \
412+
linux/aarch64/raw_syscall.h \
412413
linux/aarch64/set_error.c \
413414
linux/aarch64/set_scno.c \
414415
linux/aarch64/shuffle_scno.c \
@@ -428,6 +429,7 @@ EXTRA_DIST = \
428429
linux/alpha/get_syscall_result.c \
429430
linux/alpha/ioctls_arch0.h \
430431
linux/alpha/ioctls_inc0.h \
432+
linux/alpha/raw_syscall.h \
431433
linux/alpha/set_error.c \
432434
linux/alpha/set_scno.c \
433435
linux/alpha/signalent.h \
@@ -441,6 +443,7 @@ EXTRA_DIST = \
441443
linux/arc/get_syscall_args.c \
442444
linux/arc/ioctls_arch0.h \
443445
linux/arc/ioctls_inc0.h \
446+
linux/arc/raw_syscall.h \
444447
linux/arc/set_error.c \
445448
linux/arc/set_scno.c \
446449
linux/arc/syscallent.h \
@@ -459,6 +462,7 @@ EXTRA_DIST = \
459462
linux/arm/ioctls_arch0.h \
460463
linux/arm/ioctls_inc0.h \
461464
linux/arm/nr_prefix.c \
465+
linux/arm/raw_syscall.h \
462466
linux/arm/set_error.c \
463467
linux/arm/set_scno.c \
464468
linux/arm/shuffle_scno.c \
@@ -472,6 +476,7 @@ EXTRA_DIST = \
472476
linux/avr32/get_syscall_args.c \
473477
linux/avr32/ioctls_arch0.h \
474478
linux/avr32/ioctls_inc0.h \
479+
linux/avr32/raw_syscall.h \
475480
linux/avr32/set_error.c \
476481
linux/avr32/set_scno.c \
477482
linux/avr32/syscallent.h \
@@ -485,6 +490,7 @@ EXTRA_DIST = \
485490
linux/bfin/get_syscall_result.c \
486491
linux/bfin/ioctls_arch0.h \
487492
linux/bfin/ioctls_inc0.h \
493+
linux/bfin/raw_syscall.h \
488494
linux/bfin/rt_sigframe.h \
489495
linux/bfin/set_error.c \
490496
linux/bfin/set_scno.c \
@@ -504,6 +510,7 @@ EXTRA_DIST = \
504510
linux/hppa/get_syscall_result.c \
505511
linux/hppa/ioctls_arch0.h \
506512
linux/hppa/ioctls_inc0.h \
513+
linux/hppa/raw_syscall.h \
507514
linux/hppa/rt_sigframe.h \
508515
linux/hppa/set_error.c \
509516
linux/hppa/set_scno.c \
@@ -520,6 +527,7 @@ EXTRA_DIST = \
520527
linux/i386/get_syscall_args.c \
521528
linux/i386/ioctls_arch0.h \
522529
linux/i386/ioctls_inc0.h \
530+
linux/i386/raw_syscall.h \
523531
linux/i386/rt_sigframe.h \
524532
linux/i386/set_error.c \
525533
linux/i386/set_scno.c \
@@ -536,6 +544,7 @@ EXTRA_DIST = \
536544
linux/ia64/get_syscall_args.c \
537545
linux/ia64/ioctls_arch0.h \
538546
linux/ia64/ioctls_inc0.h \
547+
linux/ia64/raw_syscall.h \
539548
linux/ia64/rt_sigframe.h \
540549
linux/ia64/set_error.c \
541550
linux/ia64/set_scno.c \
@@ -552,6 +561,7 @@ EXTRA_DIST = \
552561
linux/m68k/get_syscall_args.c \
553562
linux/m68k/ioctls_arch0.h \
554563
linux/m68k/ioctls_inc0.h \
564+
linux/m68k/raw_syscall.h \
555565
linux/m68k/rt_sigframe.h \
556566
linux/m68k/set_error.c \
557567
linux/m68k/set_scno.c \
@@ -565,6 +575,7 @@ EXTRA_DIST = \
565575
linux/metag/get_syscall_args.c \
566576
linux/metag/ioctls_arch0.h \
567577
linux/metag/ioctls_inc0.h \
578+
linux/metag/raw_syscall.h \
568579
linux/metag/set_error.c \
569580
linux/metag/set_scno.c \
570581
linux/metag/syscallent.h \
@@ -578,6 +589,7 @@ EXTRA_DIST = \
578589
linux/microblaze/get_syscall_result.c \
579590
linux/microblaze/ioctls_arch0.h \
580591
linux/microblaze/ioctls_inc0.h \
592+
linux/microblaze/raw_syscall.h \
581593
linux/microblaze/set_error.c \
582594
linux/microblaze/set_scno.c \
583595
linux/microblaze/syscallent.h \
@@ -595,6 +607,7 @@ EXTRA_DIST = \
595607
linux/mips/get_syscall_args.c \
596608
linux/mips/ioctls_arch0.h \
597609
linux/mips/ioctls_inc0.h \
610+
linux/mips/raw_syscall.h \
598611
linux/mips/rt_sigframe.h \
599612
linux/mips/set_error.c \
600613
linux/mips/set_scno.c \
@@ -615,6 +628,7 @@ EXTRA_DIST = \
615628
linux/nios2/get_syscall_args.c \
616629
linux/nios2/ioctls_arch0.h \
617630
linux/nios2/ioctls_inc0.h \
631+
linux/nios2/raw_syscall.h \
618632
linux/nios2/set_error.c \
619633
linux/nios2/set_scno.c \
620634
linux/nios2/syscallent.h \
@@ -627,6 +641,7 @@ EXTRA_DIST = \
627641
linux/or1k/get_syscall_args.c \
628642
linux/or1k/ioctls_arch0.h \
629643
linux/or1k/ioctls_inc0.h \
644+
linux/or1k/raw_syscall.h \
630645
linux/or1k/set_error.c \
631646
linux/or1k/set_scno.c \
632647
linux/or1k/syscallent.h \
@@ -645,6 +660,7 @@ EXTRA_DIST = \
645660
linux/powerpc/getregs_old.h \
646661
linux/powerpc/ioctls_arch0.h \
647662
linux/powerpc/ioctls_inc0.h \
663+
linux/powerpc/raw_syscall.h \
648664
linux/powerpc/set_error.c \
649665
linux/powerpc/set_scno.c \
650666
linux/powerpc/syscallent.h \
@@ -665,13 +681,15 @@ EXTRA_DIST = \
665681
linux/powerpc64/ioctls_arch1.h \
666682
linux/powerpc64/ioctls_inc0.h \
667683
linux/powerpc64/ioctls_inc1.h \
684+
linux/powerpc64/raw_syscall.h \
668685
linux/powerpc64/rt_sigframe.h \
669686
linux/powerpc64/set_error.c \
670687
linux/powerpc64/set_scno.c \
671688
linux/powerpc64/signalent1.h \
672689
linux/powerpc64/syscallent.h \
673690
linux/powerpc64/syscallent1.h \
674691
linux/powerpc64/userent.h \
692+
linux/raw_syscall.h \
675693
linux/riscv/arch_defs_.h \
676694
linux/riscv/arch_regs.c \
677695
linux/riscv/arch_regs.h \
@@ -684,6 +702,7 @@ EXTRA_DIST = \
684702
linux/riscv/ioctls_arch1.h \
685703
linux/riscv/ioctls_inc0.h \
686704
linux/riscv/ioctls_inc1.h \
705+
linux/riscv/raw_syscall.h \
687706
linux/riscv/set_error.c \
688707
linux/riscv/set_scno.c \
689708
linux/riscv/signalent1.h \
@@ -700,6 +719,7 @@ EXTRA_DIST = \
700719
linux/s390/get_syscall_args.c \
701720
linux/s390/ioctls_arch0.h \
702721
linux/s390/ioctls_inc0.h \
722+
linux/s390/raw_syscall.h \
703723
linux/s390/rt_sigframe.h \
704724
linux/s390/set_error.c \
705725
linux/s390/set_scno.c \
@@ -720,6 +740,7 @@ EXTRA_DIST = \
720740
linux/s390x/ioctls_arch1.h \
721741
linux/s390x/ioctls_inc0.h \
722742
linux/s390x/ioctls_inc1.h \
743+
linux/s390x/raw_syscall.h \
723744
linux/s390x/rt_sigframe.h \
724745
linux/s390x/set_error.c \
725746
linux/s390x/set_scno.c \
@@ -737,6 +758,7 @@ EXTRA_DIST = \
737758
linux/sh/get_syscall_result.c \
738759
linux/sh/ioctls_arch0.h \
739760
linux/sh/ioctls_inc0.h \
761+
linux/sh/raw_syscall.h \
740762
linux/sh/set_error.c \
741763
linux/sh/set_scno.c \
742764
linux/sh/syscallent.h \
@@ -752,6 +774,7 @@ EXTRA_DIST = \
752774
linux/sh64/get_syscall_result.c \
753775
linux/sh64/ioctls_arch0.h \
754776
linux/sh64/ioctls_inc0.h \
777+
linux/sh64/raw_syscall.h \
755778
linux/sh64/rt_sigframe.h \
756779
linux/sh64/set_error.c \
757780
linux/sh64/set_scno.c \
@@ -773,6 +796,7 @@ EXTRA_DIST = \
773796
linux/sparc/get_syscall_args.c \
774797
linux/sparc/ioctls_arch0.h \
775798
linux/sparc/ioctls_inc0.h \
799+
linux/sparc/raw_syscall.h \
776800
linux/sparc/rt_sigframe.h \
777801
linux/sparc/set_error.c \
778802
linux/sparc/set_scno.c \
@@ -794,6 +818,7 @@ EXTRA_DIST = \
794818
linux/sparc64/ioctls_arch1.h \
795819
linux/sparc64/ioctls_inc0.h \
796820
linux/sparc64/ioctls_inc1.h \
821+
linux/sparc64/raw_syscall.h \
797822
linux/sparc64/rt_sigframe.h \
798823
linux/sparc64/set_error.c \
799824
linux/sparc64/set_scno.c \
@@ -817,6 +842,7 @@ EXTRA_DIST = \
817842
linux/tile/ioctls_arch1.h \
818843
linux/tile/ioctls_inc0.h \
819844
linux/tile/ioctls_inc1.h \
845+
linux/tile/raw_syscall.h \
820846
linux/tile/rt_sigframe.h \
821847
linux/tile/set_error.c \
822848
linux/tile/set_scno.c \
@@ -841,6 +867,7 @@ EXTRA_DIST = \
841867
linux/x32/ioctls_arch1.h \
842868
linux/x32/ioctls_inc0.h \
843869
linux/x32/ioctls_inc1.h \
870+
linux/x32/raw_syscall.h \
844871
linux/x32/rt_sigframe.h \
845872
linux/x32/set_error.c \
846873
linux/x32/set_scno.c \
@@ -868,6 +895,7 @@ EXTRA_DIST = \
868895
linux/x86_64/ioctls_inc0.h \
869896
linux/x86_64/ioctls_inc1.h \
870897
linux/x86_64/ioctls_inc2.h \
898+
linux/x86_64/raw_syscall.h \
871899
linux/x86_64/rt_sigframe.h \
872900
linux/x86_64/set_error.c \
873901
linux/x86_64/set_scno.c \
@@ -886,6 +914,7 @@ EXTRA_DIST = \
886914
linux/xtensa/get_syscall_result.c \
887915
linux/xtensa/ioctls_arch0.h \
888916
linux/xtensa/ioctls_inc0.h \
917+
linux/xtensa/raw_syscall.h \
889918
linux/xtensa/set_error.c \
890919
linux/xtensa/set_scno.c \
891920
linux/xtensa/syscallent.h \

linux/aarch64/raw_syscall.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Raw syscalls.
3+
*
4+
* Copyright (c) 2018 The strace developers.
5+
* All rights reserved.
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions
9+
* are met:
10+
* 1. Redistributions of source code must retain the above copyright
11+
* notice, this list of conditions and the following disclaimer.
12+
* 2. Redistributions in binary form must reproduce the above copyright
13+
* notice, this list of conditions and the following disclaimer in the
14+
* documentation and/or other materials provided with the distribution.
15+
* 3. The name of the author may not be used to endorse or promote products
16+
* derived from this software without specific prior written permission.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21+
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*/
29+
30+
#ifndef STRACE_RAW_SYSCALL_H
31+
#define STRACE_RAW_SYSCALL_H
32+
33+
# include "kernel_types.h"
34+
35+
static inline kernel_ulong_t
36+
raw_syscall_0(const kernel_ulong_t nr, kernel_ulong_t *err)
37+
{
38+
*err = 0;
39+
register kernel_ulong_t x8 __asm__("x8") = nr;
40+
register kernel_ulong_t x0 __asm__("x0");
41+
__asm__ __volatile__("svc 0"
42+
: "=r"(x0)
43+
: "r"(x8)
44+
: "memory");
45+
return x0;
46+
}
47+
# define raw_syscall_0 raw_syscall_0
48+
49+
#endif /* !STRACE_RAW_SYSCALL_H */

linux/alpha/raw_syscall.h

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Raw syscalls.
3+
*
4+
* Copyright (c) 2018 The strace developers.
5+
* All rights reserved.
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions
9+
* are met:
10+
* 1. Redistributions of source code must retain the above copyright
11+
* notice, this list of conditions and the following disclaimer.
12+
* 2. Redistributions in binary form must reproduce the above copyright
13+
* notice, this list of conditions and the following disclaimer in the
14+
* documentation and/or other materials provided with the distribution.
15+
* 3. The name of the author may not be used to endorse or promote products
16+
* derived from this software without specific prior written permission.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21+
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*/
29+
30+
#ifndef STRACE_RAW_SYSCALL_H
31+
#define STRACE_RAW_SYSCALL_H
32+
33+
# include "kernel_types.h"
34+
35+
static inline kernel_ulong_t
36+
raw_syscall_0(const kernel_ulong_t nr, kernel_ulong_t *err)
37+
{
38+
kernel_ulong_t sc_0 = nr;
39+
register kernel_ulong_t sc_19 __asm__("$19");
40+
__asm__ __volatile__("callsys"
41+
: "+v"(sc_0), "=r"(sc_19)
42+
:
43+
: "memory", "$1", "$2", "$3", "$4", "$5", "$6",
44+
"$7", "$8", "$16", "$17", "$18", "$20", "$21",
45+
"$22", "$23", "$24", "$25", "$27", "$28");
46+
*err = sc_19;
47+
return sc_0;
48+
}
49+
# define raw_syscall_0 raw_syscall_0
50+
51+
#endif /* !STRACE_RAW_SYSCALL_H */

linux/arc/raw_syscall.h

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Raw syscalls.
3+
*
4+
* Copyright (c) 2018 The strace developers.
5+
* All rights reserved.
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions
9+
* are met:
10+
* 1. Redistributions of source code must retain the above copyright
11+
* notice, this list of conditions and the following disclaimer.
12+
* 2. Redistributions in binary form must reproduce the above copyright
13+
* notice, this list of conditions and the following disclaimer in the
14+
* documentation and/or other materials provided with the distribution.
15+
* 3. The name of the author may not be used to endorse or promote products
16+
* derived from this software without specific prior written permission.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21+
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*/
29+
30+
#ifndef STRACE_RAW_SYSCALL_H
31+
#define STRACE_RAW_SYSCALL_H
32+
33+
# include "kernel_types.h"
34+
35+
static inline kernel_ulong_t
36+
raw_syscall_0(const kernel_ulong_t nr, kernel_ulong_t *err)
37+
{
38+
*err = 0;
39+
register kernel_ulong_t r8 __asm__("r8") = nr;
40+
register kernel_ulong_t r0 __asm__("r0");
41+
42+
# ifdef __A7__
43+
# define ARC_TRAP_INSN "trap0"
44+
# elif defined __HS__
45+
# define ARC_TRAP_INSN "trap_s 0 "
46+
# else
47+
# error unrecognized arc
48+
# endif
49+
50+
__asm__ __volatile__(ARC_TRAP_INSN
51+
: "=r"(r0)
52+
: "r"(r8)
53+
: "memory");
54+
55+
# undef ARC_TRAP_INSN
56+
57+
return r0;
58+
}
59+
# define raw_syscall_0 raw_syscall_0
60+
61+
#endif /* !STRACE_RAW_SYSCALL_H */

0 commit comments

Comments
 (0)