[uml-devel] [PATCH 1/8] UML - Compilation warning removal
With gcc 4.1.0, I get a bunch of warnings about consts being lost in the
copy_user code. This patch fixes them by adding consts where necessary.
Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
Index: linux-2.6.15/arch/um/include/skas/uaccess-skas.h
===
--- linux-2.6.15.orig/arch/um/include/skas/uaccess-skas.h 2006-02-06
17:33:55.0 -0500
+++ linux-2.6.15/arch/um/include/skas/uaccess-skas.h2006-02-06
17:34:21.0 -0500
@@ -11,8 +11,8 @@
/* No SKAS-specific checking. */
#define access_ok_skas(type, addr, size) 0
-extern int copy_from_user_skas(void *to, const void __user *from, int n);
-extern int copy_to_user_skas(void __user *to, const void *from, int n);
+extern int copy_from_user_skas(const void *to, const void __user *from, int n);
+extern int copy_to_user_skas(const void __user *to, const void *from, int n);
extern int strncpy_from_user_skas(char *dst, const char __user *src, int
count);
extern int __clear_user_skas(void __user *mem, int len);
extern int clear_user_skas(void __user *mem, int len);
Index: linux-2.6.15/arch/um/include/tt/uaccess-tt.h
===
--- linux-2.6.15.orig/arch/um/include/tt/uaccess-tt.h 2006-02-06
17:33:55.0 -0500
+++ linux-2.6.15/arch/um/include/tt/uaccess-tt.h2006-02-06
17:34:21.0 -0500
@@ -38,8 +38,8 @@ extern int __do_clear_user(void *mem, si
extern int __do_strnlen_user(const char *str, unsigned long n,
void **fault_addr, void **fault_catcher);
-extern int copy_from_user_tt(void *to, const void __user *from, int n);
-extern int copy_to_user_tt(void __user *to, const void *from, int n);
+extern int copy_from_user_tt(const void *to, const void __user *from, int n);
+extern int copy_to_user_tt(const void __user *to, const void *from, int n);
extern int strncpy_from_user_tt(char *dst, const char __user *src, int count);
extern int __clear_user_tt(void __user *mem, int len);
extern int clear_user_tt(void __user *mem, int len);
Index: linux-2.6.15/arch/um/include/um_uaccess.h
===
--- linux-2.6.15.orig/arch/um/include/um_uaccess.h 2006-01-03
17:39:46.0 -0500
+++ linux-2.6.15/arch/um/include/um_uaccess.h 2006-02-06 17:34:24.0
-0500
@@ -39,13 +39,13 @@
segment_eq(get_fs(), KERNEL_DS) || \
CHOOSE_MODE_PROC(access_ok_tt, access_ok_skas, type, addr, size)))
-static inline int copy_from_user(void *to, const void __user *from, int n)
+static inline int copy_from_user(const void *to, const void __user *from, int
n)
{
return(CHOOSE_MODE_PROC(copy_from_user_tt, copy_from_user_skas, to,
from, n));
}
-static inline int copy_to_user(void __user *to, const void *from, int n)
+static inline int copy_to_user(const void __user *to, const void *from, int n)
{
return(CHOOSE_MODE_PROC(copy_to_user_tt, copy_to_user_skas, to,
from, n));
Index: linux-2.6.15/arch/um/kernel/skas/uaccess.c
===
--- linux-2.6.15.orig/arch/um/kernel/skas/uaccess.c 2006-02-06
17:33:55.0 -0500
+++ linux-2.6.15/arch/um/kernel/skas/uaccess.c 2006-02-06 17:34:24.0
-0500
@@ -136,10 +136,10 @@ static int copy_chunk_from_user(unsigned
return(0);
}
-int copy_from_user_skas(void *to, const void __user *from, int n)
+int copy_from_user_skas(const void *to, const void __user *from, int n)
{
if(segment_eq(get_fs(), KERNEL_DS)){
- memcpy(to, (__force void*)from, n);
+ memcpy((void *) to, (__force void*)from, n);
return(0);
}
@@ -157,7 +157,7 @@ static int copy_chunk_to_user(unsigned l
return(0);
}
-int copy_to_user_skas(void __user *to, const void *from, int n)
+int copy_to_user_skas(const void __user *to, const void *from, int n)
{
if(segment_eq(get_fs(), KERNEL_DS)){
memcpy((__force void*)to, from, n);
Index: linux-2.6.15/arch/um/kernel/tt/uaccess.c
===
--- linux-2.6.15.orig/arch/um/kernel/tt/uaccess.c 2006-01-03
17:39:46.0 -0500
+++ linux-2.6.15/arch/um/kernel/tt/uaccess.c2006-02-06 17:34:24.0
-0500
@@ -6,7 +6,7 @@
#include "linux/sched.h"
#include "asm/uaccess.h"
-int copy_from_user_tt(void *to, const void __user *from, int n)
+int copy_from_user_tt(const void *to, const void __user *from, int n)
{
if(!access_ok(VERIFY_READ, from, n))
return(n);
@@ -15,7 +15,7 @@ int copy_from_user_tt(void *to, const vo
¤t->thread.fault_catcher));
}
-int copy_to_user_tt(void __user *to, const void *from, int n)
+int copy_to_user_tt(const void __user *to, const void *from, int n)
{
if(!
[uml-devel] [PATCH 0/8] UML - Eight patches for 2.6.16
The upcoming patch series fixes bugs, compilation failures, and warnings, and removes a dead file. Jeff --- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642 ___ User-mode-linux-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
[uml-devel] [PATCH 2/8] UML - Define jmpbuf access constants
With newer libcs, the JB_* macros (which we shouldn't be using anyway,
probably) go away. This patch defines them if setjmp.h doesn't. It'd
be nice to have a real way to do this, as sysrq-t requires a way to
get registers from out-of-context threads, which we store in jmpbufs.
Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
Index: linux-2.6.15/arch/um/os-Linux/sys-i386/registers.c
===
--- linux-2.6.15.orig/arch/um/os-Linux/sys-i386/registers.c 2005-10-28
12:58:12.0 -0400
+++ linux-2.6.15/arch/um/os-Linux/sys-i386/registers.c 2006-02-06
17:34:36.0 -0500
@@ -127,6 +127,12 @@ void get_safe_registers(unsigned long *r
memcpy(regs, exec_regs, HOST_FRAME_SIZE * sizeof(unsigned long));
}
+#ifndef JB_PC
+#define JB_PC 5
+#define JB_SP 4
+#define JB_BP 3
+#endif
+
void get_thread_regs(union uml_pt_regs *uml_regs, void *buffer)
{
struct __jmp_buf_tag *jmpbuf = buffer;
Index: linux-2.6.15/arch/um/os-Linux/sys-x86_64/registers.c
===
--- linux-2.6.15.orig/arch/um/os-Linux/sys-x86_64/registers.c 2005-10-28
12:58:12.0 -0400
+++ linux-2.6.15/arch/um/os-Linux/sys-x86_64/registers.c2006-02-06
17:34:36.0 -0500
@@ -75,6 +75,12 @@ void get_safe_registers(unsigned long *r
memcpy(regs, exec_regs, HOST_FRAME_SIZE * sizeof(unsigned long));
}
+#ifndef JB_PC
+#define JB_PC 7
+#define JB_RSP 6
+#define JB_RBP 1
+#endif
+
void get_thread_regs(union uml_pt_regs *uml_regs, void *buffer)
{
struct __jmp_buf_tag *jmpbuf = buffer;
---
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
___
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
[uml-devel] [PATCH 4/8] UML - Close TUN/TAP file descriptors
When UML opens a TUN/TAP device, the file descriptor could be copied into
later, long-lived threads, holding the device open even after the interface
is taken down, preventing it from being brought up again. This patch makes
these descriptors close-on-exec so that they disappear from helper processes,
and adds CLONE_FILES to a UML helper thread so that the descriptors are closed
in the thread when they are closed elsewhere in UML.
Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
Index: linux-2.6.15/arch/um/drivers/chan_user.c
===
--- linux-2.6.15.orig/arch/um/drivers/chan_user.c 2006-01-03
17:39:46.0 -0500
+++ linux-2.6.15/arch/um/drivers/chan_user.c2006-02-06 17:35:47.0
-0500
@@ -9,6 +9,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -73,7 +74,6 @@ static void winch_handler(int sig)
struct winch_data {
int pty_fd;
int pipe_fd;
- int close_me;
};
static int winch_thread(void *arg)
@@ -84,7 +84,6 @@ static int winch_thread(void *arg)
int count, err;
char c = 1;
- os_close_file(data->close_me);
pty_fd = data->pty_fd;
pipe_fd = data->pipe_fd;
count = os_write_file(pipe_fd, &c, sizeof(c));
@@ -153,15 +152,16 @@ static int winch_tramp(int fd, struct tt
}
data = ((struct winch_data) { .pty_fd = fd,
- .pipe_fd = fds[1],
- .close_me = fds[0] } );
- err = run_helper_thread(winch_thread, &data, 0, &stack, 0);
+ .pipe_fd = fds[1] } );
+ /* CLONE_FILES so this thread doesn't hold open files which are open
+* now, but later closed. This is a problem with /dev/net/tun.
+*/
+ err = run_helper_thread(winch_thread, &data, CLONE_FILES, &stack, 0);
if(err < 0){
printk("fork of winch_thread failed - errno = %d\n", errno);
goto out_close;
}
- os_close_file(fds[1]);
*fd_out = fds[0];
n = os_read_file(fds[0], &c, sizeof(c));
if(n != sizeof(c)){
@@ -169,13 +169,12 @@ static int winch_tramp(int fd, struct tt
printk("read failed, err = %d\n", -n);
printk("fd %d will not support SIGWINCH\n", fd);
err = -EINVAL;
- goto out_close1;
+ goto out_close;
}
return err ;
out_close:
os_close_file(fds[1]);
- out_close1:
os_close_file(fds[0]);
out:
return err;
Index: linux-2.6.15/arch/um/os-Linux/drivers/tuntap_user.c
===
--- linux-2.6.15.orig/arch/um/os-Linux/drivers/tuntap_user.c2006-01-03
17:39:46.0 -0500
+++ linux-2.6.15/arch/um/os-Linux/drivers/tuntap_user.c 2006-02-06
17:35:47.0 -0500
@@ -122,6 +122,7 @@ static int tuntap_open_tramp(char *gate,
return(-EINVAL);
}
*fd_out = ((int *) CMSG_DATA(cmsg))[0];
+ os_set_exec_close(*fd_out, 1);
return(0);
}
@@ -137,7 +138,8 @@ static int tuntap_open(void *data)
return(err);
if(pri->fixed_config){
- pri->fd = os_open_file("/dev/net/tun", of_rdwr(OPENFLAGS()), 0);
+ pri->fd = os_open_file("/dev/net/tun",
+ of_cloexec(of_rdwr(OPENFLAGS())), 0);
if(pri->fd < 0){
printk("Failed to open /dev/net/tun, err = %d\n",
-pri->fd);
---
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
___
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
[uml-devel] [PATCH 5/8] UML - Balance list_add and list_del in the network driver
The network driver added an interface to the "opened" list when it was
configured, not when it was brought up, and removed it when it was taken
down. A sequence of ifconfig up, ifconfig down, ... caused it to be removed
multiple times from the list without being added in between, resulting in
a crash. This patch moves the add to when the interface is brought up.
Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
Index: linux-2.6.15/arch/um/drivers/net_kern.c
===
--- linux-2.6.15.orig/arch/um/drivers/net_kern.c2006-02-06
17:33:55.0 -0500
+++ linux-2.6.15/arch/um/drivers/net_kern.c 2006-02-06 17:35:58.0
-0500
@@ -131,9 +131,8 @@ static int uml_net_open(struct net_devic
SA_INTERRUPT | SA_SHIRQ, dev->name, dev);
if(err != 0){
printk(KERN_ERR "uml_net_open: failed to get irq(%d)\n", err);
- if(lp->close != NULL) (*lp->close)(lp->fd, &lp->user);
- lp->fd = -1;
err = -ENETUNREACH;
+ goto out_close;
}
lp->tl.data = (unsigned long) &lp->user;
@@ -145,9 +144,19 @@ static int uml_net_open(struct net_devic
*/
while((err = uml_net_rx(dev)) > 0) ;
- out:
spin_unlock(&lp->lock);
- return(err);
+
+ spin_lock(&opened_lock);
+ list_add(&lp->list, &opened);
+ spin_unlock(&opened_lock);
+
+ return 0;
+out_close:
+ if(lp->close != NULL) (*lp->close)(lp->fd, &lp->user);
+ lp->fd = -1;
+out:
+ spin_unlock(&lp->lock);
+ return err;
}
static int uml_net_close(struct net_device *dev)
@@ -161,9 +170,13 @@ static int uml_net_close(struct net_devi
if(lp->close != NULL)
(*lp->close)(lp->fd, &lp->user);
lp->fd = -1;
- list_del(&lp->list);
spin_unlock(&lp->lock);
+
+ spin_lock(&opened_lock);
+ list_del(&lp->list);
+ spin_unlock(&opened_lock);
+
return 0;
}
@@ -410,11 +423,7 @@ static int eth_configure(int n, void *in
if (device->have_mac)
set_ether_mac(dev, device->mac);
- spin_lock(&opened_lock);
- list_add(&lp->list, &opened);
- spin_unlock(&opened_lock);
-
- return(0);
+ return 0;
}
static struct uml_net *find_device(int n)
---
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
___
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
[uml-devel] [PATCH 3/8] UML - Add debug switch for skas mode
It doesn't do anything but emit a warning, but there's a user population
that's used to adding 'debug' to the UML command line in order to gdb it.
With skas0 mode, that's not necessary, but these users need some indication
that 'debug' doesn't do what they want.
Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
Index: linux-2.6.15/arch/um/kernel/um_arch.c
===
--- linux-2.6.15.orig/arch/um/kernel/um_arch.c 2006-02-06 17:33:55.0
-0500
+++ linux-2.6.15/arch/um/kernel/um_arch.c 2006-02-06 17:35:35.0
-0500
@@ -193,6 +193,24 @@ __uml_setup("root=", uml_root_setup,
"root=/dev/ubd5\n\n"
);
+#ifndef CONFIG_MODE_TT
+
+static int __init no_skas_debug_setup(char *line, int *add)
+{
+ printf("'debug' is not necessary to gdb UML in skas mode - run \n");
+ printf("'gdb linux' and disable CONFIG_CMDLINE_ON_HOST if gdb \n");
+ printf("doesn't work as expected\n");
+
+ return 0;
+}
+
+__uml_setup("debug", no_skas_debug_setup,
+"debug\n"
+"this flag is not needed to run gdb on UML in skas mode\n\n"
+);
+
+#endif
+
#ifdef CONFIG_SMP
static int __init uml_ncpus_setup(char *line, int *add)
{
---
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
___
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
[uml-devel] [PATCH 6/8] UML - Block SIGWINCH in ptrace tester child
The process that UML uses to probe the host's ptrace capabilities can (rarely)
receive a SIGWINCH, confusing the parent. This fixes that by blocking
SIGWINCH.
Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
Index: linux-2.6.15/arch/um/os-Linux/start_up.c
===
--- linux-2.6.15.orig/arch/um/os-Linux/start_up.c 2006-02-06
17:33:55.0 -0500
+++ linux-2.6.15/arch/um/os-Linux/start_up.c2006-02-06 17:36:29.0
-0500
@@ -49,6 +49,7 @@ static int ptrace_child(void *arg)
int pid = os_getpid(), ppid = getppid();
int sc_result;
+ change_sig(SIGWINCH, 0);
if(ptrace(PTRACE_TRACEME, 0, 0, 0) < 0){
perror("ptrace");
os_kill_process(pid, 0);
---
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
___
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
[uml-devel] [PATCH 7/8] UML - Initialize process FP registers properly
We weren't making sure that we initialized the FP registers of new processes
to sane values.
This patch also moves some defines in the affected area closer to where they
are used.
Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
Index: linux-2.6.15/arch/um/sys-x86_64/ptrace_user.c
===
--- linux-2.6.15.orig/arch/um/sys-x86_64/ptrace_user.c 2005-08-28
19:41:01.0 -0400
+++ linux-2.6.15/arch/um/sys-x86_64/ptrace_user.c 2006-02-06
17:36:41.0 -0500
@@ -24,6 +24,13 @@ int ptrace_setregs(long pid, unsigned lo
return(0);
}
+int ptrace_setfpregs(long pid, unsigned long *regs)
+{
+ if (ptrace(PTRACE_SETFPREGS, pid, 0, regs) < 0)
+ return -errno;
+ return 0;
+}
+
void ptrace_pokeuser(unsigned long addr, unsigned long data)
{
panic("ptrace_pokeuser");
Index: linux-2.6.15/arch/um/sys-x86_64/user-offsets.c
===
--- linux-2.6.15.orig/arch/um/sys-x86_64/user-offsets.c 2005-10-28
12:58:12.0 -0400
+++ linux-2.6.15/arch/um/sys-x86_64/user-offsets.c 2006-02-06
17:36:41.0 -0500
@@ -57,7 +57,7 @@ void foo(void)
#endif
DEFINE_LONGS(HOST_FRAME_SIZE, FRAME_SIZE);
- DEFINE(HOST_FP_SIZE, 0);
+ DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long));
DEFINE(HOST_XFP_SIZE, 0);
DEFINE_LONGS(HOST_RBX, RBX);
DEFINE_LONGS(HOST_RCX, RCX);
Index: linux-2.6.15/arch/um/include/registers.h
===
--- linux-2.6.15.orig/arch/um/include/registers.h 2005-10-28
12:58:12.0 -0400
+++ linux-2.6.15/arch/um/include/registers.h2006-02-06 17:36:41.0
-0500
@@ -14,7 +14,7 @@ extern int restore_fp_registers(int pid,
extern void save_registers(int pid, union uml_pt_regs *regs);
extern void restore_registers(int pid, union uml_pt_regs *regs);
extern void init_registers(int pid);
-extern void get_safe_registers(unsigned long * regs);
+extern void get_safe_registers(unsigned long * regs, unsigned long * fp_regs);
extern void get_thread_regs(union uml_pt_regs *uml_regs, void *buffer);
#endif
Index: linux-2.6.15/arch/um/os-Linux/sys-x86_64/registers.c
===
--- linux-2.6.15.orig/arch/um/os-Linux/sys-x86_64/registers.c 2006-02-06
17:34:36.0 -0500
+++ linux-2.6.15/arch/um/os-Linux/sys-x86_64/registers.c2006-02-06
17:36:41.0 -0500
@@ -70,9 +70,12 @@ void init_registers(int pid)
err);
}
-void get_safe_registers(unsigned long *regs)
+void get_safe_registers(unsigned long *regs, unsigned long *fp_regs)
{
memcpy(regs, exec_regs, HOST_FRAME_SIZE * sizeof(unsigned long));
+ if(fp_regs != NULL)
+ memcpy(fp_regs, exec_fp_regs,
+ HOST_FP_SIZE * sizeof(unsigned long));
}
#ifndef JB_PC
Index: linux-2.6.15/arch/um/os-Linux/skas/mem.c
===
--- linux-2.6.15.orig/arch/um/os-Linux/skas/mem.c 2006-02-06
17:33:55.0 -0500
+++ linux-2.6.15/arch/um/os-Linux/skas/mem.c2006-02-06 17:36:41.0
-0500
@@ -60,7 +60,7 @@ static inline long do_syscall_stub(struc
multi_count++;
- get_safe_registers(regs);
+ get_safe_registers(regs, NULL);
regs[REGS_IP_INDEX] = UML_CONFIG_STUB_CODE +
((unsigned long) &batch_syscall_stub -
(unsigned long) &__syscall_stub_start);
Index: linux-2.6.15/arch/um/os-Linux/skas/process.c
===
--- linux-2.6.15.orig/arch/um/os-Linux/skas/process.c 2006-02-06
17:33:55.0 -0500
+++ linux-2.6.15/arch/um/os-Linux/skas/process.c2006-02-06
17:36:41.0 -0500
@@ -310,16 +310,12 @@ void userspace(union uml_pt_regs *regs)
}
}
}
-#define INIT_JMP_NEW_THREAD 0
-#define INIT_JMP_REMOVE_SIGSTACK 1
-#define INIT_JMP_CALLBACK 2
-#define INIT_JMP_HALT 3
-#define INIT_JMP_REBOOT 4
int copy_context_skas0(unsigned long new_stack, int pid)
{
int err;
- unsigned long regs[MAX_REG_NR];
+ unsigned long regs[HOST_FRAME_SIZE];
+ unsigned long fp_regs[HOST_FP_SIZE];
unsigned long current_stack = current_stub_stack();
struct stub_data *data = (struct stub_data *) current_stack;
struct stub_data *child_data = (struct stub_data *) new_stack;
@@ -334,7 +330,7 @@ int copy_context_skas0(unsigned long new
.timer= ((struct itimerval)
{ { 0, 100 / hz() },
{ 0, 100 / hz() }})});
- get_safe_registers(regs);
+ get_safe_registers(regs, fp_regs);
/* Set parent's instruction pointer to star
[uml-devel] [PATCH 8/8] UML - Remove a dead file
A previous patch removed a file from the build without removing it from
the tree.
Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
Index: linux-2.6.15/arch/um/kernel/skas/process.c
===
--- linux-2.6.15.orig/arch/um/kernel/skas/process.c 2006-02-06
17:36:54.0 -0500
+++ /dev/null 1970-01-01 00:00:00.0 +
@@ -1,569 +0,0 @@
-/*
- * Copyright (C) 2002- 2004 Jeff Dike ([EMAIL PROTECTED])
- * Licensed under the GPL
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include "user.h"
-#include "ptrace_user.h"
-#include "sysdep/ptrace.h"
-#include "user_util.h"
-#include "kern_util.h"
-#include "skas.h"
-#include "stub-data.h"
-#include "mm_id.h"
-#include "sysdep/sigcontext.h"
-#include "sysdep/stub.h"
-#include "os.h"
-#include "proc_mm.h"
-#include "skas_ptrace.h"
-#include "chan_user.h"
-#include "registers.h"
-#include "mem.h"
-#include "uml-config.h"
-#include "process.h"
-
-int is_skas_winch(int pid, int fd, void *data)
-{
-if(pid != os_getpgrp())
- return(0);
-
- register_winch_irq(-1, fd, -1, data);
- return(1);
-}
-
-void wait_stub_done(int pid, int sig, char * fname)
-{
-int n, status, err;
-
-do {
-if ( sig != -1 ) {
-err = ptrace(PTRACE_CONT, pid, 0, sig);
-if(err)
-panic("%s : continue failed, errno = %d\n",
- fname, errno);
-}
-sig = 0;
-
-CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
-} while((n >= 0) && WIFSTOPPED(status) &&
-((WSTOPSIG(status) == SIGVTALRM) ||
-/* running UML inside a detached screen can cause
- * SIGWINCHes
- */
-(WSTOPSIG(status) == SIGWINCH)));
-
-if((n < 0) || !WIFSTOPPED(status) ||
- (WSTOPSIG(status) != SIGUSR1 && WSTOPSIG(status) != SIGTRAP)){
- unsigned long regs[HOST_FRAME_SIZE];
- if(ptrace(PTRACE_GETREGS, pid, 0, regs) < 0)
- printk("Failed to get registers from stub, "
- "errno = %d\n", errno);
- else {
- int i;
-
- printk("Stub registers -\n");
- for(i = 0; i < HOST_FRAME_SIZE; i++)
- printk("\t%d - %lx\n", i, regs[i]);
- }
-panic("%s : failed to wait for SIGUSR1/SIGTRAP, "
- "pid = %d, n = %d, errno = %d, status = 0x%x\n",
- fname, pid, n, errno, status);
-}
-}
-
-void get_skas_faultinfo(int pid, struct faultinfo * fi)
-{
-int err;
-
-if(ptrace_faultinfo){
-err = ptrace(PTRACE_FAULTINFO, pid, 0, fi);
-if(err)
-panic("get_skas_faultinfo - PTRACE_FAULTINFO failed, "
- "errno = %d\n", errno);
-
-/* Special handling for i386, which has different structs */
-if (sizeof(struct ptrace_faultinfo) < sizeof(struct faultinfo))
-memset((char *)fi + sizeof(struct ptrace_faultinfo), 0,
- sizeof(struct faultinfo) -
- sizeof(struct ptrace_faultinfo));
-}
-else {
-wait_stub_done(pid, SIGSEGV, "get_skas_faultinfo");
-
-/* faultinfo is prepared by the stub-segv-handler at start of
- * the stub stack page. We just have to copy it.
- */
-memcpy(fi, (void *)current_stub_stack(), sizeof(*fi));
-}
-}
-
-static void handle_segv(int pid, union uml_pt_regs * regs)
-{
-get_skas_faultinfo(pid, ®s->skas.faultinfo);
-segv(regs->skas.faultinfo, 0, 1, NULL);
-}
-
-/*To use the same value of using_sysemu as the caller, ask it that value (in
local_using_sysemu)*/
-static void handle_trap(int pid, union uml_pt_regs *regs, int
local_using_sysemu)
-{
- int err, status;
-
- /* Mark this as a syscall */
- UPT_SYSCALL_NR(regs) = PT_SYSCALL_NR(regs->skas.regs);
-
- if (!local_using_sysemu)
- {
- err = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_NR_OFFSET,
__NR_getpid);
- if(err < 0)
- panic("handle_trap - nullifying syscall failed errno =
%d\n",
- errno);
-
- err = ptrace(PTRACE_SYSCALL, pid, 0, 0);
- if(err < 0)
- panic("handle_trap - continuing to end of syscall
failed, "
- "errno = %d\n", errno);
-
- CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED));
- if((err < 0) || !WIFSTOPP
