From c37173f76de6163d746266f78a8485f576ddb6a8 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Wed, 9 Dec 2015 00:43:39 +0000 Subject: [PATCH] aarch64: swap 64-bit and 32-bit personalities Let native 64-bit personality be personality 0, and 32-bit personality be personality 1, to follow the traditional layout used for other architectures. * defs.h [AARCH64]: Swap PERSONALITY0_WORDSIZE and PERSONALITY1_WORDSIZE, remove DEFAULT_PERSONALITY. [AARCH64 && HAVE_M32_MPERS]: Rename PERSONALITY1_* to PERSONALITY0_*. * file.c [AARCH64 || defined X86_64 || defined X32]: Define STAT32_PERSONALITY for AARCH64 as well. * syscall.c (update_personality) [AARCH64]: Adjust PERSONALITY_NAMES. * linux/aarch64/errnoent1.h: Adjust comment. * linux/aarch64/get_error.c (get_error): Adjust tcp->currpers check. * linux/aarch64/get_syscall_args.c (get_syscall_args): Likewise. * linux/arm/arch_sigreturn.c (arch_sigreturn) [AARCH64]: Likewise. * linux/aarch64/get_scno.c (arch_get_scno): Adjust update_personality invocations. * linux/aarch64/ioctls_arch0.h: Swap with ... * linux/aarch64/ioctls_arch1.h: ... this file. * linux/aarch64/ioctls_inc0.h: Swap with ... * linux/aarch64/ioctls_inc1.h: ... this file. * linux/aarch64/syscallent.h: Swap with ... * linux/aarch64/syscallent1.h: ... this file. --- defs.h | 11 +++-- file.c | 6 +-- linux/aarch64/errnoent1.h | 2 +- linux/aarch64/get_error.c | 2 +- linux/aarch64/get_scno.c | 4 +- linux/aarch64/get_syscall_args.c | 2 +- linux/aarch64/ioctls_arch0.h | 2 +- linux/aarch64/ioctls_arch1.h | 2 +- linux/aarch64/ioctls_inc0.h | 2 +- linux/aarch64/ioctls_inc1.h | 2 +- linux/aarch64/syscallent.h | 72 +++++++++++++++++++++++++++++++- linux/aarch64/syscallent1.h | 72 +------------------------------- linux/arm/arch_sigreturn.c | 2 +- syscall.c | 2 +- 14 files changed, 89 insertions(+), 94 deletions(-) diff --git a/defs.h b/defs.h index d0bef941..0538bcf5 100644 --- a/defs.h +++ b/defs.h @@ -237,13 +237,12 @@ extern char *stpcpy(char *dst, const char *src); #ifdef AARCH64 /* The existing ARM personality, then AArch64 */ # define SUPPORTED_PERSONALITIES 2 -# define PERSONALITY0_WORDSIZE 4 -# define PERSONALITY1_WORDSIZE 8 -# define DEFAULT_PERSONALITY 1 +# define PERSONALITY0_WORDSIZE 8 +# define PERSONALITY1_WORDSIZE 4 # ifdef HAVE_M32_MPERS -# define PERSONALITY0_INCLUDE_FUNCS "m32_funcs.h" -# define PERSONALITY0_INCLUDE_PRINTERS_DECLS "m32_printer_decls.h" -# define PERSONALITY0_INCLUDE_PRINTERS_DEFS "m32_printer_defs.h" +# define PERSONALITY1_INCLUDE_FUNCS "m32_funcs.h" +# define PERSONALITY1_INCLUDE_PRINTERS_DECLS "m32_printer_decls.h" +# define PERSONALITY1_INCLUDE_PRINTERS_DEFS "m32_printer_defs.h" # endif #endif diff --git a/file.c b/file.c index 7f0b1b4f..3ea0b5da 100644 --- a/file.c +++ b/file.c @@ -118,11 +118,7 @@ struct stat32 { unsigned int __unused4; unsigned int __unused5; }; -# ifdef AARCH64 -# define STAT32_PERSONALITY 0 -# else -# define STAT32_PERSONALITY 1 -# endif +# define STAT32_PERSONALITY 1 # elif defined POWERPC64 struct stat32 { unsigned int st_dev; diff --git a/linux/aarch64/errnoent1.h b/linux/aarch64/errnoent1.h index babc7f2f..a0394d45 100644 --- a/linux/aarch64/errnoent1.h +++ b/linux/aarch64/errnoent1.h @@ -1,2 +1,2 @@ -/* Native AArch64 */ +/* ARM personality */ #include "errnoent.h" diff --git a/linux/aarch64/get_error.c b/linux/aarch64/get_error.c index c5c0f69c..a3aa1272 100644 --- a/linux/aarch64/get_error.c +++ b/linux/aarch64/get_error.c @@ -5,7 +5,7 @@ static void get_error(struct tcb *tcp, const bool check_errno) { - if (tcp->currpers == 0) { + if (tcp->currpers == 1) { arm_get_error(tcp, check_errno); return; } diff --git a/linux/aarch64/get_scno.c b/linux/aarch64/get_scno.c index a712a948..c0fd4822 100644 --- a/linux/aarch64/get_scno.c +++ b/linux/aarch64/get_scno.c @@ -8,14 +8,14 @@ arch_get_scno(struct tcb *tcp) case sizeof(aarch64_regs): /* We are in 64-bit mode */ scno = aarch64_regs.regs[8]; - update_personality(tcp, 1); + update_personality(tcp, 0); break; case sizeof(arm_regs): /* We are in 32-bit mode */ /* Note: we don't support OABI, unlike 32-bit ARM build */ scno = arm_regs.ARM_r7; scno = shuffle_scno(scno); - update_personality(tcp, 0); + update_personality(tcp, 1); break; } diff --git a/linux/aarch64/get_syscall_args.c b/linux/aarch64/get_syscall_args.c index b9213013..ea6e497d 100644 --- a/linux/aarch64/get_syscall_args.c +++ b/linux/aarch64/get_syscall_args.c @@ -6,7 +6,7 @@ static int get_syscall_args(struct tcb *tcp) { - if (tcp->currpers == 0) + if (tcp->currpers == 1) return arm_get_syscall_args(tcp); tcp->u_arg[0] = aarch64_regs.regs[0]; tcp->u_arg[1] = aarch64_regs.regs[1]; diff --git a/linux/aarch64/ioctls_arch0.h b/linux/aarch64/ioctls_arch0.h index b722d22b..6a674ccd 100644 --- a/linux/aarch64/ioctls_arch0.h +++ b/linux/aarch64/ioctls_arch0.h @@ -1 +1 @@ -#include "arm/ioctls_arch0.h" +/* Generated by ioctls_gen.sh from definitions found in $linux/arch/arm64/include/ tree. */ diff --git a/linux/aarch64/ioctls_arch1.h b/linux/aarch64/ioctls_arch1.h index 6a674ccd..b722d22b 100644 --- a/linux/aarch64/ioctls_arch1.h +++ b/linux/aarch64/ioctls_arch1.h @@ -1 +1 @@ -/* Generated by ioctls_gen.sh from definitions found in $linux/arch/arm64/include/ tree. */ +#include "arm/ioctls_arch0.h" diff --git a/linux/aarch64/ioctls_inc0.h b/linux/aarch64/ioctls_inc0.h index 46c11b11..f9939faa 100644 --- a/linux/aarch64/ioctls_inc0.h +++ b/linux/aarch64/ioctls_inc0.h @@ -1 +1 @@ -#include "arm/ioctls_inc0.h" +#include "64/ioctls_inc.h" diff --git a/linux/aarch64/ioctls_inc1.h b/linux/aarch64/ioctls_inc1.h index f9939faa..46c11b11 100644 --- a/linux/aarch64/ioctls_inc1.h +++ b/linux/aarch64/ioctls_inc1.h @@ -1 +1 @@ -#include "64/ioctls_inc.h" +#include "arm/ioctls_inc0.h" diff --git a/linux/aarch64/syscallent.h b/linux/aarch64/syscallent.h index 1b892be0..286e0cb3 100644 --- a/linux/aarch64/syscallent.h +++ b/linux/aarch64/syscallent.h @@ -1 +1,71 @@ -#include "../arm/syscallent.h" +#include "64/syscallent.h" + +/* Arch-specific block, not used on AArch64 */ +[244 ... 259] = { }, + +/* Quote from asm-generic/unistd.h: + * + * All syscalls below here should go away really, + * these are provided for both review and as a porting + * help for the C library version. + * + * Last chance: are any of these important enough to + * enable by default? + */ + +[1024] = { 3, TD|TF, SEN(open), "open" }, +[1025] = { 2, TF, SEN(link), "link" }, +[1026] = { 1, TF, SEN(unlink), "unlink" }, +[1027] = { 3, TF, SEN(mknod), "mknod" }, +[1028] = { 2, TF, SEN(chmod), "chmod" }, +[1029] = { 3, TF, SEN(chown), "chown" }, +[1030] = { 2, TF, SEN(mkdir), "mkdir" }, +[1031] = { 1, TF, SEN(rmdir), "rmdir" }, +[1032] = { 3, TF, SEN(chown), "lchown" }, +[1033] = { 2, TF, SEN(access), "access" }, +[1034] = { 2, TF, SEN(rename), "rename" }, +[1035] = { 3, TF, SEN(readlink), "readlink" }, +[1036] = { 2, TF, SEN(symlink), "symlink" }, +[1037] = { 2, TF, SEN(utimes), "utimes" }, +[1038] = { 2, TF, SEN(stat), "stat" }, +[1039] = { 2, TF, SEN(lstat), "lstat" }, +[1040] = { 1, TD, SEN(pipe), "pipe" }, +[1041] = { 2, TD, SEN(dup2), "dup2" }, +[1042] = { 1, TD, SEN(epoll_create), "epoll_create" }, +[1043] = { 0, TD, SEN(inotify_init), "inotify_init" }, +[1044] = { 1, TD, SEN(eventfd), "eventfd" }, +[1045] = { 3, TD|TS, SEN(signalfd), "signalfd" }, +[1046] = { 4, TD|TN, SEN(sendfile64), "sendfile" }, +[1047] = { 2, TD, SEN(ftruncate), "ftruncate" }, +[1048] = { 2, TF, SEN(truncate), "truncate" }, +[1049] = { 2, TF, SEN(stat), "stat" }, +[1050] = { 2, TF, SEN(lstat), "lstat" }, +[1051] = { 2, TD, SEN(fstat), "fstat" }, +[1052] = { 3, TD, SEN(fcntl), "fcntl" }, +[1053] = { 4, TD, SEN(fadvise64), "fadvise64" }, +[1054] = { 4, TD|TF, SEN(newfstatat), "newfstatat" }, +[1055] = { 2, TD, SEN(fstatfs), "fstatfs" }, +[1056] = { 2, TF, SEN(statfs), "statfs" }, +[1057] = { 3, TD, SEN(lseek), "lseek" }, +[1058] = { 6, TD|TM|SI, SEN(mmap), "mmap" }, +[1059] = { 1, 0, SEN(alarm), "alarm" }, +[1060] = { 0, 0, SEN(getpgrp), "getpgrp" }, +[1061] = { 0, TS, SEN(pause), "pause" }, +[1062] = { 1, 0, SEN(time), "time" }, +[1063] = { 2, TF, SEN(utime), "utime" }, +[1064] = { 2, TD|TF, SEN(creat), "creat" }, +[1065] = { 3, TD, SEN(getdents), "getdents" }, +[1066] = { 3, TD|TF, SEN(futimesat), "futimesat" }, +[1067] = { 5, TD, SEN(select), "select" }, +[1068] = { 3, TD, SEN(poll), "poll" }, +[1069] = { 4, TD, SEN(epoll_wait), "epoll_wait" }, +[1070] = { 2, 0, SEN(ustat), "ustat" }, +[1071] = { 0, TP, SEN(vfork), "vfork" }, +[1072] = { 4, TP, SEN(wait4), "wait4" }, +[1073] = { 6, TN, SEN(recv), "recv" }, +[1074] = { 4, TN, SEN(send), "send" }, +[1075] = { 2, 0, SEN(bdflush), "bdflush" }, +[1076] = { 1, TF, SEN(umount), "umount" }, +[1077] = { 1, TF, SEN(uselib), "uselib" }, +[1078] = { 1, 0, SEN(sysctl), "sysctl" }, +[1079] = { 0, TP, SEN(fork), "fork" }, diff --git a/linux/aarch64/syscallent1.h b/linux/aarch64/syscallent1.h index 286e0cb3..1b892be0 100644 --- a/linux/aarch64/syscallent1.h +++ b/linux/aarch64/syscallent1.h @@ -1,71 +1 @@ -#include "64/syscallent.h" - -/* Arch-specific block, not used on AArch64 */ -[244 ... 259] = { }, - -/* Quote from asm-generic/unistd.h: - * - * All syscalls below here should go away really, - * these are provided for both review and as a porting - * help for the C library version. - * - * Last chance: are any of these important enough to - * enable by default? - */ - -[1024] = { 3, TD|TF, SEN(open), "open" }, -[1025] = { 2, TF, SEN(link), "link" }, -[1026] = { 1, TF, SEN(unlink), "unlink" }, -[1027] = { 3, TF, SEN(mknod), "mknod" }, -[1028] = { 2, TF, SEN(chmod), "chmod" }, -[1029] = { 3, TF, SEN(chown), "chown" }, -[1030] = { 2, TF, SEN(mkdir), "mkdir" }, -[1031] = { 1, TF, SEN(rmdir), "rmdir" }, -[1032] = { 3, TF, SEN(chown), "lchown" }, -[1033] = { 2, TF, SEN(access), "access" }, -[1034] = { 2, TF, SEN(rename), "rename" }, -[1035] = { 3, TF, SEN(readlink), "readlink" }, -[1036] = { 2, TF, SEN(symlink), "symlink" }, -[1037] = { 2, TF, SEN(utimes), "utimes" }, -[1038] = { 2, TF, SEN(stat), "stat" }, -[1039] = { 2, TF, SEN(lstat), "lstat" }, -[1040] = { 1, TD, SEN(pipe), "pipe" }, -[1041] = { 2, TD, SEN(dup2), "dup2" }, -[1042] = { 1, TD, SEN(epoll_create), "epoll_create" }, -[1043] = { 0, TD, SEN(inotify_init), "inotify_init" }, -[1044] = { 1, TD, SEN(eventfd), "eventfd" }, -[1045] = { 3, TD|TS, SEN(signalfd), "signalfd" }, -[1046] = { 4, TD|TN, SEN(sendfile64), "sendfile" }, -[1047] = { 2, TD, SEN(ftruncate), "ftruncate" }, -[1048] = { 2, TF, SEN(truncate), "truncate" }, -[1049] = { 2, TF, SEN(stat), "stat" }, -[1050] = { 2, TF, SEN(lstat), "lstat" }, -[1051] = { 2, TD, SEN(fstat), "fstat" }, -[1052] = { 3, TD, SEN(fcntl), "fcntl" }, -[1053] = { 4, TD, SEN(fadvise64), "fadvise64" }, -[1054] = { 4, TD|TF, SEN(newfstatat), "newfstatat" }, -[1055] = { 2, TD, SEN(fstatfs), "fstatfs" }, -[1056] = { 2, TF, SEN(statfs), "statfs" }, -[1057] = { 3, TD, SEN(lseek), "lseek" }, -[1058] = { 6, TD|TM|SI, SEN(mmap), "mmap" }, -[1059] = { 1, 0, SEN(alarm), "alarm" }, -[1060] = { 0, 0, SEN(getpgrp), "getpgrp" }, -[1061] = { 0, TS, SEN(pause), "pause" }, -[1062] = { 1, 0, SEN(time), "time" }, -[1063] = { 2, TF, SEN(utime), "utime" }, -[1064] = { 2, TD|TF, SEN(creat), "creat" }, -[1065] = { 3, TD, SEN(getdents), "getdents" }, -[1066] = { 3, TD|TF, SEN(futimesat), "futimesat" }, -[1067] = { 5, TD, SEN(select), "select" }, -[1068] = { 3, TD, SEN(poll), "poll" }, -[1069] = { 4, TD, SEN(epoll_wait), "epoll_wait" }, -[1070] = { 2, 0, SEN(ustat), "ustat" }, -[1071] = { 0, TP, SEN(vfork), "vfork" }, -[1072] = { 4, TP, SEN(wait4), "wait4" }, -[1073] = { 6, TN, SEN(recv), "recv" }, -[1074] = { 4, TN, SEN(send), "send" }, -[1075] = { 2, 0, SEN(bdflush), "bdflush" }, -[1076] = { 1, TF, SEN(umount), "umount" }, -[1077] = { 1, TF, SEN(uselib), "uselib" }, -[1078] = { 1, 0, SEN(sysctl), "sysctl" }, -[1079] = { 0, TP, SEN(fork), "fork" }, +#include "../arm/syscallent.h" diff --git a/linux/arm/arch_sigreturn.c b/linux/arm/arch_sigreturn.c index 6d32ac5d..28726a27 100644 --- a/linux/arm/arch_sigreturn.c +++ b/linux/arm/arch_sigreturn.c @@ -7,7 +7,7 @@ arch_sigreturn(struct tcb *tcp) const long addr = #ifdef AARCH64 - current_personality == 1 ? + tcp->currpers == 0 ? (*aarch64_sp_ptr + SIZEOF_STRUCT_SIGINFO + offsetof(struct ucontext, uc_sigmask)) : #endif diff --git a/syscall.c b/syscall.c index fae5f6b5..66154f7e 100644 --- a/syscall.c +++ b/syscall.c @@ -346,7 +346,7 @@ update_personality(struct tcb *tcp, unsigned int personality) # elif defined X32 # define PERSONALITY_NAMES {"x32", "32 bit"} # elif defined AARCH64 -# define PERSONALITY_NAMES {"32-bit", "AArch64"} +# define PERSONALITY_NAMES {"64 bit", "32 bit"} # elif defined TILE # define PERSONALITY_NAMES {"64-bit", "32-bit"} # endif -- 2.40.0