2005-04-17 00:20:36 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
|
|
|
|
* Licensed under the GPL
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __UM_PROCESSOR_GENERIC_H
|
|
|
|
#define __UM_PROCESSOR_GENERIC_H
|
|
|
|
|
|
|
|
struct pt_regs;
|
|
|
|
|
|
|
|
struct task_struct;
|
|
|
|
|
|
|
|
#include "asm/ptrace.h"
|
|
|
|
#include "choose-mode.h"
|
2005-10-04 20:53:52 +02:00
|
|
|
#include "registers.h"
|
[PATCH] uml: thread creation tidying
fork on UML has always somewhat subtle. The underlying cause has been the
need to initialize a stack for the new process. The only portable way to
initialize a new stack is to set it as the alternate signal stack and take a
signal. The signal handler does whatever initialization is needed and jumps
back to the original stack, where the fork processing is finished. The basic
context switching mechanism is a jmp_buf for each process. You switch to a
new process by longjmping to its jmp_buf.
Now that UML has its own implementation of setjmp and longjmp, and I can poke
around inside a jmp_buf without fear that libc will change the structure, a
much simpler mechanism is possible. The jmpbuf can simply be initialized by
hand.
This eliminates -
the need to set up and remove the alternate signal stack
sending and handling a signal
the signal blocking needed around the stack switching, since
there is no stack switching
setting up the jmp_buf needed to jump back to the original
stack after the new one is set up
In addition, since jmp_buf is now defined by UML, and not by libc, it can be
embedded in the thread struct. This makes it unnecessary to have it exist on
the stack, where it used to be. It also simplifies interfaces, since the
switch jmp_buf used to be a void * inside the thread struct, and functions
which took it as an argument needed to define a jmp_buf variable and assign it
from the void *.
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-09-27 10:50:40 +02:00
|
|
|
#include "sysdep/archsetjmp.h"
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
struct mm_struct;
|
|
|
|
|
|
|
|
struct thread_struct {
|
2005-05-01 17:58:56 +02:00
|
|
|
/* This flag is set to 1 before calling do_fork (and analyzed in
|
|
|
|
* copy_thread) to mark that we are begin called from userspace (fork /
|
|
|
|
* vfork / clone), and reset to 0 after. It is left to 0 when called
|
|
|
|
* from kernelspace (i.e. kernel_thread() or fork_idle(), as of 2.6.11). */
|
[PATCH] uml: breakpoint an arbitrary thread
This patch implements a stack trace for a thread, not unlike sysrq-t does.
The advantage to this is that a break point can be placed on showreqs, so that
upon showing the stack, you jump immediately into the debugger. While sysrq-t
does the same thing, sysrq-t shows *all* threads stacks. It also doesn't work
right now. In the future, I thought it might be acceptable to make this show
all pids stacks, but perhaps leaving well enough alone and just using sysrq-t
would be okay. For now, upon receiving the stack command, UML switches
context to that thread, dumps its registers, and then switches context back to
the original thread. Since UML compacts all threads into one of 4 host
threads, this sort of mechanism could be expanded in the future to include
other debugging helpers that sysrq does not cover.
Note by jdike - The main benefit to this is that it brings an arbitrary thread
back into context, where it can be examined by gdb. The fact that it dumps it
stack is secondary. This provides the capability to examine a sleeping
thread, which has existed in tt mode, but not in skas mode until now.
Also, the other threads, that sysrq doesn't cover, can be gdb-ed directly
anyway.
Signed-off-by: Allan Graves<allan.graves@gmail.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-09-17 04:27:46 +02:00
|
|
|
struct task_struct *saved_task;
|
2005-04-17 00:20:36 +02:00
|
|
|
int forking;
|
|
|
|
int nsyscalls;
|
|
|
|
struct pt_regs regs;
|
|
|
|
int singlestep_syscall;
|
|
|
|
void *fault_addr;
|
|
|
|
void *fault_catcher;
|
|
|
|
struct task_struct *prev_sched;
|
|
|
|
unsigned long temp_stack;
|
|
|
|
void *exec_buf;
|
|
|
|
struct arch_thread arch;
|
|
|
|
union {
|
|
|
|
#ifdef CONFIG_MODE_TT
|
|
|
|
struct {
|
|
|
|
int extern_pid;
|
|
|
|
int tracing;
|
|
|
|
int switch_pipe[2];
|
|
|
|
int vm_seq;
|
|
|
|
} tt;
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_MODE_SKAS
|
|
|
|
struct {
|
[PATCH] uml: thread creation tidying
fork on UML has always somewhat subtle. The underlying cause has been the
need to initialize a stack for the new process. The only portable way to
initialize a new stack is to set it as the alternate signal stack and take a
signal. The signal handler does whatever initialization is needed and jumps
back to the original stack, where the fork processing is finished. The basic
context switching mechanism is a jmp_buf for each process. You switch to a
new process by longjmping to its jmp_buf.
Now that UML has its own implementation of setjmp and longjmp, and I can poke
around inside a jmp_buf without fear that libc will change the structure, a
much simpler mechanism is possible. The jmpbuf can simply be initialized by
hand.
This eliminates -
the need to set up and remove the alternate signal stack
sending and handling a signal
the signal blocking needed around the stack switching, since
there is no stack switching
setting up the jmp_buf needed to jump back to the original
stack after the new one is set up
In addition, since jmp_buf is now defined by UML, and not by libc, it can be
embedded in the thread struct. This makes it unnecessary to have it exist on
the stack, where it used to be. It also simplifies interfaces, since the
switch jmp_buf used to be a void * inside the thread struct, and functions
which took it as an argument needed to define a jmp_buf variable and assign it
from the void *.
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-09-27 10:50:40 +02:00
|
|
|
jmp_buf switch_buf;
|
2005-04-17 00:20:36 +02:00
|
|
|
int mm_count;
|
|
|
|
} skas;
|
|
|
|
#endif
|
|
|
|
} mode;
|
|
|
|
struct {
|
|
|
|
int op;
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
int pid;
|
|
|
|
} fork, exec;
|
|
|
|
struct {
|
|
|
|
int (*proc)(void *);
|
|
|
|
void *arg;
|
|
|
|
} thread;
|
|
|
|
struct {
|
|
|
|
void (*proc)(void *);
|
|
|
|
void *arg;
|
|
|
|
} cb;
|
|
|
|
} u;
|
|
|
|
} request;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define INIT_THREAD \
|
|
|
|
{ \
|
|
|
|
.forking = 0, \
|
|
|
|
.nsyscalls = 0, \
|
|
|
|
.regs = EMPTY_REGS, \
|
|
|
|
.fault_addr = NULL, \
|
|
|
|
.prev_sched = NULL, \
|
|
|
|
.temp_stack = 0, \
|
|
|
|
.exec_buf = NULL, \
|
|
|
|
.arch = INIT_ARCH_THREAD, \
|
|
|
|
.request = { 0 } \
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned long seg;
|
|
|
|
} mm_segment_t;
|
|
|
|
|
|
|
|
extern struct task_struct *alloc_task_struct(void);
|
|
|
|
|
|
|
|
extern void release_thread(struct task_struct *);
|
|
|
|
extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
|
2005-05-01 17:58:54 +02:00
|
|
|
|
|
|
|
static inline void prepare_to_copy(struct task_struct *tsk)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
extern unsigned long thread_saved_pc(struct task_struct *t);
|
|
|
|
|
|
|
|
static inline void mm_copy_segments(struct mm_struct *from_mm,
|
|
|
|
struct mm_struct *new_mm)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#define init_stack (init_thread_union.stack)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* User space process size: 3GB (default).
|
|
|
|
*/
|
|
|
|
extern unsigned long task_size;
|
|
|
|
|
|
|
|
#define TASK_SIZE (task_size)
|
|
|
|
|
|
|
|
/* This decides where the kernel will search for a free chunk of vm
|
|
|
|
* space during mmap's.
|
|
|
|
*/
|
|
|
|
#define TASK_UNMAPPED_BASE (0x40000000)
|
|
|
|
|
|
|
|
extern void start_thread(struct pt_regs *regs, unsigned long entry,
|
|
|
|
unsigned long stack);
|
|
|
|
|
|
|
|
struct cpuinfo_um {
|
|
|
|
unsigned long loops_per_jiffy;
|
|
|
|
int ipi_pipe[2];
|
|
|
|
};
|
|
|
|
|
|
|
|
extern struct cpuinfo_um boot_cpu_data;
|
|
|
|
|
|
|
|
#define my_cpu_data cpu_data[smp_processor_id()]
|
|
|
|
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
extern struct cpuinfo_um cpu_data[];
|
|
|
|
#define current_cpu_data cpu_data[smp_processor_id()]
|
|
|
|
#else
|
|
|
|
#define cpu_data (&boot_cpu_data)
|
|
|
|
#define current_cpu_data boot_cpu_data
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2005-10-04 20:53:52 +02:00
|
|
|
#ifdef CONFIG_MODE_SKAS
|
|
|
|
#define KSTK_REG(tsk, reg) \
|
[PATCH] uml: thread creation tidying
fork on UML has always somewhat subtle. The underlying cause has been the
need to initialize a stack for the new process. The only portable way to
initialize a new stack is to set it as the alternate signal stack and take a
signal. The signal handler does whatever initialization is needed and jumps
back to the original stack, where the fork processing is finished. The basic
context switching mechanism is a jmp_buf for each process. You switch to a
new process by longjmping to its jmp_buf.
Now that UML has its own implementation of setjmp and longjmp, and I can poke
around inside a jmp_buf without fear that libc will change the structure, a
much simpler mechanism is possible. The jmpbuf can simply be initialized by
hand.
This eliminates -
the need to set up and remove the alternate signal stack
sending and handling a signal
the signal blocking needed around the stack switching, since
there is no stack switching
setting up the jmp_buf needed to jump back to the original
stack after the new one is set up
In addition, since jmp_buf is now defined by UML, and not by libc, it can be
embedded in the thread struct. This makes it unnecessary to have it exist on
the stack, where it used to be. It also simplifies interfaces, since the
switch jmp_buf used to be a void * inside the thread struct, and functions
which took it as an argument needed to define a jmp_buf variable and assign it
from the void *.
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-09-27 10:50:40 +02:00
|
|
|
get_thread_reg(reg, &tsk->thread.mode.skas.switch_buf)
|
2005-10-04 20:53:52 +02:00
|
|
|
#else
|
|
|
|
#define KSTK_REG(tsk, reg) (0xbadbabe)
|
2005-04-17 00:20:36 +02:00
|
|
|
#endif
|
2005-10-04 20:53:52 +02:00
|
|
|
#define get_wchan(p) (0)
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2005-10-04 20:53:52 +02:00
|
|
|
#endif
|