[parisc-linux-cvs] Change CR27 to CR31

Matthew Wilcox willy@ldl.fc.hp.com
Tue, 17 Apr 2001 15:42:24 -0600


 * Use cr31 instead of cr27 as a temporary register
 * Add a `set_thread_pointer' lightweight syscall (thanks to jsm for pointing
   out a bug in my original code.)
 * Update documentation to reflect the cr27->31 change.

Note that the position, functionality, etc of set_thread_pointer is not
guaranteed, this represents a `first cut', and is more to do with me
cleaning out my tree than having this finished and working.

Index: Documentation/parisc/registers
===================================================================
RCS file: /home/cvs/parisc/linux/Documentation/parisc/registers,v
retrieving revision 1.9
diff -u -p -r1.9 registers
--- registers	2001/03/22 16:24:16	1.9
+++ registers	2001/04/17 21:29:58
@@ -22,11 +22,11 @@ CR23 (EIRR)			read for pending interrupt
 CR24 (TR 0)			Kernel Space Page Directory Pointer
 CR25 (TR 1)			User   Space Page Directory Pointer
 CR26 (TR 2)			not used
-CR27 (TR 3)			Reserved for libpthread support
+CR27 (TR 3)			Thread descriptor pointer
 CR28 (TR 4)			not used
 CR29 (TR 5)			not used
 CR30 (TR 6)			current / 0
-CR31 (TR 7)			not used
+CR31 (TR 7)			Temporary register, used in various places
 
 	Space Registers (kernel mode)
 
Index: arch/parisc/kernel/entry.S
===================================================================
RCS file: /home/cvs/parisc/linux/arch/parisc/kernel/entry.S,v
retrieving revision 1.81
diff -u -p -r1.81 entry.S
--- entry.S	2001/04/13 14:04:09	1.81
+++ entry.S	2001/04/17 21:29:58
@@ -2093,7 +2093,7 @@ syscall_restore:
 	LDREG	TASK_PTRACE(%r1), %r19		/* Are we being ptraced? */
 	bb,<,n	%r19,31,syscall_restore_rfi
 	LDREG	TASK_PT_GR20(%r1),%r19
-	mtctl	%r19, %cr27
+	mtctl	%r19, %cr31
 
 	LDREG	TASK_PT_GR2(%r1),%r2		   /* restore user rp */
 	LDREG	TASK_PT_GR21(%r1),%r21
@@ -2122,7 +2122,7 @@ syscall_restore:
 	depi	3,31,2,%r31			   /* ensure return to user mode. */
 
 	mtsm	%r20				   /* restore irq state  */
-	mfctl	%cr27,%r20
+	mfctl	%cr31,%r20
 	
 	/*
 	 * Due to a dependency in the tlb miss handlers on sr7, it
Index: arch/parisc/kernel/syscall.S
===================================================================
RCS file: /home/cvs/parisc/linux/arch/parisc/kernel/syscall.S,v
retrieving revision 1.62
diff -u -p -r1.62 syscall.S
--- syscall.S	2001/04/17 15:58:38	1.62
+++ syscall.S	2001/04/17 21:29:58
@@ -44,8 +44,21 @@
 	.align 4096
 linux_gateway_page:
 
+	.rept 56
 	break   0,0
+	.endr
 
+set_thread_pointer:
+	gate	.+8, %r0		/* increase privilege */
+	depi	3, 31, 2, %r31		/* Ensure we return into user mode. */
+	be	0(%sr7,%r31)		/* return to user space */
+	mtctl	%r26, %cr27		/* move arg0 to the control register */
+
+	.rept 4
+	break   0,0
+	.endr
+
+/* This address must remain fixed, or user binaries go splat. */
 	.align 256
 linux_gateway_entry:
 	mfsp	%sr7,%r1			/* we must set sr3 to the space */
@@ -64,7 +77,7 @@ linux_gateway_entry:
 	 */
 	ssm	PSW_SM_W, %r0
 #endif
-	mtctl	%r28,%cr27
+	mtctl	%r28,%cr31
 	rsm	PSW_I, %r28			/* no ints for a bit  */
 	mfctl	%cr30,%r1			/* get the kernel task ptr */
 	mtctl	%r0,%cr30			/* zero it (flag) */
@@ -85,7 +98,7 @@ linux_gateway_entry:
 	STREG	%r25, TASK_PT_GR25(%r1)		/* 2nd argument */
 	STREG	%r26, TASK_PT_GR26(%r1)	 	/* 1st argument */
 	STREG	%r27, TASK_PT_GR27(%r1)		/* user dp */
-	mfctl	%cr27,%r19
+	mfctl	%cr31,%r19
 	STREG	%r19, TASK_PT_GR28(%r1)		/* return value 0 */
 	STREG	%r19, TASK_PT_ORIG_R28(%r1)	/* return value 0 (saved for signals) */
 	STREG	%r29, TASK_PT_GR29(%r1)		/* return value 1 */