Commit fa5a45c4 authored by Philippe Gerum's avatar Philippe Gerum
Browse files

cobalt: syscall: don't bark at internal syscalls

Some architectures may define a secondary system call range for
internal operations, fix the consistency check not to warn about them.
parent 80b47292
......@@ -33,6 +33,11 @@
#define __ARM_NR_ipipe (__NR_SYSCALL_BASE + XENO_ARM_SYSCALL)
#endif
/*
* Cobalt syscall numbers can be fetched from ARM_ORIG_r0 with ARM_r7
* containing the Xenomai syscall marker, Linux syscalls directly from
* ARM_r7 (may require the OABI tweak).
*/
#define __xn_reg_sys(__regs) ((__regs)->ARM_ORIG_r0)
/* In OABI_COMPAT mode, handle both OABI and EABI userspace syscalls */
#ifdef CONFIG_OABI_COMPAT
......@@ -46,16 +51,15 @@
#define __xn_syscall(__regs) (__xn_reg_sys(__regs) & ~__COBALT_SYSCALL_BIT)
/*
* Returns the syscall number depending on the handling core. Cobalt
* syscall numbers can be fetched from ARM_ORIG_r0 with ARM_r7
* containing the Xenomai syscall marker, Linux syscalls directly from
* ARM_r7 (may require the OABI tweak).
* Root syscall number with predicate (valid only if
* !__xn_syscall_p(__regs)).
*/
static inline long __xn_get_syscall_nr(struct pt_regs *regs)
{
return __xn_syscall_p(regs) ? __xn_reg_sys(regs) : __xn_abi_decode(regs);
}
#define __xn_rootcall_p(__regs, __code) \
({ \
*(__code) = __xn_abi_decode(__regs); \
*(__code) < NR_syscalls || *(__code) >= __ARM_NR_BASE; \
})
#define __xn_reg_rval(__regs) ((__regs)->ARM_r0)
#define __xn_reg_arg1(__regs) ((__regs)->ARM_r1)
#define __xn_reg_arg2(__regs) ((__regs)->ARM_r2)
......
......@@ -28,6 +28,10 @@
#include <asm/ptrace.h>
#include <asm-generic/xenomai/syscall.h>
/*
* Cobalt and Linux syscall numbers can be fetched from syscallno,
* masking out the __COBALT_SYSCALL_BIT marker.
*/
#define __xn_reg_sys(__regs) ((unsigned long)(__regs)->syscallno)
#define __xn_syscall_p(regs) ((__xn_reg_sys(regs) & __COBALT_SYSCALL_BIT) != 0)
#define __xn_syscall(__regs) ((unsigned long)(__xn_reg_sys(__regs) & ~__COBALT_SYSCALL_BIT))
......@@ -42,14 +46,14 @@
#define __xn_reg_sp(__regs) ((__regs)->sp)
/*
* Returns the syscall number depending on the handling core. Cobalt
* and Linux syscall numbers can be fetched from syscallno, masking
* out the __COBALT_SYSCALL_BIT marker.
* Root syscall number with predicate (valid only if
* !__xn_syscall_p(__regs)).
*/
static inline long __xn_get_syscall_nr(struct pt_regs *regs)
{
return __xn_syscall(regs);
}
#define __xn_rootcall_p(__regs, __code) \
({ \
*(__code) = __xn_syscall(__regs); \
*(__code) < NR_syscalls; \
})
static inline void __xn_error_return(struct pt_regs *regs, int v)
{
......
......@@ -23,6 +23,10 @@
#include <asm/ptrace.h>
#include <asm-generic/xenomai/syscall.h>
/*
* Cobalt and Linux syscall numbers can be fetched from P0, masking
* out the __COBALT_SYSCALL_BIT marker.
*/
#define __xn_reg_sys(__regs) ((__regs)->orig_p0)
#define __xn_syscall_p(__regs) (__xn_reg_sys(__regs) & __COBALT_SYSCALL_BIT)
#define __xn_syscall(__regs) (__xn_reg_sys(__regs) & ~__COBALT_SYSCALL_BIT)
......@@ -35,14 +39,14 @@
#define __xn_reg_arg5(__regs) ((__regs)->r4)
/*
* Returns the syscall number depending on the handling core. Cobalt
* and Linux syscall numbers can be fetched from P0, masking out the
* __COBALT_SYSCALL_BIT marker.
* Root syscall number with predicate (valid only if
* !__xn_syscall_p(__regs)).
*/
static inline long __xn_get_syscall_nr(struct pt_regs *regs)
{
return __xn_syscall(regs);
}
#define __xn_rootcall_p(__regs, __code) \
({ \
*(__code) = __xn_syscall(__regs); \
*(__code) < NR_syscalls; \
})
static inline void __xn_error_return(struct pt_regs *regs, int v)
{
......
......@@ -26,6 +26,10 @@
#include <linux/ptrace.h>
#include <asm-generic/xenomai/syscall.h>
/*
* Cobalt and Linux syscall numbers can be fetched from GPR0, masking
* out the __COBALT_SYSCALL_BIT marker.
*/
#define __xn_reg_sys(__regs) ((__regs)->gpr[0])
#define __xn_syscall_p(__regs) (__xn_reg_sys(__regs) & __COBALT_SYSCALL_BIT)
#define __xn_syscall(__regs) (__xn_reg_sys(__regs) & ~__COBALT_SYSCALL_BIT)
......@@ -40,14 +44,14 @@
#define __xn_reg_sp(__regs) ((__regs)->gpr[1])
/*
* Returns the syscall number depending on the handling core. Cobalt
* and Linux syscall numbers can be fetched from GPR0, masking out the
* __COBALT_SYSCALL_BIT marker.
* Root syscall number with predicate (valid only if
* !__xn_syscall_p(__regs)).
*/
static inline long __xn_get_syscall_nr(struct pt_regs *regs)
{
return __xn_syscall(regs);
}
#define __xn_rootcall_p(__regs, __code) \
({ \
*(__code) = __xn_syscall(__regs); \
*(__code) < NR_syscalls; \
})
static inline void __xn_error_return(struct pt_regs *regs, int v)
{
......
......@@ -23,6 +23,12 @@
#include <asm/ptrace.h>
#include <asm-generic/xenomai/syscall.h>
/*
* Cobalt and Linux syscall numbers can be fetched from ORIG_AX,
* masking out the __COBALT_SYSCALL_BIT marker. Make sure to offset
* the number by __COBALT_X32_BASE for Cobalt 32-bit compat syscalls
* only.
*/
#define __xn_reg_sys(regs) ((regs)->orig_ax)
#define __xn_reg_rval(regs) ((regs)->ax)
#ifdef __i386__
......@@ -50,15 +56,13 @@
#endif
/*
* Returns the syscall number depending on the handling core. Cobalt
* and Linux syscall numbers can be fetched from ORIG_AX, masking out
* the __COBALT_SYSCALL_BIT marker. Make sure to offset the number by
* __COBALT_X32_BASE for Cobalt 32-bit compat syscalls only.
* Root syscall number with predicate (valid only if
* !__xn_syscall_p(__regs)).
*/
#define __xn_get_syscall_nr(__regs) \
({ \
__xn_syscall_p(__regs) ? __xn_syscall(__regs) : \
(__xn_reg_sys(__regs) & ~__COBALT_SYSCALL_BIT); \
#define __xn_rootcall_p(__regs, __code) \
({ \
*(__code) = __xn_reg_sys(__regs); \
*(__code) < NR_syscalls; \
})
static inline void __xn_error_return(struct pt_regs *regs, int v)
......
......@@ -666,10 +666,6 @@ ret_handled:
return KEVENT_STOP;
linux_syscall:
code = __xn_get_syscall_nr(regs);
if (code >= NR_syscalls)
goto bad_syscall;
if (xnsched_root_p())
/*
* The call originates from the Linux domain, either
......@@ -679,6 +675,9 @@ linux_syscall:
*/
return KEVENT_PROPAGATE;
if (!__xn_rootcall_p(regs, &code))
goto bad_syscall;
/*
* We know this is a Cobalt thread since it runs over the head
* domain, however the current syscall should be handled by
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment