Linux MIPS Architecture development
 help / color / mirror / Atom feed
* mips RDHWR instruction in glibc
@ 2006-06-14 15:12 Atsushi Nemoto
  2006-06-14 16:50 ` Daniel Jacobowitz
  0 siblings, 1 reply; 7+ messages in thread
From: Atsushi Nemoto @ 2006-06-14 15:12 UTC (permalink / raw)
  To: libc-ports; +Cc: linux-mips

I got many "Reserved Instruction" exceptions with gcc 4.1 + glibc 2.4
userland.  They were due to RDHWR instruction to support TLS.

If a system call returned an error, glibc must save the result to
errno, which is thread-local, so RDHWR used.  I can understand this
scenario.  But it seems the RDHWR is often called on non-error cases.

For example, in the code below, RDHWR is placed _before_ checking the
error.  I suppose these instructions were reordered by gcc's
optimization, but the optimization would have large negative effect in
this case.

00566fc4 <_IO_file_read>:
  566fc4:	3c1c0016 	lui	gp,0x16
  566fc8:	279c87ac 	addiu	gp,gp,-30804
  566fcc:	0399e021 	addu	gp,gp,t9
  566fd0:	8c82003c 	lw	v0,60(a0)
  566fd4:	30420002 	andi	v0,v0,0x2
  566fd8:	14400003 	bnez	v0,566fe8 <_IO_file_read+0x24>
  566fdc:	8f999e9c 	lw	t9,-24932(gp)
  566fe0:	03200008 	jr	t9
  566fe4:	8c840038 	lw	a0,56(a0)
  566fe8:	8c840038 	lw	a0,56(a0)
  566fec:	24020fa3 	li	v0,4003
  566ff0:	0000000c 	syscall
  566ff4:	8f84a528 	lw	a0,-23256(gp)
  566ff8:	7c03e83b 	rdhwr	v1,$29
  566ffc:	00832021 	addu	a0,a0,v1
  567000:	14e00003 	bnez	a3,567010 <_IO_file_read+0x4c>
  567004:	00401821 	move	v1,v0
  567008:	03e00008 	jr	ra
  56700c:	00601021 	move	v0,v1
  567010:	2403ffff 	li	v1,-1
  567014:	1000fffc 	b	567008 <_IO_file_read+0x44>
  567018:	ac820000 	sw	v0,0(a0)

I'm not sure where to fix, but I doubt some inline asm code in glibc
lack "volatile" keyword.

Does anyone have a clue on this?
---
Atsushi Nemoto

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-06-22  1:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-14 15:12 mips RDHWR instruction in glibc Atsushi Nemoto
2006-06-14 16:50 ` Daniel Jacobowitz
2006-06-15 15:28   ` Atsushi Nemoto
2006-06-15 15:32     ` Daniel Jacobowitz
2006-06-16 15:58       ` Atsushi Nemoto
2006-06-16 16:59         ` Atsushi Nemoto
2006-06-22  1:21         ` Atsushi Nemoto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox