From: "Dmitry Adamushko" <dmitry.adamushko@gmail.com>
To: linux-mips@linux-mips.org
Cc: "Ralf Baechle" <ralf@linux-mips.org>,
"Dmitry Adamushko" <dmitry.adamushko@gmail.com>
Subject: unwind_stack() and an exception at the last instruction (after the epilogue)
Date: Wed, 13 Dec 2006 12:07:40 +0100 [thread overview]
Message-ID: <b647ffbd0612130307q4ea221d0l3daf34ef0048abcb@mail.gmail.com> (raw)
In-Reply-To: <b647ffbd0612121342y5b188be0o5ccce1b2c57a9725@mail.gmail.com>
[ 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
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?
Thanks in advance for any comments.
--
Best regards,
Dmitry Adamushko
next parent reply other threads:[~2006-12-13 11:07 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 ` Dmitry Adamushko [this message]
2006-12-13 11:54 ` unwind_stack() and an exception at the last instruction (after the epilogue) Thiemo Seufer
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=b647ffbd0612130307q4ea221d0l3daf34ef0048abcb@mail.gmail.com \
--to=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