|
18 | 18 | #include <linux/syscalls.h>
|
19 | 19 | #include <asm/hw_breakpoint.h>
|
20 | 20 | #include <linux/uaccess.h>
|
| 21 | +#include <asm/switch_to.h> |
21 | 22 | #include <asm/unistd.h>
|
22 | 23 | #include <asm/debug.h>
|
23 | 24 | #include <asm/tm.h>
|
24 | 25 |
|
25 | 26 | #include "signal.h"
|
26 | 27 |
|
| 28 | +#ifdef CONFIG_VSX |
| 29 | +unsigned long copy_fpr_to_user(void __user *to, |
| 30 | + struct task_struct *task) |
| 31 | +{ |
| 32 | + u64 buf[ELF_NFPREG]; |
| 33 | + int i; |
| 34 | + |
| 35 | + /* save FPR copy to local buffer then write to the thread_struct */ |
| 36 | + for (i = 0; i < (ELF_NFPREG - 1) ; i++) |
| 37 | + buf[i] = task->thread.TS_FPR(i); |
| 38 | + buf[i] = task->thread.fp_state.fpscr; |
| 39 | + return __copy_to_user(to, buf, ELF_NFPREG * sizeof(double)); |
| 40 | +} |
| 41 | + |
| 42 | +unsigned long copy_fpr_from_user(struct task_struct *task, |
| 43 | + void __user *from) |
| 44 | +{ |
| 45 | + u64 buf[ELF_NFPREG]; |
| 46 | + int i; |
| 47 | + |
| 48 | + if (__copy_from_user(buf, from, ELF_NFPREG * sizeof(double))) |
| 49 | + return 1; |
| 50 | + for (i = 0; i < (ELF_NFPREG - 1) ; i++) |
| 51 | + task->thread.TS_FPR(i) = buf[i]; |
| 52 | + task->thread.fp_state.fpscr = buf[i]; |
| 53 | + |
| 54 | + return 0; |
| 55 | +} |
| 56 | + |
| 57 | +unsigned long copy_vsx_to_user(void __user *to, |
| 58 | + struct task_struct *task) |
| 59 | +{ |
| 60 | + u64 buf[ELF_NVSRHALFREG]; |
| 61 | + int i; |
| 62 | + |
| 63 | + /* save FPR copy to local buffer then write to the thread_struct */ |
| 64 | + for (i = 0; i < ELF_NVSRHALFREG; i++) |
| 65 | + buf[i] = task->thread.fp_state.fpr[i][TS_VSRLOWOFFSET]; |
| 66 | + return __copy_to_user(to, buf, ELF_NVSRHALFREG * sizeof(double)); |
| 67 | +} |
| 68 | + |
| 69 | +unsigned long copy_vsx_from_user(struct task_struct *task, |
| 70 | + void __user *from) |
| 71 | +{ |
| 72 | + u64 buf[ELF_NVSRHALFREG]; |
| 73 | + int i; |
| 74 | + |
| 75 | + if (__copy_from_user(buf, from, ELF_NVSRHALFREG * sizeof(double))) |
| 76 | + return 1; |
| 77 | + for (i = 0; i < ELF_NVSRHALFREG ; i++) |
| 78 | + task->thread.fp_state.fpr[i][TS_VSRLOWOFFSET] = buf[i]; |
| 79 | + return 0; |
| 80 | +} |
| 81 | + |
| 82 | +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM |
| 83 | +unsigned long copy_ckfpr_to_user(void __user *to, |
| 84 | + struct task_struct *task) |
| 85 | +{ |
| 86 | + u64 buf[ELF_NFPREG]; |
| 87 | + int i; |
| 88 | + |
| 89 | + /* save FPR copy to local buffer then write to the thread_struct */ |
| 90 | + for (i = 0; i < (ELF_NFPREG - 1) ; i++) |
| 91 | + buf[i] = task->thread.TS_CKFPR(i); |
| 92 | + buf[i] = task->thread.ckfp_state.fpscr; |
| 93 | + return __copy_to_user(to, buf, ELF_NFPREG * sizeof(double)); |
| 94 | +} |
| 95 | + |
| 96 | +unsigned long copy_ckfpr_from_user(struct task_struct *task, |
| 97 | + void __user *from) |
| 98 | +{ |
| 99 | + u64 buf[ELF_NFPREG]; |
| 100 | + int i; |
| 101 | + |
| 102 | + if (__copy_from_user(buf, from, ELF_NFPREG * sizeof(double))) |
| 103 | + return 1; |
| 104 | + for (i = 0; i < (ELF_NFPREG - 1) ; i++) |
| 105 | + task->thread.TS_CKFPR(i) = buf[i]; |
| 106 | + task->thread.ckfp_state.fpscr = buf[i]; |
| 107 | + |
| 108 | + return 0; |
| 109 | +} |
| 110 | + |
| 111 | +unsigned long copy_ckvsx_to_user(void __user *to, |
| 112 | + struct task_struct *task) |
| 113 | +{ |
| 114 | + u64 buf[ELF_NVSRHALFREG]; |
| 115 | + int i; |
| 116 | + |
| 117 | + /* save FPR copy to local buffer then write to the thread_struct */ |
| 118 | + for (i = 0; i < ELF_NVSRHALFREG; i++) |
| 119 | + buf[i] = task->thread.ckfp_state.fpr[i][TS_VSRLOWOFFSET]; |
| 120 | + return __copy_to_user(to, buf, ELF_NVSRHALFREG * sizeof(double)); |
| 121 | +} |
| 122 | + |
| 123 | +unsigned long copy_ckvsx_from_user(struct task_struct *task, |
| 124 | + void __user *from) |
| 125 | +{ |
| 126 | + u64 buf[ELF_NVSRHALFREG]; |
| 127 | + int i; |
| 128 | + |
| 129 | + if (__copy_from_user(buf, from, ELF_NVSRHALFREG * sizeof(double))) |
| 130 | + return 1; |
| 131 | + for (i = 0; i < ELF_NVSRHALFREG ; i++) |
| 132 | + task->thread.ckfp_state.fpr[i][TS_VSRLOWOFFSET] = buf[i]; |
| 133 | + return 0; |
| 134 | +} |
| 135 | +#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */ |
| 136 | +#else |
| 137 | +inline unsigned long copy_fpr_to_user(void __user *to, |
| 138 | + struct task_struct *task) |
| 139 | +{ |
| 140 | + return __copy_to_user(to, task->thread.fp_state.fpr, |
| 141 | + ELF_NFPREG * sizeof(double)); |
| 142 | +} |
| 143 | + |
| 144 | +inline unsigned long copy_fpr_from_user(struct task_struct *task, |
| 145 | + void __user *from) |
| 146 | +{ |
| 147 | + return __copy_from_user(task->thread.fp_state.fpr, from, |
| 148 | + ELF_NFPREG * sizeof(double)); |
| 149 | +} |
| 150 | + |
| 151 | +#ifdef CONFIG_PPC_TRANSACTIONAL_MEM |
| 152 | +inline unsigned long copy_ckfpr_to_user(void __user *to, |
| 153 | + struct task_struct *task) |
| 154 | +{ |
| 155 | + return __copy_to_user(to, task->thread.ckfp_state.fpr, |
| 156 | + ELF_NFPREG * sizeof(double)); |
| 157 | +} |
| 158 | + |
| 159 | +inline unsigned long copy_ckfpr_from_user(struct task_struct *task, |
| 160 | + void __user *from) |
| 161 | +{ |
| 162 | + return __copy_from_user(task->thread.ckfp_state.fpr, from, |
| 163 | + ELF_NFPREG * sizeof(double)); |
| 164 | +} |
| 165 | +#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */ |
| 166 | +#endif |
| 167 | + |
27 | 168 | /* Log an error when sending an unhandled signal to a process. Controlled
|
28 | 169 | * through debug.exception-trace sysctl.
|
29 | 170 | */
|
|
0 commit comments