qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Vince Weaver <vince@csl.cornell.edu>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] one more SPARC issue
Date: Wed, 6 Aug 2008 15:31:11 -0400 (EDT)	[thread overview]
Message-ID: <20080806152607.J61277@stanley.csl.cornell.edu> (raw)
In-Reply-To: <f43fc5580808060829w380c5beakcd01c8b69749be95@mail.gmail.com>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1343 bytes --]


I found one last SPARC issue, this time with the falign() function.

This one was a pain to track down because gdb won't let you show the %gsr 
register, or any of the floating point registers above %f32.

The falign code does this:

      tmp = (*((uint64_t *)&DT0)) << ((env->gsr & 7) * 8);
      tmp |= (*((uint64_t *)&DT1)) >> (64 - (env->gsr & 7) * 8);

But in the case where %gsr is zero, the second case turns into a
shift left of 64, which on many architectures turns into a no-op (rather 
than clearning the result to zero).

So in this case, the output of the falign was rs1 *or'd* with rs2, rather 
than just plain rs1.

I've included a patch below that fixes things for me, and I've also 
attached a test case that shows the bug.

With this, I can finally run the spec 2006 bzip2 benchmark to completion 
under sparc32plus-linux-user

Vince

--- op_helper.c.orig	2008-07-29 22:38:34.000000000 -0400
+++ op_helper.c	2008-08-06 15:24:51.000000000 -0400
@@ -234,7 +234,12 @@
      uint64_t tmp;

      tmp = (*((uint64_t *)&DT0)) << ((env->gsr & 7) * 8);
-    tmp |= (*((uint64_t *)&DT1)) >> (64 - (env->gsr & 7) * 8);
+ 
+       /* on many architectures a shift of 64 does nothing */
+    if ( (env->gsr & 7) !=0) {
+       tmp |= (*((uint64_t *)&DT1)) >> (64 - (env->gsr & 7) * 8);
+    }
+
      *((uint64_t *)&DT0) = tmp;
  }




[-- Attachment #2: Type: TEXT/PLAIN, Size: 2360 bytes --]

! compile with
! as -xarch=v8plusa -o falign_test.o falign_test.s ; 
! ld -o falign_test falign_test.o

!     + Syscalls have number in %g1, options in %o0,%o1,...
!	Result returned in %o0
!	Linux syscall is called by "ta 0x10"

.equ SYSCALL_EXIT,1	
.equ SYSCALL_WRITE,4

.equ STDOUT,1

	.globl _start
_start:


!  
! print the source!
!

       set	source,%o1
       call	write_stdout
       nop

!
! copy the string
!

      set	source,%o1      
      set	destination,%o0


      alignaddr  %o1, %g0, %o3
 
      membar  #StoreStore|#LoadStore|#StoreLoad
      wr  %g0, 0xf0, %asi		       		! set block-copy asi
      nop
      
      ldda  [ %o1 ] %asi, %f0
      nop
      
      faligndata  %f0, %f2, %f16
      faligndata  %f2, %f4, %f18
      faligndata  %f4, %f6, %f20
      faligndata  %f6, %f8, %f22
      faligndata  %f8, %f10, %f24
      faligndata  %f10, %f12, %f26
      faligndata  %f12, %f14, %f28
      faligndata  %f14, %f16, %f30
after:      
      stda  %f16, [ %o0 ] %asi

      nop
      nop
       
      

!
! print the copy
!
       
      set	destination,%o1
      call	write_stdout
      nop


      ba 	exit
      nop


	#================================
	# WRITE_STDOUT
	#================================
	# %o1 has string

write_stdout:

	set	SYSCALL_WRITE,%g1	! Write syscall in %g1
	set	STDOUT,%o0		! 1 in %o0 (stdout)
	set	0,%o2			! 0 (count) in %o2

str_loop1:
	ldub	[%o1+%o2],%l0		! load byte
	cmp	%l0,%g0			! compare against zero
	bnz	str_loop1		! if not nul, repeat
	# BRANCH DELAY SLOT
	inc	%o2			! increment count

	dec	%o2			! correct count	
	ta	0x10			! run the syscall
	retl				! return
	nop

exit:		
        mov	0,%o0			! exit value
        mov	SYSCALL_EXIT,%g1        ! put the exit syscall number in g1
        ta      0x10			! and exit




!===========================================================================
.data
!===========================================================================

.balign 64    !(needs to be on 64-byte boundary)

              !           1         2         3         4
              ! 0123456789012345678901234567890123456789012345678
source: .ascii "The quick brown fox jumped over "
        .ascii  "the lazy dog! Need more fill!\n\0"

.lcomm destination,64

[-- Attachment #3: Type: APPLICATION/octet-stream, Size: 1099 bytes --]

  reply	other threads:[~2008-08-06 19:31 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-29  3:32 [Qemu-devel] x86 tcg problem Vince Weaver
2008-07-29  8:46 ` Laurent Desnogues
2008-07-29 13:43   ` Vince Weaver
2008-07-29 18:24   ` malc
2008-07-29 18:33     ` Laurent Desnogues
2008-07-29 17:18 ` Blue Swirl
2008-08-05 20:20   ` [Qemu-devel] another SPARC issue Vince Weaver
2008-08-05 20:36     ` Laurent Desnogues
2008-08-06  2:33       ` Vince Weaver
2008-08-06  8:17         ` Laurent Desnogues
2008-08-06 15:29         ` Blue Swirl
2008-08-06 19:31           ` Vince Weaver [this message]
2008-08-06 19:45             ` [Qemu-devel] one more " Julian Seward
2008-08-06 19:55             ` Blue Swirl
2008-07-29 17:51 ` [Qemu-devel] x86 tcg problem Blue Swirl

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=20080806152607.J61277@stanley.csl.cornell.edu \
    --to=vince@csl.cornell.edu \
    --cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).