All of lore.kernel.org
 help / color / mirror / Atom feed
* [uml-devel] sysrq patch
@ 2005-09-26 18:05 Allan Graves
  2005-09-27  4:54 ` Jeff Dike
  0 siblings, 1 reply; 2+ messages in thread
From: Allan Graves @ 2005-09-26 18:05 UTC (permalink / raw)
  To: user-mode-linux-devel

[-- Attachment #1: Type: text/plain, Size: 433 bytes --]

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

[-- Attachment #2: sysrq_patch --]
[-- Type: text/plain, Size: 4913 bytes --]

Index: linux-2.6.13-stack/arch/um/include/registers.h
===================================================================
--- linux-2.6.13-stack.orig/arch/um/include/registers.h
+++ linux-2.6.13-stack/arch/um/include/registers.h
@@ -16,6 +16,7 @@ extern void save_registers(int pid, unio
 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 union uml_pt_regs *get_thread_regs(union uml_pt_regs *uml_regs, void *buffer);
 
 #endif
 
Index: linux-2.6.13-stack/arch/um/kernel/sysrq.c
===================================================================
--- linux-2.6.13-stack.orig/arch/um/kernel/sysrq.c
+++ linux-2.6.13-stack/arch/um/kernel/sysrq.c
@@ -84,5 +84,5 @@ void show_stack(struct task_struct *task
 	}
 
 	printk("Call Trace: \n");
-	show_trace(current, esp);
+	show_trace(task, esp);
 }
Index: linux-2.6.13-stack/arch/um/os-Linux/sys-i386/registers.c
===================================================================
--- linux-2.6.13-stack.orig/arch/um/os-Linux/sys-i386/registers.c
+++ linux-2.6.13-stack/arch/um/os-Linux/sys-i386/registers.c
@@ -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 *r
 	memcpy(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
Index: linux-2.6.13-stack/arch/um/sys-i386/sysrq.c
===================================================================
--- linux-2.6.13-stack.orig/arch/um/sys-i386/sysrq.c
+++ linux-2.6.13-stack/arch/um/sys-i386/sysrq.c
@@ -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");
 }
 
Index: linux-2.6.13-stack/include/asm-um/processor-generic.h
===================================================================
--- linux-2.6.13-stack.orig/include/asm-um/processor-generic.h
+++ linux-2.6.13-stack/include/asm-um/processor-generic.h
@@ -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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [uml-devel] sysrq patch
  2005-09-26 18:05 [uml-devel] sysrq patch Allan Graves
@ 2005-09-27  4:54 ` Jeff Dike
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Dike @ 2005-09-27  4:54 UTC (permalink / raw)
  To: Allan Graves; +Cc: user-mode-linux-devel

On Mon, Sep 26, 2005 at 02:05:13PM -0400, Allan Graves wrote:
> Let me know what you want changed, jeff, 

OK, you asked for it :-)

> 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.

> 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(&regs, 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
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-09-27  5:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-26 18:05 [uml-devel] sysrq patch Allan Graves
2005-09-27  4:54 ` Jeff Dike

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.