From: Thiemo Seufer <ths@networkno.de>
To: Dmitry Adamushko <dmitry.adamushko@gmail.com>
Cc: linux-mips@linux-mips.org, Ralf Baechle <ralf@linux-mips.org>
Subject: Re: unwind_stack() and an exception at the last instruction (after the epilogue)
Date: Wed, 13 Dec 2006 11:54:38 +0000 [thread overview]
Message-ID: <20061213115438.GA25904@networkno.de> (raw)
In-Reply-To: <b647ffbd0612130307q4ea221d0l3daf34ef0048abcb@mail.gmail.com>
Dmitry Adamushko wrote:
> [ resend: probably, my previouse one had been rejected as it was not
> in plain-text :]
>
>
> Hello,
>
> unwind_stack() explicitly handles a case when an exception takes
> place at the first instruction, i.e. before the prologue.
>
> But what's about another corner case - when an exception is caused by
> an instruction placed after the epilogue.
>
> example:
>
> 00400e8c <cause_oops>:
> 400e8c: 3c1c0fc0 lui gp,0xfc0
> 400e90: 279c71c4 addiu gp,gp,29124
> 400e94: 0399e021 addu gp,gp,t9
> 400e98: 27bdffe0 addiu sp,sp,-32
> 400e9c: afbf0018 sw ra,24(sp)
> 400ea0: afbc0010 sw gp,16(sp)
> 400ea4: 8f84801c lw a0,-32740(gp)
> 400ea8: 8f9980ac lw t9,-32596(gp)
> 400eac: 00000000 nop
> 400eb0: 0320f809 jalr t9
> 400eb4: 24841984 addiu a0,a0,6532
> 400eb8: 8fbc0010 lw gp,16(sp)
> 400ebc: 8fbf0018 lw ra,24(sp)
> 400ec0: 27bd0020 addiu sp,sp,32
> 400ec4: 03e00008 jr ra
> 400ec8: ac000000 sw zero,0(zero)
> <----------- <epc> will be here when an exception happens
Was this example generated by a real world compiler? (Which one?)
> In this case, <sp> already points to the caller's stack frame so
> unwind_stack() will take a wrong assumption (as it looks at the
> epilogue of the callee).
>
> btw, the first and last instructions are just corner cases of an
> instruction being placed before the prologue and after the epilogue,
> right?
>
> so something like
>
> - if (unlikely(ofs == 0)) {
> + if (unlikely(offs == 0 || offs == size - sizeof_mips_instruction))
> pc = *ra;
> *ra = 0;
> return pc;
> }
>
> won't be a generic solution.
>
> Did I miss something? Hm... <epc> is always guaranted to be right
> when the instruction is in the branch delay slot?
>
> p.s. yep, the example is a part of user-space code (optimization:
> -Os) or is there anything (compiler options etc.) preventing similar
> code from being generated for kernel-space code?
I'm inclined to claim the example is broken WRT ABI rules since it
doesn't enclose the whole user code in the prologue/epilogue bracket.
Thiemo
next prev parent reply other threads:[~2006-12-13 12:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <b647ffbd0612121342y5b188be0o5ccce1b2c57a9725@mail.gmail.com>
2006-12-13 11:07 ` unwind_stack() and an exception at the last instruction (after the epilogue) Dmitry Adamushko
2006-12-13 11:54 ` Thiemo Seufer [this message]
2006-12-13 12:45 ` Dmitry Adamushko
2006-12-13 13:52 ` Thiemo Seufer
2006-12-13 14:40 ` Dmitry Adamushko
2006-12-13 16:16 ` Atsushi Nemoto
2006-12-14 1:47 ` Ralf Baechle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20061213115438.GA25904@networkno.de \
--to=ths@networkno.de \
--cc=dmitry.adamushko@gmail.com \
--cc=linux-mips@linux-mips.org \
--cc=ralf@linux-mips.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox