Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc: Rework syscall_get_arguments() so there is only one loop

Currently syscall_get_arguments() has two loops, one for compat and one
for regular tasks. In prepartion for the next patch, which changes which
registers we use, switch it to only have one loop, so we only have one
place to update.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Kees Cook <keescook@chromium.org>

+8 -11
+8 -11
arch/powerpc/include/asm/syscall.h
··· 64 64 unsigned int i, unsigned int n, 65 65 unsigned long *args) 66 66 { 67 + unsigned long mask = -1UL; 68 + 67 69 BUG_ON(i + n > 6); 68 - #ifdef CONFIG_PPC64 69 - if (test_tsk_thread_flag(task, TIF_32BIT)) { 70 - /* 71 - * Zero-extend 32-bit argument values. The high bits are 72 - * garbage ignored by the actual syscall dispatch. 73 - */ 74 - while (n-- > 0) 75 - args[n] = (u32) regs->gpr[3 + i + n]; 76 - return; 77 - } 70 + 71 + #ifdef CONFIG_COMPAT 72 + if (test_tsk_thread_flag(task, TIF_32BIT)) 73 + mask = 0xffffffff; 78 74 #endif 79 - memcpy(args, &regs->gpr[3 + i], n * sizeof(args[0])); 75 + while (n--) 76 + args[n] = regs->gpr[3 + i + n] & mask; 80 77 } 81 78 82 79 static inline void syscall_set_arguments(struct task_struct *task,