diff options
Diffstat (limited to 'arch/powerpc/kernel/align.c')
-rw-r--r-- | arch/powerpc/kernel/align.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/arch/powerpc/kernel/align.c b/arch/powerpc/kernel/align.c index 5af4e9b2dbe2..73cb6a3229ae 100644 --- a/arch/powerpc/kernel/align.c +++ b/arch/powerpc/kernel/align.c | |||
@@ -367,27 +367,24 @@ static int emulate_multiple(struct pt_regs *regs, unsigned char __user *addr, | |||
367 | static int emulate_fp_pair(unsigned char __user *addr, unsigned int reg, | 367 | static int emulate_fp_pair(unsigned char __user *addr, unsigned int reg, |
368 | unsigned int flags) | 368 | unsigned int flags) |
369 | { | 369 | { |
370 | char *ptr = (char *) ¤t->thread.TS_FPR(reg); | 370 | char *ptr0 = (char *) ¤t->thread.TS_FPR(reg); |
371 | int i, ret; | 371 | char *ptr1 = (char *) ¤t->thread.TS_FPR(reg+1); |
372 | int i, ret, sw = 0; | ||
372 | 373 | ||
373 | if (!(flags & F)) | 374 | if (!(flags & F)) |
374 | return 0; | 375 | return 0; |
375 | if (reg & 1) | 376 | if (reg & 1) |
376 | return 0; /* invalid form: FRS/FRT must be even */ | 377 | return 0; /* invalid form: FRS/FRT must be even */ |
377 | if (!(flags & SW)) { | 378 | if (flags & SW) |
378 | /* not byte-swapped - easy */ | 379 | sw = 7; |
379 | if (!(flags & ST)) | 380 | ret = 0; |
380 | ret = __copy_from_user(ptr, addr, 16); | 381 | for (i = 0; i < 8; ++i) { |
381 | else | 382 | if (!(flags & ST)) { |
382 | ret = __copy_to_user(addr, ptr, 16); | 383 | ret |= __get_user(ptr0[i^sw], addr + i); |
383 | } else { | 384 | ret |= __get_user(ptr1[i^sw], addr + i + 8); |
384 | /* each FPR value is byte-swapped separately */ | 385 | } else { |
385 | ret = 0; | 386 | ret |= __put_user(ptr0[i^sw], addr + i); |
386 | for (i = 0; i < 16; ++i) { | 387 | ret |= __put_user(ptr1[i^sw], addr + i + 8); |
387 | if (!(flags & ST)) | ||
388 | ret |= __get_user(ptr[i^7], addr + i); | ||
389 | else | ||
390 | ret |= __put_user(ptr[i^7], addr + i); | ||
391 | } | 388 | } |
392 | } | 389 | } |
393 | if (ret) | 390 | if (ret) |
@@ -646,11 +643,16 @@ static int emulate_vsx(unsigned char __user *addr, unsigned int reg, | |||
646 | unsigned int areg, struct pt_regs *regs, | 643 | unsigned int areg, struct pt_regs *regs, |
647 | unsigned int flags, unsigned int length) | 644 | unsigned int flags, unsigned int length) |
648 | { | 645 | { |
649 | char *ptr = (char *) ¤t->thread.TS_FPR(reg); | 646 | char *ptr; |
650 | int ret = 0; | 647 | int ret = 0; |
651 | 648 | ||
652 | flush_vsx_to_thread(current); | 649 | flush_vsx_to_thread(current); |
653 | 650 | ||
651 | if (reg < 32) | ||
652 | ptr = (char *) ¤t->thread.TS_FPR(reg); | ||
653 | else | ||
654 | ptr = (char *) ¤t->thread.vr[reg - 32]; | ||
655 | |||
654 | if (flags & ST) | 656 | if (flags & ST) |
655 | ret = __copy_to_user(addr, ptr, length); | 657 | ret = __copy_to_user(addr, ptr, length); |
656 | else { | 658 | else { |