align.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  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(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(instr, (unsigned int __user *)pc))
  271. return -EFAULT;
  272. if (swiz == 0 && (flags & SW))
  273. instr = cpu_to_le32(instr);
  274. nb = (instr >> 11) & 0x1f;
  275. if (nb == 0)
  276. nb = 32;
  277. }
  278. if (nb + reg * 4 > 128) {
  279. nb0 = nb + reg * 4 - 128;
  280. nb = 128 - reg * 4;
  281. }
  282. } else {
  283. /* lwm, stmw */
  284. nb = (32 - reg) * 4;
  285. }
  286. if (!access_ok((flags & ST ? VERIFY_WRITE: VERIFY_READ), addr, nb+nb0))
  287. return -EFAULT; /* bad address */
  288. rptr = &regs->gpr[reg];
  289. p = (unsigned long) addr;
  290. bswiz = (flags & SW)? 3: 0;
  291. if (!(flags & ST)) {
  292. /*
  293. * This zeroes the top 4 bytes of the affected registers
  294. * in 64-bit mode, and also zeroes out any remaining
  295. * bytes of the last register for lsw*.
  296. */
  297. memset(rptr, 0, ((nb + 3) / 4) * sizeof(unsigned long));
  298. if (nb0 > 0)
  299. memset(&regs->gpr[0], 0,
  300. ((nb0 + 3) / 4) * sizeof(unsigned long));
  301. for (i = 0; i < nb; ++i, ++p)
  302. if (__get_user(REG_BYTE(rptr, i ^ bswiz), SWIZ_PTR(p)))
  303. return -EFAULT;
  304. if (nb0 > 0) {
  305. rptr = &regs->gpr[0];
  306. addr += nb;
  307. for (i = 0; i < nb0; ++i, ++p)
  308. if (__get_user(REG_BYTE(rptr, i ^ bswiz),
  309. SWIZ_PTR(p)))
  310. return -EFAULT;
  311. }
  312. } else {
  313. for (i = 0; i < nb; ++i, ++p)
  314. if (__put_user(REG_BYTE(rptr, i ^ bswiz), SWIZ_PTR(p)))
  315. return -EFAULT;
  316. if (nb0 > 0) {
  317. rptr = &regs->gpr[0];
  318. addr += nb;
  319. for (i = 0; i < nb0; ++i, ++p)
  320. if (__put_user(REG_BYTE(rptr, i ^ bswiz),
  321. SWIZ_PTR(p)))
  322. return -EFAULT;
  323. }
  324. }
  325. return 1;
  326. }
  327. /*
  328. * Called on alignment exception. Attempts to fixup
  329. *
  330. * Return 1 on success
  331. * Return 0 if unable to handle the interrupt
  332. * Return -EFAULT if data address is bad
  333. */
  334. int fix_alignment(struct pt_regs *regs)
  335. {
  336. unsigned int instr, nb, flags;
  337. unsigned int reg, areg;
  338. unsigned int dsisr;
  339. unsigned char __user *addr;
  340. unsigned long p, swiz;
  341. int ret, t;
  342. union {
  343. u64 ll;
  344. double dd;
  345. unsigned char v[8];
  346. struct {
  347. unsigned hi32;
  348. int low32;
  349. } x32;
  350. struct {
  351. unsigned char hi48[6];
  352. short low16;
  353. } x16;
  354. } data;
  355. /*
  356. * We require a complete register set, if not, then our assembly
  357. * is broken
  358. */
  359. CHECK_FULL_REGS(regs);
  360. dsisr = regs->dsisr;
  361. /* Some processors don't provide us with a DSISR we can use here,
  362. * let's make one up from the instruction
  363. */
  364. if (cpu_has_feature(CPU_FTR_NODSISRALIGN)) {
  365. unsigned long pc = regs->nip;
  366. if (cpu_has_feature(CPU_FTR_PPC_LE) && (regs->msr & MSR_LE))
  367. pc ^= 4;
  368. if (unlikely(__get_user(instr, (unsigned int __user *)pc)))
  369. return -EFAULT;
  370. if (cpu_has_feature(CPU_FTR_REAL_LE) && (regs->msr & MSR_LE))
  371. instr = cpu_to_le32(instr);
  372. dsisr = make_dsisr(instr);
  373. }
  374. /* extract the operation and registers from the dsisr */
  375. reg = (dsisr >> 5) & 0x1f; /* source/dest register */
  376. areg = dsisr & 0x1f; /* register to update */
  377. instr = (dsisr >> 10) & 0x7f;
  378. instr |= (dsisr >> 13) & 0x60;
  379. /* Lookup the operation in our table */
  380. nb = aligninfo[instr].len;
  381. flags = aligninfo[instr].flags;
  382. /* Byteswap little endian loads and stores */
  383. swiz = 0;
  384. if (regs->msr & MSR_LE) {
  385. flags ^= SW;
  386. /*
  387. * So-called "PowerPC little endian" mode works by
  388. * swizzling addresses rather than by actually doing
  389. * any byte-swapping. To emulate this, we XOR each
  390. * byte address with 7. We also byte-swap, because
  391. * the processor's address swizzling depends on the
  392. * operand size (it xors the address with 7 for bytes,
  393. * 6 for halfwords, 4 for words, 0 for doublewords) but
  394. * we will xor with 7 and load/store each byte separately.
  395. */
  396. if (cpu_has_feature(CPU_FTR_PPC_LE))
  397. swiz = 7;
  398. }
  399. /* DAR has the operand effective address */
  400. addr = (unsigned char __user *)regs->dar;
  401. /* A size of 0 indicates an instruction we don't support, with
  402. * the exception of DCBZ which is handled as a special case here
  403. */
  404. if (instr == DCBZ)
  405. return emulate_dcbz(regs, addr);
  406. if (unlikely(nb == 0))
  407. return 0;
  408. /* Load/Store Multiple instructions are handled in their own
  409. * function
  410. */
  411. if (flags & M)
  412. return emulate_multiple(regs, addr, reg, nb,
  413. flags, instr, swiz);
  414. /* Verify the address of the operand */
  415. if (unlikely(user_mode(regs) &&
  416. !access_ok((flags & ST ? VERIFY_WRITE : VERIFY_READ),
  417. addr, nb)))
  418. return -EFAULT;
  419. /* Force the fprs into the save area so we can reference them */
  420. if (flags & F) {
  421. /* userland only */
  422. if (unlikely(!user_mode(regs)))
  423. return 0;
  424. flush_fp_to_thread(current);
  425. }
  426. /* If we are loading, get the data from user space, else
  427. * get it from register values
  428. */
  429. if (!(flags & ST)) {
  430. data.ll = 0;
  431. ret = 0;
  432. p = (unsigned long) addr;
  433. switch (nb) {
  434. case 8:
  435. ret |= __get_user(data.v[0], SWIZ_PTR(p++));
  436. ret |= __get_user(data.v[1], SWIZ_PTR(p++));
  437. ret |= __get_user(data.v[2], SWIZ_PTR(p++));
  438. ret |= __get_user(data.v[3], SWIZ_PTR(p++));
  439. case 4:
  440. ret |= __get_user(data.v[4], SWIZ_PTR(p++));
  441. ret |= __get_user(data.v[5], SWIZ_PTR(p++));
  442. case 2:
  443. ret |= __get_user(data.v[6], SWIZ_PTR(p++));
  444. ret |= __get_user(data.v[7], SWIZ_PTR(p++));
  445. if (unlikely(ret))
  446. return -EFAULT;
  447. }
  448. } else if (flags & F) {
  449. data.dd = current->thread.fpr[reg];
  450. if (flags & S) {
  451. /* Single-precision FP store requires conversion... */
  452. #ifdef CONFIG_PPC_FPU
  453. preempt_disable();
  454. enable_kernel_fp();
  455. cvt_df(&data.dd, (float *)&data.v[4], &current->thread);
  456. preempt_enable();
  457. #else
  458. return 0;
  459. #endif
  460. }
  461. } else
  462. data.ll = regs->gpr[reg];
  463. if (flags & SW) {
  464. switch (nb) {
  465. case 8:
  466. SWAP(data.v[0], data.v[7]);
  467. SWAP(data.v[1], data.v[6]);
  468. SWAP(data.v[2], data.v[5]);
  469. SWAP(data.v[3], data.v[4]);
  470. break;
  471. case 4:
  472. SWAP(data.v[4], data.v[7]);
  473. SWAP(data.v[5], data.v[6]);
  474. break;
  475. case 2:
  476. SWAP(data.v[6], data.v[7]);
  477. break;
  478. }
  479. }
  480. /* Perform other misc operations like sign extension
  481. * or floating point single precision conversion
  482. */
  483. switch (flags & ~(U|SW)) {
  484. case LD+SE: /* sign extend */
  485. if ( nb == 2 )
  486. data.ll = data.x16.low16;
  487. else /* nb must be 4 */
  488. data.ll = data.x32.low32;
  489. break;
  490. /* Single-precision FP load requires conversion... */
  491. case LD+F+S:
  492. #ifdef CONFIG_PPC_FPU
  493. preempt_disable();
  494. enable_kernel_fp();
  495. cvt_fd((float *)&data.v[4], &data.dd, &current->thread);
  496. preempt_enable();
  497. #else
  498. return 0;
  499. #endif
  500. break;
  501. }
  502. /* Store result to memory or update registers */
  503. if (flags & ST) {
  504. ret = 0;
  505. p = (unsigned long) addr;
  506. switch (nb) {
  507. case 8:
  508. ret |= __put_user(data.v[0], SWIZ_PTR(p++));
  509. ret |= __put_user(data.v[1], SWIZ_PTR(p++));
  510. ret |= __put_user(data.v[2], SWIZ_PTR(p++));
  511. ret |= __put_user(data.v[3], SWIZ_PTR(p++));
  512. case 4:
  513. ret |= __put_user(data.v[4], SWIZ_PTR(p++));
  514. ret |= __put_user(data.v[5], SWIZ_PTR(p++));
  515. case 2:
  516. ret |= __put_user(data.v[6], SWIZ_PTR(p++));
  517. ret |= __put_user(data.v[7], SWIZ_PTR(p++));
  518. }
  519. if (unlikely(ret))
  520. return -EFAULT;
  521. } else if (flags & F)
  522. current->thread.fpr[reg] = data.dd;
  523. else
  524. regs->gpr[reg] = data.ll;
  525. /* Update RA as needed */
  526. if (flags & U)
  527. regs->gpr[areg] = regs->dar;
  528. return 1;
  529. }