Linux PARISC architecture development
 help / color / mirror / Atom feed
From: Carlos O'Donell <carlos@baldric.uwo.ca>
To: John David Anglin <dave@hiauly1.hia.nrc.ca>
Cc: James.Bottomley@steeleye.com, dave.anglin@nrc-cnrc.gc.ca,
	parisc-linux@lists.parisc-linux.org
Subject: [parisc-linux] Found the r19 problem!
Date: Sun, 21 Sep 2003 11:45:01 -0400	[thread overview]
Message-ID: <20030921154501.GF6963@systemhalted> (raw)
In-Reply-To: <200309192010.h8JKAlHs004032@hiauly1.hia.nrc.ca>

On Fri, Sep 19, 2003 at 04:10:47PM -0400, John David Anglin wrote:
> > If it were major we would have fixed it :)
> > I'm trying to find the "missed a restore" point.
> 
> 0x4019063c:     stw r19,-20(sr0,sp)             # 2742
> 
> Just a note, GCC saves r19 in the frame marker in the prologue of
> non-leaf functions but we never attempt to restore r19 from the frame
> marker.  This is the mandated ABI behavior.  At the moment, GCC copies
> r19 to r4 for the save.

I would like to start this off with:
"JDA said don't put r19 into clobber list"

I didn't listen. I thought it should all still work.
James reports that removing r19 from the clobber list works, but I still
haven't rebuilt my tree, so I'll see.

Example (Assembly trace provided at the end):

getcwd: (Start of function)
	stw r19,-20(sr0,sp)
	...
syscall:
	(Syscall with save/load r19 wrapper)
	stw r19,-20(sr0,sp)
	be,l 100(sr2,r0),%sr0,%r31
	ldi 6e,r20
	ldw -20(sr0,sp),r19
	...
	(Many insn later)
	(stub) (dyncall) -> libpthread.so
	-> libc.so
	(r19 not restored)
	(Jump to syscall:)
	...

o GCC is confused by the r19 asm(...) clobber?

Notes:

I generated insn traces using gdb scripts.

  __pthread_mutex_unlock: 0x7730 <0x4018c730>	(In libpthread)
 __libc_malloc: 0x7f4a0 <0x400a34a0>		(In libc)

(return stub)
0x400a34a0:     b,l 0x400a33f8,r0
0x400a34a4:     copy r5,ret0

(__libc_malloc returning)
0x400a33f8:     ldw -54(sr0,sp),rp
0x400a33fc:     ldw -3c(sr0,sp),r5		(No need to restore r19)
0x400a3400:     ldw -38(sr0,sp),r4
0x400a3404:     ldw -34(sr0,sp),r3
0x400a3408:     bv r0(rp)			(Back to getcwd)
0x400a340c:     ldw,mb -40(sr0,sp),r6

getcwd: 0xdb128 <0x400ff128>
0x400ff128:     ldi 0,r21
0x400ff12c:     cmpib,<> 0,ret0,0x400ff034	(Jump back to do syscall)
0x400ff130:     copy ret0,r6

0x400ff034:     copy r3,r25
0x400ff038:     copy r6,r26
0x400ff03c:     stw r19,-20(sr0,sp)
0x400ff040:     be,l 100(sr2,r0),%sr0,%r31
0x400ff044:     ldi 6e,r20
0x400ff048:     ldw -20(sr0,sp),r19 (si gdb artifact, lost insn inside syscall)
0x400ff048:     ldw -20(sr0,sp),r19 
0x400ff04c:     ldi -1000,r20
0x400ff050:     cmpb,>>= r20,ret0,0x400ff070
0x400ff054:     copy ret0,r3

0x400ff070:     cmpib,>,n 0,r3,0x400ff0cc
0x400ff074:     cmpiclr,<> 0,r7,r21
0x400ff078:     ldi 1,r21
0x400ff07c:     cmpiclr,<> 0,r5,r20
0x400ff080:     ldi 1,r20
0x400ff084:     and r20,r21,r20
0x400ff088:     cmpib,<> 0,r20,0x400ff0bc
0x400ff08c:     copy r3,r25			(No r19 restore yet!!!)

(call stub)
0x400ff0bc:     b,l 0x40114e2c,rp
0x400ff0c0:     copy r6,r26

(stub)
0x40114e2c:     addil -1800,r19,%r1
0x40114e30:     ldw 428(sr0,r1),r21
0x40114e34:     bv r0(r21)
0x40114e38:     ldw 42c(sr0,r1),r19


getcwd: 0xdb0c0 <0x400ff0c0>
(stub) *BOOM*

Is there any way we can make this work?

c.

  reply	other threads:[~2003-09-21 15:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-19 13:56 [parisc-linux] r19 (aka pic-register akak ltp) not restored on entry back to libc from libpthread? Carlos O'Donell
2003-09-19 16:56 ` John David Anglin
2003-09-19 17:51   ` Carlos O'Donell
2003-09-19 18:26     ` James Bottomley
2003-09-19 18:55       ` [parisc-linux] r19 (aka pic-register akak ltp) not restored on John David Anglin
2003-09-19 19:28         ` Carlos O'Donell
2003-09-19 20:10           ` John David Anglin
2003-09-21 15:45             ` Carlos O'Donell [this message]
2003-09-21 16:39               ` [parisc-linux] Re: Found the r19 problem! John David Anglin
2003-09-21 18:53                 ` Carlos O'Donell
2003-09-21 18:55                   ` Carlos O'Donell
2003-09-21 19:12                     ` John David Anglin
2003-09-21 19:16                       ` Carlos O'Donell
2003-09-21 19:18                   ` John David Anglin

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=20030921154501.GF6963@systemhalted \
    --to=carlos@baldric.uwo.ca \
    --cc=James.Bottomley@steeleye.com \
    --cc=dave.anglin@nrc-cnrc.gc.ca \
    --cc=dave@hiauly1.hia.nrc.ca \
    --cc=parisc-linux@lists.parisc-linux.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