From: Renzo Davoli <renzo@cs.unibo.it>
To: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 1/2] ptrace_vm: ptrace for syscall emulation virtual machines
Date: Wed, 4 Feb 2009 09:02:48 +0100 [thread overview]
Message-ID: <20090204080248.GB17452@cs.unibo.it> (raw)
This patch adds the new PTRACE_VM_SKIPCALL and PTRACE_VM_SKIPEXIT
tags for ptrace's addr parameter.
In this way it is possible to (eventually) get rid of PTRACE_SYSEMU
PTRACE_SYSEMU_SINGLESTEP, while providing not only the same features
but a more general support for Virtual Machines.
Part#1: tracehook based architecture independent support
renzo
Signed-off-by: Renzo Davoli <renzo@cs.unibo.it>
---
diff -Naur linux-2.6.28.2/include/linux/ptrace.h linux-2.6.28.2-vm/include/linux/ptrace.h
--- linux-2.6.28.2/include/linux/ptrace.h 2009-01-25 01:42:07.000000000 +0100
+++ linux-2.6.28.2-vm/include/linux/ptrace.h 2009-02-02 14:31:42.000000000 +0100
@@ -46,6 +46,11 @@
#define PTRACE_EVENT_VFORK_DONE 5
#define PTRACE_EVENT_EXIT 6
+/* options for new PTRACE_SYSCALL syntax*/
+#define PTRACE_SYSCALL_SKIPEXIT 0x2
+#define PTRACE_SYSCALL_SKIPCALL 0x6
+#define PTRACE_SYSCALL_MASK 0x00000006
+
#include <asm/ptrace.h>
#ifdef __KERNEL__
@@ -68,6 +73,10 @@
#define PT_TRACE_VFORK_DONE 0x00000100
#define PT_TRACE_EXIT 0x00000200
+#define PT_SYSCALL_SKIPEXIT 0x60000000
+#define PT_SYSCALL_SKIPCALL 0x40000000
+#define PT_SYSCALL_MASK 0x60000000
+
#define PT_TRACE_MASK 0x000003f4
/* single stepping state bits (used on ARM and PA-RISC) */
diff -Naur linux-2.6.28.2/include/linux/tracehook.h linux-2.6.28.2-vm/include/linux/tracehook.h
--- linux-2.6.28.2/include/linux/tracehook.h 2009-01-25 01:42:07.000000000 +0100
+++ linux-2.6.28.2-vm/include/linux/tracehook.h 2009-02-02 14:45:13.000000000 +0100
@@ -112,7 +112,7 @@
struct pt_regs *regs)
{
ptrace_report_syscall(regs);
- return 0;
+ return (task_ptrace(current) & PT_SYSCALL_SKIPCALL)?1:0;
}
/**
@@ -134,7 +134,8 @@
*/
static inline void tracehook_report_syscall_exit(struct pt_regs *regs, int step)
{
- ptrace_report_syscall(regs);
+ if (!(task_ptrace(current) & PT_SYSCALL_SKIPEXIT))
+ ptrace_report_syscall(regs);
}
/**
diff -Naur linux-2.6.28.2/kernel/ptrace.c linux-2.6.28.2-vm/kernel/ptrace.c
--- linux-2.6.28.2/kernel/ptrace.c 2009-01-25 01:42:07.000000000 +0100
+++ linux-2.6.28.2-vm/kernel/ptrace.c 2009-02-02 14:31:43.000000000 +0100
@@ -367,7 +367,7 @@
#define is_sysemu_singlestep(request) 0
#endif
-static int ptrace_resume(struct task_struct *child, long request, long data)
+static int ptrace_resume(struct task_struct *child, long request, long addr, long data)
{
if (!valid_signal(data))
return -EIO;
@@ -396,6 +396,9 @@
else
user_disable_single_step(child);
+ child->ptrace &= ~PT_SYSCALL_MASK;
+ child->ptrace |= (addr & PTRACE_SYSCALL_MASK) << 28;
+
child->exit_code = data;
wake_up_process(child);
@@ -457,12 +460,12 @@
#endif
case PTRACE_SYSCALL:
case PTRACE_CONT:
- return ptrace_resume(child, request, data);
+ return ptrace_resume(child, request, addr, data);
case PTRACE_KILL:
if (child->exit_state) /* already dead */
return 0;
- return ptrace_resume(child, request, SIGKILL);
+ return ptrace_resume(child, request, addr, SIGKILL);
default:
break;
next reply other threads:[~2009-02-04 8:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-04 8:02 Renzo Davoli [this message]
2009-03-10 21:44 ` Renzo Davoli
2009-03-11 13:41 ` Renzo Davoli
2009-03-16 7:51 ` Américo Wang
2009-03-24 23:19 ` Renzo Davoli
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=20090204080248.GB17452@cs.unibo.it \
--to=renzo@cs.unibo.it \
--cc=linux-kernel@vger.kernel.org \
/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®