All of lore.kernel.org
 help / color / mirror / Atom feed
From: Allan Graves <allan.graves@oracle.com>
To: user-mode-linux-devel@lists.sourceforge.net
Subject: [uml-devel] sysrq patch
Date: Mon, 26 Sep 2005 14:05:13 -0400	[thread overview]
Message-ID: <43383859.7090301@oracle.com> (raw)

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

             reply	other threads:[~2005-09-26 18:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-26 18:05 Allan Graves [this message]
2005-09-27  4:54 ` [uml-devel] sysrq patch Jeff Dike

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=43383859.7090301@oracle.com \
    --to=allan.graves@oracle.com \
    --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 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.