Skip to content

Commit

Permalink
evl/syscall: handle prctl() call form
Browse files Browse the repository at this point in the history
Handle both the legacy and prctl-based call forms available from
Dovetail, i.e.:

syscall(sys_evl_<op> | __OOB_SYSCALL_BIT, ...) /* old form */
syscall(__NR_prctl, sys_evl_<op> | __OOB_SYSCALL, ...) /* new form */

With this change, we gain out-of-the-box support for Valgrind since
applications can now emit EVL system calls wrapped in prctl()
requests, which are readily recognized by the instrumentation
framework.

As a result, the ABI number is bumped to torvalds#27.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
  • Loading branch information
pgerum committed Sep 23, 2024
1 parent c01074b commit 75d1fa7
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 156 deletions.
36 changes: 3 additions & 33 deletions arch/arm/include/asm/evl/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,10 @@
#define raw_put_user(src, dst) __put_user(src, dst)
#define raw_get_user(dst, src) __get_user(dst, src)

#define oob_retval(__regs) ((__regs)->ARM_r0)
#define oob_arg1(__regs) ((__regs)->ARM_r0)
#define oob_arg2(__regs) ((__regs)->ARM_r1)
#define oob_arg3(__regs) ((__regs)->ARM_r2)
#define oob_arg4(__regs) ((__regs)->ARM_r3)
#define oob_arg5(__regs) ((__regs)->ARM_r4)

static inline bool is_oob_syscall(struct pt_regs *regs)
{
return !!(regs->ARM_r7 & __OOB_SYSCALL_BIT);
}

static inline unsigned int oob_syscall_nr(struct pt_regs *regs)
{
return regs->ARM_r7 & ~__OOB_SYSCALL_BIT;
}

static inline
bool inband_syscall_nr(struct pt_regs *regs, unsigned int *nr)
{
*nr = regs->ARM_r7;
return *nr < NR_syscalls || *nr >= __ARM_NR_BASE;
}

static inline void
set_oob_error(struct pt_regs *regs, int err)
{
oob_retval(regs) = err;
}

static inline
void set_oob_retval(struct pt_regs *regs, long ret)
static inline bool
is_valid_inband_syscall(unsigned int nr)
{
oob_retval(regs) = ret;
return nr < NR_syscalls || nr >= __ARM_NR_BASE;
}

static inline bool is_compat_oob_call(void)
Expand Down
33 changes: 2 additions & 31 deletions arch/arm64/include/asm/evl/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,12 @@
#define raw_put_user(src, dst) __put_user(src, dst)
#define raw_get_user(dst, src) __get_user(dst, src)

#define oob_retval(__regs) ((__regs)->regs[0])
#define oob_arg1(__regs) ((__regs)->regs[0])
#define oob_arg2(__regs) ((__regs)->regs[1])
#define oob_arg3(__regs) ((__regs)->regs[2])
#define oob_arg4(__regs) ((__regs)->regs[3])
#define oob_arg5(__regs) ((__regs)->regs[4])

#define __ARM_NR_BASE_compat 0xf0000

static inline bool is_oob_syscall(const struct pt_regs *regs)
{
return !!(regs->syscallno & __OOB_SYSCALL_BIT);
}

static inline unsigned int oob_syscall_nr(const struct pt_regs *regs)
{
return regs->syscallno & ~__OOB_SYSCALL_BIT;
}

static inline bool
inband_syscall_nr(struct pt_regs *regs, unsigned int *nr)
{
*nr = oob_syscall_nr(regs);

return !is_oob_syscall(regs);
}

static inline void set_oob_error(struct pt_regs *regs, int err)
{
oob_retval(regs) = err;
}

static inline void set_oob_retval(struct pt_regs *regs, long ret)
is_valid_inband_syscall(unsigned int nr)
{
oob_retval(regs) = ret;
return nr < NR_syscalls;
}

#ifdef CONFIG_COMPAT
Expand Down
34 changes: 3 additions & 31 deletions arch/x86/include/asm/evl/syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,10 @@
#define raw_put_user(src, dst) __put_user(src, dst)
#define raw_get_user(dst, src) __get_user(dst, src)

#define oob_retval(__regs) ((__regs)->ax)
#define oob_arg1(__regs) ((__regs)->di)
#define oob_arg2(__regs) ((__regs)->si)
#define oob_arg3(__regs) ((__regs)->dx)
#define oob_arg4(__regs) ((__regs)->r10)
#define oob_arg5(__regs) ((__regs)->r8)

static inline bool is_oob_syscall(const struct pt_regs *regs)
{
return !!(regs->orig_ax & __OOB_SYSCALL_BIT);
}

static inline unsigned int oob_syscall_nr(const struct pt_regs *regs)
{
return regs->orig_ax & ~__OOB_SYSCALL_BIT;
}

static inline
bool inband_syscall_nr(struct pt_regs *regs, unsigned int *nr)
{
*nr = oob_syscall_nr(regs);
return !is_oob_syscall(regs);
}

static inline void set_oob_error(struct pt_regs *regs, int err)
{
oob_retval(regs) = err;
}

static inline void set_oob_retval(struct pt_regs *regs, long ret)
static inline bool
is_valid_inband_syscall(unsigned int nr)
{
oob_retval(regs) = ret;
return nr < NR_syscalls;
}

static inline bool is_compat_oob_call(void)
Expand Down
2 changes: 1 addition & 1 deletion include/uapi/evl/control.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* latter to the former. CAUTION: a litteral value is required for the
* current ABI definition (scripts reading this may be naive).
*/
#define EVL_ABI_LEVEL 26
#define EVL_ABI_LEVEL 27

#define EVL_CONTROL_DEV "/dev/evl/control"

Expand Down
Loading

0 comments on commit 75d1fa7

Please sign in to comment.