sparc64 mcount misaligned stack

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

 



Hi!

We continue to play with qemu, and it turned out that due to some
unknow issue the kernel built with stack overflow detection traps inside
error path out of mcount. The problem with that the following code in
arch/sparc/lib/mcount.S if we happen to jump at line 68 we have
%g3 = 0x4000 and then we assign that to stack pointer.

----
arch/sparc/lib/mcount.S:

   66         ldx             [%g3 + %g1], %g7
    67         cmp             %sp, %g7
    68         bleu,pt         %xcc, 2f
    69          sethi          %hi(THREAD_SIZE), %g3
    70         add             %g7, %g3, %g7
    71         cmp             %sp, %g7
    72         blu,pn          %xcc, 1f
    73          nop
    74         /* If we are already on ovstack, don't hop onto it
    75          * again, we are already trying to output the stack overflow
    76          * message.
    77          */
    78         sethi           %hi(ovstack), %g7               ! cant
move to panic stack fast enough
    79          or             %g7, %lo(ovstack), %g7
    80         add             %g7, OVSTACKSIZE, %g3
    81         sub             %g3, STACK_BIAS + 192, %g3
    82         sub             %g7, STACK_BIAS, %g7
    83         cmp             %sp, %g7
    84         blu,pn          %xcc, 2f
    85          cmp            %sp, %g3
    86         bleu,pn         %xcc, 1f
    87          nop
    88 2:      mov             %g3, %sp
    89         sethi           %hi(panicstring), %g3
    90         call            prom_printf
    91          or             %g3, %lo(panicstring), %o0
    92         call            prom_halt
    93          nop
----

A few steps later we take misaligned trap inside prom_printf
while accessing stack frame, please see qemu trace below.

Here is qemu trace:

----
IN: _mcount
0x0000000000545b34:  or  %g3, 0xb0, %o0 ! 0x70f8b0
IN: prom_printf
0x000000000053fa80:  save  %sp, -192, %sp
IN: prom_printf
0x000000000053fa84:  add  %fp, 0x887, %g1
IN: prom_printf
0x000000000053fa88:  sethi  %hi(0x788c00), %l0
IN: prom_printf
0x000000000053fa8c:  stx  %i1, [ %fp + 0x887 ]
107007: Unaligned Memory Access (v=0034) pc=000000000053fa8c
npc=000000000053fa90 SP=0000000000003f40
----

I wonder if mcount ever works on sparc64, if it does work indeed I'd
like to know what I'm missing there.
This is running on qemu-system-sparc64 so there is an opportunity to
have bug in emulation, but still misaligned stack pointer is evident.

-- 
Kind regards,
Igor V. Kovalenko
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Development]     [DCCP]     [Linux ARM Development]     [Linux]     [Photo]     [Yosemite Help]     [Linux ARM Kernel]     [Linux SCSI]     [Linux x86_64]     [Linux Hams]

  Powered by Linux