align.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. /* align.c - handle alignment exceptions for the Power PC.
  2. *
  3. * Copyright (c) 1996 Paul Mackerras <paulus@cs.anu.edu.au>
  4. * Copyright (c) 1998-1999 TiVo, Inc.
  5. * PowerPC 403GCX modifications.
  6. * Copyright (c) 1999 Grant Erickson <grant@lcse.umn.edu>
  7. * PowerPC 403GCX/405GP modifications.
  8. * Copyright (c) 2001-2002 PPC64 team, IBM Corp
  9. * 64-bit and Power4 support
  10. * Copyright (c) 2005 Benjamin Herrenschmidt, IBM Corp
  11. * <benh@kernel.crashing.org>
  12. * Merge ppc32 and ppc64 implementations
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License
  16. * as published by the Free Software Foundation; either version
  17. * 2 of the License, or (at your option) any later version.
  18. */
  19. #include <linux/kernel.h>
  20. #include <linux/mm.h>
  21. #include <asm/processor.h>
  22. #include <asm/uaccess.h>
  23. #include <asm/system.h>
  24. #include <asm/cache.h>
  25. #include <asm/cputable.h>
  26. struct aligninfo {
  27. unsigned char len;
  28. unsigned char flags;
  29. };
  30. #define IS_XFORM(inst) (((inst) >> 26) == 31)
  31. #define IS_DSFORM(inst) (((inst) >> 26) >= 56)
  32. #define INVALID { 0, 0 }
  33. /* Bits in the flags field */
  34. #define LD 0 /* load */
  35. #define ST 1 /* store */
  36. #define SE 2 /* sign-extend value */
  37. #define F 4 /* to/from fp regs */
  38. #define U 8 /* update index register */
  39. #define M 0x10 /* multiple load/store */
  40. #define SW 0x20 /* byte swap */
  41. #define S 0x40 /* single-precision fp or... */
  42. #define SX 0x40 /* ... byte count in XER */
  43. #define HARD 0x80 /* string, stwcx. */
  44. /* DSISR bits reported for a DCBZ instruction: */
  45. #define DCBZ 0x5f /* 8xx/82xx dcbz faults when cache not enabled */
  46. #define SWAP(a, b) (t = (a), (a) = (b), (b) = t)
  47. /*
  48. * The PowerPC stores certain bits of the instruction that caused the
  49. * alignment exception in the DSISR register. This array maps those
  50. * bits to information about the operand length and what the
  51. * instruction would do.
  52. */
  53. static struct aligninfo aligninfo[128] = {
  54. { 4, LD }, /* 00 0 0000: lwz / lwarx */
  55. INVALID, /* 00 0 0001 */
  56. { 4, ST }, /* 00 0 0010: stw */
  57. INVALID, /* 00 0 0011 */
  58. { 2, LD }, /* 00 0 0100: lhz */
  59. { 2, LD+SE }, /* 00 0 0101: lha */
  60. { 2, ST }, /* 00 0 0110: sth */
  61. { 4, LD+M }, /* 00 0 0111: lmw */
  62. { 4, LD+F+S }, /* 00 0 1000: lfs */
  63. { 8, LD+F }, /* 00 0 1001: lfd */
  64. { 4, ST+F+S }, /* 00 0 1010: stfs */
  65. { 8, ST+F }, /* 00 0 1011: stfd */
  66. INVALID, /* 00 0 1100 */
  67. { 8, LD }, /* 00 0 1101: ld/ldu/lwa */
  68. INVALID, /* 00 0 1110 */
  69. { 8, ST }, /* 00 0 1111: std/stdu */
  70. { 4, LD+U }, /* 00 1 0000: lwzu */
  71. INVALID, /* 00 1 0001 */
  72. { 4, ST+U }, /* 00 1 0010: stwu */
  73. INVALID, /* 00 1 0011 */
  74. { 2, LD+U }, /* 00 1 0100: lhzu */
  75. { 2, LD+SE+U }, /* 00 1 0101: lhau */
  76. { 2, ST+U }, /* 00 1 0110: sthu */
  77. { 4, ST+M }, /* 00 1 0111: stmw */
  78. { 4, LD+F+S+U }, /* 00 1 1000: lfsu */
  79. { 8, LD+F+U }, /* 00 1 1001: lfdu */
  80. { 4, ST+F+S+U }, /* 00 1 1010: stfsu */
  81. { 8, ST+F+U }, /* 00 1 1011: stfdu */
  82. INVALID, /* 00 1 1100 */
  83. INVALID, /* 00 1 1101 */
  84. INVALID, /* 00 1 1110 */
  85. INVALID, /* 00 1 1111 */
  86. { 8, LD }, /* 01 0 0000: ldx */
  87. INVALID, /* 01 0 0001 */
  88. { 8, ST }, /* 01 0 0010: stdx */
  89. INVALID, /* 01 0 0011 */
  90. INVALID, /* 01 0 0100 */
  91. { 4, LD+SE }, /* 01 0 0101: lwax */
  92. INVALID, /* 01 0 0110 */
  93. INVALID, /* 01 0 0111 */
  94. { 4, LD+M+HARD+SX }, /* 01 0 1000: lswx */
  95. { 4, LD+M+HARD }, /* 01 0 1001: lswi */
  96. { 4, ST+M+HARD+SX }, /* 01 0 1010: stswx */
  97. { 4, ST+M+HARD }, /* 01 0 1011: stswi */
  98. INVALID, /* 01 0 1100 */
  99. { 8, LD+U }, /* 01 0 1101: ldu */
  100. INVALID, /* 01 0 1110 */
  101. { 8, ST+U }, /* 01 0 1111: stdu */
  102. { 8, LD+U }, /* 01 1 0000: ldux */
  103. INVALID, /* 01 1 0001 */
  104. { 8, ST+U }, /* 01 1 0010: stdux */
  105. INVALID, /* 01 1 0011 */
  106. INVALID, /* 01 1 0100 */
  107. { 4, LD+SE+U }, /* 01 1 0101: lwaux */
  108. INVALID, /* 01 1 0110 */
  109. INVALID, /* 01 1 0111 */
  110. INVALID, /* 01 1 1000 */
  111. INVALID, /* 01 1 1001 */
  112. INVALID, /* 01 1 1010 */
  113. INVALID, /* 01 1 1011 */
  114. INVALID, /* 01 1 1100 */
  115. INVALID, /* 01 1 1101 */
  116. INVALID, /* 01 1 1110 */
  117. INVALID, /* 01 1 1111 */
  118. INVALID, /* 10 0 0000 */
  119. INVALID, /* 10 0 0001 */
  120. INVALID, /* 10 0 0010: stwcx. */
  121. INVALID, /* 10 0 0011 */
  122. INVALID, /* 10 0 0100 */
  123. INVALID, /* 10 0 0101 */
  124. INVALID, /* 10 0 0110 */
  125. INVALID, /* 10 0 0111 */
  126. { 4, LD+SW }, /* 10 0 1000: lwbrx */
  127. INVALID, /* 10 0 1001 */
  128. { 4, ST+SW }, /* 10 0 1010: stwbrx */
  129. INVALID, /* 10 0 1011 */
  130. { 2, LD+SW }, /* 10 0 1100: lhbrx */
  131. { 4, LD+SE }, /* 10 0 1101 lwa */
  132. { 2, ST+SW }, /* 10 0 1110: sthbrx */
  133. INVALID, /* 10 0 1111 */
  134. INVALID, /* 10 1 0000 */
  135. INVALID, /* 10 1 0001 */
  136. INVALID, /* 10 1 0010 */
  137. INVALID, /* 10 1 0011 */
  138. INVALID, /* 10 1 0100 */
  139. INVALID, /* 10 1 0101 */
  140. INVALID, /* 10 1 0110 */
  141. INVALID, /* 10 1 0111 */
  142. INVALID, /* 10 1 1000 */
  143. INVALID, /* 10 1 1001 */
  144. INVALID, /* 10 1 1010 */
  145. INVALID, /* 10 1 1011 */
  146. INVALID, /* 10 1 1100 */
  147. INVALID, /* 10 1 1101 */
  148. INVALID, /* 10 1 1110 */
  149. { 0, ST+HARD }, /* 10 1 1111: dcbz */
  150. { 4, LD }, /* 11 0 0000: lwzx */
  151. INVALID, /* 11 0 0001 */
  152. { 4, ST }, /* 11 0 0010: stwx */
  153. INVALID, /* 11 0 0011 */
  154. { 2, LD }, /* 11 0 0100: lhzx */
  155. { 2, LD+SE }, /* 11 0 0101: lhax */
  156. { 2, ST }, /* 11 0 0110: sthx */
  157. INVALID, /* 11 0 0111 */
  158. { 4, LD+F+S }, /* 11 0 1000: lfsx */
  159. { 8, LD+F }, /* 11 0 1001: lfdx */
  160. { 4, ST+F+S }, /* 11 0 1010: stfsx */
  161. { 8, ST+F }, /* 11 0 1011: stfdx */
  162. INVALID, /* 11 0 1100 */
  163. { 8, LD+M }, /* 11 0 1101: lmd */
  164. INVALID, /* 11 0 1110 */
  165. { 8, ST+M }, /* 11 0 1111: stmd */
  166. { 4, LD+U }, /* 11 1 0000: lwzux */
  167. INVALID, /* 11 1 0001 */
  168. { 4, ST+U }, /* 11 1 0010: stwux */
  169. INVALID, /* 11 1 0011 */
  170. { 2, LD+U }, /* 11 1 0100: lhzux */
  171. { 2, LD+SE+U }, /* 11 1 0101: lhaux */
  172. { 2, ST+U }, /* 11 1 0110: sthux */
  173. INVALID, /* 11 1 0111 */
  174. { 4, LD+F+S+U }, /* 11 1 1000: lfsux */
  175. { 8, LD+F+U }, /* 11 1 1001: lfdux */
  176. { 4, ST+F+S+U }, /* 11 1 1010: stfsux */
  177. { 8, ST+F+U }, /* 11 1 1011: stfdux */
  178. INVALID, /* 11 1 1100 */
  179. INVALID, /* 11 1 1101 */
  180. INVALID, /* 11 1 1110 */
  181. INVALID, /* 11 1 1111 */
  182. };
  183. /*
  184. * Create a DSISR value from the instruction
  185. */
  186. static inline unsigned make_dsisr(unsigned instr)
  187. {
  188. unsigned dsisr;
  189. /* bits 6:15 --> 22:31 */
  190. dsisr = (instr & 0x03ff0000) >> 16;
  191. if (IS_XFORM(instr)) {
  192. /* bits 29:30 --> 15:16 */
  193. dsisr |= (instr & 0x00000006) << 14;
  194. /* bit 25 --> 17 */
  195. dsisr |= (instr & 0x00000040) << 8;
  196. /* bits 21:24 --> 18:21 */
  197. dsisr |= (instr & 0x00000780) << 3;
  198. } else {
  199. /* bit 5 --> 17 */
  200. dsisr |= (instr & 0x04000000) >> 12;
  201. /* bits 1: 4 --> 18:21 */
  202. dsisr |= (instr & 0x78000000) >> 17;
  203. /* bits 30:31 --> 12:13 */
  204. if (IS_DSFORM(instr))
  205. dsisr |= (instr & 0x00000003) << 18;
  206. }
  207. return dsisr;
  208. }
  209. /*
  210. * The dcbz (data cache block zero) instruction
  211. * gives an alignment fault if used on non-cacheable
  212. * memory. We handle the fault mainly for the
  213. * case when we are running with the cache disabled
  214. * for debugging.
  215. */
  216. static int emulate_dcbz(struct pt_regs *regs, unsigned char __user *addr)
  217. {
  218. long __user *p;
  219. int i, size;
  220. #ifdef __powerpc64__
  221. size = ppc64_caches.dline_size;
  222. #else
  223. size = L1_CACHE_BYTES;
  224. #endif
  225. p = (long __user *) (regs->dar & -size);
  226. if (user_mode(regs) && !access_ok(VERIFY_WRITE, p, size))
  227. return -EFAULT;
  228. for (i = 0; i < size / sizeof(long); ++i)
  229. if (__put_user_inatomic(0, p+i))
  230. return -EFAULT;
  231. return 1;
  232. }
  233. /*
  234. * Emulate load & store multiple instructions
  235. * On 64-bit machines, these instructions only affect/use the
  236. * bottom 4 bytes of each register, and the loads clear the
  237. * top 4 bytes of the affected register.
  238. */
  239. #ifdef CONFIG_PPC64
  240. #define REG_BYTE(rp, i) *((u8 *)((rp) + ((i) >> 2)) + ((i) & 3) + 4)
  241. #else
  242. #define REG_BYTE(rp, i) *((u8 *)(rp) + (i))
  243. #endif
  244. #define SWIZ_PTR(p) ((unsigned char __user *)((p) ^ swiz))
  245. static int emulate_multiple(struct pt_regs *regs, unsigned char __user *addr,
  246. unsigned int reg, unsigned int nb,
  247. unsigned int flags, unsigned int instr,
  248. unsigned long swiz)
  249. {
  250. unsigned long *rptr;
  251. unsigned int nb0, i, bswiz;
  252. unsigned long p;
  253. /*
  254. * We do not try to emulate 8 bytes multiple as they aren't really
  255. * available in our operating environments and we don't try to
  256. * emulate multiples operations in kernel land as they should never
  257. * be used/generated there at least not on unaligned boundaries
  258. */
  259. if (unlikely((nb > 4) || !user_mode(regs)))
  260. return 0;
  261. /* lmw, stmw, lswi/x, stswi/x */
  262. nb0 = 0;
  263. if (flags & HARD) {
  264. if (flags & SX) {
  265. nb = regs->xer & 127;
  266. if (nb == 0)
  267. return 1;
  268. } else {
  269. unsigned long pc = regs->nip ^ (swiz & 4);
  270. if (__get_user_inatomic(instr,
  271. (unsigned int __user *)pc))
  272. return -EFAULT;
  273. if (swiz == 0 && (flags & SW))
  274. instr = cpu_to_le32(instr);
  275. nb = (instr >> 11) & 0x1f;
  276. if (nb == 0)
  277. nb = 32;
  278. }
  279. if (nb + reg * 4 > 128) {
  280. nb0 = nb + reg * 4 - 128;
  281. nb = 128 - reg * 4;
  282. }
  283. } else {
  284. /* lwm, stmw */
  285. nb = (32 - reg) * 4;
  286. }
  287. if (!access_ok((flags & ST ? VERIFY_WRITE: VERIFY_READ), addr, nb+nb0))
  288. return -EFAULT; /* bad address */
  289. rptr = &regs->gpr[reg];
  290. p = (unsigned long) addr;
  291. bswiz = (flags & SW)? 3: 0;
  292. if (!(flags & ST)) {
  293. /*
  294. * This zeroes the top 4 bytes of the affected registers
  295. * in 64-bit mode, and also zeroes out any remaining
  296. * bytes of the last register for lsw*.
  297. */
  298. memset(rptr, 0, ((nb + 3) / 4) * sizeof(unsigned long));
  299. if (nb0 > 0)
  300. memset(&regs->gpr[0], 0,
  301. ((nb0 + 3) / 4) * sizeof(unsigned long));
  302. for (i = 0; i < nb; ++i, ++p)
  303. if (__get_user_inatomic(REG_BYTE(rptr, i ^ bswiz),
  304. SWIZ_PTR(p)))
  305. return -EFAULT;
  306. if (nb0 > 0) {
  307. rptr = &regs->gpr[0];
  308. addr += nb;
  309. for (i = 0; i < nb0; ++i, ++p)
  310. if (__get_user_inatomic(REG_BYTE(rptr,
  311. i ^ bswiz),
  312. SWIZ_PTR(p)))
  313. return -EFAULT;
  314. }
  315. } else {
  316. for (i = 0; i < nb; ++i, ++p)
  317. if (__put_user_inatomic(REG_BYTE(rptr, i ^ bswiz),
  318. SWIZ_PTR(p)))
  319. return -EFAULT;
  320. if (nb0 > 0) {
  321. rptr = &regs->gpr[0];
  322. addr += nb;
  323. for (i = 0; i < nb0; ++i, ++p)
  324. if (__put_user_inatomic(REG_BYTE(rptr,
  325. i ^ bswiz),
  326. SWIZ_PTR(p)))
  327. return -EFAULT;
  328. }
  329. }
  330. return 1;
  331. }
  332. /*
  333. * Called on alignment exception. Attempts to fixup
  334. *
  335. * Return 1 on success
  336. * Return 0 if unable to handle the interrupt
  337. * Return -EFAULT if data address is bad
  338. */
  339. int fix_alignment(struct pt_regs *regs)
  340. {
  341. unsigned int instr, nb, flags;
  342. unsigned int reg, areg;
  343. unsigned int dsisr;
  344. unsigned char __user *addr;
  345. unsigned long p, swiz;
  346. int ret, t;
  347. union {
  348. u64 ll;
  349. double dd;
  350. unsigned char v[8];
  351. struct {
  352. unsigned hi32;
  353. int low32;
  354. } x32;
  355. struct {
  356. unsigned char hi48[6];
  357. short low16;
  358. } x16;
  359. } data;
  360. /*
  361. * We require a complete register set, if not, then our assembly
  362. * is broken
  363. */
  364. CHECK_FULL_REGS(regs);
  365. dsisr = regs->dsisr;
  366. /* Some processors don't provide us with a DSISR we can use here,
  367. * let's make one up from the instruction
  368. */
  369. if (cpu_has_feature(CPU_FTR_NODSISRALIGN)) {
  370. unsigned long pc = regs->nip;
  371. if (cpu_has_feature(CPU_FTR_PPC_LE) && (regs->msr & MSR_LE))
  372. pc ^= 4;
  373. if (unlikely(__get_user_inatomic(instr,
  374. (unsigned int __user *)pc)))
  375. return -EFAULT;
  376. if (cpu_has_feature(CPU_FTR_REAL_LE) && (regs->msr & MSR_LE))
  377. instr = cpu_to_le32(instr);
  378. dsisr = make_dsisr(instr);
  379. }
  380. /* extract the operation and registers from the dsisr */
  381. reg = (dsisr >> 5) & 0x1f; /* source/dest register */
  382. areg = dsisr & 0x1f; /* register to update */
  383. instr = (dsisr >> 10) & 0x7f;
  384. instr |= (dsisr >> 13) & 0x60;
  385. /* Lookup the operation in our table */
  386. nb = aligninfo[instr].len;
  387. flags = aligninfo[instr].flags;
  388. /* Byteswap little endian loads and stores */
  389. swiz = 0;
  390. if (regs->msr & MSR_LE) {
  391. flags ^= SW;
  392. /*
  393. * So-called "PowerPC little endian" mode works by
  394. * swizzling addresses rather than by actually doing
  395. * any byte-swapping. To emulate this, we XOR each
  396. * byte address with 7. We also byte-swap, because
  397. * the processor's address swizzling depends on the
  398. * operand size (it xors the address with 7 for bytes,
  399. * 6 for halfwords, 4 for words, 0 for doublewords) but
  400. * we will xor with 7 and load/store each byte separately.
  401. */
  402. if (cpu_has_feature(CPU_FTR_PPC_LE))
  403. swiz = 7;
  404. }
  405. /* DAR has the operand effective address */
  406. addr = (unsigned char __user *)regs->dar;
  407. /* A size of 0 indicates an instruction we don't support, with
  408. * the exception of DCBZ which is handled as a special case here
  409. */
  410. if (instr == DCBZ)
  411. return emulate_dcbz(regs, addr);
  412. if (unlikely(nb == 0))
  413. return 0;
  414. /* Load/Store Multiple instructions are handled in their own
  415. * function
  416. */
  417. if (flags & M)
  418. return emulate_multiple(regs, addr, reg, nb,
  419. flags, instr, swiz);
  420. /* Verify the address of the operand */
  421. if (unlikely(user_mode(regs) &&
  422. !access_ok((flags & ST ? VERIFY_WRITE : VERIFY_READ),
  423. addr, nb)))
  424. return -EFAULT;
  425. /* Force the fprs into the save area so we can reference them */
  426. if (flags & F) {
  427. /* userland only */
  428. if (unlikely(!user_mode(regs)))
  429. return 0;
  430. flush_fp_to_thread(current);
  431. }
  432. /* If we are loading, get the data from user space, else
  433. * get it from register values
  434. */
  435. if (!(flags & ST)) {
  436. data.ll = 0;
  437. ret = 0;
  438. p = (unsigned long) addr;
  439. switch (nb) {
  440. case 8:
  441. ret |= __get_user_inatomic(data.v[0], SWIZ_PTR(p++));
  442. ret |= __get_user_inatomic(data.v[1], SWIZ_PTR(p++));
  443. ret |= __get_user_inatomic(data.v[2], SWIZ_PTR(p++));
  444. ret |= __get_user_inatomic(data.v[3], SWIZ_PTR(p++));
  445. case 4:
  446. ret |= __get_user_inatomic(data.v[4], SWIZ_PTR(p++));
  447. ret |= __get_user_inatomic(data.v[5], SWIZ_PTR(p++));
  448. case 2:
  449. ret |= __get_user_inatomic(data.v[6], SWIZ_PTR(p++));
  450. ret |= __get_user_inatomic(data.v[7], SWIZ_PTR(p++));
  451. if (unlikely(ret))
  452. return -EFAULT;
  453. }
  454. } else if (flags & F) {
  455. data.dd = current->thread.fpr[reg];
  456. if (flags & S) {
  457. /* Single-precision FP store requires conversion... */
  458. #ifdef CONFIG_PPC_FPU
  459. preempt_disable();
  460. enable_kernel_fp();
  461. cvt_df(&data.dd, (float *)&data.v[4], &current->thread);
  462. preempt_enable();
  463. #else
  464. return 0;
  465. #endif
  466. }
  467. } else
  468. data.ll = regs->gpr[reg];
  469. if (flags & SW) {
  470. switch (nb) {
  471. case 8:
  472. SWAP(data.v[0], data.v[7]);
  473. SWAP(data.v[1], data.v[6]);
  474. SWAP(data.v[2], data.v[5]);
  475. SWAP(data.v[3], data.v[4]);
  476. break;
  477. case 4:
  478. SWAP(data.v[4], data.v[7]);
  479. SWAP(data.v[5], data.v[6]);
  480. break;
  481. case 2:
  482. SWAP(data.v[6], data.v[7]);
  483. break;
  484. }
  485. }
  486. /* Perform other misc operations like sign extension
  487. * or floating point single precision conversion
  488. */
  489. switch (flags & ~(U|SW)) {
  490. case LD+SE: /* sign extend */
  491. if ( nb == 2 )
  492. data.ll = data.x16.low16;
  493. else /* nb must be 4 */
  494. data.ll = data.x32.low32;
  495. break;
  496. /* Single-precision FP load requires conversion... */
  497. case LD+F+S:
  498. #ifdef CONFIG_PPC_FPU
  499. preempt_disable();
  500. enable_kernel_fp();
  501. cvt_fd((float *)&data.v[4], &data.dd, &current->thread);
  502. preempt_enable();
  503. #else
  504. return 0;
  505. #endif
  506. break;
  507. }
  508. /* Store result to memory or update registers */
  509. if (flags & ST) {
  510. ret = 0;
  511. p = (unsigned long) addr;
  512. switch (nb) {
  513. case 8:
  514. ret |= __put_user_inatomic(data.v[0], SWIZ_PTR(p++));
  515. ret |= __put_user_inatomic(data.v[1], SWIZ_PTR(p++));
  516. ret |= __put_user_inatomic(data.v[2], SWIZ_PTR(p++));
  517. ret |= __put_user_inatomic(data.v[3], SWIZ_PTR(p++));
  518. case 4:
  519. ret |= __put_user_inatomic(data.v[4], SWIZ_PTR(p++));
  520. ret |= __put_user_inatomic(data.v[5], SWIZ_PTR(p++));
  521. case 2:
  522. ret |= __put_user_inatomic(data.v[6], SWIZ_PTR(p++));
  523. ret |= __put_user_inatomic(data.v[7], SWIZ_PTR(p++));
  524. }
  525. if (unlikely(ret))
  526. return -EFAULT;
  527. } else if (flags & F)
  528. current->thread.fpr[reg] = data.dd;
  529. else
  530. regs->gpr[reg] = data.ll;
  531. /* Update RA as needed */
  532. if (flags & U)
  533. regs->gpr[areg] = regs->dar;
  534. return 1;
  535. }