Skip to contentSkip to conversation

target-sparc/TODO

Qemu-devel Artyom Tarasenko 4 participants 17 messages Aug 17, 2009 – Aug 22, 2009

lore
Share & tools
lore
#0 lore raw
Quoted 2 lines

- Global register for regwptr, so that windowed registers can be accessed directly

looks like it's already implemented?

Quoted 1 line

- Synthetic instructions

Is it still open?

Quoted 1 line

- Hardware breakpoint/watchpoint support

Is it still open?

#1 lore raw
Quoted 4 lines · Artyom Tarasenko
Quoted 2 lines

- Global register for regwptr, so that windowed registers can be accessed directly

looks like it's already implemented?

No, this means that a global register (TCG_AREG1) would be designated as regwptr, so that the window registers (%o, %l, %i) would be defined with:

cpu_wregs[i] = tcg_global_mem_new(TCG_AREG1, offsetof(...), name).

This would need some changes to cwp handling to support TCG_AREG1, maybe also to TCG prologue.

Before TCG, this was difficult because the registers were taken by cpu_T0, cpu_T1 and cpu_T2.

But it's not clear if this gives any performance gain, because although window registers accesses may get faster (this is also not certain because CPUstate should reside in cache), there is one host register less available and that may mean more host memory accesses.

Quoted 2 lines
Quoted 1 line

- Synthetic instructions

Is it still open?

We already handle 'clr' and 'mov'. Code generation is not optimal, for example arithmetic ops with constants/%g0 or things like wrpsr which always does a XOR of the parameters even if they are constants or %g0.

Quoted 2 lines
Quoted 1 line

- Hardware breakpoint/watchpoint support

Is it still open?

I think support for these was only found in a few CPU models, so they are not used much. Nobody has also shown any interest or provided a test case.

#2 lore raw

2009/8/17 Blue Swirl <[email protected]>:

Quoted 16 lines
Quoted 4 lines · Artyom Tarasenko
Quoted 2 lines

- Global register for regwptr, so that windowed registers can be accessed directly

looks like it's already implemented?

No, this means that a global register (TCG_AREG1) would be designated as regwptr, so that the window registers (%o, %l, %i) would be defined with:

cpu_wregs[i] = tcg_global_mem_new(TCG_AREG1, offsetof(...), name).

This would need some changes to cwp handling to support TCG_AREG1, maybe also to TCG prologue.

Quoted 7 lines

Before TCG, this was difficult because the registers were taken by cpu_T0, cpu_T1 and cpu_T2.

But it's not clear if this gives any performance gain, because although window registers accesses may get faster (this is also not certain because CPUstate should reside in cache), there is one host register less available and that may mean more host memory accesses.

So, it's only about performance, otherwise the current implementation is complete?

Quoted 6 lines
Quoted 2 lines
Quoted 1 line

- Synthetic instructions

Is it still open?

We already handle 'clr' and 'mov'. Code generation is not optimal, for example arithmetic ops with constants/%g0 or things like wrpsr which always does a XOR of the parameters even if they are constants or %g0.

Would the synthetic ops with %g0 produce wrong results? Particularly I'm interested if

jmp %l1, %g4, %g0

may behave other than on a real hw.

Quoted 6 lines
Quoted 2 lines
Quoted 1 line

- Hardware breakpoint/watchpoint support

Is it still open?

I think support for these was only found in a few CPU models, so they are not used much. Nobody has also shown any interest or provided a test case.

On OBP start-up I see some "write breakpoint reg" messages in the debug log. Do they have to do with hardware breakpoint support?

#3 lore raw
Quoted 20 lines · Artyom Tarasenko

2009/8/17 Blue Swirl <[email protected]>:

Quoted 19 lines
Quoted 4 lines · Artyom Tarasenko
Quoted 2 lines

- Global register for regwptr, so that windowed registers can be accessed directly

looks like it's already implemented?

No, this means that a global register (TCG_AREG1) would be designated as regwptr, so that the window registers (%o, %l, %i) would be defined with:

cpu_wregs[i] = tcg_global_mem_new(TCG_AREG1, offsetof(...), name).

This would need some changes to cwp handling to support TCG_AREG1, maybe also to TCG prologue.

Before TCG, this was difficult because the registers were taken by cpu_T0, cpu_T1 and cpu_T2.

Quoted 7 lines
Quoted 4 lines

But it's not clear if this gives any performance gain, because although window registers accesses may get faster (this is also not certain because CPUstate should reside in cache), there is one host register less available and that may mean more host memory accesses.

So, it's only about performance, otherwise the current implementation is complete?

Yes. Sparc64/V9 side is less complete.

Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
Quoted 1 line

- Synthetic instructions

Is it still open?

We already handle 'clr' and 'mov'. Code generation is not optimal, for example arithmetic ops with constants/%g0 or things like wrpsr which always does a XOR of the parameters even if they are constants or %g0.

Quoted 6 lines

Would the synthetic ops with %g0 produce wrong results? Particularly I'm interested if

jmp     %l1, %g4, %g0

may behave other than on a real hw.

No, if rd is %g0, the current PC will not be written anywhere (not by real HW either). This is handled by translate.c:4041 call to gen_movl_TN_reg(), which suppresses the move if rd is zero. Likewise for other rd writeback.

This class of instructions ("op %x, %y, %g0") should be close to optimal except for degenerate cases like "and %g1, 1, %g0" which should not generate any code at all. "andcc %g1, 1, %g0" should and it does.

I meant that "wrpsr %g1, 0" (or %g0) should suppress the useless XOR of %g1 and 0.

Quoted 11 lines
Quoted 6 lines
Quoted 2 lines
Quoted 1 line

- Hardware breakpoint/watchpoint support

Is it still open?

I think support for these was only found in a few CPU models, so they are not used much. Nobody has also shown any interest or provided a test case.

On OBP start-up I see some "write breakpoint reg" messages in the debug log. Do they have to do with hardware breakpoint support?

Yes, or they could also be MMU breakpoint registers.

#4 lore raw
Quoted 8 lines
Quoted 5 lines

Particularly I'm interested if

jmp     %l1, %g4, %g0

may behave other than on a real hw.

No, if rd is %g0, the current PC will not be written anywhere (not by real HW either).

The reason I asked is the two following pieces of code work differently on a real and emulated SS-5. On a real one spacel! does an asi write, and spacel@ does an asi read, and under qemu spacel! seems to do nothing, and spacel@ returns its second parameter multiplied by
4. Both of them don't even try to call an [unimplemented] asi operation, I've runned the tests with mmu and asi debug turned on.

Real SS-5:

ok 0 0 spacel@ .
Data Access Error
ok 0 20 spacel@ .
0
ok 12345678 0 20 spacel!
ok 0 20 spacel@ .
12345678
ok

qemu SS-5:

ok 0 0 spacel@ .
0
ok 0 20 spacel@ .
80
ok 12345678 0 20 spacel!
ok 0 20 spacel@ .
80
ok

I don't know sparc asm good enogh, but qemu behavior seems to be
logical: in the first case I see no store op, and there are shifts which would multiply by 4:

ok see spacel!
code spacel!

ffd26e0c     ld      [%g7], %l2
ffd26e10     add     %g7, 4, %g7
ffd26e14     ld      [%g7], %l0
ffd26e18     add     %g7, 4, %g7
ffd26e1c     sll     %g4, 2, %g4
ffd26e20     call    ffd26e24
ffd26e24     add     %g0, 14, %l1

ok ffd26e24 dis

ffd26e24     add     %g0, 14, %l1
ffd26e28     add     %o7, %l1, %l1
ffd26e2c     jmp     %l1, %g4, %g0
ffd26e30     ba      ffd26f68

ok

ok see spacel@
code spacel@

ffd26830     ld      [%g7], %l0
ffd26834     add     %g7, 4, %g7
ffd26838     sll     %g4, 2, %g4
ffd2683c     call    ffd26840
ffd26840     add     %g0, 14, %l1

ok ffd26840 dis

ffd26840     add     %g0, 14, %l1
ffd26844     add     %o7, %l1, %l1
ffd26848     jmp     %l1, %g4, %g0
ffd2684c     ba      ffd26984

The code is identical on a real and emulated SS.

It must be the jump, which jumps differently on a real hw and under qemu. Do you see from the code where the jump would jump to, or maybe you have a suggestion how to check where the jump jumps to on the real hw?

#5 lore raw
Quoted 75 lines · Artyom Tarasenko
Quoted 8 lines
Quoted 5 lines

Particularly I'm interested if

jmp     %l1, %g4, %g0

may behave other than on a real hw.

No, if rd is %g0, the current PC will not be written anywhere (not by real HW either).

The reason I asked is the two following pieces of code work differently on a real and emulated SS-5. On a real one spacel! does an asi write, and spacel@ does an asi read, and under qemu  spacel! seems to do nothing, and spacel@ returns its second parameter multiplied by
4. Both of them don't even try to call an [unimplemented] asi operation, I've runned the tests with mmu and asi debug turned on.

Real SS-5:

ok 0 0 spacel@ .
Data Access Error
ok 0 20 spacel@ .
0
ok 12345678 0 20 spacel!
ok 0 20 spacel@ .
12345678
ok

qemu SS-5:

ok 0 0 spacel@ .
0
ok 0 20 spacel@ .
80
ok 12345678 0 20 spacel!
ok 0 20 spacel@ .
80
ok

I don't know sparc asm good enogh, but qemu behavior seems to be
logical: in the first case I see no store op, and there are shifts which would multiply by 4:

ok see spacel!
code spacel!
ffd26e0c     ld      [%g7], %l2
ffd26e10     add     %g7, 4, %g7
ffd26e14     ld      [%g7], %l0
ffd26e18     add     %g7, 4, %g7
ffd26e1c     sll     %g4, 2, %g4
ffd26e20     call    ffd26e24
ffd26e24     add     %g0, 14, %l1

ok ffd26e24 dis
ffd26e24     add     %g0, 14, %l1
ffd26e28     add     %o7, %l1, %l1
ffd26e2c     jmp     %l1, %g4, %g0
ffd26e30     ba      ffd26f68
ok

ok see spacel@
code spacel@
ffd26830     ld      [%g7], %l0
ffd26834     add     %g7, 4, %g7
ffd26838     sll     %g4, 2, %g4
ffd2683c     call    ffd26840
ffd26840     add     %g0, 14, %l1

ok ffd26840 dis
ffd26840     add     %g0, 14, %l1
ffd26844     add     %o7, %l1, %l1
ffd26848     jmp     %l1, %g4, %g0
ffd2684c     ba      ffd26984

Quoted 6 lines

The code is identical on a real and emulated SS.

It must be the jump, which jumps differently on a real hw and under qemu. Do you see from the code where the jump would jump to, or maybe you have a suggestion how to check where the jump jumps to on the real hw?

The target of the call instruction is also a delay slot instruction for the call itself. Maybe this case is not handled correctly?

#6 lore raw

2009/8/20 Blue Swirl <[email protected]>:

Quoted 79 lines
Quoted 77 lines · Artyom Tarasenko
Quoted 8 lines
Quoted 5 lines

Particularly I'm interested if

jmp     %l1, %g4, %g0

may behave other than on a real hw.

No, if rd is %g0, the current PC will not be written anywhere (not by real HW either).

The reason I asked is the two following pieces of code work differently on a real and emulated SS-5. On a real one spacel! does an asi write, and spacel@ does an asi read, and under qemu  spacel! seems to do nothing, and spacel@ returns its second parameter multiplied by
4. Both of them don't even try to call an [unimplemented] asi operation, I've runned the tests with mmu and asi debug turned on.

Real SS-5:

ok 0 0 spacel@ .
Data Access Error
ok 0 20 spacel@ .
0
ok 12345678 0 20 spacel!
ok 0 20 spacel@ .
12345678
ok

qemu SS-5:

ok 0 0 spacel@ .
0
ok 0 20 spacel@ .
80
ok 12345678 0 20 spacel!
ok 0 20 spacel@ .
80
ok

I don't know sparc asm good enogh, but qemu behavior seems to be
logical: in the first case I see no store op, and there are shifts which would multiply by 4:

ok see spacel!
code spacel!
ffd26e0c     ld      [%g7], %l2
ffd26e10     add     %g7, 4, %g7
ffd26e14     ld      [%g7], %l0
ffd26e18     add     %g7, 4, %g7
ffd26e1c     sll     %g4, 2, %g4
ffd26e20     call    ffd26e24
ffd26e24     add     %g0, 14, %l1

ok ffd26e24 dis
ffd26e24     add     %g0, 14, %l1
ffd26e28     add     %o7, %l1, %l1
ffd26e2c     jmp     %l1, %g4, %g0
ffd26e30     ba      ffd26f68
ok

ok see spacel@
code spacel@
ffd26830     ld      [%g7], %l0
ffd26834     add     %g7, 4, %g7
ffd26838     sll     %g4, 2, %g4
ffd2683c     call    ffd26840
ffd26840     add     %g0, 14, %l1

ok ffd26840 dis
ffd26840     add     %g0, 14, %l1
ffd26844     add     %o7, %l1, %l1
ffd26848     jmp     %l1, %g4, %g0
ffd2684c     ba      ffd26984

The code is identical on a real and emulated SS.

Quoted 7 lines
Quoted 4 lines

It must be the jump, which jumps differently on a real hw and under qemu. Do you see from the code where the jump would jump to, or maybe you have a suggestion how to check where the jump jumps to on the real hw?

The target of the call instruction is also a delay slot instruction for the call itself. Maybe this case is not handled correctly?

Good idea! Don't know how to test it though.

And what about "ba" in the delay slot of "jmp"? Is the correct behavior described somewhere? Would jump just be ignored? Whould it execute one instruction on jump destination and then branch? Would branch be ignored?

#7 lore raw

2009/8/21 Artyom Tarasenko <[email protected]>:

Quoted 88 lines

2009/8/20 Blue Swirl <[email protected]>:

Quoted 79 lines
Quoted 77 lines · Artyom Tarasenko
Quoted 8 lines
Quoted 5 lines

Particularly I'm interested if

jmp     %l1, %g4, %g0

may behave other than on a real hw.

No, if rd is %g0, the current PC will not be written anywhere (not by real HW either).

The reason I asked is the two following pieces of code work differently on a real and emulated SS-5. On a real one spacel! does an asi write, and spacel@ does an asi read, and under qemu  spacel! seems to do nothing, and spacel@ returns its second parameter multiplied by
4. Both of them don't even try to call an [unimplemented] asi operation, I've runned the tests with mmu and asi debug turned on.

Real SS-5:

ok 0 0 spacel@ .
Data Access Error
ok 0 20 spacel@ .
0
ok 12345678 0 20 spacel!
ok 0 20 spacel@ .
12345678
ok

qemu SS-5:

ok 0 0 spacel@ .
0
ok 0 20 spacel@ .
80
ok 12345678 0 20 spacel!
ok 0 20 spacel@ .
80
ok

I don't know sparc asm good enogh, but qemu behavior seems to be
logical: in the first case I see no store op, and there are shifts which would multiply by 4:

ok see spacel!
code spacel!
ffd26e0c     ld      [%g7], %l2
ffd26e10     add     %g7, 4, %g7
ffd26e14     ld      [%g7], %l0
ffd26e18     add     %g7, 4, %g7
ffd26e1c     sll     %g4, 2, %g4
ffd26e20     call    ffd26e24
ffd26e24     add     %g0, 14, %l1

ok ffd26e24 dis
ffd26e24     add     %g0, 14, %l1
ffd26e28     add     %o7, %l1, %l1
ffd26e2c     jmp     %l1, %g4, %g0
ffd26e30     ba      ffd26f68
ok

ok see spacel@
code spacel@
ffd26830     ld      [%g7], %l0
ffd26834     add     %g7, 4, %g7
ffd26838     sll     %g4, 2, %g4
ffd2683c     call    ffd26840
ffd26840     add     %g0, 14, %l1

ok ffd26840 dis
ffd26840     add     %g0, 14, %l1
ffd26844     add     %o7, %l1, %l1
ffd26848     jmp     %l1, %g4, %g0
ffd2684c     ba      ffd26984

The code is identical on a real and emulated SS.

Quoted 7 lines
Quoted 4 lines

It must be the jump, which jumps differently on a real hw and under qemu. Do you see from the code where the jump would jump to, or maybe you have a suggestion how to check where the jump jumps to on the real hw?

The target of the call instruction is also a delay slot instruction for the call itself. Maybe this case is not handled correctly?

Quoted 6 lines

Good idea! Don't know how to test it though.

And what about "ba" in the delay slot of "jmp"? Is the correct behavior described somewhere? Would jump just be ignored? Whould it execute one instruction on jump destination and then branch? Would branch be ignored?

Page 55 of The SPARC v8 Architecture Manual
(http://www.sparc.org/standards/V8.pdf) describes this case explicitly:
cpu should execute one instruction on the jump target and then branch.
Is it what qemu currently does?

I guess gcc doesn't generate such constructs, so linux & Co wouldn't notice if this behavior is not implemented as specified.

#8 lore raw
Quoted 96 lines · Artyom Tarasenko

2009/8/21 Artyom Tarasenko <[email protected]>:

Quoted 88 lines

2009/8/20 Blue Swirl <[email protected]>:

Quoted 79 lines
Quoted 77 lines · Artyom Tarasenko
Quoted 8 lines
Quoted 5 lines

Particularly I'm interested if

jmp     %l1, %g4, %g0

may behave other than on a real hw.

No, if rd is %g0, the current PC will not be written anywhere (not by real HW either).

The reason I asked is the two following pieces of code work differently on a real and emulated SS-5. On a real one spacel! does an asi write, and spacel@ does an asi read, and under qemu  spacel! seems to do nothing, and spacel@ returns its second parameter multiplied by
4. Both of them don't even try to call an [unimplemented] asi operation, I've runned the tests with mmu and asi debug turned on.

Real SS-5:

ok 0 0 spacel@ .
Data Access Error
ok 0 20 spacel@ .
0
ok 12345678 0 20 spacel!
ok 0 20 spacel@ .
12345678
ok

qemu SS-5:

ok 0 0 spacel@ .
0
ok 0 20 spacel@ .
80
ok 12345678 0 20 spacel!
ok 0 20 spacel@ .
80
ok

I don't know sparc asm good enogh, but qemu behavior seems to be
logical: in the first case I see no store op, and there are shifts which would multiply by 4:

ok see spacel!
code spacel!
ffd26e0c     ld      [%g7], %l2
ffd26e10     add     %g7, 4, %g7
ffd26e14     ld      [%g7], %l0
ffd26e18     add     %g7, 4, %g7
ffd26e1c     sll     %g4, 2, %g4
ffd26e20     call    ffd26e24
ffd26e24     add     %g0, 14, %l1

ok ffd26e24 dis
ffd26e24     add     %g0, 14, %l1
ffd26e28     add     %o7, %l1, %l1
ffd26e2c     jmp     %l1, %g4, %g0
ffd26e30     ba      ffd26f68
ok

ok see spacel@
code spacel@
ffd26830     ld      [%g7], %l0
ffd26834     add     %g7, 4, %g7
ffd26838     sll     %g4, 2, %g4
ffd2683c     call    ffd26840
ffd26840     add     %g0, 14, %l1

ok ffd26840 dis
ffd26840     add     %g0, 14, %l1
ffd26844     add     %o7, %l1, %l1
ffd26848     jmp     %l1, %g4, %g0
ffd2684c     ba      ffd26984

The code is identical on a real and emulated SS.

Quoted 7 lines
Quoted 4 lines

It must be the jump, which jumps differently on a real hw and under qemu. Do you see from the code where the jump would jump to, or maybe you have a suggestion how to check where the jump jumps to on the real hw?

The target of the call instruction is also a delay slot instruction for the call itself. Maybe this case is not handled correctly?

Quoted 6 lines

Good idea! Don't know how to test it though.

And what about "ba" in the delay slot of "jmp"? Is the correct behavior described somewhere? Would jump just be ignored? Whould it execute one instruction on jump destination and then branch? Would branch be ignored?

Quoted 5 lines

Page 55 of The SPARC v8 Architecture Manual
(http://www.sparc.org/standards/V8.pdf) describes this case explicitly:
cpu should execute one instruction on the jump target and then branch. Is it what qemu currently does?

I may be blind, I don't see the description of this case in that page. However, I made a small Linux test program to test it:
.global _start
.type _start, function
_start:

    mov 1, %o0
    call 1f

#ifdef NOP
nop
#endif
1: inc %o0

    mov 1, %g1
    ta 0x10

(and a BSD version:
#include <sys/syscall.h>

.globl _start
_start:

    mov 1, %o0
    call 1f

#ifdef NOP
nop
#endif
1: inc %o0
mov SYS_exit, %g1
ta 0
)

Both QEMU and real (Sparc64) hardware exit with return value of 3, so the inc is re-executed. If I add a nop in the call delay slot, the return value is 2.

#9 lore raw

2009/8/21 Blue Swirl <[email protected]>:

Quoted 98 lines
Quoted 96 lines · Artyom Tarasenko

2009/8/21 Artyom Tarasenko <[email protected]>:

Quoted 94 lines

2009/8/20 Blue Swirl <[email protected]>:

Quoted 79 lines
Quoted 77 lines · Artyom Tarasenko
Quoted 8 lines
Quoted 5 lines

Particularly I'm interested if

jmp     %l1, %g4, %g0

may behave other than on a real hw.

No, if rd is %g0, the current PC will not be written anywhere (not by real HW either).

The reason I asked is the two following pieces of code work differently on a real and emulated SS-5. On a real one spacel! does an asi write, and spacel@ does an asi read, and under qemu  spacel! seems to do nothing, and spacel@ returns its second parameter multiplied by
4. Both of them don't even try to call an [unimplemented] asi operation, I've runned the tests with mmu and asi debug turned on.

Real SS-5:

ok 0 0 spacel@ .
Data Access Error
ok 0 20 spacel@ .
0
ok 12345678 0 20 spacel!
ok 0 20 spacel@ .
12345678
ok

qemu SS-5:

ok 0 0 spacel@ .
0
ok 0 20 spacel@ .
80
ok 12345678 0 20 spacel!
ok 0 20 spacel@ .
80
ok

I don't know sparc asm good enogh, but qemu behavior seems to be
logical: in the first case I see no store op, and there are shifts which would multiply by 4:

ok see spacel!
code spacel!
ffd26e0c     ld      [%g7], %l2
ffd26e10     add     %g7, 4, %g7
ffd26e14     ld      [%g7], %l0
ffd26e18     add     %g7, 4, %g7
ffd26e1c     sll     %g4, 2, %g4
ffd26e20     call    ffd26e24
ffd26e24     add     %g0, 14, %l1

ok ffd26e24 dis
ffd26e24     add     %g0, 14, %l1
ffd26e28     add     %o7, %l1, %l1
ffd26e2c     jmp     %l1, %g4, %g0
ffd26e30     ba      ffd26f68
ok

ok see spacel@
code spacel@
ffd26830     ld      [%g7], %l0
ffd26834     add     %g7, 4, %g7
ffd26838     sll     %g4, 2, %g4
ffd2683c     call    ffd26840
ffd26840     add     %g0, 14, %l1

ok ffd26840 dis
ffd26840     add     %g0, 14, %l1
ffd26844     add     %o7, %l1, %l1
ffd26848     jmp     %l1, %g4, %g0
ffd2684c     ba      ffd26984

The code is identical on a real and emulated SS.

Quoted 7 lines
Quoted 4 lines

It must be the jump, which jumps differently on a real hw and under qemu. Do you see from the code where the jump would jump to, or maybe you have a suggestion how to check where the jump jumps to on the real hw?

The target of the call instruction is also a delay slot instruction for the call itself. Maybe this case is not handled correctly?

Good idea! Don't know how to test it though.

And what about "ba" in the delay slot of "jmp"? Is the correct behavior described somewhere? Would jump just be ignored? Whould it execute one instruction on jump destination and then branch? Would branch be ignored?

Quoted 7 lines
Quoted 5 lines

Page 55 of The SPARC v8 Architecture Manual
(http://www.sparc.org/standards/V8.pdf) describes this case explicitly:
cpu should execute one instruction on the jump target and then branch. Is it what qemu currently does?

I may be blind, I don't see the description of this case in that page.

I wasn't referring the call case, but jmp+ba case (two last ops in the listing above). This DCTI is described on pages marked 55-56 (pages 54-54 in a pdf reader). That's the first case in the table 5-12.

Quoted 3 lines

Both QEMU and real (Sparc64) hardware exit with return value of 3, so the inc is re-executed. If I add a nop in the call delay slot, the return value is 2.

Can you make a similar test, but with ba in the jmp's delay slot?

#10 lore raw
Quoted 111 lines · Artyom Tarasenko

2009/8/21 Blue Swirl <[email protected]>:

Quoted 98 lines
Quoted 96 lines · Artyom Tarasenko

2009/8/21 Artyom Tarasenko <[email protected]>:

Quoted 94 lines

2009/8/20 Blue Swirl <[email protected]>:

Quoted 79 lines
Quoted 77 lines · Artyom Tarasenko
Quoted 8 lines
Quoted 5 lines

Particularly I'm interested if

jmp     %l1, %g4, %g0

may behave other than on a real hw.

No, if rd is %g0, the current PC will not be written anywhere (not by real HW either).

The reason I asked is the two following pieces of code work differently on a real and emulated SS-5. On a real one spacel! does an asi write, and spacel@ does an asi read, and under qemu  spacel! seems to do nothing, and spacel@ returns its second parameter multiplied by
4. Both of them don't even try to call an [unimplemented] asi operation, I've runned the tests with mmu and asi debug turned on.

Real SS-5:

ok 0 0 spacel@ .
Data Access Error
ok 0 20 spacel@ .
0
ok 12345678 0 20 spacel!
ok 0 20 spacel@ .
12345678
ok

qemu SS-5:

ok 0 0 spacel@ .
0
ok 0 20 spacel@ .
80
ok 12345678 0 20 spacel!
ok 0 20 spacel@ .
80
ok

I don't know sparc asm good enogh, but qemu behavior seems to be
logical: in the first case I see no store op, and there are shifts which would multiply by 4:

ok see spacel!
code spacel!
ffd26e0c     ld      [%g7], %l2
ffd26e10     add     %g7, 4, %g7
ffd26e14     ld      [%g7], %l0
ffd26e18     add     %g7, 4, %g7
ffd26e1c     sll     %g4, 2, %g4
ffd26e20     call    ffd26e24
ffd26e24     add     %g0, 14, %l1

ok ffd26e24 dis
ffd26e24     add     %g0, 14, %l1
ffd26e28     add     %o7, %l1, %l1
ffd26e2c     jmp     %l1, %g4, %g0
ffd26e30     ba      ffd26f68
ok

ok see spacel@
code spacel@
ffd26830     ld      [%g7], %l0
ffd26834     add     %g7, 4, %g7
ffd26838     sll     %g4, 2, %g4
ffd2683c     call    ffd26840
ffd26840     add     %g0, 14, %l1

ok ffd26840 dis
ffd26840     add     %g0, 14, %l1
ffd26844     add     %o7, %l1, %l1
ffd26848     jmp     %l1, %g4, %g0
ffd2684c     ba      ffd26984

The code is identical on a real and emulated SS.

Quoted 7 lines
Quoted 4 lines

It must be the jump, which jumps differently on a real hw and under qemu. Do you see from the code where the jump would jump to, or maybe you have a suggestion how to check where the jump jumps to on the real hw?

The target of the call instruction is also a delay slot instruction for the call itself. Maybe this case is not handled correctly?

Good idea! Don't know how to test it though.

And what about "ba" in the delay slot of "jmp"? Is the correct behavior described somewhere? Would jump just be ignored? Whould it execute one instruction on jump destination and then branch? Would branch be ignored?

Quoted 7 lines
Quoted 5 lines

Page 55 of The SPARC v8 Architecture Manual
(http://www.sparc.org/standards/V8.pdf) describes this case explicitly:
cpu should execute one instruction on the jump target and then branch. Is it what qemu currently does?

I may be blind, I don't see the description of this case in that page.

I wasn't referring the call case, but jmp+ba case (two last ops in the listing above). This DCTI is described on pages marked 55-56 (pages 54-54 in a pdf reader). That's the first case in the table 5-12.

Quoted 5 lines
Quoted 3 lines

Both QEMU and real (Sparc64) hardware exit with return value of 3, so the inc is re-executed. If I add a nop in the call delay slot, the return value is 2.

Can you make a similar test, but with ba in the jmp's delay slot?

SPARC-V8 left as undefined the result of executing a delayed conditional branch that had a delayed control transfer in its delay slot...

Signature · 2 lines
Kind regards,
Igor V. Kovalenko
#11 lore raw

2009/8/21 Igor Kovalenko <[email protected]>:

Quoted 117 lines
Quoted 115 lines · Artyom Tarasenko

2009/8/21 Blue Swirl <[email protected]>:

Quoted 98 lines
Quoted 96 lines · Artyom Tarasenko

2009/8/21 Artyom Tarasenko <[email protected]>:

Quoted 94 lines

2009/8/20 Blue Swirl <[email protected]>:

Quoted 79 lines
Quoted 77 lines · Artyom Tarasenko
Quoted 8 lines
Quoted 5 lines

Particularly I'm interested if

jmp     %l1, %g4, %g0

may behave other than on a real hw.

No, if rd is %g0, the current PC will not be written anywhere (not by real HW either).

The reason I asked is the two following pieces of code work differently on a real and emulated SS-5. On a real one spacel! does an asi write, and spacel@ does an asi read, and under qemu  spacel! seems to do nothing, and spacel@ returns its second parameter multiplied by
4. Both of them don't even try to call an [unimplemented] asi operation, I've runned the tests with mmu and asi debug turned on.

Real SS-5:

ok 0 0 spacel@ .
Data Access Error
ok 0 20 spacel@ .
0
ok 12345678 0 20 spacel!
ok 0 20 spacel@ .
12345678
ok

qemu SS-5:

ok 0 0 spacel@ .
0
ok 0 20 spacel@ .
80
ok 12345678 0 20 spacel!
ok 0 20 spacel@ .
80
ok

I don't know sparc asm good enogh, but qemu behavior seems to be
logical: in the first case I see no store op, and there are shifts which would multiply by 4:

ok see spacel!
code spacel!
ffd26e0c     ld      [%g7], %l2
ffd26e10     add     %g7, 4, %g7
ffd26e14     ld      [%g7], %l0
ffd26e18     add     %g7, 4, %g7
ffd26e1c     sll     %g4, 2, %g4
ffd26e20     call    ffd26e24
ffd26e24     add     %g0, 14, %l1

ok ffd26e24 dis
ffd26e24     add     %g0, 14, %l1
ffd26e28     add     %o7, %l1, %l1
ffd26e2c     jmp     %l1, %g4, %g0
ffd26e30     ba      ffd26f68
ok

ok see spacel@
code spacel@
ffd26830     ld      [%g7], %l0
ffd26834     add     %g7, 4, %g7
ffd26838     sll     %g4, 2, %g4
ffd2683c     call    ffd26840
ffd26840     add     %g0, 14, %l1

ok ffd26840 dis
ffd26840     add     %g0, 14, %l1
ffd26844     add     %o7, %l1, %l1
ffd26848     jmp     %l1, %g4, %g0
ffd2684c     ba      ffd26984

The code is identical on a real and emulated SS.

Quoted 7 lines
Quoted 4 lines

It must be the jump, which jumps differently on a real hw and under qemu. Do you see from the code where the jump would jump to, or maybe you have a suggestion how to check where the jump jumps to on the real hw?

The target of the call instruction is also a delay slot instruction for the call itself. Maybe this case is not handled correctly?

Good idea! Don't know how to test it though.

And what about "ba" in the delay slot of "jmp"? Is the correct behavior described somewhere? Would jump just be ignored? Whould it execute one instruction on jump destination and then branch? Would branch be ignored?

Quoted 7 lines
Quoted 5 lines

Page 55 of The SPARC v8 Architecture Manual
(http://www.sparc.org/standards/V8.pdf) describes this case explicitly:
cpu should execute one instruction on the jump target and then branch. Is it what qemu currently does?

I may be blind, I don't see the description of this case in that page.

I wasn't referring the call case, but jmp+ba case (two last ops in the listing above). This DCTI is described on pages marked 55-56 (pages 54-54 in a pdf reader). That's the first case in the table 5-12.

Quoted 3 lines

Both QEMU and real (Sparc64) hardware exit with return value of 3, so the inc is re-executed. If I add a nop in the call delay slot, the return value is 2.

Quoted 5 lines
Quoted 1 line

Can you make a similar test, but with ba in the jmp's delay slot?

SPARC-V8 left as undefined the result of executing a delayed conditional branch that had a delayed control transfer in its delay slot...

Have you taken a look on the pages 55-56 (pages 54-55 in a pdf reader) of the V8 manual? Particularly the table 5-12 (the very first case) describe the case pretty explicitly.

Also it would have been strange if Sun used an undefined case in all of their own firmwares.

#12 lore raw
In reply to Artyom Tarasenko
Quoted 111 lines · Artyom Tarasenko

2009/8/21 Blue Swirl <[email protected]>:

Quoted 98 lines
Quoted 96 lines · Artyom Tarasenko

2009/8/21 Artyom Tarasenko <[email protected]>:

Quoted 94 lines

2009/8/20 Blue Swirl <[email protected]>:

Quoted 79 lines
Quoted 77 lines · Artyom Tarasenko
Quoted 8 lines
Quoted 5 lines

Particularly I'm interested if

jmp     %l1, %g4, %g0

may behave other than on a real hw.

No, if rd is %g0, the current PC will not be written anywhere (not by real HW either).

The reason I asked is the two following pieces of code work differently on a real and emulated SS-5. On a real one spacel! does an asi write, and spacel@ does an asi read, and under qemu  spacel! seems to do nothing, and spacel@ returns its second parameter multiplied by
4. Both of them don't even try to call an [unimplemented] asi operation, I've runned the tests with mmu and asi debug turned on.

Real SS-5:

ok 0 0 spacel@ .
Data Access Error
ok 0 20 spacel@ .
0
ok 12345678 0 20 spacel!
ok 0 20 spacel@ .
12345678
ok

qemu SS-5:

ok 0 0 spacel@ .
0
ok 0 20 spacel@ .
80
ok 12345678 0 20 spacel!
ok 0 20 spacel@ .
80
ok

I don't know sparc asm good enogh, but qemu behavior seems to be
logical: in the first case I see no store op, and there are shifts which would multiply by 4:

ok see spacel!
code spacel!
ffd26e0c     ld      [%g7], %l2
ffd26e10     add     %g7, 4, %g7
ffd26e14     ld      [%g7], %l0
ffd26e18     add     %g7, 4, %g7
ffd26e1c     sll     %g4, 2, %g4
ffd26e20     call    ffd26e24
ffd26e24     add     %g0, 14, %l1

ok ffd26e24 dis
ffd26e24     add     %g0, 14, %l1
ffd26e28     add     %o7, %l1, %l1
ffd26e2c     jmp     %l1, %g4, %g0
ffd26e30     ba      ffd26f68
ok

ok see spacel@
code spacel@
ffd26830     ld      [%g7], %l0
ffd26834     add     %g7, 4, %g7
ffd26838     sll     %g4, 2, %g4
ffd2683c     call    ffd26840
ffd26840     add     %g0, 14, %l1

ok ffd26840 dis
ffd26840     add     %g0, 14, %l1
ffd26844     add     %o7, %l1, %l1
ffd26848     jmp     %l1, %g4, %g0
ffd2684c     ba      ffd26984

The code is identical on a real and emulated SS.

Quoted 7 lines
Quoted 4 lines

It must be the jump, which jumps differently on a real hw and under qemu. Do you see from the code where the jump would jump to, or maybe you have a suggestion how to check where the jump jumps to on the real hw?

The target of the call instruction is also a delay slot instruction for the call itself. Maybe this case is not handled correctly?

Good idea! Don't know how to test it though.

And what about "ba" in the delay slot of "jmp"? Is the correct behavior described somewhere? Would jump just be ignored? Whould it execute one instruction on jump destination and then branch? Would branch be ignored?

Quoted 7 lines
Quoted 5 lines

Page 55 of The SPARC v8 Architecture Manual
(http://www.sparc.org/standards/V8.pdf) describes this case explicitly:
cpu should execute one instruction on the jump target and then branch. Is it what qemu currently does?

I may be blind, I don't see the description of this case in that page.

I wasn't referring the call case, but jmp+ba case (two last ops in the listing above). This DCTI is described on pages marked 55-56 (pages 54-54 in a pdf reader). That's the first case in the table 5-12.

Quoted 5 lines
Quoted 3 lines

Both QEMU and real (Sparc64) hardware exit with return value of 3, so the inc is re-executed. If I add a nop in the call delay slot, the return value is 2.

Can you make a similar test, but with ba in the jmp's delay slot?

Now, we have found a bug! The following program exits with 2 on real hardware for -UBA and -DBA versions, but 0 for -UBA (2 for -DBA) on QEMU!

#ifdef __OpenBSD__
#include <sys/syscall.h>
#endif

.globl _start
_start:

    clr %o0

#ifdef BA
ba first
#else
set first, %g1
jmp %g1

#endif
     ba second
    /* should not be executed: */
    or %o0, 1, %o0

second:
#ifdef __OpenBSD__
mov SYS_exit, %g1
ta 0

#else
    mov 1, %g1
    ta 0x10
#endif
first:
    or %o0, 2, %o0
    /* should not be executed: */
    ba second
     or %o0, 4, %o0

qemu.log reveals that in the -UBA case, instead of 'or %o0, 2, %o0', the first 'clr %o0' is executed:
IN:

0x00010054:  mov  %g0, %o0
0x00010058:  sethi  %hi(0x10000), %g1
0x0001005c:  or  %g1, 0x74, %g1 ! 0x10074
0x00010060:  jmp  %g1
0x00010064:  b  0x1006c

--------------
IN:
0x00010054: mov %g0, %o0

--------------
IN:
0x0001006c: mov 1, %g1
0x00010070: ta 0x10

For -DBA the log is OK:
IN:

0x00010054:  mov  %g0, %o0
0x00010058:  b  0x1006c
0x0001005c:  b  0x10064

--------------
IN:
0x0001006c: or %o0, 2, %o0

--------------
IN:
0x00010064: mov 1, %g1
0x00010068: ta 0x10

#13 lore raw

2009/8/22 Blue Swirl <[email protected]>:

Quoted 113 lines
Quoted 111 lines · Artyom Tarasenko

2009/8/21 Blue Swirl <[email protected]>:

Quoted 98 lines
Quoted 96 lines · Artyom Tarasenko

2009/8/21 Artyom Tarasenko <[email protected]>:

Quoted 94 lines

2009/8/20 Blue Swirl <[email protected]>:

Quoted 79 lines
Quoted 77 lines · Artyom Tarasenko
Quoted 8 lines
Quoted 5 lines

Particularly I'm interested if

jmp     %l1, %g4, %g0

may behave other than on a real hw.

No, if rd is %g0, the current PC will not be written anywhere (not by real HW either).

The reason I asked is the two following pieces of code work differently on a real and emulated SS-5. On a real one spacel! does an asi write, and spacel@ does an asi read, and under qemu  spacel! seems to do nothing, and spacel@ returns its second parameter multiplied by
4. Both of them don't even try to call an [unimplemented] asi operation, I've runned the tests with mmu and asi debug turned on.

Real SS-5:

ok 0 0 spacel@ .
Data Access Error
ok 0 20 spacel@ .
0
ok 12345678 0 20 spacel!
ok 0 20 spacel@ .
12345678
ok

qemu SS-5:

ok 0 0 spacel@ .
0
ok 0 20 spacel@ .
80
ok 12345678 0 20 spacel!
ok 0 20 spacel@ .
80
ok

I don't know sparc asm good enogh, but qemu behavior seems to be
logical: in the first case I see no store op, and there are shifts which would multiply by 4:

ok see spacel!
code spacel!
ffd26e0c     ld      [%g7], %l2
ffd26e10     add     %g7, 4, %g7
ffd26e14     ld      [%g7], %l0
ffd26e18     add     %g7, 4, %g7
ffd26e1c     sll     %g4, 2, %g4
ffd26e20     call    ffd26e24
ffd26e24     add     %g0, 14, %l1

ok ffd26e24 dis
ffd26e24     add     %g0, 14, %l1
ffd26e28     add     %o7, %l1, %l1
ffd26e2c     jmp     %l1, %g4, %g0
ffd26e30     ba      ffd26f68
ok

ok see spacel@
code spacel@
ffd26830     ld      [%g7], %l0
ffd26834     add     %g7, 4, %g7
ffd26838     sll     %g4, 2, %g4
ffd2683c     call    ffd26840
ffd26840     add     %g0, 14, %l1

ok ffd26840 dis
ffd26840     add     %g0, 14, %l1
ffd26844     add     %o7, %l1, %l1
ffd26848     jmp     %l1, %g4, %g0
ffd2684c     ba      ffd26984

The code is identical on a real and emulated SS.

Quoted 7 lines
Quoted 4 lines

It must be the jump, which jumps differently on a real hw and under qemu. Do you see from the code where the jump would jump to, or maybe you have a suggestion how to check where the jump jumps to on the real hw?

The target of the call instruction is also a delay slot instruction for the call itself. Maybe this case is not handled correctly?

Good idea! Don't know how to test it though.

And what about "ba" in the delay slot of "jmp"? Is the correct behavior described somewhere? Would jump just be ignored? Whould it execute one instruction on jump destination and then branch? Would branch be ignored?

Quoted 7 lines
Quoted 5 lines

Page 55 of The SPARC v8 Architecture Manual
(http://www.sparc.org/standards/V8.pdf) describes this case explicitly:
cpu should execute one instruction on the jump target and then branch. Is it what qemu currently does?

I may be blind, I don't see the description of this case in that page.

I wasn't referring the call case, but jmp+ba case (two last ops in the listing above). This DCTI is described on pages marked 55-56 (pages 54-54 in a pdf reader). That's the first case in the table 5-12.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Both QEMU and real (Sparc64) hardware exit with return value of 3, so the inc is re-executed. If I add a nop in the call delay slot, the return value is 2.

Can you make a similar test, but with ba in the jmp's delay slot?

Now, we have found a bug!

Looks better now!

Probing Memory Bank #0 64 Megabytes of DRAM
Probing Memory Bank #1 64 Megabytes of DRAM
Probing Memory Bank #2 64 Megabytes of DRAM
Probing Memory Bank #3 64 Megabytes of DRAM
Probing Memory Bank #4 Data Access Error
ok

Used to be "Nothing there". What is a bit surprising, is that only 256 Mib found when started with -m 512. May be a next bug, this time in ASI.

With -m 128 :
Probing Memory Bank #0 64 Megabytes of DRAM
Probing Memory Bank #1 64 Megabytes of DRAM
Probing Memory Bank #2 Nothing there
Probing Memory Bank #3 Nothing there
Probing Memory Bank #4 Data Access Error
ok

#14 lore raw
Quoted 144 lines · Artyom Tarasenko

2009/8/22 Blue Swirl <[email protected]>:

Quoted 120 lines
Quoted 117 lines · Artyom Tarasenko

2009/8/21 Blue Swirl <[email protected]>:

Quoted 102 lines
Quoted 99 lines · Artyom Tarasenko

2009/8/21 Artyom Tarasenko <[email protected]>:

Quoted 97 lines

2009/8/20 Blue Swirl <[email protected]>:

Quoted 80 lines
Quoted 77 lines · Artyom Tarasenko
Quoted 9 lines
Quoted 6 lines

Particularly I'm interested if

jmp %l1, %g4, %g0

may behave other than on a real hw.

No, if rd is %g0, the current PC will not be written anywhere (not by real HW either).

The reason I asked is the two following pieces of code work differently on a real and emulated SS-5. On a real one spacel! does an asi write, and spacel@ does an asi read, and under qemu spacel! seems to do nothing, and spacel@ returns its second parameter multiplied by
4. Both of them don't even try to call an [unimplemented] asi operation, I've runned the tests with mmu and asi debug turned on.

Real SS-5:

ok 0 0 spacel@ .
Data Access Error
ok 0 20 spacel@ .
0
ok 12345678 0 20 spacel!
ok 0 20 spacel@ .
12345678
ok

qemu SS-5:

ok 0 0 spacel@ .
0
ok 0 20 spacel@ .
80
ok 12345678 0 20 spacel!
ok 0 20 spacel@ .
80
ok

I don't know sparc asm good enogh, but qemu behavior seems to be
logical: in the first case I see no store op, and there are shifts which would multiply by 4:

ok see spacel!
code spacel!

ffd26e0c     ld      [%g7], %l2
ffd26e10     add     %g7, 4, %g7
ffd26e14     ld      [%g7], %l0
ffd26e18     add     %g7, 4, %g7
ffd26e1c     sll     %g4, 2, %g4
ffd26e20     call    ffd26e24
ffd26e24     add     %g0, 14, %l1

ok ffd26e24 dis

ffd26e24     add     %g0, 14, %l1
ffd26e28     add     %o7, %l1, %l1
ffd26e2c     jmp     %l1, %g4, %g0
ffd26e30     ba      ffd26f68

ok

ok see spacel@
code spacel@

ffd26830     ld      [%g7], %l0
ffd26834     add     %g7, 4, %g7
ffd26838     sll     %g4, 2, %g4
ffd2683c     call    ffd26840
ffd26840     add     %g0, 14, %l1

ok ffd26840 dis

ffd26840     add     %g0, 14, %l1
ffd26844     add     %o7, %l1, %l1
ffd26848     jmp     %l1, %g4, %g0
ffd2684c     ba      ffd26984

The code is identical on a real and emulated SS.

Quoted 8 lines
Quoted 5 lines

It must be the jump, which jumps differently on a real hw and under qemu. Do you see from the code where the jump would jump to, or maybe you have a suggestion how to check where the jump jumps to on the real hw?

The target of the call instruction is also a delay slot instruction for the call itself. Maybe this case is not handled correctly?

Good idea! Don't know how to test it though.

And what about "ba" in the delay slot of "jmp"? Is the correct behavior described somewhere? Would jump just be ignored? Whould it execute one instruction on jump destination and then branch? Would branch be ignored?

Quoted 8 lines
Quoted 6 lines

Page 55 of The SPARC v8 Architecture Manual
(http://www.sparc.org/standards/V8.pdf) describes this case explicitly:
cpu should execute one instruction on the jump target and then branch.
Is it what qemu currently does?

I may be blind, I don't see the description of this case in that page.

I wasn't referring the call case, but jmp+ba case (two last ops in the listing above). This DCTI is described on pages marked 55-56 (pages 54-54 in a pdf reader). That's the first case in the table 5-12.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Both QEMU and real (Sparc64) hardware exit with return value of 3, so the inc is re-executed. If I add a nop in the call delay slot, the return value is 2.

Can you make a similar test, but with ba in the jmp's delay slot?

Now, we have found a bug!

Looks better now!

Probing Memory Bank #0 64 Megabytes of DRAM
Probing Memory Bank #1 64 Megabytes of DRAM
Probing Memory Bank #2 64 Megabytes of DRAM
Probing Memory Bank #3 64 Megabytes of DRAM
Probing Memory Bank #4 Data Access Error
ok

Used to be "Nothing there". What is a bit surprising, is that only 256 Mib found when started with -m 512. May be a next bug, this time in ASI.

Quoted 11 lines

With -m 128 :
Probing Memory Bank #0 64 Megabytes of DRAM
Probing Memory Bank #1 64 Megabytes of DRAM
Probing Memory Bank #2 Nothing there
Probing Memory Bank #3 Nothing there
Probing Memory Bank #4 Data Access Error
ok

Here is a very old patch for the eccmemctl that fixes a bug I found while trying to fix the memory probing problem that is now fixed.

hw/eccmemctl.c +5 -4
index 28519c8..b2bff98 100644
@@ -301,10 +301,11 @@ static void ecc_reset(void *opaque)
 
     if (s->version == ECC_MCC)
         s->regs[ECC_MER] &= ECC_MER_REU;
-    else
-        s->regs[ECC_MER] &= (ECC_MER_VER | ECC_MER_IMPL | ECC_MER_MRR |
-                             ECC_MER_DCI);
-    s->regs[ECC_MDR] = 0x20;
+    else {
+        s->regs[ECC_MER] &= (ECC_MER_VER | ECC_MER_IMPL | ECC_MER_DCI);
+        s->regs[ECC_MER] |= ECC_MER_MRR;
+    }
+    s->regs[ECC_MDR] = 0x40;
     s->regs[ECC_MFSR] = 0;
     s->regs[ECC_VCR] = 0;
     s->regs[ECC_MFAR0] = 0x07c00000;
#15 lore raw

2009/8/22 Robert Reif <[email protected]>:

Quoted 197 lines
Quoted 168 lines · Artyom Tarasenko

2009/8/22 Blue Swirl <[email protected]>:

Quoted 146 lines
Quoted 142 lines · Artyom Tarasenko

2009/8/21 Blue Swirl <[email protected]>:

Quoted 118 lines
Quoted 114 lines · Artyom Tarasenko

2009/8/21 Artyom Tarasenko <[email protected]>:

Quoted 110 lines

2009/8/20 Blue Swirl <[email protected]>:

Quoted 96 lines
Quoted 82 lines · Artyom Tarasenko
Quoted 12 lines
Quoted 7 lines

Particularly I'm interested if

jmp     %l1, %g4, %g0

may behave other than on a real hw.

No, if rd is %g0, the current PC will not be written anywhere (not by
real HW either).

The reason I asked is the two following pieces of code work differently on a real and emulated SS-5. On a real one spacel! does an
asi write, and spacel@ does an asi read, and under qemu  spacel! seems
to do nothing, and spacel@ returns its second parameter multiplied by
4. Both of them don't even try to call an [unimplemented] asi operation, I've runned the tests with mmu and asi debug turned on.

Real SS-5:

ok 0 0 spacel@ .
Data Access Error
ok 0 20 spacel@ .
0
ok 12345678 0 20 spacel!
ok 0 20 spacel@ .
12345678
ok

qemu SS-5:

ok 0 0 spacel@ .
0
ok 0 20 spacel@ .
80
ok 12345678 0 20 spacel!
ok 0 20 spacel@ .
80
ok

I don't know sparc asm good enogh, but qemu behavior seems to be
logical: in the first case I see no store op, and there are shifts which would multiply by 4:

ok see spacel!
code spacel!
ffd26e0c     ld      [%g7], %l2
ffd26e10     add     %g7, 4, %g7
ffd26e14     ld      [%g7], %l0
ffd26e18     add     %g7, 4, %g7
ffd26e1c     sll     %g4, 2, %g4
ffd26e20     call    ffd26e24
ffd26e24     add     %g0, 14, %l1

ok ffd26e24 dis
ffd26e24     add     %g0, 14, %l1
ffd26e28     add     %o7, %l1, %l1
ffd26e2c     jmp     %l1, %g4, %g0
ffd26e30     ba      ffd26f68
ok

ok see spacel@
code spacel@
ffd26830     ld      [%g7], %l0
ffd26834     add     %g7, 4, %g7
ffd26838     sll     %g4, 2, %g4
ffd2683c     call    ffd26840
ffd26840     add     %g0, 14, %l1

ok ffd26840 dis
ffd26840     add     %g0, 14, %l1
ffd26844     add     %o7, %l1, %l1
ffd26848     jmp     %l1, %g4, %g0
ffd2684c     ba      ffd26984

Quoted 9 lines

The code is identical on a real and emulated SS.

It must be the jump, which jumps differently on a real hw and under qemu. Do you see from the code where the jump would jump to, or maybe
you have a suggestion how to check where the jump jumps to on the real
hw?

Quoted 3 lines

The target of the call instruction is also a delay slot instruction for the call itself. Maybe this case is not handled correctly?

Good idea! Don't know how to test it though.

And what about "ba" in the delay slot of "jmp"? Is the correct behavior described somewhere? Would jump just be ignored? Whould it execute one instruction on jump destination and then branch? Would branch be ignored?

Quoted 9 lines
Quoted 6 lines

Page 55 of The SPARC v8 Architecture Manual
(http://www.sparc.org/standards/V8.pdf) describes this case explicitly:
cpu should execute one instruction on the jump target and then branch. Is it what qemu currently does?

I may be blind, I don't see the description of this case in that page.

I wasn't referring the call case, but jmp+ba case (two last ops in the listing above). This DCTI is described on pages marked 55-56 (pages 54-54 in a pdf reader). That's the first case in the table 5-12.

Quoted 5 lines

Both QEMU and real (Sparc64) hardware exit with return value of 3, so the inc is re-executed. If I add a nop in the call delay slot, the return value is 2.

Quoted 5 lines
Quoted 2 lines

Can you make a similar test, but with ba in the jmp's delay slot?

Now, we have found a bug!

Looks better now!

Probing Memory Bank #0 64 Megabytes of DRAM
Probing Memory Bank #1 64 Megabytes of DRAM
Probing Memory Bank #2 64 Megabytes of DRAM
Probing Memory Bank #3 64 Megabytes of DRAM
Probing Memory Bank #4 Data Access Error
ok

Used to be "Nothing there". What is a bit surprising, is that only 256 Mib found when started with -m 512. May be a next bug, this time in ASI.

Quoted 11 lines

With -m 128 :
Probing Memory Bank #0 64 Megabytes of DRAM
Probing Memory Bank #1 64 Megabytes of DRAM
Probing Memory Bank #2 Nothing there
Probing Memory Bank #3 Nothing there
Probing Memory Bank #4 Data Access Error
ok

Here is a very old patch for the eccmemctl that fixes a bug I found while trying to fix the memory probing problem that is now fixed.

hw/eccmemctl.c +0 -2
index 28519c8..b2bff98 100644
@@ -301,10 +301,11 @@ static void ecc_reset(void *opaque)
 
     if (s->version == ECC_MCC)
         s->regs[ECC_MER] &= ECC_MER_REU;
-    else
-        s->regs[ECC_MER] &= (ECC_MER_VER | ECC_MER_IMPL | ECC_MER_MRR |

hw/eccmemctl.c static void ecc_reset(void *opaque) · line 311

Quoted 10 lines
hw/eccmemctl.c +5 -2
-                             ECC_MER_DCI);
-    s->regs[ECC_MDR] = 0x20;
+    else {
+        s->regs[ECC_MER] &= (ECC_MER_VER | ECC_MER_IMPL | ECC_MER_DCI);
+        s->regs[ECC_MER] |= ECC_MER_MRR;
+    }
+    s->regs[ECC_MDR] = 0x40;
     s->regs[ECC_MFSR] = 0;
     s->regs[ECC_VCR] = 0;
     s->regs[ECC_MFAR0] = 0x07c00000;

The piece of code is still there, but the patch makes no visible effect on SS-5, 10 and 20:

Probing Memory Bank #0 64 Megabytes of DRAM
...
Probing Memory Bank #3 64 Megabytes of DRAM
Probing Memory Bank #4 Data Access Error
ok

Do you remember, for which machine/OBP was it intended?

#16 lore raw
Quoted 214 lines · Artyom Tarasenko

2009/8/22 Robert Reif <[email protected]>:

Quoted 198 lines
Quoted 167 lines · Artyom Tarasenko

2009/8/22 Blue Swirl <[email protected]>:

Quoted 145 lines
Quoted 141 lines · Artyom Tarasenko

2009/8/21 Blue Swirl <[email protected]>:

Quoted 117 lines
Quoted 113 lines · Artyom Tarasenko

2009/8/21 Artyom Tarasenko <[email protected]>:

Quoted 110 lines

2009/8/20 Blue Swirl <[email protected]>:

Quoted 95 lines
Quoted 81 lines · Artyom Tarasenko
Quoted 12 lines
Quoted 7 lines

Particularly I'm interested if

jmp %l1, %g4, %g0

may behave other than on a real hw.

No, if rd is %g0, the current PC will not be written anywhere (not by
real HW either).

The reason I asked is the two following pieces of code work differently on a real and emulated SS-5. On a real one spacel! does an
asi write, and spacel@ does an asi read, and under qemu spacel! seems
to do nothing, and spacel@ returns its second parameter multiplied by
4. Both of them don't even try to call an [unimplemented] asi operation, I've runned the tests with mmu and asi debug turned on.

Real SS-5:

ok 0 0 spacel@ .
Data Access Error
ok 0 20 spacel@ .
0
ok 12345678 0 20 spacel!
ok 0 20 spacel@ .
12345678
ok

qemu SS-5:

ok 0 0 spacel@ .
0
ok 0 20 spacel@ .
80
ok 12345678 0 20 spacel!
ok 0 20 spacel@ .
80
ok

I don't know sparc asm good enogh, but qemu behavior seems to be
logical: in the first case I see no store op, and there are shifts which would multiply by 4:

ok see spacel!
code spacel!

ffd26e0c     ld      [%g7], %l2
ffd26e10     add     %g7, 4, %g7
ffd26e14     ld      [%g7], %l0
ffd26e18     add     %g7, 4, %g7
ffd26e1c     sll     %g4, 2, %g4
ffd26e20     call    ffd26e24
ffd26e24     add     %g0, 14, %l1

ok ffd26e24 dis

ffd26e24     add     %g0, 14, %l1
ffd26e28     add     %o7, %l1, %l1
ffd26e2c     jmp     %l1, %g4, %g0
ffd26e30     ba      ffd26f68

ok

ok see spacel@
code spacel@

ffd26830     ld      [%g7], %l0
ffd26834     add     %g7, 4, %g7
ffd26838     sll     %g4, 2, %g4
ffd2683c     call    ffd26840
ffd26840     add     %g0, 14, %l1

ok ffd26840 dis

ffd26840     add     %g0, 14, %l1
ffd26844     add     %o7, %l1, %l1
ffd26848     jmp     %l1, %g4, %g0
ffd2684c     ba      ffd26984
Quoted 10 lines

The code is identical on a real and emulated SS.

It must be the jump, which jumps differently on a real hw and under qemu. Do you see from the code where the jump would jump to, or maybe
you have a suggestion how to check where the jump jumps to on the real
hw?

Quoted 4 lines

The target of the call instruction is also a delay slot instruction for the call itself. Maybe this case is not handled correctly?

Good idea! Don't know how to test it though.

And what about "ba" in the delay slot of "jmp"? Is the correct behavior described somewhere? Would jump just be ignored? Whould it execute one instruction on jump destination and then branch? Would branch be ignored?

Quoted 10 lines
Quoted 7 lines

Page 55 of The SPARC v8 Architecture Manual
(http://www.sparc.org/standards/V8.pdf) describes this case explicitly:
cpu should execute one instruction on the jump target and then branch.
Is it what qemu currently does?

I may be blind, I don't see the description of this case in that page.

I wasn't referring the call case, but jmp+ba case (two last ops in the listing above). This DCTI is described on pages marked 55-56 (pages 54-54 in a pdf reader). That's the first case in the table 5-12.

Quoted 5 lines

Both QEMU and real (Sparc64) hardware exit with return value of 3, so the inc is re-executed. If I add a nop in the call delay slot, the return value is 2.

Quoted 6 lines
Quoted 3 lines

Can you make a similar test, but with ba in the jmp's delay slot?

Now, we have found a bug!

Looks better now!

Probing Memory Bank #0 64 Megabytes of DRAM
Probing Memory Bank #1 64 Megabytes of DRAM
Probing Memory Bank #2 64 Megabytes of DRAM
Probing Memory Bank #3 64 Megabytes of DRAM
Probing Memory Bank #4 Data Access Error
ok

Used to be "Nothing there". What is a bit surprising, is that only 256 Mib found when started with -m 512. May be a next bug, this time in ASI.

Quoted 12 lines

With -m 128 :
Probing Memory Bank #0 64 Megabytes of DRAM
Probing Memory Bank #1 64 Megabytes of DRAM
Probing Memory Bank #2 Nothing there
Probing Memory Bank #3 Nothing there
Probing Memory Bank #4 Data Access Error
ok

Here is a very old patch for the eccmemctl that fixes a bug I found while trying to fix the memory probing problem that is now fixed.

hw/eccmemctl.c +0 -2
index 28519c8..b2bff98 100644
@@ -301,10 +301,11 @@ static void ecc_reset(void *opaque)
 
    if (s->version == ECC_MCC)
        s->regs[ECC_MER] &= ECC_MER_REU;
-    else
-        s->regs[ECC_MER] &= (ECC_MER_VER | ECC_MER_IMPL | ECC_MER_MRR |

hw/eccmemctl.c static void ecc_reset(void *opaque) · line 311

Quoted 10 lines
hw/eccmemctl.c +5 -2
-                             ECC_MER_DCI);
-    s->regs[ECC_MDR] = 0x20;
+    else {
+        s->regs[ECC_MER] &= (ECC_MER_VER | ECC_MER_IMPL | ECC_MER_DCI);
+        s->regs[ECC_MER] |= ECC_MER_MRR;
+    }
+    s->regs[ECC_MDR] = 0x40;
    s->regs[ECC_MFSR] = 0;
    s->regs[ECC_VCR] = 0;
    s->regs[ECC_MFAR0] = 0x07c00000;

The piece of code is still there, but the patch makes no visible effect on SS-5, 10 and 20:

Quoted 11 lines

Probing Memory Bank #0 64 Megabytes of DRAM
...
Probing Memory Bank #3 64 Megabytes of DRAM
Probing Memory Bank #4 Data Access Error
ok

Do you remember, for which machine/OBP was it intended?

It's for the ss10/20. I just found the bug by stepping through the code and compairing what it was doing with the chip manual. I'm not suprised it didn't help. It's just a correctness fix.

You have to be careful when specifing a memory size on the ss10/20 because a SIMM slot uses 64M reguardless of the actual size of the SIMM. A smaller size will be mirrored to fill the entire space and OBP checks for mirrioing to determine the actual size. QEMU doesn't do any mirroring for small SIMMS which will confuse OBP. I don't think that is the issue are seeing but just something to keep in mind.