[PATCH] sh: Implemented syscall_{get|set}_arguments for i != 0.

From: Konstantin Tokarev
Date: Mon Apr 14 2014 - 12:38:00 EST


syscall_get_arguments and syscall_set_arguments implementations for SH
will not call BUG() when invokend with i != 0 anymore.

Signed-off-by: Konstantin Tokarev <ktokarev@xxxxxxxxxxxx>
---
arch/sh/include/asm/syscall_32.h | 74
+++++++++++++++++++++-----------------
1 files changed, 41 insertions(+), 33 deletions(-)

diff --git a/arch/sh/include/asm/syscall_32.h
b/arch/sh/include/asm/syscall_32.h
index 7d80df4..52fb5ad 100755
--- a/arch/sh/include/asm/syscall_32.h
+++ b/arch/sh/include/asm/syscall_32.h
@@ -44,53 +44,61 @@ static inline void syscall_set_return_value(struct
task_struct *task,
regs->regs[0] = val;
}

-static inline void syscall_get_arguments(struct task_struct *task,
- struct pt_regs *regs,
- unsigned int i, unsigned int n,
- unsigned long *args)
+static inline unsigned long sh_get_syscall_arg(struct pt_regs *regs,
+ unsigned int n)
{
- /*
- * Do this simply for now. If we need to start supporting
- * fetching arguments from arbitrary indices, this will need some
- * extra logic. Presently there are no in-tree users that depend
- * on this behaviour.
- */
- BUG_ON(i);
-
/* Argument pattern is: R4, R5, R6, R7, R0, R1 */
switch (n) {
- case 6: args[5] = regs->regs[1];
- case 5: args[4] = regs->regs[0];
- case 4: args[3] = regs->regs[7];
- case 3: args[2] = regs->regs[6];
- case 2: args[1] = regs->regs[5];
- case 1: args[0] = regs->regs[4];
+ case 5: return regs->regs[1];
+ case 4: return regs->regs[0];
+ case 3: return regs->regs[7];
+ case 2: return regs->regs[6];
+ case 1: return regs->regs[5];
+ case 0: return regs->regs[4];
+ default:
+ BUG();
+ }
+ return ~0;
+}
+
+static inline void sh_set_syscall_arg(struct pt_regs *regs,
+ unsigned int n,
+ unsigned long val)
+{
+ switch (n) {
+ case 5:
+ regs->regs[1] = val;
+ case 4:
+ regs->regs[0] = val;
+ case 3:
+ regs->regs[7] = val;
+ case 2:
+ regs->regs[6] = val;
+ case 1:
+ regs->regs[5] = val;
case 0:
- break;
+ regs->regs[4] = val;
default:
BUG();
}
}

+static inline void syscall_get_arguments(struct task_struct *task,
+ struct pt_regs *regs,
+ unsigned int i, unsigned int n,
+ unsigned long *args)
+{
+ while (n--)
+ *args++ = sh_get_syscall_arg(regs, i++);
+}
+
static inline void syscall_set_arguments(struct task_struct *task,
struct pt_regs *regs,
unsigned int i, unsigned int n,
const unsigned long *args)
{
- /* Same note as above applies */
- BUG_ON(i);
-
- switch (n) {
- case 6: regs->regs[1] = args[5];
- case 5: regs->regs[0] = args[4];
- case 4: regs->regs[7] = args[3];
- case 3: regs->regs[6] = args[2];
- case 2: regs->regs[5] = args[1];
- case 1: regs->regs[4] = args[0];
- break;
- default:
- BUG();
- }
+ while (n--)
+ sh_set_syscall_arg(regs, i++, *args++);
}

#endif /* __ASM_SH_SYSCALL_32_H */
--
1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/