diff mbox

[RFC] parisc: avoid saving & restoring fp regs at syscall entry

Message ID 20140413201733.GA7858@ls3530.fritz.box (mailing list archive)
State Under Review, archived
Headers show

Commit Message

Helge Deller April 13, 2014, 8:17 p.m. UTC
This is a work-in-progress patch to avoid unneccesary saving of floating
point regs when entering syscalls (it still generates segfaults...!).
The compiler option -mdisable-fpregs takes care that we don't use fp
regs in kernel code by accident.

Signed-off-by: Helge Deller <deller@gmx.de>

--
To unsubscribe from this list: send the line "unsubscribe linux-parisc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/parisc/kernel/entry.S b/arch/parisc/kernel/entry.S
index e8f07dd..810769b 100644
--- a/arch/parisc/kernel/entry.S
+++ b/arch/parisc/kernel/entry.S
@@ -785,9 +785,13 @@  ENDPROC(ret_from_kernel_thread)
 ENTRY(_switch_to)
 	STREG	 %r2, -RP_OFFSET(%r30)
 
-	callee_save_float
 	callee_save
 
+	/* TODO: we could check TASK_FLAGS and only save the fpregs when
+	 * switching away from a userspace task. */
+	ldo	TASK_PT_FR0(%r26), %r1	/* save fpregs for task switch */
+	save_fp	%r1
+
 	load32	_switch_to_ret, %r2
 
 	STREG	%r2, TASK_PT_KPC(%r26)
@@ -795,6 +799,12 @@  ENTRY(_switch_to)
 
 	STREG	%r30, TASK_PT_KSP(%r26)
 	LDREG	TASK_PT_KSP(%r25), %r30
+
+	/* TODO: we could check TASK_FLAGS and restore the fpregs only when
+	 * we return to a userspace task. */
+	ldo	TASK_PT_FR31(%r25),%r1	/* reload fpregs */
+	rest_fp	%r1
+
 	LDREG	TASK_THREAD_INFO(%r25), %r25
 	bv	%r0(%r2)
 	mtctl   %r25,%cr30
@@ -802,7 +812,6 @@  ENTRY(_switch_to)
 _switch_to_ret:
 	mtctl	%r0, %cr0		/* Needed for single stepping */
 	callee_rest
-	callee_rest_float
 
 	LDREG	-RP_OFFSET(%r30), %r2
 	bv	%r0(%r2)
@@ -913,8 +922,6 @@  intr_check_sig:
 
 intr_restore:
 	copy            %r16,%r29
-	ldo             PT_FR31(%r29),%r1
-	rest_fp         %r1
 	rest_general    %r29
 
 	/* inverse of virt_map */
@@ -1013,9 +1020,6 @@  intr_extint:
 	virt_map
 	save_general	%r29
 
-	ldo	PT_FR0(%r29), %r24
-	save_fp	%r24
-	
 	loadgp
 
 	copy	%r29, %r26	/* arg0 is pt_regs */
@@ -1094,9 +1098,6 @@  skip_save_ior:
 	virt_map
 	save_general	%r29
 
-	ldo		PT_FR0(%r29), %r25
-	save_fp		%r25
-	
 	loadgp
 
 	copy		%r29, %r25	/* arg1 is pt_regs */
@@ -1856,9 +1857,6 @@  syscall_restore:
 	and,COND(=)	%r19,%r2,%r0
 	b,n	syscall_restore_rfi
 
-	ldo	TASK_PT_FR31(%r1),%r19		   /* reload fpregs */
-	rest_fp	%r19
-
 	LDREG	TASK_PT_SAR(%r1),%r19		   /* restore SAR */
 	mtsar	%r19
 
diff --git a/arch/parisc/kernel/syscall.S b/arch/parisc/kernel/syscall.S
index a63bb179..89163e7 100644
--- a/arch/parisc/kernel/syscall.S
+++ b/arch/parisc/kernel/syscall.S
@@ -184,9 +184,6 @@  linux_gateway_entry:
 	STREG	%r29, TASK_PT_GR29(%r1)		/* return value 1 */
 	STREG	%r31, TASK_PT_GR31(%r1)		/* preserve syscall return ptr */
 	
-	ldo	TASK_PT_FR0(%r1), %r27		/* save fpregs from the kernel */
-	save_fp	%r27				/* or potential task switch  */
-
 	mfctl	%cr11, %r27			/* i.e. SAR */
 	STREG	%r27, TASK_PT_SAR(%r1)
 
@@ -310,6 +307,8 @@  tracesys:
 	STREG	%r16,PT_GR16(%r2)
 	STREG	%r17,PT_GR17(%r2)
 	STREG	%r18,PT_GR18(%r2)
+	ldo	PT_FR0(%r2), %r1	/* save fpregs */
+	save_fp %r1
 	/* Finished saving things for the debugger */
 
 	copy	%r2,%r26