Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

register long sp asm("r1") incorrect

3 views
Skip to first unread message

Pavel Machek

unread,
Feb 9, 2010, 10:30:03 AM2/9/10
to

...according to gcc docs, sp should be global, or placement in
register is not guaranteed (except at asm boundaries, but there are
none).
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majo...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Benjamin Herrenschmidt

unread,
Feb 11, 2010, 12:40:01 AM2/11/10
to
On Tue, 2010-02-09 at 16:24 +0100, Pavel Machek wrote:
> ...according to gcc docs, sp should be global, or placement in
> register is not guaranteed (except at asm boundaries, but there are
> none).

Sorry I'm not sure I grok what you mean.

Cheers,
Ben.

Pavel Machek

unread,
Feb 15, 2010, 2:40:02 AM2/15/10
to
> On Tue, 2010-02-09 at 16:24 +0100, Pavel Machek wrote:
> > ...according to gcc docs, sp should be global, or placement in
> > register is not guaranteed (except at asm boundaries, but there are
> > none).
>
> Sorry I'm not sure I grok what you mean.

Well, according to gcc doscs and my experience, local "register int
__asm()" variables only work by accident (or not at all).

Benjamin Herrenschmidt

unread,
Feb 15, 2010, 3:10:02 PM2/15/10
to
On Mon, 2010-02-15 at 08:34 +0100, Pavel Machek wrote:
> > On Tue, 2010-02-09 at 16:24 +0100, Pavel Machek wrote:
> > > ...according to gcc docs, sp should be global, or placement in
> > > register is not guaranteed (except at asm boundaries, but there
> are
> > > none).
> >
> > Sorry I'm not sure I grok what you mean.
>
> Well, according to gcc doscs and my experience, local "register int
> __asm()" variables only work by accident (or not at all).

Hrm... we definitely rely on that for our thread_info() access, and so
far it has worked well for us, but I'll poke our gcc folks just in case.

Cheers,
Ben.

Pavel Machek

unread,
Feb 15, 2010, 3:30:01 PM2/15/10
to
On Tue 2010-02-16 06:59:52, Benjamin Herrenschmidt wrote:
> On Mon, 2010-02-15 at 08:34 +0100, Pavel Machek wrote:
> > > On Tue, 2010-02-09 at 16:24 +0100, Pavel Machek wrote:
> > > > ...according to gcc docs, sp should be global, or placement in
> > > > register is not guaranteed (except at asm boundaries, but there
> > are
> > > > none).
> > >
> > > Sorry I'm not sure I grok what you mean.
> >
> > Well, according to gcc doscs and my experience, local "register int
> > __asm()" variables only work by accident (or not at all).
>
> Hrm... we definitely rely on that for our thread_info() access, and so
> far it has worked well for us, but I'll poke our gcc folks just in case.

Thanks, and let me know about any results.

Benjamin Herrenschmidt

unread,
Feb 15, 2010, 4:10:03 PM2/15/10
to
On Mon, 2010-02-15 at 21:28 +0100, Pavel Machek wrote:
> On Tue 2010-02-16 06:59:52, Benjamin Herrenschmidt wrote:
> > On Mon, 2010-02-15 at 08:34 +0100, Pavel Machek wrote:
> > > > On Tue, 2010-02-09 at 16:24 +0100, Pavel Machek wrote:
> > > > > ...according to gcc docs, sp should be global, or placement in
> > > > > register is not guaranteed (except at asm boundaries, but there
> > > are
> > > > > none).
> > > >
> > > > Sorry I'm not sure I grok what you mean.
> > >
> > > Well, according to gcc doscs and my experience, local "register int
> > > __asm()" variables only work by accident (or not at all).
> >
> > Hrm... we definitely rely on that for our thread_info() access, and so
> > far it has worked well for us, but I'll poke our gcc folks just in case.
>
> Thanks, and let me know about any results.

All the gcc folks I talked to say something along the lines that there
is no way in hell it doesn't work :-)

It's true that most other use of it we have are global scope (local_paca
in r13, glibc use of r2/r13, etc...) afaik, but since r1 itself is the
stack pointer always, I think they pretty much guarantee it works.

I'm CCing a couple of experts just to be sure.

Cheers,
Ben.

H. Peter Anvin

unread,
Feb 15, 2010, 5:20:01 PM2/15/10
to
On 02/15/2010 01:04 PM, Benjamin Herrenschmidt wrote:
>
> It's true that most other use of it we have are global scope (local_paca
> in r13, glibc use of r2/r13, etc...) afaik, but since r1 itself is the
> stack pointer always, I think they pretty much guarantee it works.
>

It should work, because r1, being the stack pointer, is already marked a
reserved register in gcc.

The reference Pavel is citing bascially states that gcc won't globally
reserve the register, which is true, but it is already reserved anyway.

-hpa

--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.

Pavel Machek

unread,
Feb 19, 2010, 3:10:02 PM2/19/10
to
On Mon 2010-02-15 14:15:17, H. Peter Anvin wrote:
> On 02/15/2010 01:04 PM, Benjamin Herrenschmidt wrote:
> >
> > It's true that most other use of it we have are global scope (local_paca
> > in r13, glibc use of r2/r13, etc...) afaik, but since r1 itself is the
> > stack pointer always, I think they pretty much guarantee it works.
> >
>
> It should work, because r1, being the stack pointer, is already marked a
> reserved register in gcc.
>
> The reference Pavel is citing bascially states that gcc won't globally
> reserve the register, which is true, but it is already reserved anyway.

Ok, thanks for clarification.

0 new messages