Subject: Re: syscall trap
To: Emmanuel Dreyfus <manu@netbsd.org>
From: Klaus Klein <kleink@reziprozitaet.de>
List: port-powerpc
Date: 11/25/2002 00:26:42
manu@netbsd.org (Emmanuel Dreyfus) writes:

> I tried the following patch , but it does not work (theses system calls
> are not ignored at all). Any idea why?


>         .globl  _C_LABEL(sctrap),_C_LABEL(scsize)
>  _C_LABEL(sctrap):
>         mtsprg  1,1                     /* save SP */
>         stmw    28,tempsave(0)          /* free r28-r31 */
> +#ifdef COMPAT_MACH
> +/*
> + * Handle the cthread Mach fast traps: Do nothing, but do it fast.
> + */
> +       li      28,0x7ff2       # cthread_info
> +       cmp     0,28
> +       beq     1f
> +       li      28,0x7ff1       # cthread_set_self
> +       cmp     0,28
> +       beq     1f
> +#endif
>         mflr    28                      /* save LR */
>         mfcr    29                      /* save CR */
>         bla     s_sctrap
>         _C_LABEL(scsize) = .-_C_LABEL(sctrap)

[You're not describing _how_ it does not work, but ...]

The branch instructions would appear to be your main problem. The
sctrap code is copied to and executed at the EXC_SC trap vector
address (see mpc6xx_machdep.c), so taking a relative branch to
s_sctrap doesn't work.

Also, FRAME_LEAVE() at that label (1) in s_sctrap would expect a prior
FRAME_SETUP(), thus clobbering some of the frame. For the purposes
testing your patch I'd suggest rfi'ing from sctrap itself.

In addition to that, making the comparisions before saving the CR will
clobber it.


- Klaus