Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/sys/arch/pmax/stand/common



Matt Thomas wrote:

> On Nov 25, 2010, at 2:20 PM, Simon Burge wrote:
> 
> > Matt Thomas wrote:
> > 
> >> On Nov 25, 2010, at 9:00 AM, Antti Kantee wrote:
> >> 
> >>> On Fri Nov 26 2010 at 01:50:11 +0900, Izumi Tsutsui wrote:
> >>>> but shouldn't we fix stub first, then discuss pros and blah of the 
> >>>> change?
> >>>> Current binaries have not worked at all on MIPS1 since the last December.
> >>> 
> >>> Like I said, I don't have strong feelings about this.
> >>> 
> >>> If you want to fix stubs, go for it!
> >>> (there's no need for a discussion after that, anyway, since the issue
> >>> is decided and fixed)
> >> 
> >> Please don't.  I've changed the mips1 syscall handler to save t0-t2
> >> just like the mips3+ handler does.
> > 
> > Why is it necessary to save three extra regs for every syscall, when
> > only two syscalls actually use t0?  Callers of the syscalls don't expect
> > t0-t3 to be saved.
> 
> Because N32/N64 requires that $gp be caller saved/restored.  Normally this
> would be done on the stack but we can't do that since that would mess up
> accessing stack based arguments.  So the other alternative is to save it
> in a temporary register.

http://cvsweb.NetBSD.org/bsdweb.cgi/src/lib/libc/arch/mips/SYS.h.diff?r1=1.18&r2=1.19
+# if defined(__mips_o32) || defined(__mips_o64)
+#  define PIC_PROLOGUE(x)      SETUP_GP
+#  define PIC_TAILCALL(l)      PTR_LA t9, _C_LABEL(l); jr t9
+#  define PIC_RETURN()         j ra
+# else
+#  define PIC_PROLOGUE(x)      SETUP_GP64(t3, x)
+#  define PIC_TAILCALL(l)      PTR_LA t9, _C_LABEL(l); RESTORE_GP64; jr t9
+#  define PIC_RETURN()         RESTORE_GP64; j ra
+# endif

http://cvsweb.NetBSD.org/bsdweb.cgi/src/sys/arch/mips/mips/mipsX_subr.S.diff?r1=1.34&r2=1.35

-       #REG_S  t0, FRAME_T0(k1)                # no need to save temp regs
-       #REG_S  t1, FRAME_T1(k1)
-       #REG_S  t2, FRAME_T2(k1)
-       #REG_S  t3, FRAME_T3(k1)
-       mfc0    a1, MIPS_COP_0_STATUS           # 2nd arg is STATUS

 :

+       move    s0, t0                          # since the saved registers have
+       move    s1, t1                          # been saved we can use them to
+       move    s2, t2                          # stash most of temporary regs
+       REG_S   t3, FRAME_T3(k1)                # syscall saved gp for fork
+       mfc0    a1, MIPS_COP_0_STATUS           # 2nd arg is STATUS

> > Also, why go to the effort of saving t0-t2 and not t3 as well?  Surely
> > that violates POLA?
> 
> Because it was wasn't needed.

t3 seems used to save $gp, but is it needed to save t0-t2 on MIPS3+?

Anyway if t0-t2 are saved but t3 not, it's bad idea to put
dumb optimization that assumes t0 is preserved in stubs
because such hacks will cause no benefit but annoying bugs
unless it's officially defined as ABI.

---
Izumi Tsutsui


Home | Main Index | Thread Index | Old Index