From: Jun Sun <jsun@mvista.com>
To: Thiemo Seufer <ica2_ts@csv.ica.uni-stuttgart.de>
Cc: Ralf Baechle <ralf@linux-mips.org>,
David Daney <ddaney@avtrex.com>,
"Maciej W. Rozycki" <macro@ds2.pg.gda.pl>,
linux-mips@linux-mips.org, jsun@mvista.com
Subject: Re: [patch] Prevent dead code/data removal with gcc 3.4
Date: Fri, 13 Feb 2004 22:13:53 -0800 [thread overview]
Message-ID: <20040214061353.GA21449@mvista.com> (raw)
In-Reply-To: <20040214021740.GE20118@rembrandt.csv.ica.uni-stuttgart.de>
On Sat, Feb 14, 2004 at 03:17:40AM +0100, Thiemo Seufer wrote:
> Ralf Baechle wrote:
> [snip]
> > Anyway, gcc could load next weeks lucky lottery numbers into the
> > s-registers after saving them. That'd break save_static but not the
> > ABI which only promises to restore the old values in s-registers on
> > return.
>
> Ok, it could, but adding such insns to the prologue wouldn't make
> sense at all, so this is unlikely to happen.
>
OS people who have been around long enough know "unlikely" things
always end up happening. :)
See my posting around Oct 2000 below. Granted - gcc has changed a lot
and perhaps it won't do it again. But just like a Chinese saying,
"Once bitten by the snake, afraid of the straw rope for three years". :)
I like the safe alternative.
Jun
P.S., the actual fix was done by Ralf
http://www.linux-mips.org/xcvs/linux-mips/patches/001282_001027_MAIN_ralf
------------------------------------------------------------------
Nasty degree - 3 days of tracking.
The symptom was pthread cannot be created. In the end the caller will
get a BUS error.
What exactly happened has to do with how registers are saved. Below
attached is the beginning part of sys_sigsuspend() function. It is easy
to see that s0 is saved into stack frame AFTER its modified. Next time
when process returns to userland, the s0 reg will be wrong!
So the bug is either
1) that we need to save s0 register in SAVE_SOME and not save it in
save_static; or that
2) we fix compiler so that it does not use s0 register in that case (it
does the same thing for sys_rt_sigsuspend)
I am sure Ralf will have something to say about it. :-) In any case, I
attached a patch for 1) fix.
Jun
------------
sys_sigsuspend(struct pt_regs regs)
{
8008e280: 27bdffc0 addiu $sp,$sp,-64
8008e284: afb00030 sw $s0,48($sp)
sigset_t *uset, saveset, newset;
save_static(®s);
8008e288: 27b00040 addiu $s0,$sp,64
8008e28c: afbf003c sw $ra,60($sp)
8008e290: afb20038 sw $s2,56($sp)
8008e294: afb10034 sw $s1,52($sp)
8008e298: afa40040 sw $a0,64($sp)
8008e29c: afa50044 sw $a1,68($sp)
8008e2a0: afa60048 sw $a2,72($sp)
8008e2a4: afa7004c sw $a3,76($sp)
8008e2a8: ae100058 sw $s0,88($s0)
8008e2ac: ae11005c sw $s1,92($s0)
.....
next prev parent reply other threads:[~2004-02-14 6:14 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-13 14:20 [patch] Prevent dead code/data removal with gcc 3.4 Maciej W. Rozycki
2004-02-13 14:53 ` Ralf Baechle
2004-02-13 17:51 ` Jun Sun
2004-02-13 18:35 ` Maciej W. Rozycki
2004-02-13 22:07 ` Ralf Baechle
2004-02-16 9:18 ` Maciej W. Rozycki
2004-02-13 22:22 ` Thiemo Seufer
2004-02-13 22:35 ` David Daney
2004-02-13 22:50 ` Thiemo Seufer
2004-02-14 1:15 ` Ralf Baechle
2004-02-14 1:22 ` Eric Christopher
2004-02-14 1:28 ` Thiemo Seufer
2004-02-14 1:45 ` Ralf Baechle
2004-02-14 2:17 ` Thiemo Seufer
2004-02-14 6:13 ` Jun Sun [this message]
2004-02-14 6:28 ` Thiemo Seufer
2004-02-15 1:44 ` Daniel Jacobowitz
2004-02-17 12:50 ` Maciej W. Rozycki
2004-06-28 13:12 ` Maciej W. Rozycki
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=20040214061353.GA21449@mvista.com \
--to=jsun@mvista.com \
--cc=ddaney@avtrex.com \
--cc=ica2_ts@csv.ica.uni-stuttgart.de \
--cc=linux-mips@linux-mips.org \
--cc=macro@ds2.pg.gda.pl \
--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