sysrq patch
Changes: Fixes sysrq t to work under skas mode. Adds macros to get register arguments from the jmp bufs in conjunction with a new function. Changes the show_trace call to pass the correct task, not the current one.
Let me know what you want changed, jeff, i set vim to hardtabs, i hope the white space comes out okay, don't want to get you in trouble again. i ran this in both frame pointer and no frame pointer mode. Allan
arch/um/include/registers.h +1 -0
@@ -16,6 +16,7 @@ extern void save_registers(int pid, unioextern 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 union uml_pt_regs *get_thread_regs (union uml_pt_regs *uml_regs,void *buffer);#endif
arch/um/kernel/sysrq.c +1 -1
@@ -84,5 +84,5 @@ void show_stack(struct task_struct *task }printk ("Call Trace: \n" ); -show_trace (current, esp); +show_trace (task, esp); }
arch/um/os-Linux/sys-i386/registers.c +20 -0
@@ -5,6 +5,7 @@#include <errno.h> #include <string.h> +#include <setjmp.h> #include "sysdep/ptrace_user.h" #include "sysdep/ptrace.h" #include "uml-config.h"
@@ -126,6 +127,25 @@ void get_safe_registers(unsigned long *rmemcpy (regs, exec_regs,HOST_FRAME_SIZE *sizeof (unsigned long )); } + + +union uml_pt_regs *get_thread_regs (union uml_pt_regs *uml_regs,void *buffer) +{ +//jmp_buf * jmpbuf=(jmp_buf *)buffer; +struct __jmp_buf_tag *jmpbuf=(struct __jmp_buf_tag *)buffer; + +/*uml_regs->skas.regs[HOST_IP]=jmpbuf->__jmp_buf[JB_PC]; +uml_regs->skas.regs[HOST_SP]=jmpbuf->__jmp_buf[JB_SP]; +uml_regs->skas.regs[HOST_EBP]=jmpbuf->__jmp_buf[JB_BP];*/ + +UPT_SET (uml_regs,EIP , jmpbuf->__jmpbuf[JB_PC ]); +UPT_SET (uml_regs,UESP , jmpbuf->__jmpbuf[JB_SP ]); +UPT_SET (uml_regs,EBP , jmpbuf->__jmpbuf[JB_BP ]); + + +return uml_regs; + +}/* * Overrides for Emacs so that we follow Linus's tabbing style. * Emacs will notice this stuff at the end of the file and automatically
arch/um/sys-i386/sysrq.c +4 -12
@@ -11,6 +11,7 @@#include "asm/ptrace.h" #include "sysrq.h" +int stop_here=0 ;/* This is declared by <linux/sched.h> */ void show_regs (struct pt_regs *regs) {
@@ -49,6 +50,7 @@ static inline unsigned long print_contex unsigned long *stack, unsigned long ebp) {unsigned long addr; +int r;#ifdef CONFIG_FRAME_POINTER while (valid_stack_ptr (tinfo, (void *)ebp)) {
@@ -88,26 +90,16 @@ void show_trace(struct task_struct* task task = current;if (task != current) { -//ebp = (unsigned long) KSTK_EBP(task); -/* Which one? No actual difference - just coding style.*/ - ebp = (unsigned long )PT_REGS_EBP (&task->thread.regs); + ebp = (unsigned long )KSTK_EBP (task); }else { asm ("movl %%ebp, %0" :"=r" (ebp) : ); +printk ("ASM\n" ); } context = (struct thread_info *) ((unsigned long )stack & (~(THREAD_SIZE -1 )));print_context_stack (context, stack, ebp); -/*while (((long) stack & (THREAD_SIZE-1)) != 0) { -addr = *stack; -if (__kernel_text_address(addr)) { -printk("%08lx: [<%08lx>]", (unsigned long) stack, addr); -print_symbol(" %s", addr); -printk("\n"); -} -stack++; -}*/ printk ("\n" ); }
include/asm-um/processor-generic.h +10 -0
@@ -13,6 +13,7 @@ struct task_struct;#include "linux/config.h" #include "asm/ptrace.h" #include "choose-mode.h" +#include "registers.h" struct mm_struct ;
@@ -22,6 +23,7 @@ struct thread_struct {* 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). */ struct task_struct *saved_task; +union uml_pt_regs sysrq_regs;int forking;int nsyscalls;struct pt_regs regs;
@@ -136,8 +138,16 @@ extern struct cpuinfo_um cpu_data[];#define current_cpu_data boot_cpu_data#endif +#ifdef CONFIG_MODE_SKAS + +#define KSTK_EIP (tsk) UPT_REG(get_thread_regs(&tsk->thread.sysrq_regs, tsk->thread.mode.skas.switch_buf), EIP); +#define KSTK_ESP (tsk) UPT_REG(get_thread_regs(&tsk->thread.sysrq_regs, tsk->thread.mode.skas.switch_buf), UESP); +#define KSTK_EBP (tsk) UPT_REG(get_thread_regs(&tsk->thread.sysrq_regs, tsk->thread.mode.skas.switch_buf), EBP); + +#else #define KSTK_EIP (tsk) (PT_REGS_IP(&tsk->thread.regs))#define KSTK_ESP (tsk) (PT_REGS_SP(&tsk->thread.regs)) +#endif #define get_wchan (p) (0)#endif
Quoted 1 line · Allan Graves
Let me know what you want changed, jeff,
OK, you asked for it :-)
Quoted 2 lines
i set vim to hardtabs, i hope
the white space comes out okay, don't want to get you in trouble again.
The tabs look OK this time, thanks.
Quoted 1 line
i ran this in both frame pointer and no frame pointer mode.
+union uml_pt_regs *get_thread_regs(union uml_pt_regs *uml_regs, void *buffer)
+{
...+ return uml_regs;
+}
This should just be a void, there's usually no sense in returning an argument. I see why you do it this way, but see my comments later.
//jmp_buf * jmpbuf=(jmp_buf *)buffer;
Just get rid of commented code - act like you mean it :-)
+int stop_here=0;
You should have gotten rid of that.
+ printk("ASM\n");
What's that?
+#ifdef CONFIG_MODE_SKAS
+
+#define KSTK_EIP(tsk) UPT_REG(get_thread_regs(&tsk->thread.sysrq_regs, tsk->thread.mode.skas.switch_buf), EIP); +#define KSTK_ESP(tsk) UPT_REG(get_thread_regs(&tsk->thread.sysrq_regs, tsk->thread.mode.skas.switch_buf), UESP); +#define KSTK_EBP(tsk) UPT_REG(get_thread_regs(&tsk->thread.sysrq_regs, tsk->thread.mode.skas.switch_buf), EBP); +
+#else
With this, I would prefer something like
static inline unsigned long KSTK_EIP(struct task_struct *task)
{
union uml_pt_regs regs;
get_thread_regs(®s, task->thread.mode.skas.switch_buf);
return(UPT_REG(regs, EIP));
}No need to make the thread structure any larger than it needs to be. Plus the typechecking is better with a function than a macro.
Also, is KSTK_EBP needed? It wasn't defined before, and yet UML still linked.
And I would make the tt mode versions return obviously bogus values (0x00badbad, maybe :-), rather than non-obviously bogus values.
Jeff
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel