qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Enabled building of x86_64 code on Mac OS X
@ 2009-01-24 19:44 Alexander Graf
  2009-01-26 15:40 ` Anthony Liguori
  0 siblings, 1 reply; 10+ messages in thread
From: Alexander Graf @ 2009-01-24 19:44 UTC (permalink / raw)
  To: qemu-devel

Mac OS X 10.5 supports 64-bit userspace on an x86_64 kernel and
by default uses 32-bit userspace applications, so the detection for
the host architecture fails.

This patch enabled building of x86_64 code on x86_64 capable CPUS
with Mac OS X.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 configure |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/configure b/configure
index 3c9d832..c3fbbbe 100755
--- a/configure
+++ b/configure
@@ -243,11 +243,21 @@ oss_lib="-lossaudio"
 Darwin)
 bsd="yes"
 darwin="yes"
+# on Leopard most of the system is 32-bit, so we have to ask the kernel it if we can run 64-bit userspace code
+is_x86_64=`sysctl -n hw.optional.x86_64`
+if [ "$is_x86_64" = "1" ]; then
+    cpu=x86_64
+fi
+if [ "$cpu" = "x86_64" ] ; then
+    OS_CFLAGS="-arch x86_64"
+    LDFLAGS="-arch x86_64"
+else
+    OS_CFLAGS="-mdynamic-no-pic"
+fi
 darwin_user="yes"
 cocoa="yes"
 audio_drv_list="coreaudio"
 audio_possible_drivers="coreaudio sdl fmod"
-OS_CFLAGS="-mdynamic-no-pic"
 OS_LDFLAGS="-framework CoreFoundation -framework IOKit"
 ;;
 SunOS)
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] Enabled building of x86_64 code on Mac OS X
  2009-01-24 19:44 [Qemu-devel] [PATCH] Enabled building of x86_64 code on Mac OS X Alexander Graf
@ 2009-01-26 15:40 ` Anthony Liguori
  2009-01-27  0:34   ` Paul Brook
       [not found]   ` <BCD74E09-BC4C-4FC6-B814-D0276B763A9C@hotmail.com>
  0 siblings, 2 replies; 10+ messages in thread
From: Anthony Liguori @ 2009-01-26 15:40 UTC (permalink / raw)
  To: qemu-devel

Alexander Graf wrote:
> Mac OS X 10.5 supports 64-bit userspace on an x86_64 kernel and
> by default uses 32-bit userspace applications, so the detection for
> the host architecture fails.
>
> This patch enabled building of x86_64 code on x86_64 capable CPUS
> with Mac OS X.
>   
Applied.  Thanks.

Out of curiousity, what are the benefits of using 64-bit apps in OS X?  
I guess greater memory addressability is important for QEMU.

Regards,

Anthony Liguori

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] Enabled building of x86_64 code on Mac OS X
  2009-01-26 15:40 ` Anthony Liguori
@ 2009-01-27  0:34   ` Paul Brook
  2009-01-27  0:42     ` Jamie Lokier
       [not found]   ` <BCD74E09-BC4C-4FC6-B814-D0276B763A9C@hotmail.com>
  1 sibling, 1 reply; 10+ messages in thread
From: Paul Brook @ 2009-01-27  0:34 UTC (permalink / raw)
  To: qemu-devel; +Cc: Anthony Liguori

> Out of curiousity, what are the benefits of using 64-bit apps in OS X?

My guess is that same as most other x86 targets: The i386 legacy mode is 
crippled by lack of registers, modern x86 hardware has a big fat wide memory 
bus, and noone's bothered implementing an ILP32 64-bit API[1], so 64-bit apps 
give measurably better overall performance.

Paul

[1] ILP32 APIs for 64-bit x86 do exist, but the architecture is missing a 
couple of features so they're a bit hairy, and AFAIK not supported by any 
mainstream operating systems.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] Enabled building of x86_64 code on Mac OS X
       [not found]   ` <BCD74E09-BC4C-4FC6-B814-D0276B763A9C@hotmail.com>
@ 2009-01-27  0:40     ` C.W. Betts
  0 siblings, 0 replies; 10+ messages in thread
From: C.W. Betts @ 2009-01-27  0:40 UTC (permalink / raw)
  To: qemu-devel

I think like all X86_64 programs, it has access to more registers than  
just plain i386.  However, that is only on the X86 platform: the  
PowerPC platform has the same number of registers in both 32 and 64- 
bit mode.
On Jan 26, 2009, at 8:40 AM, Anthony Liguori wrote:

> Alexander Graf wrote:
>> Mac OS X 10.5 supports 64-bit userspace on an x86_64 kernel and
>> by default uses 32-bit userspace applications, so the detection for
>> the host architecture fails.
>>
>> This patch enabled building of x86_64 code on x86_64 capable CPUS
>> with Mac OS X.
>>
> Applied.  Thanks.
>
> Out of curiousity, what are the benefits of using 64-bit apps in OS  
> X?  I guess greater memory addressability is important for QEMU.
>
> Regards,
>
> Anthony Liguori
>
>
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] Enabled building of x86_64 code on Mac OS X
  2009-01-27  0:34   ` Paul Brook
@ 2009-01-27  0:42     ` Jamie Lokier
  2009-01-27  0:59       ` Paul Brook
  0 siblings, 1 reply; 10+ messages in thread
From: Jamie Lokier @ 2009-01-27  0:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: Anthony Liguori

Paul Brook wrote:
> > Out of curiousity, what are the benefits of using 64-bit apps in OS X?
> 
> My guess is that same as most other x86 targets: The i386 legacy
> mode is crippled by lack of registers, modern x86 hardware has a big
> fat wide memory bus, and noone's bothered implementing an ILP32
> 64-bit API[1], so 64-bit apps give measurably better overall
> performance.

Except they use more memory and memory bandwidth (arguably filling
nearly half of it with zeros most of the time :-) so worse overall
performance in some cases.

-- Jamie

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] Enabled building of x86_64 code on Mac OS X
  2009-01-27  0:42     ` Jamie Lokier
@ 2009-01-27  0:59       ` Paul Brook
  2009-01-27  1:22         ` Anthony Liguori
  0 siblings, 1 reply; 10+ messages in thread
From: Paul Brook @ 2009-01-27  0:59 UTC (permalink / raw)
  To: qemu-devel; +Cc: Anthony Liguori

On Tuesday 27 January 2009, Jamie Lokier wrote:
> Paul Brook wrote:
> > > Out of curiousity, what are the benefits of using 64-bit apps in OS X?
> >
> > My guess is that same as most other x86 targets: The i386 legacy
> > mode is crippled by lack of registers, modern x86 hardware has a big
> > fat wide memory bus, and noone's bothered implementing an ILP32
> > 64-bit API[1], so 64-bit apps give measurably better overall
> > performance.
>
> Except they use more memory and memory bandwidth (arguably filling
> nearly half of it with zeros most of the time :-) so worse overall
> performance in some cases.

I did say overall performance.

My experience with AMD hardware is that you generally get ~10% overall 
improvement from LP64. Intel hardware (particularly the early 64-bit cores) 
less so, but it's generally still a win.

I guess ILP32 long mode would probably increase that further, and avoid the 
odd regressions. It's an awful lot of work to implement though, especially on 
a target that isn't used to having lots of incompatible variants.

Paul

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] Enabled building of x86_64 code on Mac OS X
  2009-01-27  0:59       ` Paul Brook
@ 2009-01-27  1:22         ` Anthony Liguori
  2009-01-27  9:21           ` Alexander Graf
  0 siblings, 1 reply; 10+ messages in thread
From: Anthony Liguori @ 2009-01-27  1:22 UTC (permalink / raw)
  To: Paul Brook; +Cc: qemu-devel

Paul Brook wrote:
> I did say overall performance.
> My experience with AMD hardware is that you generally get ~10% overall 
> improvement from LP64. Intel hardware (particularly the early 64-bit cores) 
> less so, but it's generally still a win.
>
> I guess ILP32 long mode would probably increase that further, and avoid the 
> odd regressions. It's an awful lot of work to implement though, especially on 
> a target that isn't used to having lots of incompatible variants.
>   

I expected a performance boost.  Since OS X only runs on Intel CPUs, I 
don't think it's dramatically worth it to get a few percent CPU 
improvement.  The reason I asked is that if we decided to drop Cocoa in 
favor of SDL, it would prevent the use of 64-bit.

However, as long as someone is willing to fix Cocoa, I don't think 
there's any harm keeping it around so it doesn't matter that much.

Regards,

Anthony Liguori

> Paul
>
>   

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] Enabled building of x86_64 code on Mac OS X
  2009-01-27  1:22         ` Anthony Liguori
@ 2009-01-27  9:21           ` Alexander Graf
  2009-01-27 14:37             ` Jamie Lokier
  2009-01-27 15:00             ` Laurent Desnogues
  0 siblings, 2 replies; 10+ messages in thread
From: Alexander Graf @ 2009-01-27  9:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paul Brook

Anthony Liguori wrote:
> Paul Brook wrote:
>> I did say overall performance.
>> My experience with AMD hardware is that you generally get ~10%
>> overall improvement from LP64. Intel hardware (particularly the early
>> 64-bit cores) less so, but it's generally still a win.
>>
>> I guess ILP32 long mode would probably increase that further, and
>> avoid the odd regressions. It's an awful lot of work to implement
>> though, especially on a target that isn't used to having lots of
>> incompatible variants.
>>   
>
> I expected a performance boost.  Since OS X only runs on Intel CPUs, I
> don't think it's dramatically worth it to get a few percent CPU
> improvement.  The reason I asked is that if we decided to drop Cocoa
> in favor of SDL, it would prevent the use of 64-bit.

The extra registers should speed up things quite a bit. While that's not
too much of a problem when emulating x86, which has few registers
anyway, emulating a ppc or x86_64 target should be faster on an x86_64
host. I haven't done measurements though.

As for the plus in code size on x86_64 - that doesn't really apply to
tcg, as that still generates 32-bit code when only 32-bit code is
necessary, which still looks the same on x86_64. Plus it does simplify
64-bit operations.

I would be very surprised if the improvement of emulating x86_64 on x86
vs. x86_64 is only ~10%.

Alex

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] Enabled building of x86_64 code on Mac OS X
  2009-01-27  9:21           ` Alexander Graf
@ 2009-01-27 14:37             ` Jamie Lokier
  2009-01-27 15:00             ` Laurent Desnogues
  1 sibling, 0 replies; 10+ messages in thread
From: Jamie Lokier @ 2009-01-27 14:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paul Brook

Alexander Graf wrote:
> As for the plus in code size on x86_64 - that doesn't really apply to
> tcg, as that still generates 32-bit code when only 32-bit code is
> necessary, which still looks the same on x86_64. Plus it does simplify
> 64-bit operations.

TCG doesn't use the available x86_64 registers when generating code
for 32-bit operations on an x86_64 host?

> I would be very surprised if the improvement of emulating x86_64 on x86
> vs. x86_64 is only ~10%.

So would I.

By the way, with KVM, can QEMU (the I/O model) be a 32-bit app while
the KVM kernel module provides an x86_64 CPU?

That might be useful, if there are advantages to QEMU itself being
32-bit on MacOS X and if there's a KVM module for it.

-- Jamie

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH] Enabled building of x86_64 code on Mac OS X
  2009-01-27  9:21           ` Alexander Graf
  2009-01-27 14:37             ` Jamie Lokier
@ 2009-01-27 15:00             ` Laurent Desnogues
  1 sibling, 0 replies; 10+ messages in thread
From: Laurent Desnogues @ 2009-01-27 15:00 UTC (permalink / raw)
  To: qemu-devel

On Tue, Jan 27, 2009 at 10:21 AM, Alexander Graf <agraf@suse.de> wrote:
>
> The extra registers should speed up things quite a bit. While that's not
> too much of a problem when emulating x86, which has few registers
> anyway, emulating a ppc or x86_64 target should be faster on an x86_64
> host. I haven't done measurements though.
>
> As for the plus in code size on x86_64 - that doesn't really apply to
> tcg, as that still generates 32-bit code when only 32-bit code is
> necessary, which still looks the same on x86_64. Plus it does simplify
> 64-bit operations.
>
> I would be very surprised if the improvement of emulating x86_64 on x86
> vs. x86_64 is only ~10%.

Here is a quick result for user mode.

x on y means running an target x on host y (the host is the same,
I just forced --cpu=i386 when compiling qemu).

Host:  CentOS 5.2 x86_64, E6600 (2.4GHz)
Benchmark: Spec2k gcc/integrate (compiled with gcc 4.1.2 -O2)

i386 on x86_64
gen code size       4005696/33497088
TB count            30704/524288
real    0m24.983s/user    0m24.834s

x86_64 on x86_64
gen code size       4413408/33497088
TB count            30247/524288
real    0m24.932s/user    0m24.749s

i386 on i386
gen code size       3439008/33497088
TB count            30704/524288
real    0m26.391s/user    0m26.131s

x86_64 on i386
gen code size       5715248/33497088
TB count            30254/524288
real    0m28.233s/user    0m27.985s


Laurent

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-01-27 15:00 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-24 19:44 [Qemu-devel] [PATCH] Enabled building of x86_64 code on Mac OS X Alexander Graf
2009-01-26 15:40 ` Anthony Liguori
2009-01-27  0:34   ` Paul Brook
2009-01-27  0:42     ` Jamie Lokier
2009-01-27  0:59       ` Paul Brook
2009-01-27  1:22         ` Anthony Liguori
2009-01-27  9:21           ` Alexander Graf
2009-01-27 14:37             ` Jamie Lokier
2009-01-27 15:00             ` Laurent Desnogues
     [not found]   ` <BCD74E09-BC4C-4FC6-B814-D0276B763A9C@hotmail.com>
2009-01-27  0:40     ` C.W. Betts

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).