Skip to content

Instantly share code, notes, and snippets.

@tsutsui
Created February 20, 2021 02:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsutsui/a45a96ba9ce067cec1523be3f6e24eb5 to your computer and use it in GitHub Desktop.
Save tsutsui/a45a96ba9ce067cec1523be3f6e24eb5 to your computer and use it in GitHub Desktop.
a dumb possible fix for NetBSD PR Port-m68k/55990 https://gnats.netbsd.org/55990
Index: m68k/reenter_syscall.s
===================================================================
RCS file: /cvsroot/src/sys/arch/m68k/m68k/reenter_syscall.s,v
retrieving revision 1.4
diff -u -p -d -r1.4 reenter_syscall.s
--- m68k/reenter_syscall.s 7 Sep 2013 19:06:29 -0000 1.4
+++ m68k/reenter_syscall.s 20 Feb 2021 01:38:49 -0000
@@ -6,6 +6,7 @@
*/
#include <m68k/asm.h>
+#include "assym.h"
/*
* void reenter_syscall(struct frame *fp, int stkadj)
@@ -38,18 +39,31 @@ ENTRY_NOPROFILE(reenter_syscall)
.Lcpfr: movel (%a0)+,(%a1)+
dbra %d0,.Lcpfr
- movew %d1,%sp@(16*4+2) | set stack adjust count
+ movew %d1,%sp@(FR_ADJ) | set stack adjust count
movel (%sp),-(%sp) | push syscall no (original d0 value)
jbsr _C_LABEL(syscall) | re-enter syscall()
addql #4,%sp | pop syscall no
#ifdef DEBUG
- tstw %sp@(16*4+2) | stack adjust must be zero
+ tstw %sp@(FR_ADJ) | stack adjust must be zero
jeq .Ladjzero
PANIC("reenter_syscall")
.Ladjzero:
#endif
- moveal %sp@(15*4),%a0 | grab and restore
+ moveal %sp@(FR_SP),%a0 | grab and restore
movel %a0,%usp | user SP
+ movw %sp@(FR_ADJ),%d0 | need to adjust stack?
+ jne .Ladjstk | yes, go to it
moveml (%sp)+,#0x7FFF | restore user registers
addql #8,%sp | pop SP and stack adjust
jra _ASM_LABEL(rei) | rte
+.Ladjstk:
+ lea %sp@(FR_HW),%a1 | pointer to HW frame
+ addql #8,%a1 | source pointer
+ movl %a1,%a0 | source
+ addw %d0,%a0 | + hole size = dest pointer
+ movl %a1@-,%a0@- | copy
+ movl %a1@-,%a0@- | 8 bytes
+ movl %a0,%sp@(FR_SP) | new SSP
+ moveml %sp@+,#0x7FFF | restore user register
+ movl %sp@,%sp | and do real RTE
+ jra _ASM_LABEL(rei) | rte
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment