Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LsTzK-0000um-Ns for qemu-devel@nongnu.org; Fri, 10 Apr 2009 23:34:38 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LsTzE-0000oX-RM for qemu-devel@nongnu.org; Fri, 10 Apr 2009 23:34:37 -0400 Received: from [199.232.76.173] (port=53900 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LsTzE-0000oN-IV for qemu-devel@nongnu.org; Fri, 10 Apr 2009 23:34:32 -0400 Received: from bay0-omc2-s6.bay0.hotmail.com ([65.54.246.142]:47275) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LsTzE-0006sn-27 for qemu-devel@nongnu.org; Fri, 10 Apr 2009 23:34:32 -0400 Message-ID: Message-Id: From: C.W. Betts In-Reply-To: Content-Type: multipart/alternative; boundary=Apple-Mail-7--879347297 Mime-Version: 1.0 (Apple Message framework v930.3) Subject: Re: [Qemu-devel] [RFC] OSX/ppc64 TCG support Date: Fri, 10 Apr 2009 21:34:17 -0600 References: Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org --Apple-Mail-7--879347297 Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable On Apr 10, 2009, at 4:34 PM, Andreas F=E4rber wrote: > Hello, > > I've tried to add TCG backend support for Mac OS X ppc64 with =20 > limited success. It seems the linkage area and LR offset are the =20 > same as on Linux, so the main difference I could find was the =20 > register usage. > > This brought up two questions: > > i) In ppc/tcg-target.c TCG_REG_R2 is listed twice in =20 > tcg_target_reg_alloc_order for __APPLE__. I assume this is not =20 > intended? It does so far work with or without this patch eliminating =20= > the second use: > > diff --git a/tcg/ppc/tcg-target.c b/tcg/ppc/tcg-target.c > index 23f94a8..7607d85 100644 > --- a/tcg/ppc/tcg-target.c > +++ b/tcg/ppc/tcg-target.c > @@ -114,7 +114,9 @@ static const int tcg_target_reg_alloc_order[] =3D = { > #endif > TCG_REG_R0, > TCG_REG_R1, > +#ifndef __APPLE__ > TCG_REG_R2, > +#endif > TCG_REG_R24, > TCG_REG_R25, > TCG_REG_R26, > > Alternatively, if the order of r2 does not matter too much, we could =20= > remove the initial __APPLE__ section instead for simplicity. > > ii) In ppc64/tcg-target.c tcg_target_call_oarg_regs is declared with =20= > a length of 2 but only contains one register. Intended? > > diff --git a/tcg/ppc64/tcg-target.c b/tcg/ppc64/tcg-target.c > index a96314c..2a8eaec 100644 > --- a/tcg/ppc64/tcg-target.c > +++ b/tcg/ppc64/tcg-target.c > @@ -125,11 +134,15 @@ static const int tcg_target_call_iarg_regs[] =3D = { > TCG_REG_R10 > }; > > -static const int tcg_target_call_oarg_regs[2] =3D { > +static const int tcg_target_call_oarg_regs[1] =3D { > TCG_REG_R3 > }; > > > Then for the real OSX/ppc64 changes, I have marked r11 and r13 =20 > callee-saved, like for OSX/ppc. > Reference: = http://developer.apple.com/documentation/DeveloperTools/Conceptual/LowLeve= lABI/110-64-bit_PowerPC_Function_Calling_Conventions/64bitPowerPC.html > > To my knowledge in ppc64 mode (at least on the G5) the lmw and stmw =20= > instructions are illegal. We should probably remove their =20 > definitions, they are not currently being used in the ppc64 backend. > > Unfortunately qemu-system-ppc still crashes immediately, any hints =20 > welcome. > > Program received signal EXC_BAD_INSTRUCTION, Illegal instruction/=20 > operand. > 0x00000000005a9680 in code_gen_prologue () > (gdb) bt > #0 0x00000000005a9680 in code_gen_prologue () > #1 0x00000000000c5ba0 in cpu_ppc_exec (env1=3D unavailable, due to optimizations>) at /Users/andreas/Q/qemu/cpu-=20 > exec.c:622 > #2 0x000000000000a208 in qemu_main (argc=3D unavailable, due to optimizations>, argv=3D unavailable, due to optimizations>, envp=3D unavailable, due to optimizations>) at /Users/andreas/Q/qemu/vl.c:3828 > #3 0x00000000000b2788 in -[QemuCocoaAppController =20 > startEmulationWithArgc:argv:] (self=3D due to optimizations>, _cmd=3D optimizations>, argc=3D optimizations>, argv=3D optimizations>) at /Users/andreas/Q/qemu/cocoa.m:780 > #4 0x00007fff81b3ff08 in _nsnote_callback () > #5 0x00007fff8104fd34 in _CFXNotificationPostNotification () > #6 0x00007fff81b3c970 in -[NSNotificationCenter =20 > postNotificationName:object:userInfo:] () > #7 0x00007fff81b476e0 in -[NSNotificationCenter =20 > postNotificationName:object:] () > #8 0x00007fff81f58e24 in -[NSApplication =20 > _postDidFinishNotification] () > #9 0x00007fff81f58ce4 in -[NSApplication =20 > _sendFinishLaunchingNotification] () > #10 0x00007fff81eaf02c in -[NSApplication(NSAppleEventHandling) =20 > _handleAEOpen:] () > #11 0x00007fff81eae51c in -[NSApplication(NSAppleEventHandling) =20 > _handleCoreEvent:withReplyEvent:] () > #12 0x00007fff81b6bbe0 in -[NSAppleEventManager =20 > dispatchRawAppleEvent:withRawReply:handlerRefCon:] () > #13 0x00007fff81b6b974 in _NSAppleEventManagerGenericHandler () > #14 0x000000010067708c in aeDispatchAppleEvent () > #15 0x000000010065f810 in dispatchEventAndSendReply () > #16 0x000000010065f5cc in aeProcessAppleEvent () > #17 0x00007fff843962dc in AEProcessAppleEvent () > #18 0x00007fff81eaaf68 in _DPSNextEvent () > #19 0x00007fff81eaa49c in -[NSApplication =20 > nextEventMatchingMask:untilDate:inMode:dequeue:] () > #20 0x00007fff81ea185c in -[NSApplication run] () > #21 0x00000000000b346c in main (argc=3D due to optimizations>, argv=3D optimizations>) at /Users/andreas/Q/qemu/cocoa.m:905 > (gdb) q Try using i386-softmmu as a test base. It is more stable and better =20 supported. --Apple-Mail-7--879347297 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On Apr 10, 2009, = at 4:34 PM, Andreas F=E4rber wrote:

Hello,

I've tried to add TCG backend support = for Mac OS X ppc64 with limited success. It seems the linkage area and = LR offset are the same as on Linux, so the main difference I could find = was the register usage.

This brought up two questions:

i) = In ppc/tcg-target.c TCG_REG_R2 is listed twice in = tcg_target_reg_alloc_order for __APPLE__. I assume this is not intended? = It does so far work with or without this patch eliminating the second = use:

diff --git a/tcg/ppc/tcg-target.c = b/tcg/ppc/tcg-target.c
index 23f94a8..7607d85 100644
--- = a/tcg/ppc/tcg-target.c
+++ b/tcg/ppc/tcg-target.c
@@ -114,7 +114,9 = @@ static const int tcg_target_reg_alloc_order[] =3D {
#endif
=     TCG_REG_R0,
=     TCG_REG_R1,
+#ifndef __APPLE__
=     TCG_REG_R2,
+#endif
=     TCG_REG_R24,
=     TCG_REG_R25,
=     TCG_REG_R26,

Alternatively, if the order = of r2 does not matter too much, we could remove the initial __APPLE__ = section instead for simplicity.

ii) In ppc64/tcg-target.c = tcg_target_call_oarg_regs is declared with a length of 2 but only = contains one register. Intended?

diff --git = a/tcg/ppc64/tcg-target.c b/tcg/ppc64/tcg-target.c
index = a96314c..2a8eaec 100644
--- a/tcg/ppc64/tcg-target.c
+++ = b/tcg/ppc64/tcg-target.c
@@ -125,11 +134,15 @@ static const int = tcg_target_call_iarg_regs[] =3D {
=     TCG_REG_R10
};

-static const int = tcg_target_call_oarg_regs[2] =3D {
+static const int = tcg_target_call_oarg_regs[1] =3D {
=     TCG_REG_R3
};


Then for the real = OSX/ppc64 changes, I have marked r11 and r13 callee-saved, like for = OSX/ppc.
Reference: http://developer.apple.com/documentation/DeveloperTools/Conceptual/L= owLevelABI/110-64-bit_PowerPC_Function_Calling_Conventions/64bitPowerPC.ht= ml

To my knowledge in ppc64 mode (at least on the G5) the lmw = and stmw instructions are illegal. We should probably remove their = definitions, they are not currently being used in the ppc64 = backend.

Unfortunately qemu-system-ppc still crashes immediately, = any hints welcome.

Program received signal EXC_BAD_INSTRUCTION, = Illegal instruction/operand.
0x00000000005a9680 in code_gen_prologue = ()
(gdb) bt
#0  0x00000000005a9680 in code_gen_prologue = ()
#1  0x00000000000c5ba0 in cpu_ppc_exec (env1=3D<value = temporarily unavailable, due to optimizations>) at = /Users/andreas/Q/qemu/cpu-exec.c:622
#2  0x000000000000a208 in = qemu_main (argc=3D<value temporarily unavailable, due to = optimizations>, argv=3D<value temporarily unavailable, due to = optimizations>, envp=3D<value temporarily unavailable, due to = optimizations>) at /Users/andreas/Q/qemu/vl.c:3828
#3 =  0x00000000000b2788 in -[QemuCocoaAppController = startEmulationWithArgc:argv:] (self=3D<value temporarily unavailable, = due to optimizations>, _cmd=3D<value temporarily unavailable, due = to optimizations>, argc=3D<value temporarily unavailable, due to = optimizations>, argv=3D<value temporarily unavailable, due to = optimizations>) at /Users/andreas/Q/qemu/cocoa.m:780
#4 =  0x00007fff81b3ff08 in _nsnote_callback ()
#5 =  0x00007fff8104fd34 in _CFXNotificationPostNotification ()
#6 =  0x00007fff81b3c970 in -[NSNotificationCenter = postNotificationName:object:userInfo:] ()
#7  0x00007fff81b476e0 = in -[NSNotificationCenter postNotificationName:object:] ()
#8 =  0x00007fff81f58e24 in -[NSApplication _postDidFinishNotification] = ()
#9  0x00007fff81f58ce4 in -[NSApplication = _sendFinishLaunchingNotification] ()
#10 0x00007fff81eaf02c in = -[NSApplication(NSAppleEventHandling) _handleAEOpen:] ()
#11 = 0x00007fff81eae51c in -[NSApplication(NSAppleEventHandling) = _handleCoreEvent:withReplyEvent:] ()
#12 0x00007fff81b6bbe0 in = -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] = ()
#13 0x00007fff81b6b974 in _NSAppleEventManagerGenericHandler = ()
#14 0x000000010067708c in aeDispatchAppleEvent ()
#15 = 0x000000010065f810 in dispatchEventAndSendReply ()
#16 = 0x000000010065f5cc in aeProcessAppleEvent ()
#17 0x00007fff843962dc = in AEProcessAppleEvent ()
#18 0x00007fff81eaaf68 in _DPSNextEvent = ()
#19 0x00007fff81eaa49c in -[NSApplication = nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#20 = 0x00007fff81ea185c in -[NSApplication run] ()
#21 0x00000000000b346c = in main (argc=3D<value temporarily unavailable, due to = optimizations>, argv=3D<value temporarily unavailable, due to = optimizations>) at /Users/andreas/Q/qemu/cocoa.m:905
(gdb) = q
Try using i386-softmmu as a test base.  It = is more stable and better supported.

= --Apple-Mail-7--879347297--