Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9b5bbf72 authored by Chris Metcalf's avatar Chris Metcalf
Browse files

tile: correct r1 value during syscall tracing



The r1 value is set based on the r0 value as we return to user space.
So tracing tools won't automatically see the right value.  Fix this by
generating the correct r1 value in do_syscall_trace_exit() rather
than trying to tamper with the hot path in syscall return.

Signed-off-by: default avatarChris Metcalf <cmetcalf@tilera.com>
parent 8d8cf067
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -265,6 +265,21 @@ int do_syscall_trace_enter(struct pt_regs *regs)

void do_syscall_trace_exit(struct pt_regs *regs)
{
	long errno;

	/*
	 * The standard tile calling convention returns the value (or negative
	 * errno) in r0, and zero (or positive errno) in r1.
	 * It saves a couple of cycles on the hot path to do this work in
	 * registers only as we return, rather than updating the in-memory
	 * struct ptregs.
	 */
	errno = (long) regs->regs[0];
	if (errno < 0 && errno > -4096)
		regs->regs[1] = -errno;
	else
		regs->regs[1] = 0;

	if (test_thread_flag(TIF_SYSCALL_TRACE))
		tracehook_report_syscall_exit(regs, 0);