Skip to contentSkip to conversation

More PPC emulation fixes

Qemu-devel J. Mayer 3 participants 10 messages Mar 2, 2005 – Mar 8, 2005

lore
Share & tools
lore

J. Mayer

author
#0 lore raw

Here's a new patch that fixes the last (!) bug in PPC fixed point operations and most FPU bugs.

Apply and enjoy.

More infos about this patch:

I did test exhaustively all arithmetic, logical and compare operations for fixed point and floating points computation with large ranges of operands then compared the result with the ones I got from a real G3.

The bugs I found which are fixed with this patch are:
- srawi did set the overflow bit in XER register in some case when used with a 0 shift. Then, I now do no computation if shift is 0.
- I did forget to generate FP_UNAVAILABLE exception when trying to use lfd, lfs, stfd and stfs instructions when FPU is not enabled. This lead to random
crashes or bad computations under Linux.
- operands for fsel where interverted.
- fres major opcode was false.
- conversion from float to int has been improved.
- floating points operations applied on single operands where false: PPC specifies that the cast to single should be done only on the computation result. Then I removed all micro-ops for single float operands and
now just use frsp after computation.
- multiply-and-add/sub-and-negate
operations have been fixed for special operands (NaN, infinite, ...)
- estimated single operation (ie fres, frsqrte) have been fixed for special operands
- absolute values computation have been fixed.
- I also removed unusefull tb_flush & tlb_flush which are not needed anymore
now that tb flags are set properly.

There still are some things to improve:
- some computations on single operands
may have a difference on the last
significant bit of the mantissa. This only
appears when a multiplication is involved,
ie for fmuls, fmadds, fmsubs, fnmadds and
fnmsubs. All other operations give exactly
the same result as a real G3. As PPC specs
talks about multiply computation with 105
bits mantissa intermediary results, I may
have to use long doubles to fix this issue
(not tried). But I really think the current
results may not hurt anyone.
- No flags are managed for floating-point
computations, except for compare
instructions. This does not seem to be
important for the glibc but is a potential
problem for other OSes.

With this patch, Debian Sarge is now able to install. It need OHW patches to reboot and go on running the installer. I'll released a second 0.4 preview with fixes for this (and more...) soon. However, one need to run "expert" installation, or the installer will go into an infinite loop trying to probe the link on the NE2k device.

Signature · 2 lines
J. Mayer <[email protected]>
Never organized

Index: target-ppc/exec.h
===================================================================
RCS file: /cvsroot/qemu/qemu/target-ppc/exec.h,v
retrieving revision 1.9

exec.h +1 -9
diff -u -d -w -B -b -d -p -r1.9 exec.h
@@ -32,9 +32,6 @@ register uint32_t T2 asm(AREG3);
 #define FT0 (env->ft0)
 #define FT1 (env->ft1)
 #define FT2 (env->ft2)
-#define FTS0 ((float)env->ft0)
-#define FTS1 ((float)env->ft1)
-#define FTS2 ((float)env->ft2)
 
 #if defined (DEBUG_OP)
 #define RETURN() __asm__ __volatile__("nop");
@@ -137,17 +134,12 @@ void do_fctiw (void);
 void do_fctiwz (void);
 void do_fnmadd (void);
 void do_fnmsub (void);
-void do_fnmadds (void);
-void do_fnmsubs (void);
 void do_fsqrt (void);
-void do_fsqrts (void);
 void do_fres (void);
-void do_fsqrte (void);
+void do_frsqrte (void);
 void do_fsel (void);
 void do_fcmpu (void);
 void do_fcmpo (void);
-void do_fabs (void);
-void do_fnabs (void);
 
 void do_check_reservation (void);
 void do_icbi (void);

Index: target-ppc/helper.c
===================================================================
RCS file: /cvsroot/qemu/qemu/target-ppc/helper.c,v retrieving revision 1.21

helper.c +1 -2
diff -u -d -w -B -b -d -p -r1.21 helper.c
@@ -809,6 +809,7 @@ void do_interrupt (CPUState *env)
         msr |= 0x00010000;
         goto store_current;
     case EXCP_NO_FP:
+        msr &= ~0xFFFF0000;
         goto store_current;
     case EXCP_DECR:
         if (msr_ee == 0) {
@@ -854,7 +855,6 @@ void do_interrupt (CPUState *env)
         return;
     case EXCP_RFI:
         /* Restore user-mode state */
-	tb_flush(env);
 #if defined (DEBUG_EXCEPTIONS)
 	if (msr_pr == 1)
 	    printf("Return from exception => 0x%08x\n", (uint32_t)env->nip);
@@ -887,7 +888,6 @@ void do_interrupt (CPUState *env)
     env->nip = excp << 8;
     env->exception_index = EXCP_NONE;
     /* Invalidate all TLB as we may have changed translation mode */
-    tlb_flush(env, 1);
     /* ensure that no TB jump will be modified as
        the program flow was changed */
 #ifdef __sparc__

Index: target-ppc/op.c
===================================================================
RCS file: /cvsroot/qemu/qemu/target-ppc/op.c,v
retrieving revision 1.15

op.c +5 -69

149 lines not on this page · raw message

Index: target-ppc/op_helper.c
===================================================================
RCS file: /cvsroot/qemu/qemu/target-ppc/op_helper.c,v retrieving revision 1.11

op_helper.c +111 -39

205 lines not on this page · raw message

Index: target-ppc/translate.c
===================================================================
RCS file: /cvsroot/qemu/qemu/target-ppc/translate.c,v retrieving revision 1.27

translate.c +69 -26

229 lines not on this page · raw message

author
#1 lore raw
Quoted 4 lines · J. Mayer

Here's a new patch that fixes the last (!) bug in PPC fixed point operations and most FPU bugs.

Apply and enjoy.

I realise I missed one "detail":
FPU has to be activated in OHW, or it would crash. I'll send a modified version 0.3 tonight. For those who don't want to wait, here's the needed patch.

Signature · 2 lines
J. Mayer <[email protected]>
Never organized
vectors.S +2 -0
Index: src/vectors.S
===================================================================
@@ -73,6 +73,8 @@
         stwu    r14, 4(r13)                               ;
         bdnz    _bios_copy_loop                           ;
         /* Synchronize the whole execution context */
+        /* Also enable FPU */
+        ori     r0, r0, (1 << 13)                         ;
         mtspr   26, r29                                   ;
         mtspr   27, r0                                    ;
         rfi                                               ;
author
#2 lore raw
Quoted 10 lines · J. Mayer
Quoted 4 lines · J. Mayer

Here's a new patch that fixes the last (!) bug in PPC fixed point operations and most FPU bugs.

Apply and enjoy.

I realise I missed one "detail":
FPU has to be activated in OHW, or it would crash. I'll send a modified version 0.3 tonight. For those who don't want to wait, here's the needed patch.

A patched OHW binary is now available here:
<http://perso.magic.fr/l_indien/OpenHackWare/0.3/OpenHackWare_0.3.2_bin.tar.bz2>
It's exactly the same that the one commited in qemu repository, except that it enables FPU at startup, so it runs if the FPU fixes are applied. It will run exactly the same as current one if used with current qemu CVS.

Signature · 2 lines
J. Mayer <[email protected]>
Never organized
#3 lore raw
In reply to J. Mayer
Quoted 10 lines · J. Mayer
Quoted 4 lines · J. Mayer

Here's a new patch that fixes the last (!) bug in PPC fixed point operations and most FPU bugs.

Apply and enjoy.

I realise I missed one "detail":
FPU has to be activated in OHW, or it would crash. I'll send a modified version 0.3 tonight. For those who don't want to wait, here's the needed patch.

I've been using the patches for a bit now. All of my previously reported problems are gone.

Thanks.

#4 lore raw

May I ask you guys, who've done work on Qemu/PPC side, how far is it from being "Linux on Mac"?

7.3.2005 kello 19:52, Thayne Harbaugh kirjoitti:

Quoted 24 lines · J. Mayer
Quoted 10 lines · J. Mayer
Quoted 4 lines

Here's a new patch that fixes the last (!) bug in PPC fixed point operations and most FPU bugs.

Apply and enjoy.

I realise I missed one "detail":
FPU has to be activated in OHW, or it would crash. I'll send a modified version 0.3 tonight. For those who don't want to wait, here's the needed patch.

I've been using the patches for a bit now. All of my previously reported problems are gone.

Thanks.

_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel

#5 lore raw
Quoted 2 lines · Asko Kauppi

May I ask you guys, who've done work on Qemu/PPC side, how far is it from being "Linux on Mac"?

I haven't tested anything except linux-powerpc on linux-x86 - which works quite well except for a few features of a 2.6 guest kernel (I'm working on fixing these). I once tried to boot Mac OS X on linux-x86, but it died with an Altivec problem (at least that's what Jocelyn said).

author
#6 lore raw
Quoted 8 lines · Thayne Harbaugh
Quoted 2 lines · Asko Kauppi

May I ask you guys, who've done work on Qemu/PPC side, how far is it from being "Linux on Mac"?

I haven't tested anything except linux-powerpc on linux-x86 - which works quite well except for a few features of a 2.6 guest kernel (I'm working on fixing these). I once tried to boot Mac OS X on linux-x86, but it died with an Altivec problem (at least that's what Jocelyn said).

Altivec problem seems to appear with Mac OS X 10.3. Version 10.2 fails to mount it's root partition, I really need to understand why. I didn't check any other version, but I noticed that OpenDarwin sometimes acts like Mac OS X 10.2 and sometimes crashes, depending on the version. Those problem as, I suppose, related to buggy OF properties.

Signature · 2 lines
J. Mayer <[email protected]>
Never organized
author
#7 lore raw
In reply to Thayne Harbaugh
Quoted 7 lines · Thayne Harbaugh
Quoted 6 lines · J. Mayer
Quoted 4 lines · J. Mayer

Here's a new patch that fixes the last (!) bug in PPC fixed point operations and most FPU bugs.

Apply and enjoy.

Quoted 7 lines
Quoted 4 lines

I realise I missed one "detail":
FPU has to be activated in OHW, or it would crash. I'll send a modified version 0.3 tonight. For those who don't want to wait, here's the needed patch.

I've been using the patches for a bit now. All of my previously reported problems are gone.

Great !
I think most of qemu PPC cpu emulation bugs are now fixed. I still know two problems that seems related to emulation:
- top in Debian Sarge crashes.
- Debian woody installer crashes.

Other problems seem OHW or hardware emulation related. For example ne2k seems to miss MII related stuff emulation, then most automatic hardware probes stay stuck while checking the network device.

I played a lot with qemu this week-end, recompiled kernels and qemu in the emulated machine. Then I was able to run qemu x86 emulation under qemu-ppc (but that's really slooooow...).
I was also able to launch ppc user emulation but missed memory to launch ppc system emulation.
I'm also re-compiling MOL to try to launch Mac OS X using it ;-)

I did put some screenshots of Qemu running Debian Sarge for PPC here:
<http://perso.magic.fr/l_indien/qemu-ppc/snapshots/index.html>

Signature · 2 lines
J. Mayer <[email protected]>
Never organized
#8 lore raw
Quoted 9 lines · J. Mayer
Quoted 2 lines · Thayne Harbaugh

I've been using the patches for a bit now. All of my previously reported problems are gone.

Great !
I think most of qemu PPC cpu emulation bugs are now fixed. I still know two problems that seems related to emulation:
- top in Debian Sarge crashes.

I've noticed the same thing.

Quoted 3 lines

- Debian woody installer crashes.

Other problems seem OHW or hardware emulation related.

I'm supposed to be looking at some of these, but lately I've had to focus on some other things outside of qemu/OHW. Hopefully I can get back to this soon.

Quoted 3 lines

For example ne2k
seems to miss MII related stuff emulation, then most automatic hardware probes stay stuck while checking the network device.

I don't think I've had this problem - or maybe I just don't recognize it.

Quoted 6 lines

I played a lot with qemu this week-end, recompiled kernels and qemu in the emulated machine. Then I was able to run qemu x86 emulation under qemu-ppc (but that's really slooooow...).
I was also able to launch ppc user emulation but missed memory to launch ppc system emulation.
I'm also re-compiling MOL to try to launch Mac OS X using it ;-)

Very cool.

Quoted 2 lines

I did put some screenshots of Qemu running Debian Sarge for PPC here:
<http://perso.magic.fr/l_indien/qemu-ppc/snapshots/index.html>

Interesting.

#9 lore raw

The problems were pinned down to an old Qemu version in Fink, plus OpenHackware it uses.

I've already contacted the fink qemu package maintainer about this. Thanks. :)

8.3.2005 kello 17:05, Thayne Harbaugh kirjoitti:

Quoted 48 lines · J. Mayer
Quoted 9 lines · Thayne Harbaugh
Quoted 3 lines

I've been using the patches for a bit now. All of my previously reported problems are gone.

Great !
I think most of qemu PPC cpu emulation bugs are now fixed. I still know two problems that seems related to emulation:
- top in Debian Sarge crashes.

I've noticed the same thing.

Quoted 3 lines

- Debian woody installer crashes.

Other problems seem OHW or hardware emulation related.

I'm supposed to be looking at some of these, but lately I've had to focus on some other things outside of qemu/OHW. Hopefully I can get back to this soon.

Quoted 3 lines

For example ne2k
seems to miss MII related stuff emulation, then most automatic hardware probes stay stuck while checking the network device.

I don't think I've had this problem - or maybe I just don't recognize it.

Quoted 6 lines

I played a lot with qemu this week-end, recompiled kernels and qemu in the emulated machine. Then I was able to run qemu x86 emulation under qemu-ppc (but that's really slooooow...).
I was also able to launch ppc user emulation but missed memory to launch ppc system emulation.
I'm also re-compiling MOL to try to launch Mac OS X using it ;-)

Very cool.

Quoted 2 lines

I did put some screenshots of Qemu running Debian Sarge for PPC here:
<http://perso.magic.fr/l_indien/qemu-ppc/snapshots/index.html>

Interesting.

_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel