From: Roland McGrath <roland@redhat.com>
To: Russell King <rmk@arm.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>, linux-kernel@vger.kernel.org
Subject: [PATCH 16/17] arm: asm/syscall.h (unfinished)
Date: Fri, 24 Apr 2009 17:15:03 -0700 (PDT) [thread overview]
Message-ID: <20090425001503.85473FC3C8@magilla.sf.frob.com> (raw)
In-Reply-To: Roland McGrath's message of Friday, 24 April 2009 17:06:34 -0700 <20090425000634.313E4FC3C8@magilla.sf.frob.com>
This provides the user_stack_pointer() macro in asm/ptrace.h,
which some new arch-independent code wants to be able to use.
It also adds the asm/syscall.h header to let arch-independent
code interpret the registers as system call arguments or return.
The syscall_get_nr() function here is not really right. I don't
know enough about ARM to finish it correctly. It needs to figure
out if the blocked user task is really in the kernel for a system
call and return -1 if not. I also did not try to handle all the
different ABI variants, which I don't really understand.
Until this is fixed, /proc/pid/syscall can show bogus results
for a process that is blocked inside a fault or something else
that's not a system call. (It's probably all wrong for !AEABI too.)
Signed-off-by: Roland McGrath <roland@redhat.com>
---
arch/arm/include/asm/ptrace.h | 4 +-
arch/arm/include/asm/syscall.h | 65 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 67 insertions(+), 2 deletions(-)
create mode 100644 arch/arm/include/asm/syscall.h
diff --git a/arch/arm/include/asm/ptrace.h b/arch/arm/include/asm/ptrace.h
index 236a06b..34075dc 100644
--- a/arch/arm/include/asm/ptrace.h
+++ b/arch/arm/include/asm/ptrace.h
@@ -140,7 +140,8 @@ static inline int valid_user_regs(struct pt_regs *regs)
return 0;
}
-#define instruction_pointer(regs) (regs)->ARM_pc
+#define instruction_pointer(regs) ((regs)->ARM_pc)
+#define user_stack_pointer(regs) ((regs)->ARM_sp)
#ifdef CONFIG_SMP
extern unsigned long profile_pc(struct pt_regs *regs);
@@ -156,4 +157,3 @@ extern unsigned long profile_pc(struct pt_regs *regs);
#endif /* __ASSEMBLY__ */
#endif
-
diff --git a/arch/arm/include/asm/syscall.h b/arch/arm/include/asm/syscall.h
new file mode 100644
index 0000000..56aefe6
--- /dev/null
+++ b/arch/arm/include/asm/syscall.h
@@ -0,0 +1,65 @@
+/*
+ * Access to user system call parameters and results
+ *
+ * See asm-generic/syscall.h for descriptions of what we must do here.
+ */
+
+#ifndef _ASM_SYSCALL_H
+#define _ASM_SYSCALL_H 1
+
+#include <linux/sched.h>
+#include <linux/err.h>
+
+static inline long syscall_get_nr(struct task_struct *task,
+ struct pt_regs *regs)
+{
+ /* XXX how to figure out if blocked in a syscall or not?? */
+
+ return regs->ARM_r7; /* XXX apparently */
+ return task_thread_info(task)->syscall; /* XXX if changed via ptrace */
+}
+
+static inline void syscall_rollback(struct task_struct *task,
+ struct pt_regs *regs)
+{
+ regs->ARM_r0 = regs->ARM_ORIG_r0;
+}
+
+static inline long syscall_get_error(struct task_struct *task,
+ struct pt_regs *regs)
+{
+ return IS_ERR_VALUE(regs->ARM_r0) ? regs->ARM_r0 : 0;
+}
+
+static inline long syscall_get_return_value(struct task_struct *task,
+ struct pt_regs *regs)
+{
+ return regs->ARM_r0;
+}
+
+static inline void syscall_set_return_value(struct task_struct *task,
+ struct pt_regs *regs,
+ int error, long val)
+{
+ regs->ARM_r0 = (long) error ?: val;
+}
+
+static inline void syscall_get_arguments(struct task_struct *task,
+ struct pt_regs *regs,
+ unsigned int i, unsigned int n,
+ unsigned long *args)
+{
+ BUG_ON(i + n > 6);
+ memcpy(args, ®s->uregs[i], n * sizeof(args[0]));
+}
+
+static inline void syscall_set_arguments(struct task_struct *task,
+ struct pt_regs *regs,
+ unsigned int i, unsigned int n,
+ const unsigned long *args)
+{
+ BUG_ON(i + n > 6);
+ memcpy(®s->uregs[i], args, n * sizeof(args[0]));
+}
+
+#endif /* _ASM_SYSCALL_H */
next prev parent reply other threads:[~2009-04-25 0:16 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-25 0:06 [PATCH 0/17] tracehook & user_regset for ARM Roland McGrath
2009-04-25 0:07 ` [PATCH 01/17] arm: arch_ptrace clean-up Roland McGrath
2009-06-19 9:13 ` Russell King
2009-06-24 6:55 ` Roland McGrath
2009-04-25 0:08 ` [PATCH 02/17] arm: arch_ptrace indentation Roland McGrath
2009-04-25 0:08 ` [PATCH 03/17] arm: tracehook_report_syscall Roland McGrath
2009-04-25 0:09 ` [PATCH 04/17] arm: tracehook_signal_handler Roland McGrath
2009-04-25 0:09 ` [PATCH 05/17] arm: TIF_NOTIFY_RESUME Roland McGrath
2009-04-25 0:10 ` [PATCH 06/17] arm: user_regset: general regs Roland McGrath
2009-04-25 0:10 ` [PATCH 07/17] arm: user_regset: FPU regs Roland McGrath
2009-04-25 0:11 ` [PATCH 08/17] arm: CORE_DUMP_USE_REGSET Roland McGrath
2009-04-25 0:11 ` [PATCH 09/17] arm: user_regset: VFP regs Roland McGrath
2009-04-25 0:12 ` [PATCH 10/17] arm: user_regset: VFP in core dumps Roland McGrath
2009-04-25 0:12 ` [PATCH 11/17] arm: user_regset: iWMMXt regs Roland McGrath
2009-04-25 0:12 ` [PATCH 12/17] arm: user_regset: iWMMXt in core dumps Roland McGrath
2009-04-27 22:43 ` Paul Mundt
2009-04-28 2:53 ` Roland McGrath
2009-04-25 0:13 ` [PATCH 13/17] arm: user_regset: Crunch regs Roland McGrath
2009-04-25 0:13 ` [PATCH 14/17] arm: user_regset: Crunch in core dumps Roland McGrath
2009-04-25 0:14 ` [PATCH 15/17] arm: user_regset: thread pointer " Roland McGrath
2009-04-25 0:15 ` Roland McGrath [this message]
2009-06-19 9:31 ` [PATCH 16/17] arm: asm/syscall.h (unfinished) Russell King
2009-06-24 8:56 ` Roland McGrath
2009-04-25 0:15 ` [PATCH 17/17] arm: HAVE_ARCH_TRACEHOOK Roland McGrath
2009-06-06 14:42 ` [PATCH 0/17] tracehook & user_regset for ARM Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090425001503.85473FC3C8@magilla.sf.frob.com \
--to=roland@redhat.com \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=rmk@arm.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®