Skip to contentSkip to conversation

UML - Factor out register saving and restoring

PATCH New Jeff Dike 1 participant 1 message Jan 10, 2005 User-mode Linux (UML)

lore
Share & tools
lore

Jeff Dike

author
#0 lore raw

PATCH 7/28 UML - Factor out register saving and restoring

This moves the register shuffling code into arch/um/os-Linux/sys-$(SUBARCH), making it purely userspace code. It also adds an x86_64 implementation of registers.c.

arch/um/include/registers.h +27 -0
Index: 2.6.10/arch/um/include/registers.h
===================================================================
@@ -0,0 +1,27 @@
+/* 
+ * Copyright (C) 2004 PathScale, Inc
+ * Licensed under the GPL
+ */
+
+#ifndef __REGISTERS_H
+#define __REGISTERS_H
+
+#include "sysdep/ptrace.h"
+
+extern void init_thread_registers(union uml_pt_regs *to);
+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);
+
+#endif
+
+/*
+ * Overrides for Emacs so that we follow Linus's tabbing style.
+ * Emacs will notice this stuff at the end of the file and automatically
+ * adjust the settings for this buffer only.  This must remain at the end
+ * of the file.
+ * ---------------------------------------------------------------------------
+ * Local variables:
+ * c-file-style: "linux"
+ * End:
+ */
arch/um/kernel/process.c +1 -0
Index: 2.6.10/arch/um/kernel/process.c
===================================================================
@@ -40,6 +40,7 @@
 #ifdef UML_CONFIG_MODE_SKAS
 #include "skas.h"
 #include "skas_ptrace.h"
+#include "registers.h"
 #endif
 
 void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int))
arch/um/kernel/skas/include/skas.h +0 -3
Index: 2.6.10/arch/um/kernel/skas/include/skas.h
===================================================================
@@ -29,10 +29,7 @@
 		   int r, int w, int x, int must_succeed);
 extern void user_signal(int sig, union uml_pt_regs *regs);
 extern int new_mm(int from);
-extern void save_registers(union uml_pt_regs *regs);
-extern void restore_registers(union uml_pt_regs *regs);
 extern void start_userspace(int cpu);
-extern void init_registers(int pid);
 
 #endif
 
arch/um/kernel/skas/process.c +4 -85

131 lines not on this page · raw message

arch/um/kernel/skas/process_kern.c +2 -6
Index: 2.6.10/arch/um/kernel/skas/process_kern.c
===================================================================
@@ -22,6 +22,7 @@
 #include "kern.h"
 #include "mode.h"
 #include "proc_mm.h"
+#include "registers.h"
 
 void *switch_to_skas(void *prev, void *next)
 {
@@ -118,12 +119,7 @@
 		handler = fork_handler;
 	}
 	else {
-	  	memcpy(p->thread.regs.regs.skas.regs, exec_regs, 
-		       sizeof(p->thread.regs.regs.skas.regs));
-		memcpy(p->thread.regs.regs.skas.fp, exec_fp_regs, 
-		       sizeof(p->thread.regs.regs.skas.fp));
-	  	memcpy(p->thread.regs.regs.skas.xfp, exec_fpx_regs, 
-		       sizeof(p->thread.regs.regs.skas.xfp));
+		init_thread_registers(&p->thread.regs.regs);
                 p->thread.request.u.thread = current->thread.request.u.thread;
 		handler = new_thread_handler;
 	}
arch/um/os-Linux/Makefile +2 -1
Index: 2.6.10/arch/um/os-Linux/Makefile
===================================================================
@@ -3,7 +3,8 @@
 # Licensed under the GPL
 #
 
-obj-y = elf_aux.o file.o process.o time.o tty.o user_syms.o drivers/
+obj-y = elf_aux.o file.o process.o time.o tty.o user_syms.o drivers/ \
+	sys-$(SUBARCH)/
 
 USER_OBJS := elf_aux.o file.o process.o time.o tty.o
 USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file))
arch/um/os-Linux/sys-i386/Makefile +11 -0
Index: 2.6.10/arch/um/os-Linux/sys-i386/Makefile
===================================================================
@@ -0,0 +1,11 @@
+# 
+# Copyright (C) 2000 Jeff Dike ([email protected])
+# Licensed under the GPL
+#
+
+obj-$(CONFIG_MODE_SKAS) = registers.o
+
+USER_OBJS := $(foreach file,$(obj-y),$(obj)/$(file))
+
+$(USER_OBJS) : %.o: %.c
+	$(CC) $(CFLAGS_$(notdir $@)) $(USER_CFLAGS) -c -o $@ $<
arch/um/os-Linux/sys-i386/registers.c +115 -0

115 lines not on this page · raw message

arch/um/os-Linux/sys-x86_64/Makefile +11 -0
Index: 2.6.10/arch/um/os-Linux/sys-x86_64/Makefile
===================================================================
@@ -0,0 +1,11 @@
+# 
+# Copyright (C) 2000 Jeff Dike ([email protected])
+# Licensed under the GPL
+#
+
+obj-$(CONFIG_MODE_SKAS) = registers.o
+
+USER_OBJS := $(foreach file,$(obj-y),$(obj)/$(file))
+
+$(USER_OBJS) : %.o: %.c
+	$(CC) $(CFLAGS_$(notdir $@)) $(USER_CFLAGS) -c -o $@ $<
arch/um/os-Linux/sys-x86_64/registers.c +82 -0

82 lines not on this page · raw message