9 #include <linux/kernel.h>
10 #include <linux/sched.h>
13 #include <linux/errno.h>
14 #include <linux/ptrace.h>
17 #include <linux/audit.h>
18 #include <linux/signal.h>
19 #include <linux/elf.h>
22 #include <linux/seccomp.h>
25 #include <asm/segment.h>
27 #include <asm/pgtable.h>
28 #include <asm/pgalloc.h>
29 #include <asm/uaccess.h>
30 #include <asm/unistd.h>
31 #include <asm/switch_to.h>
38 #define CREATE_TRACE_POINTS
59 unsigned long cr0, cr0_new;
64 cr0_new = cr0 & ~(3
UL << 54);
66 cr0_new = cr0 | (3
UL << 54);
73 new.control = thread->
per_user.control;
124 task->
thread.per_flags = 0;
128 # define __ADDR_MASK 3
130 # define __ADDR_MASK 7
145 0 : child->
thread.per_user.start;
156 return child->
thread.per_user.start;
159 return child->
thread.per_user.end;
162 return (
unsigned long)
166 return child->
thread.per_event.address;
169 return (
unsigned long)
197 }
else if (addr < (
addr_t) &dummy->
regs.orig_gpr2) {
209 tmp = ((
unsigned long) child->
thread.acrs[15]) << 32;
214 }
else if (addr == (
addr_t) &dummy->
regs.orig_gpr2) {
220 }
else if (addr < (
addr_t) &dummy->
regs.fp_regs) {
227 }
else if (addr < (
addr_t) (&dummy->
regs.fp_regs + 1)) {
231 offset = addr - (
addr_t) &dummy->
regs.fp_regs;
233 if (addr == (
addr_t) &dummy->
regs.fp_regs.fpc)
237 }
else if (addr < (
addr_t) (&dummy->
regs.per_info + 1)) {
242 tmp = __peek_user_per(child, addr);
268 tmp = __peek_user(child, addr);
272 static inline void __poke_user_per(
struct task_struct *child,
291 child->
thread.per_user.control =
295 child->
thread.per_user.start = data;
298 child->
thread.per_user.end = data;
323 }
else if (addr < (
addr_t) (&dummy->
regs.orig_gpr2)) {
336 child->
thread.acrs[15] = (
unsigned int) (data >> 32);
341 }
else if (addr == (
addr_t) &dummy->
regs.orig_gpr2) {
347 }
else if (addr < (
addr_t) &dummy->
regs.fp_regs) {
354 }
else if (addr < (
addr_t) (&dummy->
regs.fp_regs + 1)) {
358 if (addr == (
addr_t) &dummy->
regs.fp_regs.fpc &&
362 offset = addr - (
addr_t) &dummy->
regs.fp_regs;
365 }
else if (addr < (
addr_t) (&dummy->
regs.per_info + 1)) {
370 __poke_user_per(child, addr, data);
394 return __poke_user(child, addr, data);
398 unsigned long addr,
unsigned long data)
406 return peek_user(child, addr, data);
410 return poke_user(child, addr, data);
420 while (copied < parea.
len) {
422 ret = peek_user(child, addr, data);
428 ret = poke_user(child, addr, utmp);
432 addr +=
sizeof(
unsigned long);
433 data +=
sizeof(
unsigned long);
434 copied +=
sizeof(
unsigned long);
439 (
unsigned long __user *) data);
488 0 : child->
thread.per_user.start;
505 return (
__u32) child->
thread.per_event.cause << 16;
529 if (addr == (
addr_t) &dummy32->
regs.psw.mask) {
531 tmp = (
__u32)(regs->
psw.mask >> 32);
533 }
else if (addr == (
addr_t) &dummy32->
regs.psw.addr) {
541 }
else if (addr < (
addr_t) (&dummy32->
regs.orig_gpr2)) {
548 }
else if (addr == (
addr_t) (&dummy32->
regs.orig_gpr2)) {
554 }
else if (addr < (
addr_t) &dummy32->
regs.fp_regs) {
561 }
else if (addr < (
addr_t) (&dummy32->
regs.fp_regs + 1)) {
565 offset = addr - (
addr_t) &dummy32->
regs.fp_regs;
568 }
else if (addr < (
addr_t) (&dummy32->
regs.per_info + 1)) {
573 tmp = __peek_user_per_compat(child, addr);
581 static int peek_user_compat(
struct task_struct *child,
589 tmp = __peek_user_compat(child, addr);
596 static inline void __poke_user_per_compat(
struct task_struct *child,
603 child->
thread.per_user.control =
607 child->
thread.per_user.start = data;
610 child->
thread.per_user.end = data;
616 static int __poke_user_compat(
struct task_struct *child,
628 if (addr == (
addr_t) &dummy32->
regs.psw.mask) {
634 (regs->
psw.mask & PSW_MASK_BA) |
636 }
else if (addr == (
addr_t) &dummy32->
regs.psw.addr) {
640 regs->
psw.mask = (regs->
psw.mask & ~PSW_MASK_BA) |
646 }
else if (addr < (
addr_t) (&dummy32->
regs.orig_gpr2)) {
653 }
else if (addr == (
addr_t) (&dummy32->
regs.orig_gpr2)) {
659 }
else if (addr < (
addr_t) &dummy32->
regs.fp_regs) {
666 }
else if (addr < (
addr_t) (&dummy32->
regs.fp_regs + 1)) {
670 if (addr == (
addr_t) &dummy32->
regs.fp_regs.fpc &&
674 offset = addr - (
addr_t) &dummy32->
regs.fp_regs;
677 }
else if (addr < (
addr_t) (&dummy32->
regs.per_info + 1)) {
682 __poke_user_per_compat(child, addr, data);
688 static int poke_user_compat(
struct task_struct *child,
695 return __poke_user_compat(child, addr, data);
701 unsigned long addr = caddr;
702 unsigned long data =
cdata;
709 return peek_user_compat(child, addr, data);
713 return poke_user_compat(child, addr, data);
723 while (copied < parea.
len) {
725 ret = peek_user_compat(child, addr, data);
731 ret = poke_user_compat(child, addr, utmp);
735 addr +=
sizeof(
unsigned int);
736 data +=
sizeof(
unsigned int);
737 copied +=
sizeof(
unsigned int);
742 (
unsigned int __user *) data);
745 return compat_ptrace_request(child, request, addr, data);
754 if (secure_computing(regs->
gprs[2])) {
765 (tracehook_report_syscall_entry(regs) ||
777 trace_sys_enter(regs, regs->
gprs[2]);
785 return ret ?: regs->
gprs[2];
790 audit_syscall_exit(regs);
793 trace_sys_exit(regs, regs->
gprs[2]);
796 tracehook_report_syscall_exit(regs, 0);
805 unsigned int pos,
unsigned int count,
806 void *kbuf,
void __user *ubuf)
809 save_access_regs(target->
thread.acrs);
812 unsigned long *
k = kbuf;
814 *k++ = __peek_user(target, pos);
819 unsigned long __user *
u = ubuf;
821 if (
__put_user(__peek_user(target, pos), u++))
830 static int s390_regs_set(
struct task_struct *target,
832 unsigned int pos,
unsigned int count,
833 const void *kbuf,
const void __user *ubuf)
838 save_access_regs(target->
thread.acrs);
841 const unsigned long *k = kbuf;
842 while (count > 0 && !rc) {
843 rc = __poke_user(target, pos, *k++);
848 const unsigned long __user *u = ubuf;
849 while (count > 0 && !rc) {
854 rc = __poke_user(target, pos, word);
860 if (rc == 0 && target ==
current)
861 restore_access_regs(target->
thread.acrs);
866 static int s390_fpregs_get(
struct task_struct *target,
867 const struct user_regset *regset,
unsigned int pos,
868 unsigned int count,
void *kbuf,
void __user *ubuf)
871 save_fp_regs(&target->
thread.fp_regs);
873 return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
874 &target->
thread.fp_regs, 0, -1);
877 static int s390_fpregs_set(
struct task_struct *target,
878 const struct user_regset *regset,
unsigned int pos,
879 unsigned int count,
const void *kbuf,
880 const void __user *ubuf)
885 save_fp_regs(&target->
thread.fp_regs);
889 u32 fpc[2] = { target->
thread.fp_regs.fpc, 0 };
890 rc = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &fpc,
896 target->
thread.fp_regs.fpc = fpc[0];
899 if (rc == 0 && count > 0)
900 rc = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
901 target->
thread.fp_regs.fprs,
904 if (rc == 0 && target ==
current)
905 restore_fp_regs(&target->
thread.fp_regs);
912 static int s390_last_break_get(
struct task_struct *target,
914 unsigned int pos,
unsigned int count,
915 void *kbuf,
void __user *ubuf)
919 unsigned long *k = kbuf;
922 unsigned long __user *u = ubuf;
930 static int s390_last_break_set(
struct task_struct *target,
932 unsigned int pos,
unsigned int count,
933 const void *kbuf,
const void __user *ubuf)
938 static int s390_tdb_get(
struct task_struct *target,
940 unsigned int pos,
unsigned int count,
941 void *kbuf,
void __user *ubuf)
948 data = target->
thread.trap_tdb;
949 return user_regset_copyout(&pos, &count, &kbuf, &ubuf, data, 0, 256);
952 static int s390_tdb_set(
struct task_struct *target,
954 unsigned int pos,
unsigned int count,
955 const void *kbuf,
const void __user *ubuf)
962 static int s390_system_call_get(
struct task_struct *target,
964 unsigned int pos,
unsigned int count,
965 void *kbuf,
void __user *ubuf)
968 return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
969 data, 0,
sizeof(
unsigned int));
972 static int s390_system_call_set(
struct task_struct *target,
974 unsigned int pos,
unsigned int count,
975 const void *kbuf,
const void __user *ubuf)
978 return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
979 data, 0,
sizeof(
unsigned int));
986 .size =
sizeof(
long),
987 .
align =
sizeof(
long),
988 .get = s390_regs_get,
989 .set = s390_regs_set,
994 .size =
sizeof(
long),
995 .
align =
sizeof(
long),
996 .get = s390_fpregs_get,
997 .set = s390_fpregs_set,
1003 .size =
sizeof(
long),
1004 .
align =
sizeof(
long),
1005 .get = s390_last_break_get,
1006 .set = s390_last_break_set,
1013 .get = s390_tdb_get,
1014 .set = s390_tdb_set,
1020 .size =
sizeof(
unsigned int),
1021 .
align =
sizeof(
unsigned int),
1022 .get = s390_system_call_get,
1023 .set = s390_system_call_set,
1028 .name = UTS_MACHINE,
1030 .regsets = s390_regsets,
1034 #ifdef CONFIG_COMPAT
1035 static int s390_compat_regs_get(
struct task_struct *target,
1037 unsigned int pos,
unsigned int count,
1038 void *kbuf,
void __user *ubuf)
1041 save_access_regs(target->
thread.acrs);
1046 *k++ = __peek_user_compat(target, pos);
1047 count -=
sizeof(*k);
1053 if (
__put_user(__peek_user_compat(target, pos), u++))
1055 count -=
sizeof(*u);
1062 static int s390_compat_regs_set(
struct task_struct *target,
1064 unsigned int pos,
unsigned int count,
1065 const void *kbuf,
const void __user *ubuf)
1070 save_access_regs(target->
thread.acrs);
1074 while (count > 0 && !rc) {
1075 rc = __poke_user_compat(target, pos, *k++);
1076 count -=
sizeof(*k);
1081 while (count > 0 && !rc) {
1086 rc = __poke_user_compat(target, pos, word);
1087 count -=
sizeof(*u);
1092 if (rc == 0 && target ==
current)
1093 restore_access_regs(target->
thread.acrs);
1098 static int s390_compat_regs_high_get(
struct task_struct *target,
1100 unsigned int pos,
unsigned int count,
1101 void *kbuf,
void __user *ubuf)
1112 count -=
sizeof(*k);
1120 count -=
sizeof(*u);
1126 static int s390_compat_regs_high_set(
struct task_struct *target,
1128 unsigned int pos,
unsigned int count,
1129 const void *kbuf,
const void __user *ubuf)
1141 count -=
sizeof(*k);
1145 while (count > 0 && !rc) {
1152 count -=
sizeof(*u);
1159 static int s390_compat_last_break_get(
struct task_struct *target,
1161 unsigned int pos,
unsigned int count,
1162 void *kbuf,
void __user *ubuf)
1169 unsigned long *k = kbuf;
1172 unsigned long __user *u = ubuf;
1180 static int s390_compat_last_break_set(
struct task_struct *target,
1182 unsigned int pos,
unsigned int count,
1183 const void *kbuf,
const void __user *ubuf)
1188 static const struct user_regset s390_compat_regsets[] = {
1194 .get = s390_compat_regs_get,
1195 .set = s390_compat_regs_set,
1202 .get = s390_fpregs_get,
1203 .set = s390_fpregs_set,
1208 .size =
sizeof(
long),
1209 .
align =
sizeof(
long),
1210 .get = s390_compat_last_break_get,
1211 .set = s390_compat_last_break_set,
1218 .get = s390_tdb_get,
1219 .set = s390_tdb_set,
1226 .get = s390_system_call_get,
1227 .set = s390_system_call_set,
1234 .get = s390_compat_regs_high_get,
1235 .set = s390_compat_regs_high_set,
1242 .regsets = s390_compat_regsets,
1249 #ifdef CONFIG_COMPAT
1250 if (test_tsk_thread_flag(task,
TIF_31BIT))
1251 return &user_s390_compat_view;
1253 return &user_s390_view;
1256 static const char *gpr_names[
NUM_GPRS] = {
1257 "r0",
"r1",
"r2",
"r3",
"r4",
"r5",
"r6",
"r7",
1258 "r8",
"r9",
"r10",
"r11",
"r12",
"r13",
"r14",
"r15",
1272 if (!name || *name !=
'r')
1285 return gpr_names[
offset];
1311 return *(
unsigned long *)addr;