From: Jeff Dike <jdike@addtoit.com>
To: Andrew Morton <akpm@osdl.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
uml-devel <user-mode-linux-devel@lists.sourceforge.net>
Subject: [PATCH 2/4] UML - use ptrace directly in libc code
Date: Tue, 20 Nov 2007 13:26:32 -0500 [thread overview]
Message-ID: <20071120182632.GA7689@c2.user-mode-linux.org> (raw)
Some register accessor cleanups -
userspace() was calling restore_registers and save_registers for no
reason, since userspace() is on the libc side of the house, and these
add no value over calling ptrace directly
init_thread_registers and get_safe_registers were the same thing,
so init_thread_registers is gone
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
---
arch/um/include/registers.h | 1 -
arch/um/kernel/process.c | 2 +-
arch/um/os-Linux/registers.c | 13 ++++---------
arch/um/os-Linux/skas/process.c | 9 +++++++--
4 files changed, 12 insertions(+), 13 deletions(-)
Index: linux-2.6.22/arch/um/os-Linux/skas/process.c
===================================================================
--- linux-2.6.22.orig/arch/um/os-Linux/skas/process.c 2007-11-20 13:05:22.000000000 -0500
+++ linux-2.6.22/arch/um/os-Linux/skas/process.c 2007-11-20 13:05:45.000000000 -0500
@@ -298,7 +298,9 @@ void userspace(struct uml_pt_regs *regs)
nsecs += os_nsecs();
while (1) {
- restore_registers(pid, regs);
+ if (ptrace(PTRACE_SETREGS, pid, 0, regs->gp))
+ panic("userspace - PTRACE_SETREGS failed, "
+ "errno = %d\n", errno);
/* Now we set local_using_sysemu to be used for one loop */
local_using_sysemu = get_using_sysemu();
@@ -318,7 +320,10 @@ void userspace(struct uml_pt_regs *regs)
errno);
regs->is_user = 1;
- save_registers(pid, regs);
+ if (ptrace(PTRACE_GETREGS, pid, 0, regs->gp))
+ panic("userspace - saving registers failed, "
+ "errno = %d\n", errno);
+
UPT_SYSCALL_NR(regs) = -1; /* Assume: It's not a syscall */
if (WIFSTOPPED(status)) {
@@ -341,7 +346,7 @@ void userspace(struct uml_pt_regs *regs)
break;
case SIGVTALRM:
now = os_nsecs();
- if(now < nsecs)
+ if (now < nsecs)
break;
block_signals();
(*sig_info[sig])(sig, regs);
Index: linux-2.6.22/arch/um/kernel/process.c
===================================================================
--- linux-2.6.22.orig/arch/um/kernel/process.c 2007-11-20 13:05:20.000000000 -0500
+++ linux-2.6.22/arch/um/kernel/process.c 2007-11-20 13:05:24.000000000 -0500
@@ -200,7 +200,7 @@ int copy_thread(int nr, unsigned long cl
arch_copy_thread(¤t->thread.arch, &p->thread.arch);
}
else {
- init_thread_registers(&p->thread.regs.regs);
+ get_safe_registers(p->thread.regs.regs.gp);
p->thread.request.u.thread = current->thread.request.u.thread;
handler = new_thread_handler;
}
Index: linux-2.6.22/arch/um/os-Linux/registers.c
===================================================================
--- linux-2.6.22.orig/arch/um/os-Linux/registers.c 2007-11-20 13:05:20.000000000 -0500
+++ linux-2.6.22/arch/um/os-Linux/registers.c 2007-11-20 13:05:24.000000000 -0500
@@ -10,15 +10,6 @@
#include "sysdep/ptrace.h"
#include "user.h"
-/* This is set once at boot time and not changed thereafter */
-
-static unsigned long exec_regs[MAX_REG_NR];
-
-void init_thread_registers(struct uml_pt_regs *to)
-{
- memcpy(to->gp, exec_regs, sizeof(to->gp));
-}
-
void save_registers(int pid, struct uml_pt_regs *regs)
{
int err;
@@ -39,6 +30,10 @@ void restore_registers(int pid, struct u
"errno = %d\n", errno);
}
+/* This is set once at boot time and not changed thereafter */
+
+static unsigned long exec_regs[MAX_REG_NR];
+
void init_registers(int pid)
{
int err;
Index: linux-2.6.22/arch/um/include/registers.h
===================================================================
--- linux-2.6.22.orig/arch/um/include/registers.h 2007-11-20 13:05:20.000000000 -0500
+++ linux-2.6.22/arch/um/include/registers.h 2007-11-20 13:05:24.000000000 -0500
@@ -9,7 +9,6 @@
#include "sysdep/ptrace.h"
#include "sysdep/archsetjmp.h"
-extern void init_thread_registers(struct uml_pt_regs *to);
extern int save_fp_registers(int pid, unsigned long *fp_regs);
extern int restore_fp_registers(int pid, unsigned long *fp_regs);
extern int save_fpx_registers(int pid, unsigned long *fp_regs);
reply other threads:[~2007-11-20 18:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20071120182632.GA7689@c2.user-mode-linux.org \
--to=jdike@addtoit.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=user-mode-linux-devel@lists.sourceforge.net \
/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