]> granicus.if.org Git - strace/commitdiff
Move shuffle_scno to arch-specific file
authorEugene Syromyatnikov <evgsyr@gmail.com>
Wed, 31 Jan 2018 18:59:48 +0000 (19:59 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 9 Feb 2018 22:11:50 +0000 (22:11 +0000)
While we are here, let's fix AArch64 by limiting scno shuffling
to compat personality only.

* syscall.c: Include shuffle_scno.c.
(shuffle_scno): Move it to a...
* linux/arm/shuffle_scno.c: New file.
* linux/aarch64/shuffle_scno.c: New file, define arm's shuffle_scno
as arm_shuffle_scno and call it only for personality 1.
* linux/shuffle_scno.c: New file, fallback trivial shuffle_scno
definition.
* Makefile.am (EXTRA_DIST): Add them.

Makefile.am
linux/aarch64/shuffle_scno.c [new file with mode: 0644]
linux/arm/shuffle_scno.c [new file with mode: 0644]
linux/shuffle_scno.c [new file with mode: 0644]
syscall.c

index 7e0dab7813af3bff33939f6f689f470123e82f35..35859f3efdbf1c72271441016a86984c811fb798 100644 (file)
@@ -406,6 +406,7 @@ EXTRA_DIST =                                \
        linux/aarch64/ioctls_inc1.h     \
        linux/aarch64/set_error.c       \
        linux/aarch64/set_scno.c        \
+       linux/aarch64/shuffle_scno.c    \
        linux/aarch64/signalent1.h      \
        linux/aarch64/syscallent.h      \
        linux/aarch64/syscallent1.h     \
@@ -454,6 +455,7 @@ EXTRA_DIST =                                \
        linux/arm/ioctls_inc0.h         \
        linux/arm/set_error.c           \
        linux/arm/set_scno.c            \
+       linux/arm/shuffle_scno.c        \
        linux/arm/syscallent.h          \
        linux/arm/userent.h             \
        linux/avr32/arch_regs.c         \
@@ -747,6 +749,7 @@ EXTRA_DIST =                                \
        linux/sh64/set_scno.c           \
        linux/sh64/syscallent.h         \
        linux/sh64/userent.h            \
+       linux/shuffle_scno.c            \
        linux/signalent.h               \
        linux/smc_diag.h                \
        linux/sock_diag.h               \
diff --git a/linux/aarch64/shuffle_scno.c b/linux/aarch64/shuffle_scno.c
new file mode 100644 (file)
index 0000000..8184633
--- /dev/null
@@ -0,0 +1,12 @@
+#define shuffle_scno arm_shuffle_scno
+#include "../arm/shuffle_scno.c"
+#undef shuffle_scno
+
+static kernel_ulong_t
+shuffle_scno(kernel_ulong_t scno)
+{
+       if (current_personality == 1)
+               return arm_shuffle_scno(scno);
+
+       return scno;
+}
diff --git a/linux/arm/shuffle_scno.c b/linux/arm/shuffle_scno.c
new file mode 100644 (file)
index 0000000..af77f87
--- /dev/null
@@ -0,0 +1,28 @@
+static kernel_ulong_t
+shuffle_scno(kernel_ulong_t scno)
+{
+       if (scno < ARM_FIRST_SHUFFLED_SYSCALL)
+               return scno;
+
+       /* __ARM_NR_cmpxchg? Swap with LAST_ORDINARY+1 */
+       if (scno == ARM_FIRST_SHUFFLED_SYSCALL)
+               return 0x000ffff0;
+       if (scno == 0x000ffff0)
+               return ARM_FIRST_SHUFFLED_SYSCALL;
+
+#define ARM_SECOND_SHUFFLED_SYSCALL (ARM_FIRST_SHUFFLED_SYSCALL + 1)
+       /*
+        * Is it ARM specific syscall?
+        * Swap [0x000f0000, 0x000f0000 + LAST_SPECIAL] range
+        * with [SECOND_SHUFFLED, SECOND_SHUFFLED + LAST_SPECIAL] range.
+        */
+       if (scno >= 0x000f0000 &&
+           scno <= 0x000f0000 + ARM_LAST_SPECIAL_SYSCALL) {
+               return scno - 0x000f0000 + ARM_SECOND_SHUFFLED_SYSCALL;
+       }
+       if (scno <= ARM_SECOND_SHUFFLED_SYSCALL + ARM_LAST_SPECIAL_SYSCALL) {
+               return scno + 0x000f0000 - ARM_SECOND_SHUFFLED_SYSCALL;
+       }
+
+       return scno;
+}
diff --git a/linux/shuffle_scno.c b/linux/shuffle_scno.c
new file mode 100644 (file)
index 0000000..e99f55c
--- /dev/null
@@ -0,0 +1,5 @@
+static kernel_ulong_t
+shuffle_scno(kernel_ulong_t scno)
+{
+       return scno;
+}
index abd635820e3cf67f5db1c7508b5971e81392b0c5..a02a534f7f059f172cb23e7ef2d452e27acfdeef 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -490,36 +490,7 @@ dumpio(struct tcb *tcp)
  * Shuffle syscall numbers so that we don't have huge gaps in syscall table.
  * The shuffling should be an involution: shuffle_scno(shuffle_scno(n)) == n.
  */
-static kernel_ulong_t
-shuffle_scno(kernel_ulong_t scno)
-{
-#ifdef ARM_FIRST_SHUFFLED_SYSCALL      /* So far only 32-bit ARM needs this */
-       if (scno < ARM_FIRST_SHUFFLED_SYSCALL)
-               return scno;
-
-       /* __ARM_NR_cmpxchg? Swap with LAST_ORDINARY+1 */
-       if (scno == ARM_FIRST_SHUFFLED_SYSCALL)
-               return 0x000ffff0;
-       if (scno == 0x000ffff0)
-               return ARM_FIRST_SHUFFLED_SYSCALL;
-
-# define ARM_SECOND_SHUFFLED_SYSCALL (ARM_FIRST_SHUFFLED_SYSCALL + 1)
-       /*
-        * Is it ARM specific syscall?
-        * Swap [0x000f0000, 0x000f0000 + LAST_SPECIAL] range
-        * with [SECOND_SHUFFLED, SECOND_SHUFFLED + LAST_SPECIAL] range.
-        */
-       if (scno >= 0x000f0000 &&
-           scno <= 0x000f0000 + ARM_LAST_SPECIAL_SYSCALL) {
-               return scno - 0x000f0000 + ARM_SECOND_SHUFFLED_SYSCALL;
-       }
-       if (scno <= ARM_SECOND_SHUFFLED_SYSCALL + ARM_LAST_SPECIAL_SYSCALL) {
-               return scno + 0x000f0000 - ARM_SECOND_SHUFFLED_SYSCALL;
-       }
-#endif /* ARM_FIRST_SHUFFLED_SYSCALL */
-
-       return scno;
-}
+static kernel_ulong_t shuffle_scno(kernel_ulong_t scno);
 
 const char *
 err_name(unsigned long err)
@@ -1304,6 +1275,7 @@ get_syscall_result(struct tcb *tcp)
 #ifdef HAVE_GETREGS_OLD
 # include "getregs_old.c"
 #endif
+#include "shuffle_scno.c"
 
 const char *
 syscall_name(kernel_ulong_t scno)