All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/03] m68k: clean up and merge MMU and non-MMU versions of entry.S
@ 2012-05-15  6:55 gerg
  2012-05-15  6:55 ` [PATCH 1/3] m68k: consistently call ret_from_exception in entry code gerg
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: gerg @ 2012-05-15  6:55 UTC (permalink / raw)
  To: linux-m68k, uclinux-dev


m68k: clean up and merge the MMU and non-MMU versions of entry.S

With a little cleanup we can use much of the entry.S code on both the
MMU and non-MMU m68k targets.

---
 arch/m68k/kernel/entry.S    |  452 +++++++++++++++++++++++++++++++++++++++++++-
 arch/m68k/kernel/entry_mm.S |  422 -----------------------------------------
 arch/m68k/kernel/entry_no.S |  130 ------------
 3 files changed, 451 insertions(+), 553 deletions(-)

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

* [PATCH 1/3] m68k: consistently call ret_from_exception in entry code
  2012-05-15  6:55 [PATCH 00/03] m68k: clean up and merge MMU and non-MMU versions of entry.S gerg
@ 2012-05-15  6:55 ` gerg
  2012-05-15  8:18   ` Andreas Schwab
  2012-05-15  6:55 ` [PATCH 2/3] m68k: use jbsr to call functions instead of bsrl gerg
  2012-05-15  6:55 ` [PATCH 3/3] m68k: merge the MMU and non-MMU versions of the entry.S code gerg
  2 siblings, 1 reply; 6+ messages in thread
From: gerg @ 2012-05-15  6:55 UTC (permalink / raw)
  To: linux-m68k, uclinux-dev; +Cc: Greg Ungerer

From: Greg Ungerer <gerg@uclinux.org>

The ret_from_excption code is referenced by its function name, or by a label
set at the start of its code. Modify all uses to consistently just use the
function name "ret_from_exception".

This will help when we come to merge the MMU and non-MMU entry code.

Signed-off-by: Greg Ungerer <gerg@uclinux.org>
---
 arch/m68k/kernel/entry_mm.S |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/arch/m68k/kernel/entry_mm.S b/arch/m68k/kernel/entry_mm.S
index 675a854..f2ecc64 100644
--- a/arch/m68k/kernel/entry_mm.S
+++ b/arch/m68k/kernel/entry_mm.S
@@ -57,7 +57,7 @@ ENTRY(buserr)
 	movel	%sp,%sp@-		| stack frame pointer argument
 	bsrl	buserr_c
 	addql	#4,%sp
-	jra	.Lret_from_exception
+	jra	ret_from_exception
 
 ENTRY(trap)
 	SAVE_ALL_INT
@@ -65,7 +65,7 @@ ENTRY(trap)
 	movel	%sp,%sp@-		| stack frame pointer argument
 	bsrl	trap_c
 	addql	#4,%sp
-	jra	.Lret_from_exception
+	jra	ret_from_exception
 
 	| After a fork we jump here directly from resume,
 	| so that %d1 contains the previous task
@@ -74,7 +74,7 @@ ENTRY(ret_from_fork)
 	movel	%d1,%sp@-
 	jsr	schedule_tail
 	addql	#4,%sp
-	jra	.Lret_from_exception
+	jra	ret_from_exception
 
 do_trace_entry:
 	movel	#-ENOSYS,%sp@(PT_OFF_D0)| needed for strace
@@ -96,7 +96,7 @@ do_trace_exit:
 	jbsr	syscall_trace
 	RESTORE_SWITCH_STACK
 	addql	#4,%sp
-	jra	.Lret_from_exception
+	jra	ret_from_exception
 
 ENTRY(ret_from_signal)
 	movel	%curptr@(TASK_STACK),%a1
@@ -115,7 +115,7 @@ ENTRY(ret_from_signal)
 	addql	#4,%sp
 1:
 #endif
-	jra	.Lret_from_exception
+	jra	ret_from_exception
 
 ENTRY(system_call)
 	SAVE_ALL_SYS
@@ -154,7 +154,6 @@ syscall_exit_work:
 
 
 ENTRY(ret_from_exception)
-.Lret_from_exception:
 	btst	#5,%sp@(PT_OFF_SR)	| check if returning to kernel
 	bnes	1f			| if so, skip resched, signals
 	| only allow interrupts when we are really the last one on the
@@ -230,7 +229,7 @@ ret_from_last_interrupt:
 
 	/* check if we need to do software interrupts */
 	tstl	irq_stat+CPUSTAT_SOFTIRQ_PENDING
-	jeq	.Lret_from_exception
+	jeq	ret_from_exception
 	pea	ret_from_exception
 	jra	do_softirq
 
-- 
1.7.0.4

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

* [PATCH 2/3] m68k: use jbsr to call functions instead of bsrl
  2012-05-15  6:55 [PATCH 00/03] m68k: clean up and merge MMU and non-MMU versions of entry.S gerg
  2012-05-15  6:55 ` [PATCH 1/3] m68k: consistently call ret_from_exception in entry code gerg
@ 2012-05-15  6:55 ` gerg
  2012-05-15  6:55 ` [PATCH 3/3] m68k: merge the MMU and non-MMU versions of the entry.S code gerg
  2 siblings, 0 replies; 6+ messages in thread
From: gerg @ 2012-05-15  6:55 UTC (permalink / raw)
  To: linux-m68k, uclinux-dev; +Cc: Greg Ungerer

From: Greg Ungerer <gerg@uclinux.org>

There is a few places that the m68k entry code uses the bsrl instruction
to call other functions. That instruction is only supported on 68020 and
higher CPU types. If we use jbsr instead the code will be clean for all
68k and ColdFire CPU types.

Signed-off-by: Greg Ungerer <gerg@uclinux.org>
---
 arch/m68k/kernel/entry_mm.S |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/m68k/kernel/entry_mm.S b/arch/m68k/kernel/entry_mm.S
index f2ecc64..fca00b4 100644
--- a/arch/m68k/kernel/entry_mm.S
+++ b/arch/m68k/kernel/entry_mm.S
@@ -55,7 +55,7 @@ ENTRY(buserr)
 	SAVE_ALL_INT
 	GET_CURRENT(%d0)
 	movel	%sp,%sp@-		| stack frame pointer argument
-	bsrl	buserr_c
+	jbsr	buserr_c
 	addql	#4,%sp
 	jra	ret_from_exception
 
@@ -63,7 +63,7 @@ ENTRY(trap)
 	SAVE_ALL_INT
 	GET_CURRENT(%d0)
 	movel	%sp,%sp@-		| stack frame pointer argument
-	bsrl	trap_c
+	jbsr	trap_c
 	addql	#4,%sp
 	jra	ret_from_exception
 
-- 
1.7.0.4

_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

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

* [PATCH 3/3] m68k: merge the MMU and non-MMU versions of the entry.S code
  2012-05-15  6:55 [PATCH 00/03] m68k: clean up and merge MMU and non-MMU versions of entry.S gerg
  2012-05-15  6:55 ` [PATCH 1/3] m68k: consistently call ret_from_exception in entry code gerg
  2012-05-15  6:55 ` [PATCH 2/3] m68k: use jbsr to call functions instead of bsrl gerg
@ 2012-05-15  6:55 ` gerg
  2 siblings, 0 replies; 6+ messages in thread
From: gerg @ 2012-05-15  6:55 UTC (permalink / raw)
  To: linux-m68k, uclinux-dev; +Cc: Greg Ungerer

From: Greg Ungerer <gerg@uclinux.org>

Some of the entry.S code is common to both MMU and non-MMU builds.
So merge the entry_no.S and entry_mm.S files back into a single file.
With a little code movement we only need a single #ifdef.

Signed-off-by: Greg Ungerer <gerg@uclinux.org>
---
 arch/m68k/kernel/{entry_mm.S => entry.S} |  105 ++++++++++++++++--------
 arch/m68k/kernel/entry_no.S              |  130 ------------------------------
 2 files changed, 69 insertions(+), 166 deletions(-)
 rename arch/m68k/kernel/{entry_mm.S => entry.S} (94%)
 delete mode 100644 arch/m68k/kernel/entry_no.S

diff --git a/arch/m68k/kernel/entry_mm.S b/arch/m68k/kernel/entry.S
similarity index 94%
rename from arch/m68k/kernel/entry_mm.S
rename to arch/m68k/kernel/entry.S
index fca00b4..072626a 100644
--- a/arch/m68k/kernel/entry_mm.S
+++ b/arch/m68k/kernel/entry.S
@@ -51,6 +51,42 @@
 .globl user_irqvec_fixup
 
 .text
+ENTRY(sys_fork)
+	SAVE_SWITCH_STACK
+	pea	%sp@(SWITCH_STACK_SIZE)
+	jbsr	m68k_fork
+	addql	#4,%sp
+	RESTORE_SWITCH_STACK
+	rts
+
+ENTRY(sys_clone)
+	SAVE_SWITCH_STACK
+	pea	%sp@(SWITCH_STACK_SIZE)
+	jbsr	m68k_clone
+	addql	#4,%sp
+	RESTORE_SWITCH_STACK
+	rts
+
+ENTRY(sys_vfork)
+	SAVE_SWITCH_STACK
+	pea	%sp@(SWITCH_STACK_SIZE)
+	jbsr	m68k_vfork
+	addql	#4,%sp
+	RESTORE_SWITCH_STACK
+	rts
+
+ENTRY(sys_sigreturn)
+	SAVE_SWITCH_STACK
+	jbsr	do_sigreturn
+	RESTORE_SWITCH_STACK
+	rts
+
+ENTRY(sys_rt_sigreturn)
+	SAVE_SWITCH_STACK
+	jbsr	do_rt_sigreturn
+	RESTORE_SWITCH_STACK
+	rts
+
 ENTRY(buserr)
 	SAVE_ALL_INT
 	GET_CURRENT(%d0)
@@ -76,6 +112,38 @@ ENTRY(ret_from_fork)
 	addql	#4,%sp
 	jra	ret_from_exception
 
+#if defined(CONFIG_COLDFIRE) || !defined(CONFIG_MMU)
+
+#ifdef TRAP_DBG_INTERRUPT
+
+.globl dbginterrupt
+ENTRY(dbginterrupt)
+	SAVE_ALL_INT
+	GET_CURRENT(%d0)
+	movel	%sp,%sp@- 		/* stack frame pointer argument */
+	jsr	dbginterrupt_c
+	addql	#4,%sp
+	jra	ret_from_exception
+#endif
+
+ENTRY(reschedule)
+	/* save top of frame */
+	pea	%sp@
+	jbsr	set_esp0
+	addql	#4,%sp
+	pea	ret_from_exception
+	jmp	schedule
+
+ENTRY(ret_from_user_signal)
+	moveq #__NR_sigreturn,%d0
+	trap #0
+
+ENTRY(ret_from_user_rt_signal)
+	movel #__NR_rt_sigreturn,%d0
+	trap #0
+
+#else
+
 do_trace_entry:
 	movel	#-ENOSYS,%sp@(PT_OFF_D0)| needed for strace
 	subql	#4,%sp
@@ -273,42 +341,6 @@ ENTRY(bad_inthandler)
 	RESTORE_ALL
 
 
-ENTRY(sys_fork)
-	SAVE_SWITCH_STACK
-	pea	%sp@(SWITCH_STACK_SIZE)
-	jbsr	m68k_fork
-	addql	#4,%sp
-	RESTORE_SWITCH_STACK
-	rts
-
-ENTRY(sys_clone)
-	SAVE_SWITCH_STACK
-	pea	%sp@(SWITCH_STACK_SIZE)
-	jbsr	m68k_clone
-	addql	#4,%sp
-	RESTORE_SWITCH_STACK
-	rts
-
-ENTRY(sys_vfork)
-	SAVE_SWITCH_STACK
-	pea	%sp@(SWITCH_STACK_SIZE)
-	jbsr	m68k_vfork
-	addql	#4,%sp
-	RESTORE_SWITCH_STACK
-	rts
-
-ENTRY(sys_sigreturn)
-	SAVE_SWITCH_STACK
-	jbsr	do_sigreturn
-	RESTORE_SWITCH_STACK
-	rts
-
-ENTRY(sys_rt_sigreturn)
-	SAVE_SWITCH_STACK
-	jbsr	do_rt_sigreturn
-	RESTORE_SWITCH_STACK
-	rts
-
 resume:
 	/*
 	 * Beware - when entering resume, prev (the current task) is
@@ -416,3 +448,4 @@ resume:
 
 	rts
 
+#endif /* CONFIG_MMU && !CONFIG_COLDFIRE */
diff --git a/arch/m68k/kernel/entry_no.S b/arch/m68k/kernel/entry_no.S
deleted file mode 100644
index d80cba4..0000000
--- a/arch/m68k/kernel/entry_no.S
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- *  linux/arch/m68knommu/kernel/entry.S
- *
- *  Copyright (C) 1999-2002, Greg Ungerer (gerg@snapgear.com)
- *  Copyright (C) 1998  D. Jeff Dionne <jeff@lineo.ca>,
- *                      Kenneth Albanowski <kjahds@kjahds.com>,
- *  Copyright (C) 2000  Lineo Inc. (www.lineo.com) 
- *
- * Based on:
- *
- *  linux/arch/m68k/kernel/entry.S
- *
- *  Copyright (C) 1991, 1992  Linus Torvalds
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file README.legal in the main directory of this archive
- * for more details.
- *
- * Linux/m68k support by Hamish Macdonald
- *
- * 68060 fixes by Jesper Skov
- * ColdFire support by Greg Ungerer (gerg@snapgear.com)
- * 5307 fixes by David W. Miller
- * linux 2.4 support David McCullough <davidm@snapgear.com>
- */
-
-#include <linux/linkage.h>
-#include <asm/errno.h>
-#include <asm/setup.h>
-#include <asm/segment.h>
-#include <asm/asm-offsets.h>
-#include <asm/entry.h>
-#include <asm/unistd.h>
-
-.text
-
-.globl buserr
-.globl trap
-.globl ret_from_exception
-.globl ret_from_signal
-.globl sys_fork
-.globl sys_clone
-.globl sys_vfork
-
-ENTRY(buserr)
-	SAVE_ALL_INT
-	GET_CURRENT(%d0)
-	movel	%sp,%sp@- 		/* stack frame pointer argument */
-	jsr	buserr_c
-	addql	#4,%sp
-	jra	ret_from_exception
-
-ENTRY(trap)
-	SAVE_ALL_INT
-	GET_CURRENT(%d0)
-	movel	%sp,%sp@- 		/* stack frame pointer argument */
-	jsr	trap_c
-	addql	#4,%sp
-	jra	ret_from_exception
-
-#ifdef TRAP_DBG_INTERRUPT
-
-.globl dbginterrupt
-ENTRY(dbginterrupt)
-	SAVE_ALL_INT
-	GET_CURRENT(%d0)
-	movel	%sp,%sp@- 		/* stack frame pointer argument */
-	jsr	dbginterrupt_c
-	addql	#4,%sp
-	jra	ret_from_exception
-#endif
-
-ENTRY(reschedule)
-	/* save top of frame */
-	pea	%sp@
-	jbsr	set_esp0
-	addql	#4,%sp
-	pea	ret_from_exception
-	jmp	schedule
-
-ENTRY(ret_from_fork)
-	movel	%d1,%sp@-
-	jsr	schedule_tail
-	addql	#4,%sp
-	jra	ret_from_exception
-
-ENTRY(sys_fork)
-	SAVE_SWITCH_STACK
-	pea	%sp@(SWITCH_STACK_SIZE)
-	jbsr	m68k_fork
-	addql	#4,%sp
-	RESTORE_SWITCH_STACK
-	rts
-
-ENTRY(sys_vfork)
-	SAVE_SWITCH_STACK
-	pea	%sp@(SWITCH_STACK_SIZE)
-	jbsr	m68k_vfork
-	addql	#4,%sp
-	RESTORE_SWITCH_STACK
-	rts
-
-ENTRY(sys_clone)
-	SAVE_SWITCH_STACK
-	pea	%sp@(SWITCH_STACK_SIZE)
-	jbsr	m68k_clone
-	addql	#4,%sp
-	RESTORE_SWITCH_STACK
-	rts
-
-ENTRY(sys_sigreturn)
-	SAVE_SWITCH_STACK
-	jbsr	do_sigreturn
-	RESTORE_SWITCH_STACK
-	rts
-
-ENTRY(sys_rt_sigreturn)
-	SAVE_SWITCH_STACK
-	jbsr	do_rt_sigreturn
-	RESTORE_SWITCH_STACK
-	rts
-
-ENTRY(ret_from_user_signal)
-	moveq #__NR_sigreturn,%d0
-	trap #0
-
-ENTRY(ret_from_user_rt_signal)
-	movel #__NR_rt_sigreturn,%d0
-	trap #0
-
-- 
1.7.0.4

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

* Re: [PATCH 1/3] m68k: consistently call ret_from_exception in entry code
  2012-05-15  6:55 ` [PATCH 1/3] m68k: consistently call ret_from_exception in entry code gerg
@ 2012-05-15  8:18   ` Andreas Schwab
  2012-05-16  3:38     ` Greg Ungerer
  0 siblings, 1 reply; 6+ messages in thread
From: Andreas Schwab @ 2012-05-15  8:18 UTC (permalink / raw)
  To: gerg; +Cc: linux-m68k, uclinux-dev, Greg Ungerer

<gerg@snapgear.com> writes:

> The ret_from_excption code is referenced by its function name, or by a label
> set at the start of its code. Modify all uses to consistently just use the
> function name "ret_from_exception".

This will cause all branches to use the long variant, because
ret_from_exception is a global symbol (and thus overridable in the ELF
model).  The point of the additional local label is to allow the
assembler to relax the branches.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: [PATCH 1/3] m68k: consistently call ret_from_exception in entry code
  2012-05-15  8:18   ` Andreas Schwab
@ 2012-05-16  3:38     ` Greg Ungerer
  0 siblings, 0 replies; 6+ messages in thread
From: Greg Ungerer @ 2012-05-16  3:38 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: linux-m68k, uclinux-dev, Greg Ungerer


Hi Andreas,

On 15/05/12 18:18, Andreas Schwab wrote:
> <gerg@snapgear.com>  writes:
>
>> The ret_from_excption code is referenced by its function name, or by a label
>> set at the start of its code. Modify all uses to consistently just use the
>> function name "ret_from_exception".
>
> This will cause all branches to use the long variant, because
> ret_from_exception is a global symbol (and thus overridable in the ELF
> model).  The point of the additional local label is to allow the
> assembler to relax the branches.

Ah, ok. I was wondering why it was done this way.

The only problem cases for me in merging entry.S are the uses in:

     buserr
     trap
     ret_from_fork

buserr and trap are not hot paths, so do you see any issue making
them the long variant?

I don't know that even the ret_from_fork case is too much to worry
about either. We have done an awfull lot of work up to this point,
a couple of bytes more and a long branch won't make any real difference
to performance here.

Regards
Greg


------------------------------------------------------------------------
Greg Ungerer  --  Principal Engineer        EMAIL:     gerg@snapgear.com
SnapGear Group, McAfee                      PHONE:       +61 7 3435 2888
8 Gardner Close                             FAX:         +61 7 3217 5323
Milton, QLD, 4064, Australia                WEB: http://www.SnapGear.com

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

end of thread, other threads:[~2012-05-16  3:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-15  6:55 [PATCH 00/03] m68k: clean up and merge MMU and non-MMU versions of entry.S gerg
2012-05-15  6:55 ` [PATCH 1/3] m68k: consistently call ret_from_exception in entry code gerg
2012-05-15  8:18   ` Andreas Schwab
2012-05-16  3:38     ` Greg Ungerer
2012-05-15  6:55 ` [PATCH 2/3] m68k: use jbsr to call functions instead of bsrl gerg
2012-05-15  6:55 ` [PATCH 3/3] m68k: merge the MMU and non-MMU versions of the entry.S code gerg

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.