From: Jurij Smakov <jurij@wooyd.org>
To: sparclinux@vger.kernel.org
Subject: Re: longjmp question
Date: Wed, 12 Oct 2011 21:22:51 +0000 [thread overview]
Message-ID: <20111012212251.GA3135@wooyd.org> (raw)
In-Reply-To: <20111007232209.GA11892@wooyd.org>
On Sat, Oct 08, 2011 at 03:22:51PM -0400, David Miller wrote:
> From: Jurij Smakov <jurij@wooyd.org>
> Date: Sat, 8 Oct 2011 13:55:35 +0100
>
> > On Sat, Oct 08, 2011 at 02:43:55AM -0400, David Miller wrote:
> >> @@ -67,15 +67,13 @@ LOC(thread):
> >> #ifdef PTR_DEMANGLE
> >> ld ENV(g1,JB_PC), %g5 /* Set return PC. */
> >> ld ENV(g1,JB_SP), %g1 /* Set saved SP on restore below. */
> >> - PTR_DEMANGLE2 (%o7, %g5, %g4)
> >> + PTR_DEMANGLE2 (%i7, %g5, %g4)
> >> PTR_DEMANGLE2 (%fp, %g1, %g4)
> >> #else
> >> - ld ENV(g1,JB_PC), %o7 /* Set return PC. */
> >> + ld ENV(g1,JB_PC), %i7 /* Set return PC. */
> >> ld ENV(g1,JB_SP), %fp /* Set saved SP on restore below. */
> >> #endif
> >> - sub %fp, 64, %sp /* Allocate a register frame. */
> >> - st %g3, RW_FP /* Set saved FP on restore below. */
> >> - retl
> >> + jmp %i7 + 8
> >> restore %g2, 0, %o0 /* Restore values from above register frame. */
> >
> > I don't really see anything in the code which would ensure that after
> > we execute this restore, fp is going to be set to target fp value
> > (available as ENV(g1,JB_FP) or g3. It might be the responsibility of
> > the unwinding part, but then it would not explain why such code was
> > explicitly present in the old version.
>
> Because the restore traps, causing a window fill, and that trap
> handler will load up the register window at JB_SP, inside of which
> JB_FP is contained.
>
> The only reason we store JB_FP is for the implementation the optimized
> longjmp loop.
Thanks for the explanation.
I've built eglibc with this patch, and nothing exploded in an obvious
way. Ruby test is still failing though, so I'm pretty sure now that
this was not a problem even before the patch.
On an unrelated note, I was not able to decipher what's the purpose of
the following code in __longjmp:
0:
xor %fp, %g3, %o0
add %fp, 512, %o1
andncc %o0, 4095, %o0
bne LOC(thread)
cmp %o1, %g3
bl LOC(thread)
It looks like this code is *very* old (was added back in 1998, it
seems [0]), so I was not able to find any description for it. If you
don't mind explaining what's going on here, I would appreciate it.
[0] http://lwn.net/1998/1022/a/sparc-glibc-patch.html
Best regards,
--
Jurij Smakov jurij@wooyd.org
Key: http://www.wooyd.org/pgpkey/ KeyID: C99E03CC
next prev parent reply other threads:[~2011-10-12 21:22 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-07 23:22 longjmp question Jurij Smakov
2011-10-07 23:42 ` David Miller
2011-10-08 6:43 ` David Miller
2011-10-08 12:55 ` Jurij Smakov
2011-10-08 19:22 ` David Miller
2011-10-12 21:22 ` Jurij Smakov [this message]
2011-10-12 22:09 ` David Miller
2011-10-12 22:17 ` David Miller
2011-10-12 23:06 ` David Miller
2011-10-12 23:21 ` Jurij Smakov
2011-10-12 23:42 ` David Miller
2011-10-13 22:06 ` Jurij Smakov
2011-10-13 22:35 ` David Miller
2011-10-14 23:06 ` Jurij Smakov
2011-10-14 23:26 ` David Miller
2011-10-16 17:07 ` Jurij Smakov
2011-10-17 0:56 ` David Miller
2011-10-18 20:46 ` Jurij Smakov
2011-10-18 20:53 ` David Miller
2011-10-22 9:00 ` Jurij Smakov
2011-10-22 9:05 ` David Miller
2011-10-22 9:43 ` Jurij Smakov
2011-10-22 22:54 ` David Miller
2011-10-23 13:47 ` Jurij Smakov
2011-10-23 20:35 ` David Miller
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=20111012212251.GA3135@wooyd.org \
--to=jurij@wooyd.org \
--cc=sparclinux@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.