Skip to contentSkip to conversation

[4932] Preliminary PPC64/Linux host support

Qemu-devel malc 5 participants 29 messages Jul 23, 2008 – Aug 3, 2008 Kbuild

lore
Share & tools
lore

malc

author
#0 lore raw

Revision: 4932

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4932
Author:   malc
Date:     2008-07-23 19:17:46 +0000 (Wed, 23 Jul 2008)

Log Message:
-----------
Preliminary PPC64/Linux host support

ppc64.ld from Heikki Lindholm's patch
http://marc.info/?l=qemu-devel&m=114086179024634&w=2

Issues:
x86_64 tripple faults shortly after decompressing the kernel No immediate versions of most 64 bit operations More...

Modified Paths:
--------------
trunk/Makefile.target
trunk/configure
trunk/dyngen-exec.h
trunk/dyngen.c
trunk/exec-all.h
trunk/tcg/tcg.h

Added Paths:
-----------

    trunk/ppc64.ld
    trunk/tcg/ppc64/
    trunk/tcg/ppc64/tcg-target.c
    trunk/tcg/ppc64/tcg-target.h

Modified: trunk/Makefile.target
===================================================================

Makefile.target +4 -0
@@ -342,6 +342,10 @@
 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
 endif
 
+ifeq ($(ARCH),ppc64)
+LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
+endif
+
 ifeq ($(ARCH),s390)
 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
 endif

Modified: trunk/configure
===================================================================

configure +25 -2
@@ -637,6 +637,24 @@
     hostlongbits="64"
 fi
 
+# ppc specific hostlongbits selection
+if test "$cpu" = "powerpc" ; then
+    cat > $TMPC <<EOF
+int main(void){return sizeof(long);}
+EOF
+
+    if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null; then
+        $TMPE
+        case $? in
+            4) hostlongbits="32";;
+            8) hostlongbits="64";;
+            *) echo "Couldn't determine bits per long value";;
+        esac
+    else
+        echo hostlongbits test failed
+    fi
+fi
+
 # check gcc options support
 cat > $TMPC <<EOF
 int main(void) {
@@ -995,8 +1013,13 @@
     echo "#define HOST_MIPS64 1" >> $config_h
   ;;
   powerpc)
-    echo "ARCH=ppc" >> $config_mak
-    echo "#define HOST_PPC 1" >> $config_h
+  if test "$hostlongbits" = "32"; then
+      echo "ARCH=ppc" >> $config_mak
+      echo "#define HOST_PPC 1" >> $config_h
+  else
+      echo "ARCH=ppc64" >> $config_mak
+      echo "#define HOST_PPC64 1" >> $config_h
+  fi
   ;;
   s390)
     echo "ARCH=s390" >> $config_mak

Modified: trunk/dyngen-exec.h
===================================================================

dyngen-exec.h +2 -2
@@ -38,7 +38,7 @@
 // Linux/Sparc64 defines uint64_t
 #if !(defined (__sparc_v9__) && defined(__linux__)) && !(defined(__APPLE__) && defined(__x86_64__))
 /* XXX may be done for all 64 bits targets ? */
-#if defined (__x86_64__) || defined(__ia64) || defined(__s390x__) || defined(__alpha__)
+#if defined (__x86_64__) || defined(__ia64) || defined(__s390x__) || defined(__alpha__) || defined(__powerpc64__)
 typedef unsigned long uint64_t;
 #else
 typedef unsigned long long uint64_t;
@@ -55,7 +55,7 @@
 typedef signed int int32_t;
 // Linux/Sparc64 defines int64_t
 #if !(defined (__sparc_v9__) && defined(__linux__)) && !(defined(__APPLE__) && defined(__x86_64__))
-#if defined (__x86_64__) || defined(__ia64) || defined(__s390x__) || defined(__alpha__)
+#if defined (__x86_64__) || defined(__ia64) || defined(__s390x__) || defined(__alpha__) || defined(__powerpc64__)
 typedef signed long int64_t;
 #else
 typedef signed long long int64_t;

Modified: trunk/dyngen.c
===================================================================

dyngen.c +11 -0
@@ -68,6 +68,13 @@
 #define elf_check_arch(x) ((x) == EM_PPC)
 #define ELF_USES_RELOCA
 
+#elif defined(HOST_PPC64)
+
+#define ELF_CLASS	ELFCLASS64
+#define ELF_ARCH	EM_PPC64
+#define elf_check_arch(x) ((x) == EM_PPC64)
+#define ELF_USES_RELOCA
+
 #elif defined(HOST_S390)
 
 #define ELF_CLASS	ELFCLASS32
@@ -1551,6 +1558,8 @@
     }
 #elif defined(HOST_ARM)
     error("dyngen targets not supported on ARM");
+#elif defined(HOST_PPC64)
+    error("dyngen targets not supported on PPC64");
 #else
 #error unsupported CPU
 #endif
@@ -2592,6 +2601,8 @@
             }
 #elif defined(HOST_ARM)
     error("dyngen targets not supported on ARM");
+#elif defined(HOST_PPC64)
+    error("dyngen targets not supported on PPC64");
 #else
 #error unsupported CPU
 #endif

Modified: trunk/exec-all.h
===================================================================

exec-all.h +5 -0
@@ -191,6 +191,10 @@
 #if defined(USE_DIRECT_JUMP)
 
 #if defined(__powerpc__)
+#if defined(__powerpc64__)
+extern void ppc_tb_set_jmp_target(unsigned long jmp_addr, unsigned long addr);
+#define tb_set_jmp_target1 ppc_tb_set_jmp_target
+#else
 static inline void flush_icache_range(unsigned long start, unsigned long stop);
 static inline void tb_set_jmp_target1(unsigned long jmp_addr, unsigned long addr)
 {
@@ -223,6 +227,7 @@
     /* flush icache */
     flush_icache_range(jmp_addr, jmp_addr + patch_size);
 }
+#endif
 #elif defined(__i386__) || defined(__x86_64__)
 static inline void tb_set_jmp_target1(unsigned long jmp_addr, unsigned long addr)
 {

Added: trunk/ppc64.ld
===================================================================

ppc64.ld +230 -0

230 lines not on this page · raw message

Added: trunk/tcg/ppc64/tcg-target.c
===================================================================

tcg/ppc64/tcg-target.c +1435 -0

1,435 lines not on this page · raw message

Added: trunk/tcg/ppc64/tcg-target.h
===================================================================

tcg/ppc64/tcg-target.h +100 -0

100 lines not on this page · raw message

Modified: trunk/tcg/tcg.h
===================================================================

tcg/tcg.h +15 -0
@@ -414,8 +414,23 @@
 
 extern uint8_t code_gen_prologue[];
 #ifdef __powerpc__
+#ifdef __powerpc64__
+#define tcg_qemu_tb_exec(tb_ptr)                                        \
+    ({ unsigned long p;                                                 \
+       asm volatile (                                                   \
+         "mtctr %1\n\t"                                                 \
+         "mr 3,%2\n\t"                                                  \
+         "bctrl\n\t"                                                    \
+         "mr %0,3\n\t"                                                  \
+         : "=r" (p)                                                     \
+         : "r" (code_gen_prologue), "r" (tb_ptr)                        \
+         : "3", "4", "5", "6", "7", "8", "9", "10", "11", "12");        \
+    p;                                                                  \
+    })
+#else
 #define tcg_qemu_tb_exec(tb_ptr) \
     ((long REGPARM __attribute__ ((longcall)) (*)(void *))code_gen_prologue)(tb_ptr)
+#endif
 #else
 #define tcg_qemu_tb_exec(tb_ptr) ((long REGPARM (*)(void *))code_gen_prologue)(tb_ptr)
 #endif
#1 lore raw

Hi,

Quoted 9 lines · malc

Revision: 4932

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4932
Author:   malc
Date:     2008-07-23 19:17:46 +0000 (Wed, 23 Jul 2008)

Log Message:
-----------
Preliminary PPC64/Linux host support

Quoted 7 lines

ppc64.ld from Heikki Lindholm's patch
http://marc.info/?l=qemu-devel&m=114086179024634&w=2

Issues:
x86_64 tripple faults shortly after decompressing the kernel No immediate versions of most 64 bit operations

Nice! I already spent some hours fixing a previous ppc64 patch that was sent to the list like half a year ago, which was pre TCG and did not work with relocations generated by latest toolchains.

I'll definetly give this patch a try ASAP and try to find some time slots to help streamlining it.

Yours,

Signature · 2 lines
 René Rebe - ExactCODE GmbH - Europe, Germany, Berlin
 http://exactcode.de | http://t2-project.org | http://rene.rebe.name
author
#2 lore raw
Quoted 19 lines · Ren Rebe

Hi,

Quoted 9 lines · malc

Revision: 4932

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4932
Author:   malc
Date:     2008-07-23 19:17:46 +0000 (Wed, 23 Jul 2008)

Log Message:
-----------
Preliminary PPC64/Linux host support

Quoted 7 lines

ppc64.ld from Heikki Lindholm's patch
http://marc.info/?l=qemu-devel&m=114086179024634&w=2

Issues:
x86_64 tripple faults shortly after decompressing the kernel No immediate versions of most 64 bit operations

Quoted 6 lines

Nice! I already spent some hours fixing a previous ppc64 patch that was sent to the list like half a year ago, which was pre TCG and did not work with relocations generated by latest toolchains.

I'll definetly give this patch a try ASAP and try to find some time slots to help streamlining it.

That would be great. One thing i failed to mention in the commit message is that linux-user support seems completely broken on ppc64, i.e. doesn't even compile and error messages are frightening (or maybe it was the amount of them that scared me)

Signature · 1 line
mailto:[email protected]
#3 lore raw

Hi Vassili,

Am 24.07.2008 um 19:41 schrieb malc:

Quoted 6 lines · Ren Rebe
Quoted 3 lines

I'll definetly give this patch a try ASAP and try to find some time slots to help streamlining it.

That would be great.

I'll chime in testing on Linux/ppc64.

Sorry, finally I have some more time - I've already been unsuccessfully working on a patch for OSX/ppc, adjusting the stack offsets, but kept getting an immediate crash. I'll post what I have the next days.

Andreas

#8 lore raw
In reply to malc

Building it under OS X 10.5.4 doesn't work. After editing the config-host files, I get the following:
In file included from /Users/cwbetts/makestuff/qemu-allmac/src/exec-all.h:320,
from /Users/cwbetts/makestuff/qemu-allmac/src/vl.c:
136:
/Users/cwbetts/makestuff/qemu-allmac/src/qemu-lock.h:216:2: error: #error unimplemented CPU support

After adding
#define __powerpc__ 1
#define __powerpc64__ 1
It chokes up under
In file included from /usr/include/inttypes.h:255,
from /Users/cwbetts/makestuff/qemu-allmac/src/cpu-
defs.h:29,
from /Users/cwbetts/makestuff/qemu-allmac/src/target-
i386/exec.h:30,
from /Users/cwbetts/makestuff/qemu-allmac/src/cpu-
exec.c:22:
/usr/lib/gcc/powerpc-apple-darwin9/4.2.1/include/stdint.h:35: error: conflicting types for ‘int64_t’ /Users/cwbetts/makestuff/qemu-allmac/src/dyngen-exec.h:59: error: previous declaration of ‘int64_t’ was here /usr/lib/gcc/powerpc-apple-darwin9/4.2.1/include/stdint.h:55: error: conflicting types for ‘uint64_t’ /Users/cwbetts/makestuff/qemu-allmac/src/dyngen-exec.h:42: error: previous declaration of ‘uint64_t’ was here
make: *** [cpu-exec.o] Error 1
I know that this isn't exactly designed for PPC Macs, but the tcg files compiled without a problem.

Quoted 35 lines · malc

Revision: 4932

         http://svn.sv.gnu.org/viewvc/? 
view=rev&root=qemu&revision=4932
Author:   malc
Date:     2008-07-23 19:17:46 +0000 (Wed, 23 Jul 2008)

Log Message:
-----------
Preliminary PPC64/Linux host support

ppc64.ld from Heikki Lindholm's patch
http://marc.info/?l=qemu-devel&m=114086179024634&w=2

Issues:
x86_64 tripple faults shortly after decompressing the kernel No immediate versions of most 64 bit operations More...

Modified Paths:
--------------
trunk/Makefile.target
trunk/configure
trunk/dyngen-exec.h
trunk/dyngen.c
trunk/exec-all.h
trunk/tcg/tcg.h

Added Paths:
-----------
trunk/ppc64.ld
trunk/tcg/ppc64/
trunk/tcg/ppc64/tcg-target.c
trunk/tcg/ppc64/tcg-target.h

#4 lore raw
In reply to malc
Quoted 26 lines · malc
Quoted 24 lines · Ren Rebe

Hi,

Quoted 10 lines · malc

Revision: 4932

http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4932

Author:   malc
Date:     2008-07-23 19:17:46 +0000 (Wed, 23 Jul 2008)

Log Message:
-----------
Preliminary PPC64/Linux host support

Quoted 7 lines

ppc64.ld from Heikki Lindholm's patch
http://marc.info/?l=qemu-devel&m=114086179024634&w=2

Issues:
x86_64 tripple faults shortly after decompressing the kernel No immediate versions of most 64 bit operations

Nice! I already spent some hours fixing a previous ppc64 patch that was sent to the list like half a year ago, which was pre TCG and did not work with relocations generated by latest toolchains.

Quoted 7 lines
Quoted 2 lines

I'll definetly give this patch a try ASAP and try to find some time slots to help streamlining it.

That would be great. One thing i failed to mention in the commit message is that linux-user support seems completely broken on ppc64, i.e. doesn't even compile and error messages are frightening (or maybe it was the amount of them that scared me)

I gave it a spin yesterday, it built and managed to boot a decent linux-2.6 system until the first user-space programs after init where running and segfaulted thereafter.

I'm abroad the next days, but I'll definetly will help (or try to, I'm no yet that into TCG, yet :-) to hunt those segfaults :-)

Yours,

Signature · 2 lines
 René Rebe - ExactCODE GmbH - Europe, Germany, Berlin
 http://exactcode.de | http://t2-project.org | http://rene.rebe.name
author
#5 lore raw
Quoted 3 lines · Ren? Rebe
Quoted 2 lines · malc

On Thu, 24 Jul 2008, Ren Rebe wrote:

[..snip..]

Quoted 3 lines

I gave it a spin yesterday, it built and managed to boot a decent linux-2.6 system until the first user-space programs after init where running and segfaulted thereafter.

'Decent linux-2.6 system'? Recent perhaps? In any case that is strange since linux-test image does work here as does ls after booting it (not much, i know)

Quoted 2 lines

I'm abroad the next days, but I'll definetly will help (or try to, I'm no yet that into TCG, yet :-) to hunt those segfaults :-)

Thanks, in the meantime can You tell what is that you have unsuccessfully tried to boot?

Signature · 1 line
mailto:[email protected]
author
#9 lore raw
In reply to C.W. Betts
Quoted 5 lines · C.W. Betts

Building it under OS X 10.5.4 doesn't work. After editing the config-host files, I get the following:
In file included from /Users/cwbetts/makestuff/qemu-allmac/src/exec-all.h:320,
from /Users/cwbetts/makestuff/qemu-allmac/src/vl.c:136:
/Users/cwbetts/makestuff/qemu-allmac/src/qemu-lock.h:216:2: error: #error unimplemented CPU support

Quoted 14 lines

After adding
#define __powerpc__ 1
#define __powerpc64__ 1
It chokes up under
In file included from /usr/include/inttypes.h:255,
from /Users/cwbetts/makestuff/qemu-allmac/src/cpu-defs.h:29,
from
/Users/cwbetts/makestuff/qemu-allmac/src/target-i386/exec.h:30,
from /Users/cwbetts/makestuff/qemu-allmac/src/cpu-exec.c:22:
/usr/lib/gcc/powerpc-apple-darwin9/4.2.1/include/stdint.h:35: error: conflicting types for ?int64_t? /Users/cwbetts/makestuff/qemu-allmac/src/dyngen-exec.h:59: error: previous declaration of ?int64_t? was here /usr/lib/gcc/powerpc-apple-darwin9/4.2.1/include/stdint.h:55: error: conflicting types for ?uint64_t? /Users/cwbetts/makestuff/qemu-allmac/src/dyngen-exec.h:42: error: previous declaration of ?uint64_t? was here
make: *** [cpu-exec.o] Error 1

Uh, weird, what are [u]int64_t are defined to on darwin?

Quoted 1 line

I know that this isn't exactly designed for PPC Macs, but the tcg files compiled without a problem.

What gives you that idea?

Signature · 1 line
mailto:[email protected]
#10 lore raw

Am 25.07.2008 um 20:18 schrieb malc:

Quoted 10 lines · C.W. Betts
Quoted 9 lines

Building it under OS X 10.5.4 doesn't work. After editing the config-host files, I get the following:
In file included from /Users/cwbetts/makestuff/qemu-allmac/src/exec-all.h:320,
from /Users/cwbetts/makestuff/qemu-allmac/src/vl.c:136:
/Users/cwbetts/makestuff/qemu-allmac/src/qemu-lock.h:216:2: error: #error unimplemented CPU support

After adding
#define __powerpc__ 1
#define __powerpc64__ 1

I don't think it's is a good idea to define these as such, it may confuse other software. You should check the places where they are used and add appropriate checks for either __ppc__ or __ppc64__ respectively (they are never defined at the same time, contrary to Linux).

In TCG Spotlight came up only with this:

tcg/tcg.h +1 -1
index bc5b902..860bce9 100644
@@ -413,7 +413,7 @@ uint64_t tcg_helper_divu_i64(uint64_t arg1, uint64_t arg2);
 uint64_t tcg_helper_remu_i64(uint64_t arg1, uint64_t arg2);
 
 extern uint8_t code_gen_prologue[];
-#if defined(__powerpc__) && !defined(__powerpc64__)
+#if (defined(__powerpc__) || defined(__ppc__)) && !defined(__powerpc64__)
 #define tcg_qemu_tb_exec(tb_ptr) \
     ((long REGPARM __attribute__ ((longcall)) (*)(void  

*))code_gen_prologue)(tb
#else

and it shouldn't affect ppc64. Not sure if it's needed at all for OSX? What's it supposed to change?

Quoted 14 lines
Quoted 5 lines

It chokes up under
In file included from /usr/include/inttypes.h:255,
from /Users/cwbetts/makestuff/qemu-allmac/src/cpu-
defs.h:29,
from /Users/cwbetts/makestuff/qemu-allmac/src/target-

Quoted 8 lines

i386/exec.h:30,
from /Users/cwbetts/makestuff/qemu-allmac/src/cpu-
exec.c:22:
/usr/lib/gcc/powerpc-apple-darwin9/4.2.1/include/stdint.h:35: error: conflicting types for ?int64_t? /Users/cwbetts/makestuff/qemu-allmac/src/dyngen-exec.h:59: error: previous declaration of ?int64_t? was here /usr/lib/gcc/powerpc-apple-darwin9/4.2.1/include/stdint.h:55: error: conflicting types for ?uint64_t? /Users/cwbetts/makestuff/qemu-allmac/src/dyngen-exec.h:42: error: previous declaration of ?uint64_t? was here
make: *** [cpu-exec.o] Error 1

Quoted 1 line

Uh, weird,

Well, afaik dyngen didn't have support for ppc64...

Quoted 1 line

what are [u]int64_t are defined to on darwin?

uint64_t is defined to u_int64_t (stdint.h), which is defined to unsigned long long (ppc/types.h). int64_t is defined to long long (ppc/types.h).

Quoted 3 lines
Quoted 1 line

I know that this isn't exactly designed for PPC Macs, but the tcg files compiled without a problem.

What gives you that idea?

He probably meant designed for PPC Mac OS X - you said so, and it doesn't work yet. See my patch, there are currently numbers hardcoded for Linux.

Andreas

#27 lore raw
In reply to C.W. Betts

Am 25.07.2008 um 01:33 schrieb C.W. Betts:

Quoted 10 lines

Building it under OS X 10.5.4 doesn't work. After editing the config-host files, I get the following:
In file included from /Users/cwbetts/makestuff/qemu-allmac/src/exec-all.h:320,
from /Users/cwbetts/makestuff/qemu-allmac/src/vl.c:
136:
/Users/cwbetts/makestuff/qemu-allmac/src/qemu-lock.h:216:2: error: #error unimplemented CPU support

After adding
#define __powerpc__ 1
#define __powerpc64__ 1

Quoted 13 lines

It chokes up under
In file included from /usr/include/inttypes.h:255,
from /Users/cwbetts/makestuff/qemu-allmac/src/cpu-
defs.h:29,
from /Users/cwbetts/makestuff/qemu-allmac/src/target-
i386/exec.h:30,
from /Users/cwbetts/makestuff/qemu-allmac/src/cpu-
exec.c:22:
/usr/lib/gcc/powerpc-apple-darwin9/4.2.1/include/stdint.h:35: error: conflicting types for ‘int64_t’ /Users/cwbetts/makestuff/qemu-allmac/src/dyngen-exec.h:59: error: previous declaration of ‘int64_t’ was here /usr/lib/gcc/powerpc-apple-darwin9/4.2.1/include/stdint.h:55: error: conflicting types for ‘uint64_t’ /Users/cwbetts/makestuff/qemu-allmac/src/dyngen-exec.h:42: error: previous declaration of ‘uint64_t’ was here
make: *** [cpu-exec.o] Error 1

Could you please try if the dyngen-exec.h patch I just posted works for you?

Andreas

#28 lore raw

Yes, it fixes compilation. Thanks.

Quoted 33 lines · Andreas Färber

Am 25.07.2008 um 01:33 schrieb C.W. Betts:

Quoted 10 lines

Building it under OS X 10.5.4 doesn't work. After editing the config-host files, I get the following:
In file included from /Users/cwbetts/makestuff/qemu-allmac/src/exec-all.h:320,
from /Users/cwbetts/makestuff/qemu-allmac/src/vl.c:
136:
/Users/cwbetts/makestuff/qemu-allmac/src/qemu-lock.h:216:2: error: #error unimplemented CPU support

After adding
#define __powerpc__ 1
#define __powerpc64__ 1

Quoted 13 lines

It chokes up under
In file included from /usr/include/inttypes.h:255,
from /Users/cwbetts/makestuff/qemu-allmac/src/cpu-
defs.h:29,
from /Users/cwbetts/makestuff/qemu-allmac/src/target-
i386/exec.h:30,
from /Users/cwbetts/makestuff/qemu-allmac/src/cpu-
exec.c:22:
/usr/lib/gcc/powerpc-apple-darwin9/4.2.1/include/stdint.h:35: error: conflicting types for ‘int64_t’ /Users/cwbetts/makestuff/qemu-allmac/src/dyngen-exec.h:59: error: previous declaration of ‘int64_t’ was here /usr/lib/gcc/powerpc-apple-darwin9/4.2.1/include/stdint.h:55: error: conflicting types for ‘uint64_t’ /Users/cwbetts/makestuff/qemu-allmac/src/dyngen-exec.h:42: error: previous declaration of ‘uint64_t’ was here
make: *** [cpu-exec.o] Error 1

Could you please try if the dyngen-exec.h patch I just posted works for you?

Andreas

#11 lore raw
In reply to Andreas Färber
Quoted 10 lines · Andreas Färber

Am 25.07.2008 um 20:18 schrieb malc:

Quoted 7 lines · C.W. Betts
Quoted 6 lines

Building it under OS X 10.5.4 doesn't work. After editing the config-host files, I get the following:
In file included from /Users/cwbetts/makestuff/qemu-allmac/src/exec-all.h:320,
from /Users/cwbetts/makestuff/qemu-allmac/src/vl.c:136:
/Users/cwbetts/makestuff/qemu-allmac/src/qemu-lock.h:216:2: error: #error unimplemented CPU support

Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

After adding
#define __powerpc__ 1
#define __powerpc64__ 1

I don't think it's is a good idea to define these as such, it may confuse other software. You should check the places where they are used and add appropriate checks for either __ppc__ or __ppc64__ respectively (they are never defined at the same time, contrary to Linux).

When ARCH=ppc is defined in config-host.mak, it adds -D__powerpc__ to the compiler command line. However, it doesn't seem to do that when it is defined as ppc64. I also remember seeing __powerpc64__ mentioned in the patch.

Quoted 14 lines
Quoted 14 lines
Quoted 13 lines

It chokes up under
In file included from /usr/include/inttypes.h:255,
from /Users/cwbetts/makestuff/qemu-allmac/src/cpu-
defs.h:29,
from /Users/cwbetts/makestuff/qemu-allmac/src/target-
i386/exec.h:30,
from /Users/cwbetts/makestuff/qemu-allmac/src/cpu-
exec.c:22:
/usr/lib/gcc/powerpc-apple-darwin9/4.2.1/include/stdint.h:35: error: conflicting types for ?int64_t? /Users/cwbetts/makestuff/qemu-allmac/src/dyngen-exec.h:59: error: previous declaration of ?int64_t? was here /usr/lib/gcc/powerpc-apple-darwin9/4.2.1/include/stdint.h:55: error: conflicting types for ?uint64_t? /Users/cwbetts/makestuff/qemu-allmac/src/dyngen-exec.h:42: error: previous declaration of ?uint64_t? was here
make: *** [cpu-exec.o] Error 1

Quoted 3 lines
Quoted 1 line

Uh, weird,

Well, afaik dyngen didn't have support for ppc64...

I usually touch dyngen to make it not compile. I think cpu-exec.c includes dyngen-exec.h.

#12 lore raw

Am 26.07.2008 um 19:36 schrieb C.W. Betts:

Quoted 13 lines · Andreas Färber
Quoted 11 lines

Am 25.07.2008 um 20:18 schrieb malc:

Quoted 7 lines · C.W. Betts
Quoted 6 lines

Building it under OS X 10.5.4 doesn't work. After editing the config-host files, I get the following:
In file included from /Users/cwbetts/makestuff/qemu-allmac/src/exec-all.h:320,
from /Users/cwbetts/makestuff/qemu-allmac/src/vl.c:136:
/Users/cwbetts/makestuff/qemu-allmac/src/qemu-lock.h:216:2: error: #error unimplemented CPU support

Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

After adding
#define __powerpc__ 1
#define __powerpc64__ 1

I don't think it's is a good idea to define these as such, it may confuse other software. You should check the places where they are used and add appropriate checks for either __ppc__ or __ppc64__ respectively (they are never defined at the same time, contrary to Linux).

When ARCH=ppc is defined in config-host.mak, it adds -D__powerpc__ to the compiler command line. However, it doesn't seem to do that when it is defined as ppc64.

Okay, I found it in Makefile.target. The attached patch should define them, let me know if it works.

Makefile.target +4 -0
index 0c33f85..0d77fce 100644
@@ -109,6 +109,10 @@ CPPFLAGS+= -D__powerpc__
 OP_CFLAGS+= -mlongcall
 endif
 
+ifeq ($(ARCH),ppc64)
+CPPFLAGS+= -D__powerpc__ -D__powerpc64__
+endif
+
 ifeq ($(ARCH),sparc)
   CFLAGS+=-ffixed-g2 -ffixed-g3
   OP_CFLAGS+=-fno-delayed-branch -ffixed-i0
Quoted 3 lines

I also remember seeing __powerpc64__ mentioned in the patch.

On Linux, both __powerpc__ and __powerpc64__ are defined.

However I'm still not comfortable with defining these because they might be used to distinguish between Linux and OSX elsewhere. PowerPC is the only target that does such a hack, so I'd rather eliminate it than extend it...

Andreas

author
#13 lore raw
In reply to Andreas Färber
Quoted 10 lines · Andreas F?rber

Am 25.07.2008 um 20:18 schrieb malc:

Quoted 7 lines · C.W. Betts
Quoted 6 lines

Building it under OS X 10.5.4 doesn't work. After editing the config-host files, I get the following:
In file included from /Users/cwbetts/makestuff/qemu-allmac/src/exec-all.h:320,
from /Users/cwbetts/makestuff/qemu-allmac/src/vl.c:136:
/Users/cwbetts/makestuff/qemu-allmac/src/qemu-lock.h:216:2: error: #error unimplemented CPU support

Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

After adding
#define __powerpc__ 1
#define __powerpc64__ 1

I don't think it's is a good idea to define these as such, it may confuse other software. You should check the places where they are used and add appropriate checks for either __ppc__ or __ppc64__ respectively (they are never defined at the same time, contrary to Linux).

You are replying to both me and C.W. Betts this is somewhat confusing.

Quoted 32 lines

In TCG Spotlight came up only with this:

tcg/tcg.h +1 -1
index bc5b902..860bce9 100644
@@ -413,7 +413,7 @@ uint64_t tcg_helper_divu_i64(uint64_t arg1, uint64_t 
 arg2);
 uint64_t tcg_helper_remu_i64(uint64_t arg1, uint64_t arg2);
 
 extern uint8_t code_gen_prologue[];
-#if defined(__powerpc__) && !defined(__powerpc64__)
+#if (defined(__powerpc__) || defined(__ppc__)) && !defined(__powerpc64__)
 #define tcg_qemu_tb_exec(tb_ptr) \
   ((long REGPARM __attribute__ ((longcall)) (*)(void 

*))code_gen_prologue)(tb
#else

and it shouldn't affect ppc64. Not sure if it's needed at all for OSX? What's it supposed to change?

Quoted 12 lines
Quoted 11 lines

It chokes up under
In file included from /usr/include/inttypes.h:255,
from /Users/cwbetts/makestuff/qemu-allmac/src/cpu-defs.h:29,
from
/Users/cwbetts/makestuff/qemu-allmac/src/target-i386/exec.h:30,
from /Users/cwbetts/makestuff/qemu-allmac/src/cpu-exec.c:22:
/usr/lib/gcc/powerpc-apple-darwin9/4.2.1/include/stdint.h:35: error: conflicting types for ?int64_t? /Users/cwbetts/makestuff/qemu-allmac/src/dyngen-exec.h:59: error: previous declaration of ?int64_t? was here /usr/lib/gcc/powerpc-apple-darwin9/4.2.1/include/stdint.h:55: error: conflicting types for ?uint64_t? /Users/cwbetts/makestuff/qemu-allmac/src/dyngen-exec.h:42: error: previous declaration of ?uint64_t? was here
make: *** [cpu-exec.o] Error 1

Quoted 3 lines
Quoted 1 line

Uh, weird,

Well, afaik dyngen didn't have support for ppc64...

No that's not what i find weird, the weird part is darwin elects to use (unsigned) long long for (u)int64_t while Linux uses plain longs.

Quoted 10 lines
Quoted 1 line

what are [u]int64_t are defined to on darwin?

uint64_t is defined to u_int64_t (stdint.h), which is defined to unsigned long long (ppc/types.h). int64_t is defined to long long (ppc/types.h).

Quoted 3 lines
Quoted 1 line

I know that this isn't exactly designed for PPC Macs, but the tcg files compiled without a problem.

What gives you that idea?

He probably meant designed for PPC Mac OS X - you said so, and it doesn't work yet. See my patch, there are currently numbers hardcoded for Linux.

It's not just about numbers, last time i looked (cursory) the ABIs where a lot different (PPC32 case) just changing the numbers wont get one very far i think.

Signature · 1 line
mailto:[email protected]
#6 lore raw
In reply to malc

Hi,

Quoted 8 lines · malc
Quoted 3 lines · Ren? Rebe
Quoted 2 lines · malc

On Thu, 24 Jul 2008, Ren Rebe wrote:

[..snip..]

Quoted 7 lines
Quoted 3 lines

I gave it a spin yesterday, it built and managed to boot a decent linux-2.6 system until the first user-space programs after init where running and segfaulted thereafter.

'Decent linux-2.6 system'? Recent perhaps? In any case that is strange since linux-test image does work here as does ls after booting it (not much, i know)

Yes, recent (2.6.2x), of course :-)

Quoted 5 lines
Quoted 2 lines

I'm abroad the next days, but I'll definetly will help (or try to, I'm no yet that into TCG, yet :-) to hunt those segfaults :-)

Thanks, in the meantime can You tell what is that you have unsuccessfully tried to boot?

Well it's my standard T2 SDE (http://t2-project.org) test image. Actually it boots, and quite some user-space is running (statically linked early userspace of the initrd for u/dev & co) and then the system init and even mounting the virtual/pseudo filesystems. It "only" segfaults somewhere soonish after init is already running and executed the first tasks. So on my side actually "quite a lot" already worked.

However, I just checked with the qemu:HEAD and the qemu segfault booting my system is already gone - though it's booting quite slowly :-(

Great work so far!

René

Signature · 2 lines
 René Rebe - ExactCODE GmbH - Europe, Germany, Berlin
 http://exactcode.de | http://t2-project.org | http://rene.rebe.name
#14 lore raw
In reply to malc

Am 26.07.2008 um 20:54 schrieb malc:

Quoted 5 lines
Quoted 1 line

there are currently numbers hardcoded for Linux.

It's not just about numbers, last time i looked (cursory) the ABIs where a lot different (PPC32 case) just changing the numbers wont get one very far i think.

Of course not only, but it's one step that could be applied. The stack alignment is 16 Bytes for both, and the prolog in my ppc(32) branch seems to match the referenced Apple pseudocode now.

Where else do you have differences in mind? Which additional functions may need to be adjusted?

Andreas

tcg/ppc/tcg-target.c +5 -6
index 7dfb17f..3ebe68c 100644
@@ -806,23 +806,22 @@ void tcg_target_qemu_prologue (TCGContext *s)
     int i, frame_size;
 
     frame_size = 0
-        + 4                     /* back chain */
-        + 4                     /* LR */
+        + TCG_TARGET_CALL_STACK_OFFSET
         + TCG_STATIC_CALL_ARGS_SIZE
         + ARRAY_SIZE (tcg_target_callee_save_regs) * 4
         ;
     frame_size = (frame_size + 15) & ~15;
 
     tcg_out32 (s, MFSPR | RT (0) | LR);
+    tcg_out32 (s, STW | RS (0) | RA (1) | (TCG_TARGET_CALL_LR_OFFSET));
     tcg_out32 (s, STWU | RS (1) | RA (1) | (-frame_size & 0xffff));
     for (i = 0; i < ARRAY_SIZE (tcg_target_callee_save_regs); ++i)
         tcg_out32 (s, (STW
                        | RS (tcg_target_callee_save_regs[i])
                        | RA (1)
-                       | (i * 4 + 8 + TCG_STATIC_CALL_ARGS_SIZE)
+                       | (TCG_TARGET_CALL_STACK_OFFSET + TCG_STATIC_CALL_ARGS_SIZE + i * 4)
                        )
             );
-    tcg_out32 (s, STW | RS (0) | RA (1) | (frame_size + 4));
 
     tcg_out32 (s, MTSPR | RS (3) | CTR);
     tcg_out32 (s, BCCTR | BO_ALWAYS);
@@ -832,10 +831,10 @@ void tcg_target_qemu_prologue (TCGContext *s)
         tcg_out32 (s, (LWZ
                        | RT (tcg_target_callee_save_regs[i])
                        | RA (1)
-                       | (i * 4 + 8 + TCG_STATIC_CALL_ARGS_SIZE)
+                       | (TCG_TARGET_CALL_STACK_OFFSET + TCG_STATIC_CALL_ARGS_SIZE + i * 4)
                        )
             );
-    tcg_out32 (s, LWZ | RT (0) | RA (1) | (frame_size + 4));
+    tcg_out32 (s, LWZ | RT (0) | RA (1) | (frame_size + TCG_TARGET_CALL_LR_OFFSET));
     tcg_out32 (s, MTSPR | RS (0) | LR);
     tcg_out32 (s, ADDI | RT (1) | RA (1) | frame_size);
     tcg_out32 (s, BCLR | BO_ALWAYS);
tcg/ppc/tcg-target.h +6 -0
index e21b992..7e2c8bd 100644
@@ -65,7 +65,13 @@ enum {
 /* used for function call generation */
 #define TCG_REG_CALL_STACK TCG_REG_R1
 #define TCG_TARGET_STACK_ALIGN 16
+#ifdef __APPLE__
+#define TCG_TARGET_CALL_STACK_OFFSET 24
+#define TCG_TARGET_CALL_LR_OFFSET 8
+#else
 #define TCG_TARGET_CALL_STACK_OFFSET 8
+#define TCG_TARGET_CALL_LR_OFFSET 4
+#endif
 #define TCG_TARGET_CALL_ALIGN_ARGS 1
 
 /* optional instructions */
tcg/tcg.h +1 -1
index bc5b902..860bce9 100644
@@ -413,7 +413,7 @@ uint64_t tcg_helper_divu_i64(uint64_t arg1, uint64_t arg2);
 uint64_t tcg_helper_remu_i64(uint64_t arg1, uint64_t arg2);
 
 extern uint8_t code_gen_prologue[];
-#if defined(__powerpc__) && !defined(__powerpc64__)
+#if (defined(__powerpc__) || defined(__ppc__)) && !defined(__powerpc64__)
 #define tcg_qemu_tb_exec(tb_ptr) \
     ((long REGPARM __attribute__ ((longcall)) (*)(void *))code_gen_prologue)(tb_ptr)
 #else
author
#7 lore raw
In reply to René Rebe
Quoted 32 lines · Ren? Rebe

Hi,

Quoted 8 lines · malc
Quoted 3 lines · Ren? Rebe
Quoted 2 lines · malc

On Thu, 24 Jul 2008, Ren Rebe wrote:

[..snip..]

Quoted 7 lines
Quoted 3 lines

I gave it a spin yesterday, it built and managed to boot a decent linux-2.6 system until the first user-space programs after init where running and segfaulted thereafter.

'Decent linux-2.6 system'? Recent perhaps? In any case that is strange since linux-test image does work here as does ls after booting it (not much, i know)

Yes, recent (2.6.2x), of course :-)

Quoted 5 lines
Quoted 2 lines

I'm abroad the next days, but I'll definetly will help (or try to, I'm no yet that into TCG, yet :-) to hunt those segfaults :-)

Thanks, in the meantime can You tell what is that you have unsuccessfully tried to boot?

Well it's my standard T2 SDE (http://t2-project.org) test image. Actually it boots, and quite some user-space is running (statically linked early userspace of the initrd for u/dev & co) and then the system init and even mounting the virtual/pseudo filesystems. It "only" segfaults somewhere soonish after init is already running and executed the first tasks. So on my side actually "quite a lot" already worked.

Quoted 2 lines

However, I just checked with the qemu:HEAD and the qemu segfault booting my system is already gone - though it's booting quite slowly :-(

Compared to what?

[...snip..]

Signature · 1 line
mailto:[email protected]
author
#15 lore raw
In reply to Andreas Färber
Quoted 5 lines · Andreas F?rber

Am 26.07.2008 um 20:54 schrieb malc:

Quoted 2 lines
Quoted 1 line

there are currently numbers hardcoded for Linux.

Quoted 7 lines
Quoted 3 lines

It's not just about numbers, last time i looked (cursory) the ABIs where a lot different (PPC32 case) just changing the numbers wont get one very far i think.

Of course not only, but it's one step that could be applied. The stack alignment is 16 Bytes for both, and the prolog in my ppc(32) branch seems to match the referenced Apple pseudocode now.

Where else do you have differences in mind? Which additional functions may need to be adjusted?

I'd have to check Darwins ABI to be sure, but here's the short list:

a. Alignement of 64 bit arguments (in the register file)
(This was the thing that confused Sparcs ASI helpers when i first
tried to boot Sparc on, then new, PPC32 tcg)

b. List of reserved registers

c. The approach to TOC (or however Apple calls the substitute)

In any case, PPC32 + MacOS X i can help with. PPC64 + MacOS X not so much.

Signature · 1 line
mailto:[email protected]
#16 lore raw

Re: [Qemu-devel] Mac OS X PPC host support (was: [4932] Preliminary PPC64/Linux host support)

Am 27.07.2008 um 20:14 schrieb malc:

Quoted 10 lines · Andreas F?rber
Quoted 9 lines

Am 26.07.2008 um 20:54 schrieb malc:

Quoted 4 lines
Quoted 1 line

there are currently numbers hardcoded for Linux.

It's not just about numbers, last time i looked (cursory) the ABIs where a lot different (PPC32 case) just changing the numbers wont get one very far i think.

Quoted 5 lines
Quoted 3 lines

Of course not only, but it's one step that could be applied. The stack alignment is 16 Bytes for both, and the prolog in my ppc(32) branch seems to match the referenced Apple pseudocode now.

Where else do you have differences in mind? Which additional functions may need to be adjusted?

I'd have to check Darwins ABI to be sure, but here's the short list:

http://developer.apple.com/documentation/DeveloperTools/Conceptual/LowLevelABI/Articles/32bitPowerPC.html

Quoted 3 lines

a. Alignement of 64 bit arguments (in the register file)
(This was the thing that confused Sparcs ASI helpers when i first
tried to boot Sparc on, then new, PPC32 tcg)

What register file? Please be more detailed, I'm not intimate with TCG.

Quoted 1 line

b. List of reserved registers

According to the Apple ppc ABI document, r2 is not system-reserved compared to SVR4 ppc ABI. The other general-purpose registers look similar (assuming we don't have nested functions), although Apple seems to have less strict prescriptions what to store where.

Quoted 1 line

c. The approach to TOC (or however Apple calls the substitute)

Not sure what you mean. Pointers to concrete files and functions might help.

Quoted 1 line

In any case, PPC32 + MacOS X i can help with. PPC64 + MacOS X not so much.

Restoring Mac OS X ppc(32) to work again would be just great.
PPC64 didn't work pre-TCG. We'll probably know where to poke ourselves once ppc is running.

Andreas

author
#17 lore raw

Re: [Qemu-devel] Mac OS X PPC host support (was: [4932] Preliminary PPC64/Linux host support)

Quoted 19 lines · Andreas F?rber

Am 27.07.2008 um 20:14 schrieb malc:

Quoted 10 lines · Andreas F?rber
Quoted 9 lines

Am 26.07.2008 um 20:54 schrieb malc:

Quoted 4 lines
Quoted 1 line

there are currently numbers hardcoded for Linux.

It's not just about numbers, last time i looked (cursory) the ABIs where a lot different (PPC32 case) just changing the numbers wont get one very far i think.

Quoted 5 lines
Quoted 3 lines

Of course not only, but it's one step that could be applied. The stack alignment is 16 Bytes for both, and the prolog in my ppc(32) branch seems to match the referenced Apple pseudocode now.

Where else do you have differences in mind? Which additional functions may need to be adjusted?

I'd have to check Darwins ABI to be sure, but here's the short list:

Quoted 7 lines

http://developer.apple.com/documentation/DeveloperTools/Conceptual/LowLevelABI/Articles/32bitPowerPC.html

Quoted 3 lines

a. Alignement of 64 bit arguments (in the register file)
(This was the thing that confused Sparcs ASI helpers when i first
tried to boot Sparc on, then new, PPC32 tcg)

What register file? Please be more detailed, I'm not intimate with TCG.

I meant this http://en.wikipedia.org/wiki/Register_file
But anyhow it is not aligned hence the ASI failure You saw earlier.

Quoted 7 lines
Quoted 1 line

b. List of reserved registers

According to the Apple ppc ABI document, r2 is not system-reserved compared to SVR4 ppc ABI. The other general-purpose registers look similar (assuming we don't have nested functions), although Apple seems to have less strict prescriptions what to store where.

Quoted 1 line

c. The approach to TOC (or however Apple calls the substitute)

Not sure what you mean. Pointers to concrete files and functions might help.

I have checked and MacOS X on PPC32 doesn't use those.

Quoted 5 lines
Quoted 2 lines

In any case, PPC32 + MacOS X i can help with. PPC64 + MacOS X not so much.

Restoring Mac OS X ppc(32) to work again would be just great.
PPC64 didn't work pre-TCG. We'll probably know where to poke ourselves once ppc is running.

I have made a stab at making it work and tried it on MacOS X (Tiger) that i have here, for Sparc it progress a bit further but still meets it's doom shortly:

qemu: fatal: Trap 0x29 while interrupts disabled, Error state
pc: ffd04020 npc: ffd04024
General Registers:

%g0: 00000000   %g1: 00000000   %g2: ffd908e0   %g3: ffd00000
%g4: ffd83038   %g5: 00000001   %g6: 00000000   %g7: 00000000
Current Register Window:
%o0: 00000000   %o1: 00000000   %o2: 00000000   %o3: 00000000
%o4: 00000000   %o5: 00000000   %o6: ffdd3fa0   %o7: 00000000
%l0: 00000000   %l1: 00000000   %l2: 00000000   %l3: 00000000
%l4: 00000000   %l5: 00000000   %l6: 00000000   %l7: 00000000
%i0: 00000000   %i1: 00000000   %i2: 00000000   %i3: 00000000
%i4: 00000000   %i5: 00000000   %i6: 00000000   %i7: 00000000

Floating Point Registers:
[all bit zero FPRs snipped]
psr: 0x04001fc0 -> ---- SP- wim: 0x00000001
fsr: 0x00080000

BlueSwirl, rings any bells?

I tried my best to hack it while in Mac OSX, but, honestly, i can not stand that system and have no spare (quiet enough) machine to SSH into it and do things remotely, sorry.

The code is available at:

http://repo.or.cz/w/qemu/malc.git?a=shortlog;h=refs/heads/tcgppc32macosx

Signature · 1 line
mailto:[email protected]
#18 lore raw

Re: [Qemu-devel] Mac OS X PPC host support (was: [4932] Preliminary PPC64/Linux host support)

Quoted 17 lines · malc

I have made a stab at making it work and tried it on MacOS X (Tiger) that i have here, for Sparc it progress a bit further but still meets it's doom shortly:

qemu: fatal: Trap 0x29 while interrupts disabled, Error state
pc: ffd04020 npc: ffd04024
General Registers:

 %g0: 00000000   %g1: 00000000   %g2: ffd908e0   %g3: ffd00000
 %g4: ffd83038   %g5: 00000001   %g6: 00000000   %g7: 00000000
 Current Register Window:
 %o0: 00000000   %o1: 00000000   %o2: 00000000   %o3: 00000000
 %o4: 00000000   %o5: 00000000   %o6: ffdd3fa0   %o7: 00000000
 %l0: 00000000   %l1: 00000000   %l2: 00000000   %l3: 00000000
 %l4: 00000000   %l5: 00000000   %l6: 00000000   %l7: 00000000
 %i0: 00000000   %i1: 00000000   %i2: 00000000   %i3: 00000000
 %i4: 00000000   %i5: 00000000   %i6: 00000000   %i7: 00000000
Quoted 6 lines

Floating Point Registers:
[all bit zero FPRs snipped]
psr: 0x04001fc0 -> ---- SP- wim: 0x00000001
fsr: 0x00080000

BlueSwirl, rings any bells?

29 is Data Access Exception, raised from unassigned memory access. The code is

0xffd04020: std %l0, [ %sp ]

which is a double word store. Address in %sp (%o6, 0xffdd3fa0) is OK. So I'd check if qemu_st64 generates correct code.

author
#19 lore raw

Re: [Qemu-devel] Mac OS X PPC host support (was: [4932] Preliminary PPC64/Linux host support)

Quoted 23 lines · Blue Swirl
Quoted 22 lines · malc

I have made a stab at making it work and tried it on MacOS X (Tiger) that i have here, for Sparc it progress a bit further but still meets it's doom shortly:

qemu: fatal: Trap 0x29 while interrupts disabled, Error state
pc: ffd04020 npc: ffd04024
General Registers:

 %g0: 00000000   %g1: 00000000   %g2: ffd908e0   %g3: ffd00000
 %g4: ffd83038   %g5: 00000001   %g6: 00000000   %g7: 00000000
 Current Register Window:
 %o0: 00000000   %o1: 00000000   %o2: 00000000   %o3: 00000000
 %o4: 00000000   %o5: 00000000   %o6: ffdd3fa0   %o7: 00000000
 %l0: 00000000   %l1: 00000000   %l2: 00000000   %l3: 00000000
 %l4: 00000000   %l5: 00000000   %l6: 00000000   %l7: 00000000
 %i0: 00000000   %i1: 00000000   %i2: 00000000   %i3: 00000000
 %i4: 00000000   %i5: 00000000   %i6: 00000000   %i7: 00000000

Floating Point Registers:
[all bit zero FPRs snipped]
psr: 0x04001fc0 -> ---- SP- wim: 0x00000001
fsr: 0x00080000

Quoted 8 lines
Quoted 1 line

BlueSwirl, rings any bells?

29 is Data Access Exception, raised from unassigned memory access. The code is

0xffd04020: std %l0, [ %sp ]

which is a double word store. Address in %sp (%o6, 0xffdd3fa0) is OK. So I'd check if qemu_st64 generates correct code.

Thanks, i'll look into this if i found courage to boot into MacOS X again.

Signature · 1 line
mailto:[email protected]
author
#20 lore raw

Re: [Qemu-devel] Mac OS X PPC host support (was: [4932] Preliminary PPC64/Linux host support)

In reply to Blue Swirl
Quoted 23 lines · Blue Swirl
Quoted 22 lines · malc

I have made a stab at making it work and tried it on MacOS X (Tiger) that i have here, for Sparc it progress a bit further but still meets it's doom shortly:

qemu: fatal: Trap 0x29 while interrupts disabled, Error state
pc: ffd04020 npc: ffd04024
General Registers:

 %g0: 00000000   %g1: 00000000   %g2: ffd908e0   %g3: ffd00000
 %g4: ffd83038   %g5: 00000001   %g6: 00000000   %g7: 00000000
 Current Register Window:
 %o0: 00000000   %o1: 00000000   %o2: 00000000   %o3: 00000000
 %o4: 00000000   %o5: 00000000   %o6: ffdd3fa0   %o7: 00000000
 %l0: 00000000   %l1: 00000000   %l2: 00000000   %l3: 00000000
 %l4: 00000000   %l5: 00000000   %l6: 00000000   %l7: 00000000
 %i0: 00000000   %i1: 00000000   %i2: 00000000   %i3: 00000000
 %i4: 00000000   %i5: 00000000   %i6: 00000000   %i7: 00000000

Floating Point Registers:
[all bit zero FPRs snipped]
psr: 0x04001fc0 -> ---- SP- wim: 0x00000001
fsr: 0x00080000

Quoted 8 lines
Quoted 1 line

BlueSwirl, rings any bells?

29 is Data Access Exception, raised from unassigned memory access. The code is

0xffd04020: std %l0, [ %sp ]

which is a double word store. Address in %sp (%o6, 0xffdd3fa0) is OK. So I'd check if qemu_st64 generates correct code.

That was spot on, thanks once again. I have notified main tcg proper to not align register parameters, but failed to do so myself when calling qemu_stXX helpers.

With that fixed Sparc test image boots in MacOS X, i386 test image does make it to ext2fs warning but then just hangs there waiting for something, and some dma timer warning messages popup in the console after a while, therefore i'm reluctant on commiting it just now.

That said the code is there:
http://repo.or.cz/w/qemu/malc.git?a=shortlog;h=refs/heads/tcgppc32macosx
(warning, one commit was amended so things will not fast-forward)

My MacOS X stuff is outdated so maybe the i386 problem is not a TCG one, testing from uptodate MacOS X/PPC32 people would be needed. And i think someone more MacOS X inclined should take over this part.

Signature · 1 line
mailto:[email protected]
#21 lore raw

Re: [Qemu-devel] Mac OS X PPC host support (was: [4932] Preliminary PPC64/Linux host support)

Am 31.07.2008 um 20:57 schrieb malc:

Quoted 18 lines · Blue Swirl
Quoted 7 lines

29 is Data Access Exception, raised from unassigned memory access. The code is

0xffd04020: std %l0, [ %sp ]

which is a double word store. Address in %sp (%o6, 0xffdd3fa0) is OK. So I'd check if qemu_st64 generates correct code.

That was spot on, thanks once again. I have notified main tcg proper to not align register parameters, but failed to do so myself when calling qemu_stXX helpers.

With that fixed Sparc test image boots in MacOS X, i386 test image does make it to ext2fs warning but then just hangs there waiting for something, and some dma timer warning messages popup in the console after a while, therefore i'm reluctant on commiting it just now.

Quoted 7 lines

That said the code is there:
http://repo.or.cz/w/qemu/malc.git?a=shortlog;h=refs/heads/tcgppc32macosx
(warning, one commit was amended so things will not fast-forward)

My MacOS X stuff is outdated so maybe the i386 problem is not a TCG one, testing from uptodate MacOS X/PPC32 people would be needed. And i think someone more MacOS X inclined should take over this part.

I still think your Apple linkage area define is incorrect. The ABI document clearly says it's 24 bytes, with some reserved space in there after the three fields. You sure it's safe to strip that space?

Leaving my linkage area in and applying your alignment fixes I was finally able to boot into Sparc Etch.
http://repo.or.cz/w/qemu/afaerber.git?a=shortlog;h=refs/heads/tcg-osx-ppc

Thanks a lot for your help so far!

After some progress on booting, I get a whole screen full of "esp0: Data transfer overrun." - sounds related to your i386 issue. The monitor is awfully slow at that point, i.e. ~1 second per char typed. Last time I saw these, something was wrong in slavio interrupt handling I believe - haven't checked on another platform yet.

Andreas

author
#22 lore raw

Re: [Qemu-devel] Mac OS X PPC host support (was: [4932] Preliminary PPC64/Linux host support)

Quoted 5 lines · Andreas F?rber

Am 31.07.2008 um 20:57 schrieb malc:

Quoted 2 lines · Blue Swirl

[..snip..]

Quoted 7 lines
Quoted 4 lines

My MacOS X stuff is outdated so maybe the i386 problem is not a TCG one, testing from uptodate MacOS X/PPC32 people would be needed. And i think someone more MacOS X inclined should take over this part.

I still think your Apple linkage area define is incorrect. The ABI document clearly says it's 24 bytes, with some reserved space in there after the three fields. You sure it's safe to strip that space?

Yes, you are right i missed the 'Note: ...' part.

Quoted 4 lines

Leaving my linkage area in and applying your alignment fixes I was finally able to boot into Sparc Etch.
http://repo.or.cz/w/qemu/afaerber.git?a=shortlog;h=refs/heads/tcg-osx-ppc

Thanks a lot for your help so far!

You are welcome, but this is most likely as far as i can ever get, to
reiterate: MacOS X is too foreign for me and working in it is a great pain - sorry.

Quoted 1 line

After some progress on booting, I get a whole screen full of "esp0: Data transfer overrun." - sounds related to your i386 issue. The monitor is awfully slow at that point, i.e. ~1 second per char typed. Last time I saw these, something was wrong in slavio interrupt handling I believe - haven't checked on another platform yet.

Can you try i386 testimage (http://bellard.org/qemu/linux-0.2.img.bz2)?
Does it behave the same as on my box?

Signature · 1 line
mailto:[email protected]
#25 lore raw

Re: [Qemu-devel] Mac OS X PPC host support (was: [4932] Preliminary PPC64/Linux host support)

In reply to Andreas Färber

Am 31.07.2008 um 23:50 schrieb Andreas Färber:

Quoted 1 line

After some progress on booting, I get a whole screen full of "esp0: Data transfer overrun."

Yesterday I managed to boot up and work with sparc-softmmu on OSX/ppc just fine. What was different was that on first try it ran fsck for sda2 and probably got hung during that, on second try it ran fsck for sda2 and then for sda1 and failed shortly after. Since then I have not seen these issues again, neither on OSX/ppc nor an Solaris/amd64. So maybe it's just a problem when under stress.

Andreas

#26 lore raw

Re: [Qemu-devel] Mac OS X PPC host support (was: [4932] Preliminary PPC64/Linux host support)

I have a feeling that Sparc tcg target might have a problem under load. The same thing happened under Mac OS X X86-64, as well as i386. I doubt this is a problem with OS X.

Quoted 6 lines · Andreas Färber

Am 31.07.2008 um 23:50 schrieb Andreas Färber:

Quoted 1 line

After some progress on booting, I get a whole screen full of "esp0: Data transfer overrun."

#23 lore raw

Re: [Qemu-devel] Mac OS X PPC host support (was: [4932] Preliminary PPC64/Linux host support)

In reply to malc

Am 01.08.2008 um 20:52 schrieb malc:

Quoted 2 lines

Can you try i386 testimage (http://bellard.org/qemu/linux-0.2.img.bz2)?
Does it behave the same as on my box?

It boots up okay for me. I did not notice an ext2fs warning or a hang, other than waiting half a second for the screen refresh after emitting one line of console text (not comparable to sparc-softmmu or pre-TCG afair). But there is an error "vmport: Unknown command 13" in the Terminal.

Andreas

author
#24 lore raw

Re: [Qemu-devel] Mac OS X PPC host support (was: [4932] Preliminary PPC64/Linux host support)

Quoted 7 lines · Andreas F?rber

Am 01.08.2008 um 20:52 schrieb malc:

Quoted 2 lines

Can you try i386 testimage (http://bellard.org/qemu/linux-0.2.img.bz2)?
Does it behave the same as on my box?

It boots up okay for me. I did not notice an ext2fs warning or a hang, other than waiting half a second for the screen refresh after emitting one line of console text (not comparable to sparc-softmmu or pre-TCG afair). But there is an error "vmport: Unknown command 13" in the Terminal.

I've tried last pre-tcg QEMU checkout and it behaves the same (i.e. hangs there after ext2fs warning), therefore it's probably safe to conclude that tcg per se has little to do with it, thanks for testing.

And vmport is just the fallout of recently added vmware backdoor thing.

Signature · 1 line
mailto:[email protected]