Commit b878a1c0 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull MIPS fixes from Thomas Bogendoerfer:
 "Fix for o32 ptrace/get_syscall_info"

* tag 'mips-fixes_6.14_1' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux:
  MIPS: fix mips_get_syscall_arg() for o32
  MIPS: Export syscall stack arguments properly for remote use
parents ad1b832b 733a9056
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -27,8 +27,8 @@
 */
struct pt_regs {
#ifdef CONFIG_32BIT
	/* Pad bytes for argument save space on the stack. */
	unsigned long pad0[8];
	/* Saved syscall stack arguments; entries 0-3 unused. */
	unsigned long args[8];
#endif

	/* Saved main processor registers. */
+8 −24
Original line number Diff line number Diff line
@@ -57,37 +57,21 @@ static inline void mips_syscall_update_nr(struct task_struct *task,
static inline void mips_get_syscall_arg(unsigned long *arg,
	struct task_struct *task, struct pt_regs *regs, unsigned int n)
{
	unsigned long usp __maybe_unused = regs->regs[29];

#ifdef CONFIG_32BIT
	switch (n) {
	case 0: case 1: case 2: case 3:
		*arg = regs->regs[4 + n];

		return;

#ifdef CONFIG_32BIT
	case 4: case 5: case 6: case 7:
		get_user(*arg, (int *)usp + n);
		*arg = regs->args[n];
		return;
#endif

#ifdef CONFIG_64BIT
	case 4: case 5: case 6: case 7:
#ifdef CONFIG_MIPS32_O32
		if (test_tsk_thread_flag(task, TIF_32BIT_REGS))
			get_user(*arg, (int *)usp + n);
		else
#endif
	}
#else
	*arg = regs->regs[4 + n];

		return;
	if ((IS_ENABLED(CONFIG_MIPS32_O32) &&
	     test_tsk_thread_flag(task, TIF_32BIT_REGS)))
		*arg = (unsigned int)*arg;
#endif

	default:
		BUG();
	}

	unreachable();
}

static inline long syscall_get_error(struct task_struct *task,
+6 −0
Original line number Diff line number Diff line
@@ -27,6 +27,12 @@ void output_ptreg_defines(void);
void output_ptreg_defines(void)
{
	COMMENT("MIPS pt_regs offsets.");
#ifdef CONFIG_32BIT
	OFFSET(PT_ARG4, pt_regs, args[4]);
	OFFSET(PT_ARG5, pt_regs, args[5]);
	OFFSET(PT_ARG6, pt_regs, args[6]);
	OFFSET(PT_ARG7, pt_regs, args[7]);
#endif
	OFFSET(PT_R0, pt_regs, regs[0]);
	OFFSET(PT_R1, pt_regs, regs[1]);
	OFFSET(PT_R2, pt_regs, regs[2]);
+4 −4
Original line number Diff line number Diff line
@@ -64,10 +64,10 @@ load_a6: user_lw(t7, 24(t0)) # argument #7 from usp
load_a7: user_lw(t8, 28(t0))		# argument #8 from usp
loads_done:

	sw	t5, 16(sp)		# argument #5 to ksp
	sw	t6, 20(sp)		# argument #6 to ksp
	sw	t7, 24(sp)		# argument #7 to ksp
	sw	t8, 28(sp)		# argument #8 to ksp
	sw	t5, PT_ARG4(sp)		# argument #5 to ksp
	sw	t6, PT_ARG5(sp)		# argument #6 to ksp
	sw	t7, PT_ARG6(sp)		# argument #7 to ksp
	sw	t8, PT_ARG7(sp)		# argument #8 to ksp
	.set	pop

	.section __ex_table,"a"