Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * Copyright (C) 1994 Linus Torvalds |
| 3 | * |
| 4 | * Pentium III FXSR, SSE support |
| 5 | * General FPU state handling cleanups |
| 6 | * Gareth Hughes <gareth@valinux.com>, May 2000 |
| 7 | */ |
Alexey Dobriyan | 129f694 | 2005-06-23 00:08:33 -0700 | [diff] [blame] | 8 | #include <linux/module.h> |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 9 | #include <linux/regset.h> |
Ingo Molnar | f668964 | 2008-03-05 15:37:32 +0100 | [diff] [blame] | 10 | #include <linux/sched.h> |
| 11 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <asm/sigcontext.h> |
Ingo Molnar | f668964 | 2008-03-05 15:37:32 +0100 | [diff] [blame] | 13 | #include <asm/processor.h> |
| 14 | #include <asm/math_emu.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <asm/uaccess.h> |
Ingo Molnar | f668964 | 2008-03-05 15:37:32 +0100 | [diff] [blame] | 16 | #include <asm/ptrace.h> |
| 17 | #include <asm/i387.h> |
| 18 | #include <asm/user.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 20 | #ifdef CONFIG_X86_64 |
Ingo Molnar | f668964 | 2008-03-05 15:37:32 +0100 | [diff] [blame] | 21 | # include <asm/sigcontext32.h> |
| 22 | # include <asm/user32.h> |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 23 | #else |
Ingo Molnar | f668964 | 2008-03-05 15:37:32 +0100 | [diff] [blame] | 24 | # define save_i387_ia32 save_i387 |
| 25 | # define restore_i387_ia32 restore_i387 |
| 26 | # define _fpstate_ia32 _fpstate |
| 27 | # define user_i387_ia32_struct user_i387_struct |
| 28 | # define user32_fxsr_struct user_fxsr_struct |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 29 | #endif |
| 30 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | #ifdef CONFIG_MATH_EMULATION |
Ingo Molnar | f668964 | 2008-03-05 15:37:32 +0100 | [diff] [blame] | 32 | # define HAVE_HWFP (boot_cpu_data.hard_math) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | #else |
Ingo Molnar | f668964 | 2008-03-05 15:37:32 +0100 | [diff] [blame] | 34 | # define HAVE_HWFP 1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | #endif |
| 36 | |
Ingo Molnar | f668964 | 2008-03-05 15:37:32 +0100 | [diff] [blame] | 37 | static unsigned int mxcsr_feature_mask __read_mostly = 0xffffffffu; |
Suresh Siddha | 61c4628 | 2008-03-10 15:28:04 -0700 | [diff] [blame] | 38 | unsigned int xstate_size; |
| 39 | static struct i387_fxsave_struct fx_scratch __cpuinitdata; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | |
Suresh Siddha | 61c4628 | 2008-03-10 15:28:04 -0700 | [diff] [blame] | 41 | void __cpuinit mxcsr_feature_mask_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | { |
| 43 | unsigned long mask = 0; |
Ingo Molnar | f668964 | 2008-03-05 15:37:32 +0100 | [diff] [blame] | 44 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | clts(); |
| 46 | if (cpu_has_fxsr) { |
Suresh Siddha | 61c4628 | 2008-03-10 15:28:04 -0700 | [diff] [blame] | 47 | memset(&fx_scratch, 0, sizeof(struct i387_fxsave_struct)); |
| 48 | asm volatile("fxsave %0" : : "m" (fx_scratch)); |
| 49 | mask = fx_scratch.mxcsr_mask; |
Cyrill Gorcunov | 3b095a0 | 2008-01-30 13:31:26 +0100 | [diff] [blame] | 50 | if (mask == 0) |
| 51 | mask = 0x0000ffbf; |
| 52 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | mxcsr_feature_mask &= mask; |
| 54 | stts(); |
| 55 | } |
| 56 | |
Suresh Siddha | 61c4628 | 2008-03-10 15:28:04 -0700 | [diff] [blame] | 57 | void __init init_thread_xstate(void) |
| 58 | { |
Suresh Siddha | e8a496a | 2008-05-23 16:26:37 -0700 | [diff] [blame] | 59 | if (!HAVE_HWFP) { |
| 60 | xstate_size = sizeof(struct i387_soft_struct); |
| 61 | return; |
| 62 | } |
| 63 | |
Suresh Siddha | dc1e35c | 2008-07-29 10:29:19 -0700 | [diff] [blame] | 64 | if (cpu_has_xsave) { |
| 65 | xsave_cntxt_init(); |
| 66 | return; |
| 67 | } |
| 68 | |
Suresh Siddha | 61c4628 | 2008-03-10 15:28:04 -0700 | [diff] [blame] | 69 | if (cpu_has_fxsr) |
| 70 | xstate_size = sizeof(struct i387_fxsave_struct); |
| 71 | #ifdef CONFIG_X86_32 |
| 72 | else |
| 73 | xstate_size = sizeof(struct i387_fsave_struct); |
| 74 | #endif |
Suresh Siddha | 61c4628 | 2008-03-10 15:28:04 -0700 | [diff] [blame] | 75 | } |
| 76 | |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 77 | #ifdef CONFIG_X86_64 |
| 78 | /* |
| 79 | * Called at bootup to set up the initial FPU state that is later cloned |
| 80 | * into all processes. |
| 81 | */ |
| 82 | void __cpuinit fpu_init(void) |
| 83 | { |
| 84 | unsigned long oldcr0 = read_cr0(); |
Ingo Molnar | f668964 | 2008-03-05 15:37:32 +0100 | [diff] [blame] | 85 | |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 86 | set_in_cr4(X86_CR4_OSFXSR); |
| 87 | set_in_cr4(X86_CR4_OSXMMEXCPT); |
| 88 | |
Ingo Molnar | f668964 | 2008-03-05 15:37:32 +0100 | [diff] [blame] | 89 | write_cr0(oldcr0 & ~(X86_CR0_TS|X86_CR0_EM)); /* clear TS and EM */ |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 90 | |
Suresh Siddha | dc1e35c | 2008-07-29 10:29:19 -0700 | [diff] [blame] | 91 | /* |
| 92 | * Boot processor to setup the FP and extended state context info. |
| 93 | */ |
| 94 | if (!smp_processor_id()) |
| 95 | init_thread_xstate(); |
| 96 | xsave_init(); |
| 97 | |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 98 | mxcsr_feature_mask_init(); |
| 99 | /* clean state in init */ |
Suresh Siddha | b359e8a | 2008-07-29 10:29:20 -0700 | [diff] [blame^] | 100 | if (cpu_has_xsave) |
| 101 | current_thread_info()->status = TS_XSAVE; |
| 102 | else |
| 103 | current_thread_info()->status = 0; |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 104 | clear_used_math(); |
| 105 | } |
| 106 | #endif /* CONFIG_X86_64 */ |
| 107 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | /* |
| 109 | * The _current_ task is using the FPU for the first time |
| 110 | * so initialize it and set the mxcsr to its default |
| 111 | * value at reset if we support XMM instructions and then |
| 112 | * remeber the current task has used the FPU. |
| 113 | */ |
Suresh Siddha | aa283f4 | 2008-03-10 15:28:05 -0700 | [diff] [blame] | 114 | int init_fpu(struct task_struct *tsk) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | { |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 116 | if (tsk_used_math(tsk)) { |
Suresh Siddha | e8a496a | 2008-05-23 16:26:37 -0700 | [diff] [blame] | 117 | if (HAVE_HWFP && tsk == current) |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 118 | unlazy_fpu(tsk); |
Suresh Siddha | aa283f4 | 2008-03-10 15:28:05 -0700 | [diff] [blame] | 119 | return 0; |
| 120 | } |
| 121 | |
| 122 | /* |
| 123 | * Memory allocation at the first usage of the FPU and other state. |
| 124 | */ |
| 125 | if (!tsk->thread.xstate) { |
| 126 | tsk->thread.xstate = kmem_cache_alloc(task_xstate_cachep, |
| 127 | GFP_KERNEL); |
| 128 | if (!tsk->thread.xstate) |
| 129 | return -ENOMEM; |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 130 | } |
| 131 | |
Suresh Siddha | e8a496a | 2008-05-23 16:26:37 -0700 | [diff] [blame] | 132 | #ifdef CONFIG_X86_32 |
| 133 | if (!HAVE_HWFP) { |
| 134 | memset(tsk->thread.xstate, 0, xstate_size); |
| 135 | finit(); |
| 136 | set_stopped_child_used_math(tsk); |
| 137 | return 0; |
| 138 | } |
| 139 | #endif |
| 140 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | if (cpu_has_fxsr) { |
Suresh Siddha | 61c4628 | 2008-03-10 15:28:04 -0700 | [diff] [blame] | 142 | struct i387_fxsave_struct *fx = &tsk->thread.xstate->fxsave; |
| 143 | |
| 144 | memset(fx, 0, xstate_size); |
| 145 | fx->cwd = 0x37f; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | if (cpu_has_xmm) |
Suresh Siddha | 61c4628 | 2008-03-10 15:28:04 -0700 | [diff] [blame] | 147 | fx->mxcsr = MXCSR_DEFAULT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | } else { |
Suresh Siddha | 61c4628 | 2008-03-10 15:28:04 -0700 | [diff] [blame] | 149 | struct i387_fsave_struct *fp = &tsk->thread.xstate->fsave; |
| 150 | memset(fp, 0, xstate_size); |
| 151 | fp->cwd = 0xffff037fu; |
| 152 | fp->swd = 0xffff0000u; |
| 153 | fp->twd = 0xffffffffu; |
| 154 | fp->fos = 0xffff0000u; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | } |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 156 | /* |
| 157 | * Only the device not available exception or ptrace can call init_fpu. |
| 158 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | set_stopped_child_used_math(tsk); |
Suresh Siddha | aa283f4 | 2008-03-10 15:28:05 -0700 | [diff] [blame] | 160 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | } |
| 162 | |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 163 | int fpregs_active(struct task_struct *target, const struct user_regset *regset) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | { |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 165 | return tsk_used_math(target) ? regset->n : 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | } |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 167 | |
| 168 | int xfpregs_active(struct task_struct *target, const struct user_regset *regset) |
| 169 | { |
| 170 | return (cpu_has_fxsr && tsk_used_math(target)) ? regset->n : 0; |
| 171 | } |
| 172 | |
| 173 | int xfpregs_get(struct task_struct *target, const struct user_regset *regset, |
| 174 | unsigned int pos, unsigned int count, |
| 175 | void *kbuf, void __user *ubuf) |
| 176 | { |
Suresh Siddha | aa283f4 | 2008-03-10 15:28:05 -0700 | [diff] [blame] | 177 | int ret; |
| 178 | |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 179 | if (!cpu_has_fxsr) |
| 180 | return -ENODEV; |
| 181 | |
Suresh Siddha | aa283f4 | 2008-03-10 15:28:05 -0700 | [diff] [blame] | 182 | ret = init_fpu(target); |
| 183 | if (ret) |
| 184 | return ret; |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 185 | |
| 186 | return user_regset_copyout(&pos, &count, &kbuf, &ubuf, |
Suresh Siddha | 61c4628 | 2008-03-10 15:28:04 -0700 | [diff] [blame] | 187 | &target->thread.xstate->fxsave, 0, -1); |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 188 | } |
| 189 | |
| 190 | int xfpregs_set(struct task_struct *target, const struct user_regset *regset, |
| 191 | unsigned int pos, unsigned int count, |
| 192 | const void *kbuf, const void __user *ubuf) |
| 193 | { |
| 194 | int ret; |
| 195 | |
| 196 | if (!cpu_has_fxsr) |
| 197 | return -ENODEV; |
| 198 | |
Suresh Siddha | aa283f4 | 2008-03-10 15:28:05 -0700 | [diff] [blame] | 199 | ret = init_fpu(target); |
| 200 | if (ret) |
| 201 | return ret; |
| 202 | |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 203 | set_stopped_child_used_math(target); |
| 204 | |
| 205 | ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, |
Suresh Siddha | 61c4628 | 2008-03-10 15:28:04 -0700 | [diff] [blame] | 206 | &target->thread.xstate->fxsave, 0, -1); |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 207 | |
| 208 | /* |
| 209 | * mxcsr reserved bits must be masked to zero for security reasons. |
| 210 | */ |
Suresh Siddha | 61c4628 | 2008-03-10 15:28:04 -0700 | [diff] [blame] | 211 | target->thread.xstate->fxsave.mxcsr &= mxcsr_feature_mask; |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 212 | |
| 213 | return ret; |
| 214 | } |
| 215 | |
| 216 | #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | /* |
| 219 | * FPU tag word conversions. |
| 220 | */ |
| 221 | |
Cyrill Gorcunov | 3b095a0 | 2008-01-30 13:31:26 +0100 | [diff] [blame] | 222 | static inline unsigned short twd_i387_to_fxsr(unsigned short twd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | { |
| 224 | unsigned int tmp; /* to avoid 16 bit prefixes in the code */ |
Cyrill Gorcunov | 3b095a0 | 2008-01-30 13:31:26 +0100 | [diff] [blame] | 225 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | /* Transform each pair of bits into 01 (valid) or 00 (empty) */ |
Cyrill Gorcunov | 3b095a0 | 2008-01-30 13:31:26 +0100 | [diff] [blame] | 227 | tmp = ~twd; |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 228 | tmp = (tmp | (tmp>>1)) & 0x5555; /* 0V0V0V0V0V0V0V0V */ |
Cyrill Gorcunov | 3b095a0 | 2008-01-30 13:31:26 +0100 | [diff] [blame] | 229 | /* and move the valid bits to the lower byte. */ |
| 230 | tmp = (tmp | (tmp >> 1)) & 0x3333; /* 00VV00VV00VV00VV */ |
| 231 | tmp = (tmp | (tmp >> 2)) & 0x0f0f; /* 0000VVVV0000VVVV */ |
| 232 | tmp = (tmp | (tmp >> 4)) & 0x00ff; /* 00000000VVVVVVVV */ |
Ingo Molnar | f668964 | 2008-03-05 15:37:32 +0100 | [diff] [blame] | 233 | |
Cyrill Gorcunov | 3b095a0 | 2008-01-30 13:31:26 +0100 | [diff] [blame] | 234 | return tmp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | } |
| 236 | |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 237 | #define FPREG_ADDR(f, n) ((void *)&(f)->st_space + (n) * 16); |
| 238 | #define FP_EXP_TAG_VALID 0 |
| 239 | #define FP_EXP_TAG_ZERO 1 |
| 240 | #define FP_EXP_TAG_SPECIAL 2 |
| 241 | #define FP_EXP_TAG_EMPTY 3 |
| 242 | |
| 243 | static inline u32 twd_fxsr_to_i387(struct i387_fxsave_struct *fxsave) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | { |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 245 | struct _fpxreg *st; |
| 246 | u32 tos = (fxsave->swd >> 11) & 7; |
| 247 | u32 twd = (unsigned long) fxsave->twd; |
| 248 | u32 tag; |
| 249 | u32 ret = 0xffff0000u; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | int i; |
| 251 | |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 252 | for (i = 0; i < 8; i++, twd >>= 1) { |
Cyrill Gorcunov | 3b095a0 | 2008-01-30 13:31:26 +0100 | [diff] [blame] | 253 | if (twd & 0x1) { |
| 254 | st = FPREG_ADDR(fxsave, (i - tos) & 7); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | |
Cyrill Gorcunov | 3b095a0 | 2008-01-30 13:31:26 +0100 | [diff] [blame] | 256 | switch (st->exponent & 0x7fff) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | case 0x7fff: |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 258 | tag = FP_EXP_TAG_SPECIAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | break; |
| 260 | case 0x0000: |
Cyrill Gorcunov | 3b095a0 | 2008-01-30 13:31:26 +0100 | [diff] [blame] | 261 | if (!st->significand[0] && |
| 262 | !st->significand[1] && |
| 263 | !st->significand[2] && |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 264 | !st->significand[3]) |
| 265 | tag = FP_EXP_TAG_ZERO; |
| 266 | else |
| 267 | tag = FP_EXP_TAG_SPECIAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | break; |
| 269 | default: |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 270 | if (st->significand[3] & 0x8000) |
| 271 | tag = FP_EXP_TAG_VALID; |
| 272 | else |
| 273 | tag = FP_EXP_TAG_SPECIAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | break; |
| 275 | } |
| 276 | } else { |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 277 | tag = FP_EXP_TAG_EMPTY; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | } |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 279 | ret |= tag << (2 * i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | } |
| 281 | return ret; |
| 282 | } |
| 283 | |
| 284 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | * FXSR floating point environment conversions. |
| 286 | */ |
| 287 | |
Ingo Molnar | f668964 | 2008-03-05 15:37:32 +0100 | [diff] [blame] | 288 | static void |
| 289 | convert_from_fxsr(struct user_i387_ia32_struct *env, struct task_struct *tsk) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | { |
Suresh Siddha | 61c4628 | 2008-03-10 15:28:04 -0700 | [diff] [blame] | 291 | struct i387_fxsave_struct *fxsave = &tsk->thread.xstate->fxsave; |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 292 | struct _fpreg *to = (struct _fpreg *) &env->st_space[0]; |
| 293 | struct _fpxreg *from = (struct _fpxreg *) &fxsave->st_space[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | int i; |
| 295 | |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 296 | env->cwd = fxsave->cwd | 0xffff0000u; |
| 297 | env->swd = fxsave->swd | 0xffff0000u; |
| 298 | env->twd = twd_fxsr_to_i387(fxsave); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 300 | #ifdef CONFIG_X86_64 |
| 301 | env->fip = fxsave->rip; |
| 302 | env->foo = fxsave->rdp; |
| 303 | if (tsk == current) { |
| 304 | /* |
| 305 | * should be actually ds/cs at fpu exception time, but |
| 306 | * that information is not available in 64bit mode. |
| 307 | */ |
Ingo Molnar | f668964 | 2008-03-05 15:37:32 +0100 | [diff] [blame] | 308 | asm("mov %%ds, %[fos]" : [fos] "=r" (env->fos)); |
| 309 | asm("mov %%cs, %[fcs]" : [fcs] "=r" (env->fcs)); |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 310 | } else { |
| 311 | struct pt_regs *regs = task_pt_regs(tsk); |
Ingo Molnar | f668964 | 2008-03-05 15:37:32 +0100 | [diff] [blame] | 312 | |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 313 | env->fos = 0xffff0000 | tsk->thread.ds; |
| 314 | env->fcs = regs->cs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | } |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 316 | #else |
| 317 | env->fip = fxsave->fip; |
Jan Beulich | 609b529 | 2008-03-05 08:35:14 +0000 | [diff] [blame] | 318 | env->fcs = (u16) fxsave->fcs | ((u32) fxsave->fop << 16); |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 319 | env->foo = fxsave->foo; |
| 320 | env->fos = fxsave->fos; |
| 321 | #endif |
| 322 | |
| 323 | for (i = 0; i < 8; ++i) |
| 324 | memcpy(&to[i], &from[i], sizeof(to[0])); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | } |
| 326 | |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 327 | static void convert_to_fxsr(struct task_struct *tsk, |
| 328 | const struct user_i387_ia32_struct *env) |
| 329 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | { |
Suresh Siddha | 61c4628 | 2008-03-10 15:28:04 -0700 | [diff] [blame] | 331 | struct i387_fxsave_struct *fxsave = &tsk->thread.xstate->fxsave; |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 332 | struct _fpreg *from = (struct _fpreg *) &env->st_space[0]; |
| 333 | struct _fpxreg *to = (struct _fpxreg *) &fxsave->st_space[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | int i; |
| 335 | |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 336 | fxsave->cwd = env->cwd; |
| 337 | fxsave->swd = env->swd; |
| 338 | fxsave->twd = twd_i387_to_fxsr(env->twd); |
| 339 | fxsave->fop = (u16) ((u32) env->fcs >> 16); |
| 340 | #ifdef CONFIG_X86_64 |
| 341 | fxsave->rip = env->fip; |
| 342 | fxsave->rdp = env->foo; |
| 343 | /* cs and ds ignored */ |
| 344 | #else |
| 345 | fxsave->fip = env->fip; |
| 346 | fxsave->fcs = (env->fcs & 0xffff); |
| 347 | fxsave->foo = env->foo; |
| 348 | fxsave->fos = env->fos; |
| 349 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 351 | for (i = 0; i < 8; ++i) |
| 352 | memcpy(&to[i], &from[i], sizeof(from[0])); |
| 353 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 355 | int fpregs_get(struct task_struct *target, const struct user_regset *regset, |
| 356 | unsigned int pos, unsigned int count, |
| 357 | void *kbuf, void __user *ubuf) |
| 358 | { |
| 359 | struct user_i387_ia32_struct env; |
Suresh Siddha | aa283f4 | 2008-03-10 15:28:05 -0700 | [diff] [blame] | 360 | int ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | |
Suresh Siddha | aa283f4 | 2008-03-10 15:28:05 -0700 | [diff] [blame] | 362 | ret = init_fpu(target); |
| 363 | if (ret) |
| 364 | return ret; |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 365 | |
Suresh Siddha | e8a496a | 2008-05-23 16:26:37 -0700 | [diff] [blame] | 366 | if (!HAVE_HWFP) |
| 367 | return fpregs_soft_get(target, regset, pos, count, kbuf, ubuf); |
| 368 | |
Ingo Molnar | f668964 | 2008-03-05 15:37:32 +0100 | [diff] [blame] | 369 | if (!cpu_has_fxsr) { |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 370 | return user_regset_copyout(&pos, &count, &kbuf, &ubuf, |
Suresh Siddha | 61c4628 | 2008-03-10 15:28:04 -0700 | [diff] [blame] | 371 | &target->thread.xstate->fsave, 0, |
| 372 | -1); |
Ingo Molnar | f668964 | 2008-03-05 15:37:32 +0100 | [diff] [blame] | 373 | } |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 374 | |
| 375 | if (kbuf && pos == 0 && count == sizeof(env)) { |
| 376 | convert_from_fxsr(kbuf, target); |
| 377 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | } |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 379 | |
| 380 | convert_from_fxsr(&env, target); |
Ingo Molnar | f668964 | 2008-03-05 15:37:32 +0100 | [diff] [blame] | 381 | |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 382 | return user_regset_copyout(&pos, &count, &kbuf, &ubuf, &env, 0, -1); |
| 383 | } |
| 384 | |
| 385 | int fpregs_set(struct task_struct *target, const struct user_regset *regset, |
| 386 | unsigned int pos, unsigned int count, |
| 387 | const void *kbuf, const void __user *ubuf) |
| 388 | { |
| 389 | struct user_i387_ia32_struct env; |
| 390 | int ret; |
| 391 | |
Suresh Siddha | aa283f4 | 2008-03-10 15:28:05 -0700 | [diff] [blame] | 392 | ret = init_fpu(target); |
| 393 | if (ret) |
| 394 | return ret; |
| 395 | |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 396 | set_stopped_child_used_math(target); |
| 397 | |
Suresh Siddha | e8a496a | 2008-05-23 16:26:37 -0700 | [diff] [blame] | 398 | if (!HAVE_HWFP) |
| 399 | return fpregs_soft_set(target, regset, pos, count, kbuf, ubuf); |
| 400 | |
Ingo Molnar | f668964 | 2008-03-05 15:37:32 +0100 | [diff] [blame] | 401 | if (!cpu_has_fxsr) { |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 402 | return user_regset_copyin(&pos, &count, &kbuf, &ubuf, |
Suresh Siddha | 61c4628 | 2008-03-10 15:28:04 -0700 | [diff] [blame] | 403 | &target->thread.xstate->fsave, 0, -1); |
Ingo Molnar | f668964 | 2008-03-05 15:37:32 +0100 | [diff] [blame] | 404 | } |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 405 | |
| 406 | if (pos > 0 || count < sizeof(env)) |
| 407 | convert_from_fxsr(&env, target); |
| 408 | |
| 409 | ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &env, 0, -1); |
| 410 | if (!ret) |
| 411 | convert_to_fxsr(target, &env); |
| 412 | |
| 413 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | } |
| 415 | |
| 416 | /* |
| 417 | * Signal frame handlers. |
| 418 | */ |
| 419 | |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 420 | static inline int save_i387_fsave(struct _fpstate_ia32 __user *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | { |
| 422 | struct task_struct *tsk = current; |
Suresh Siddha | 61c4628 | 2008-03-10 15:28:04 -0700 | [diff] [blame] | 423 | struct i387_fsave_struct *fp = &tsk->thread.xstate->fsave; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | |
Cyrill Gorcunov | 3b095a0 | 2008-01-30 13:31:26 +0100 | [diff] [blame] | 425 | unlazy_fpu(tsk); |
Suresh Siddha | 61c4628 | 2008-03-10 15:28:04 -0700 | [diff] [blame] | 426 | fp->status = fp->swd; |
| 427 | if (__copy_to_user(buf, fp, sizeof(struct i387_fsave_struct))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | return -1; |
| 429 | return 1; |
| 430 | } |
| 431 | |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 432 | static int save_i387_fxsave(struct _fpstate_ia32 __user *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | { |
| 434 | struct task_struct *tsk = current; |
Suresh Siddha | 61c4628 | 2008-03-10 15:28:04 -0700 | [diff] [blame] | 435 | struct i387_fxsave_struct *fx = &tsk->thread.xstate->fxsave; |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 436 | struct user_i387_ia32_struct env; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | int err = 0; |
| 438 | |
Cyrill Gorcunov | 3b095a0 | 2008-01-30 13:31:26 +0100 | [diff] [blame] | 439 | unlazy_fpu(tsk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 441 | convert_from_fxsr(&env, tsk); |
| 442 | if (__copy_to_user(buf, &env, sizeof(env))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | return -1; |
| 444 | |
Suresh Siddha | 61c4628 | 2008-03-10 15:28:04 -0700 | [diff] [blame] | 445 | err |= __put_user(fx->swd, &buf->status); |
Cyrill Gorcunov | 3b095a0 | 2008-01-30 13:31:26 +0100 | [diff] [blame] | 446 | err |= __put_user(X86_FXSR_MAGIC, &buf->magic); |
| 447 | if (err) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | return -1; |
| 449 | |
Suresh Siddha | 61c4628 | 2008-03-10 15:28:04 -0700 | [diff] [blame] | 450 | if (__copy_to_user(&buf->_fxsr_env[0], fx, |
Cyrill Gorcunov | 3b095a0 | 2008-01-30 13:31:26 +0100 | [diff] [blame] | 451 | sizeof(struct i387_fxsave_struct))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | return -1; |
| 453 | return 1; |
| 454 | } |
| 455 | |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 456 | int save_i387_ia32(struct _fpstate_ia32 __user *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | { |
Cyrill Gorcunov | 3b095a0 | 2008-01-30 13:31:26 +0100 | [diff] [blame] | 458 | if (!used_math()) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | return 0; |
Ingo Molnar | f668964 | 2008-03-05 15:37:32 +0100 | [diff] [blame] | 460 | /* |
| 461 | * This will cause a "finit" to be triggered by the next |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | * attempted FPU operation by the 'current' process. |
| 463 | */ |
| 464 | clear_used_math(); |
| 465 | |
Ingo Molnar | f668964 | 2008-03-05 15:37:32 +0100 | [diff] [blame] | 466 | if (!HAVE_HWFP) { |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 467 | return fpregs_soft_get(current, NULL, |
| 468 | 0, sizeof(struct user_i387_ia32_struct), |
| 469 | NULL, buf) ? -1 : 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 470 | } |
Ingo Molnar | f668964 | 2008-03-05 15:37:32 +0100 | [diff] [blame] | 471 | |
| 472 | if (cpu_has_fxsr) |
| 473 | return save_i387_fxsave(buf); |
| 474 | else |
| 475 | return save_i387_fsave(buf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 476 | } |
| 477 | |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 478 | static inline int restore_i387_fsave(struct _fpstate_ia32 __user *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | { |
| 480 | struct task_struct *tsk = current; |
Ingo Molnar | f668964 | 2008-03-05 15:37:32 +0100 | [diff] [blame] | 481 | |
Suresh Siddha | 61c4628 | 2008-03-10 15:28:04 -0700 | [diff] [blame] | 482 | return __copy_from_user(&tsk->thread.xstate->fsave, buf, |
Cyrill Gorcunov | 3b095a0 | 2008-01-30 13:31:26 +0100 | [diff] [blame] | 483 | sizeof(struct i387_fsave_struct)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 484 | } |
| 485 | |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 486 | static int restore_i387_fxsave(struct _fpstate_ia32 __user *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 487 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | struct task_struct *tsk = current; |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 489 | struct user_i387_ia32_struct env; |
Ingo Molnar | f668964 | 2008-03-05 15:37:32 +0100 | [diff] [blame] | 490 | int err; |
| 491 | |
Suresh Siddha | 61c4628 | 2008-03-10 15:28:04 -0700 | [diff] [blame] | 492 | err = __copy_from_user(&tsk->thread.xstate->fxsave, &buf->_fxsr_env[0], |
Cyrill Gorcunov | 3b095a0 | 2008-01-30 13:31:26 +0100 | [diff] [blame] | 493 | sizeof(struct i387_fxsave_struct)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | /* mxcsr reserved bits must be masked to zero for security reasons */ |
Suresh Siddha | 61c4628 | 2008-03-10 15:28:04 -0700 | [diff] [blame] | 495 | tsk->thread.xstate->fxsave.mxcsr &= mxcsr_feature_mask; |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 496 | if (err || __copy_from_user(&env, buf, sizeof(env))) |
| 497 | return 1; |
| 498 | convert_to_fxsr(tsk, &env); |
Ingo Molnar | f668964 | 2008-03-05 15:37:32 +0100 | [diff] [blame] | 499 | |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 500 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | } |
| 502 | |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 503 | int restore_i387_ia32(struct _fpstate_ia32 __user *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 504 | { |
| 505 | int err; |
Suresh Siddha | e8a496a | 2008-05-23 16:26:37 -0700 | [diff] [blame] | 506 | struct task_struct *tsk = current; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 507 | |
Suresh Siddha | e8a496a | 2008-05-23 16:26:37 -0700 | [diff] [blame] | 508 | if (HAVE_HWFP) |
Suresh Siddha | fd3c3ed | 2008-05-07 12:09:52 -0700 | [diff] [blame] | 509 | clear_fpu(tsk); |
| 510 | |
Suresh Siddha | e8a496a | 2008-05-23 16:26:37 -0700 | [diff] [blame] | 511 | if (!used_math()) { |
| 512 | err = init_fpu(tsk); |
| 513 | if (err) |
| 514 | return err; |
| 515 | } |
Suresh Siddha | fd3c3ed | 2008-05-07 12:09:52 -0700 | [diff] [blame] | 516 | |
Suresh Siddha | e8a496a | 2008-05-23 16:26:37 -0700 | [diff] [blame] | 517 | if (HAVE_HWFP) { |
Ingo Molnar | f668964 | 2008-03-05 15:37:32 +0100 | [diff] [blame] | 518 | if (cpu_has_fxsr) |
Cyrill Gorcunov | 3b095a0 | 2008-01-30 13:31:26 +0100 | [diff] [blame] | 519 | err = restore_i387_fxsave(buf); |
Ingo Molnar | f668964 | 2008-03-05 15:37:32 +0100 | [diff] [blame] | 520 | else |
Cyrill Gorcunov | 3b095a0 | 2008-01-30 13:31:26 +0100 | [diff] [blame] | 521 | err = restore_i387_fsave(buf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | } else { |
Roland McGrath | 4421011 | 2008-01-30 13:31:50 +0100 | [diff] [blame] | 523 | err = fpregs_soft_set(current, NULL, |
| 524 | 0, sizeof(struct user_i387_ia32_struct), |
| 525 | NULL, buf) != 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | } |
| 527 | set_used_math(); |
Ingo Molnar | f668964 | 2008-03-05 15:37:32 +0100 | [diff] [blame] | 528 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | return err; |
| 530 | } |
| 531 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 532 | /* |
| 533 | * FPU state for core dumps. |
Roland McGrath | 60b3b9a | 2008-01-30 13:31:55 +0100 | [diff] [blame] | 534 | * This is only used for a.out dumps now. |
| 535 | * It is declared generically using elf_fpregset_t (which is |
| 536 | * struct user_i387_struct) but is in fact only used for 32-bit |
| 537 | * dumps, so on 64-bit it is really struct user_i387_ia32_struct. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | */ |
Cyrill Gorcunov | 3b095a0 | 2008-01-30 13:31:26 +0100 | [diff] [blame] | 539 | int dump_fpu(struct pt_regs *regs, struct user_i387_struct *fpu) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 541 | struct task_struct *tsk = current; |
Ingo Molnar | f668964 | 2008-03-05 15:37:32 +0100 | [diff] [blame] | 542 | int fpvalid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | |
| 544 | fpvalid = !!used_math(); |
Roland McGrath | 60b3b9a | 2008-01-30 13:31:55 +0100 | [diff] [blame] | 545 | if (fpvalid) |
| 546 | fpvalid = !fpregs_get(tsk, NULL, |
| 547 | 0, sizeof(struct user_i387_ia32_struct), |
| 548 | fpu, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 549 | |
| 550 | return fpvalid; |
| 551 | } |
Alexey Dobriyan | 129f694 | 2005-06-23 00:08:33 -0700 | [diff] [blame] | 552 | EXPORT_SYMBOL(dump_fpu); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | |
Roland McGrath | 60b3b9a | 2008-01-30 13:31:55 +0100 | [diff] [blame] | 554 | #endif /* CONFIG_X86_32 || CONFIG_IA32_EMULATION */ |