lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon,  8 Jan 2024 18:32:21 +0900
From: Daniel Palmer <daniel@...f.com>
To: gerg@...ux-m68k.org,
	geert@...ux-m68k.org,
	fthain@...ux-m68k.org
Cc: linux-m68k@...ts.linux-m68k.org,
	linux-kernel@...r.kernel.org,
	Daniel Palmer <daniel@...f.com>
Subject: [PATCH v2 2/2] m68k: Fix interrupt stack frames for 68000

The plain old 68000 does not push the frame type/vector on the
stack when an interrupt starts like the brand new 68010 does.

This means that currently everything in struct pt_regs is
a bit off because it expects the processor to push an extra
short before the kernel interrupt code adds the rest.

In entry.S for the 68000 we already need to manually put
the vector number on the stack to work out what interrupt
is being handled because the cpu doesn't push that to the
stack.

So we can jiggle this around a bit to fix the issue:
- For 68000 use the same struct pt_regs layout as coldfire
  where frame/vector is after pc and sp.
- In entry.S push the vector number first, the stack pointer
  now lines up with the sktadj field in pt_regs and when saving
  the remaining registers the offsets match the fields in the
  struct.
- Remove the vec argument from the DragonBall interrupt
  decoding logic as it's not pushed on the stack anymore
  and not used either way.

Signed-off-by: Daniel Palmer <daniel@...f.com>
---
 arch/m68k/68000/entry.S             | 9 ++++-----
 arch/m68k/68000/ints.c              | 2 +-
 arch/m68k/include/asm/entry.h       | 3 +++
 arch/m68k/include/uapi/asm/ptrace.h | 2 +-
 4 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/arch/m68k/68000/entry.S b/arch/m68k/68000/entry.S
index e1fc740412f2..58c64656713a 100644
--- a/arch/m68k/68000/entry.S
+++ b/arch/m68k/68000/entry.S
@@ -54,6 +54,7 @@ do_trace:
 	jra	ret_from_exception
 
 ENTRY(system_call)
+	movew	#32,%sp@-
 	SAVE_ALL_SYS
 
 	/* save top of frame*/
@@ -116,17 +117,15 @@ Lsignal_return:
  .macro inthandler num func
 	.globl inthandler\num
 	inthandler\num:
+	movew	#\num,%sp@-
 	SAVE_ALL_INT
-	movew	%sp@(PT_OFF_FORMATVEC), %d0
-	and	#0x3ff, %d0
 
+	/* Push frame address onto stack */
 	movel	%sp,%sp@-
-	/* put vector # on stack*/
-	movel	#\num,%sp@-
 	/* process the IRQ*/
 	jbsr	\func
 	/* pop parameters off stack*/
-	addql	#8,%sp
+	addql	#4,%sp
 	bra	ret_from_exception
  .endm
 
diff --git a/arch/m68k/68000/ints.c b/arch/m68k/68000/ints.c
index e721932e495d..67c8f9e000ca 100644
--- a/arch/m68k/68000/ints.c
+++ b/arch/m68k/68000/ints.c
@@ -77,7 +77,7 @@ asmlinkage irqreturn_t inthandler71(void);
  * into one vector and look in the blasted mask register...
  * This code is designed to be fast, almost constant time, not clean!
  */
-asmlinkage void process_int(int vec, struct pt_regs *fp)
+asmlinkage void process_int(struct pt_regs *fp)
 {
 	int irq;
 	int mask;
diff --git a/arch/m68k/include/asm/entry.h b/arch/m68k/include/asm/entry.h
index 9b52b060c76a..71396c948162 100644
--- a/arch/m68k/include/asm/entry.h
+++ b/arch/m68k/include/asm/entry.h
@@ -184,6 +184,7 @@
  * that the stack frame is NOT for syscall
  */
 .macro SAVE_ALL_INT
+					/* entry.S should populate the vector */
 	clrl	%sp@-			/* stk_adj */
 	pea	-1:w			/* orig d0 */
 	movel	%d0,%sp@-		/* d0 */
@@ -191,6 +192,7 @@
 .endm
 
 .macro SAVE_ALL_SYS
+					/* entry.S should populate the vector */
 	clrl	%sp@-			/* stk_adj */
 	movel	%d0,%sp@-		/* orig d0 */
 	movel	%d0,%sp@-		/* d0 */
@@ -202,6 +204,7 @@
 	movel	%sp@+,%d0
 	addql	#4,%sp			/* orig d0 */
 	addl	%sp@+,%sp		/* stk adj */
+	addql	#2,%sp			/* entry.S populated vector */
 	rte
 .endm
 
diff --git a/arch/m68k/include/uapi/asm/ptrace.h b/arch/m68k/include/uapi/asm/ptrace.h
index 5b50ea592e00..49d7829df77c 100644
--- a/arch/m68k/include/uapi/asm/ptrace.h
+++ b/arch/m68k/include/uapi/asm/ptrace.h
@@ -39,7 +39,7 @@ struct pt_regs {
   long     d0;
   long     orig_d0;
   long     stkadj;
-#ifdef CONFIG_COLDFIRE
+#if defined(CONFIG_COLDFIRE) || defined(CONFIG_M68000)
   unsigned format :  4; /* frame format specifier */
   unsigned vector : 12; /* vector offset */
   unsigned short sr;
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ