Hi, <<qemu-0.8.2-solaris20060930__v9_stubs.gdiff>> ## only a messy personal testing-snapshot FYI, with no compatibility or clarity in mind ## a gdiff -Nurb against 20060930's http://www.opensolaris.org/os/project/qemu/downloads/qemu-0.8.2-solaris.tar.gz
Current Status: ============= This is still the very best I can get on an OpenSolaris sparc64 host when cd'ing to linux-test (from http://www.qemu.com/linux-test-0.5.1.tar.gz) and running # /tmp/Q_E_M_U/sparcv9_testing/qemu-0.8.2-solaris__v9_stubs/i386-softmmu/qemu -nographic -hda linux.img -kernel bzImage-2.4.21 -append "console=ttyS0 root=/dev/hda sb=0x220,5,1,5 ide2=noprobe ide3=noprobe ide4=noprobe ide5=noprobe" -d all : # uname -a SunOS mb1x-ws1 5.11 snv_41 sun4u sparc SUNW,Sun-Fire-280R # isainfo -k sparcv9 # ls -al /tmp/qemu.log -rw-r--r-- 1 root root 2022 Oct 5 13:03 /tmp/qemu.log # cat /tmp/qemu.log EAX=00000000 EBX=00000000 ECX=00000000 EDX=00000600 ESI=00000000 EDI=00000000 EBP=00000000 ESP=00000000 EIP=0000fff0 EFL=00000002 [-------] CPL=0 II=0 A20=1 HLT=0 ES =0000 00000000 0000ffff 00000000 CS =f000 ffff0000 0000ffff 00000000 SS =0000 00000000 0000ffff 00000000 DS =0000 00000000 0000ffff 00000000 FS =0000 00000000 0000ffff 00000000 GS =0000 00000000 0000ffff 00000000 LDT=0000 00000000 0000ffff 00008000 TR =0000 00000000 0000ffff 00008000 GDT= 00000000 0000ffff IDT= 00000000 0000ffff CR0=60000010 CR2=00000000 CR3=00000000 CR4=00000000 CCS=00000000 CCD=00000000 CCO=EFLAGS ---------------- IN: 0xfffffff0: ljmp $0xf000,$0xe05b OP: 0x0000: movl_T0_im 0xf000 0x0001: movl_T1_imu 0xe05b 0x0002: movl_seg_T0_vm 0x4c 0x0003: movl_T0_T1 0x0004: jmp_T0 0x0005: movl_T0_0 0x0006: exit_tb 0x0007: end AFTER FLAGS OPT: 0x0000: movl_T0_im 0xf000 0x0001: movl_T1_imu 0xe05b 0x0002: movl_seg_T0_vm 0x4c 0x0003: movl_T0_T1 0x0004: jmp_T0 0x0005: movl_T0_0 0x0006: exit_tb 0x0007: end OUT: [size=124] 0x101242060: sethi %hi(0), %o5 0x101242064: or %o5, 1, %o5 ! 0x1 0x101242068: unknown 0x10124206c: sethi %hi(0x11f9400), %o4 0x101242070: add %o5, %o4, %o5 0x101242074: mov %o5, %o5 0x101242078: mov %o5, %g4 0x10124207c: sethi %hi(0), %o5 0x101242080: or %o5, 1, %o5 ! 0x1 0x101242084: unknown 0x101242088: sethi %hi(0x11f9400), %o4 0x10124208c: add %o5, %o4, %o5 0x101242090: or %o5, 0x5b, %o5 0x101242094: mov %o5, %g5 0x101242098: sethi %hi(0xfc00), %o5 0x10124209c: or %o5, 0x3ff, %o5 ! 0xffff 0x1012420a0: and %g4, %o5, %o3 0x1012420a4: sethi %hi(0), %o5 0x1012420a8: or %o5, 1, %o5 ! 0x1 0x1012420ac: unknown 0x1012420b0: sethi %hi(0x11f9400), %o4 0x1012420b4: add %o5, %o4, %o5 0x1012420b8: or %o5, 0x4c, %o5 0x1012420bc: add %g3, %o5, %o5 0x1012420c0: st %o3, [ %o5 ] 0x1012420c4: sll %o3, 4, %o3 0x1012420c8: st %o3, [ %o5 + 4 ] 0x1012420cc: mov %g5, %g4 0x1012420d0: st %g4, [ %g3 + 0x20 ] 0x1012420d4: clr %g4 0x1012420d8: jmp %i0 + 8 # file /tmp/Q_E_M_U/sparcv9_testing/qemu-0.8.2-solaris__v9_stubs/i386-softmmu/qemu i386-softmmu/qemu: ELF 64-bit MSB executable SPARCV9 Version 1, dynamically linked, not stripped # Summary ========= I know, being able to natively build for sparcv9 is not "required" by any means (because ultrasparc asm [i.e. ticks] _can_ already be used via sparcv8plus [which is basically 32bit with UltraSPARC extensions / no v8plus cpu ever existed], no sparc-X-sparc kqemu LKM driver exists as of now that would make building for sparcv9 a requirement, and of course can qemu be built now for v8plus, v8 or v7 [special thanks again to Juergen Keil and Johannes Schindelin] and then be run under a booted sparcv9 host kernel), but it would be interesting to see, how one would get it working / what is still missing. References: http://www.cs.utexas.edu/users/novak/sparcv9.pdf http://libvncserver.sourceforge.net/qemu/qemu-porting.html http://www.qemu.com/qemu-tech.html p.s. I finally return to the rather trivial task of bringing the promised SUNWqemu and CSWqemu packages out, plus a patch against http://www.qemu.com/qemu-0.8.2.tar.gz Globally switching to current CVS afterwards (already tested it on sparc32). I apologize for the delay. Regards, Maddin http://www.martux.org
diff -Nurb ./qemu-0.8.2-solaris__20060930/Makefile ./qemu-0.8.2-solaris__v9_stubs/Makefile --- ./qemu-0.8.2-solaris__20060930/Makefile 2006-09-13 09:40:58.000000000 +0200 +++ ./qemu-0.8.2-solaris__v9_stubs/Makefile 2006-10-05 11:23:34.109516000 +0200 @@ -5,12 +5,12 @@ .PHONY: all clean distclean dvi info install install-doc tar tarbin \ speed test test2 html dvi info -CFLAGS+=-Wall -O2 -g -fno-strict-aliasing -I. +CFLAGS+=-Wall -O1 -g -fno-strict-aliasing -I. ifdef CONFIG_DARWIN CFLAGS+= -mdynamic-no-pic endif ifeq ($(ARCH),sparc) -CFLAGS+=-mcpu=ultrasparc +CFLAGS+=-mcpu=ultrasparc -O2 endif LDFLAGS+=-g LIBS= diff -Nurb ./qemu-0.8.2-solaris__20060930/Makefile.target ./qemu-0.8.2-solaris__v9_stubs/Makefile.target --- ./qemu-0.8.2-solaris__20060930/Makefile.target 2006-09-13 09:40:58.000000000 +0200 +++ ./qemu-0.8.2-solaris__v9_stubs/Makefile.target 2006-10-05 12:11:45.427095200 +0200 @@ -17,7 +17,7 @@ VPATH+=:$(SRC_PATH)/linux-user DEFINES+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ARCH) endif -CFLAGS+=-Wall -O2 -g -fno-strict-aliasing +CFLAGS+=-Wall -O1 -g -fno-strict-aliasing #CFLAGS+=-Werror LDFLAGS+=-g LIBS= @@ -108,7 +108,7 @@ ifeq ($(ARCH),sparc) ifeq ($(CONFIG_SOLARIS),yes) -CFLAGS+=-mcpu=ultrasparc -m32 -ffixed-g2 -ffixed-g3 +CFLAGS+=-mcpu=ultrasparc -m32 -ffixed-g1 -ffixed-g2 -ffixed-g4 -ffixed-g5 -ffixed-g6 -ffixed-g7 -ffixed-l0 -ffixed-l1 -ffixed-l2 -ffixed-l3 LDFLAGS+=-m32 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -fno-omit-frame-pointer -ffixed-i0 else @@ -122,10 +122,12 @@ endif ifeq ($(ARCH),sparc64) -CFLAGS+=-mcpu=ultrasparc -m64 -ffixed-g1 -ffixed-g4 -ffixed-g5 -ffixed-g7 +CFLAGS+=-mcpu=ultrasparc -m64 -ffixed-g1 -ffixed-g2 -ffixed-g4 -ffixed-g5 -ffixed-g6 -ffixed-g7 -ffixed-l0 -ffixed-l1 -ffixed-l2 -ffixed-l3 LDFLAGS+=-m64 -LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc64.ld +# LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc64.ld +# only when linking with gld OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0 +DEFINES+=-D__sparc_v9__ endif ifeq ($(ARCH),alpha) @@ -417,7 +419,8 @@ ifeq ($(ARCH),sparc64) VL_LDFLAGS+=-m64 -VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc64.ld +# VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc64.ld +# only when linking with gld endif ifeq ($(CONFIG_SOLARIS),yes) diff -Nurb ./qemu-0.8.2-solaris__20060930/configure ./qemu-0.8.2-solaris__v9_stubs/configure --- ./qemu-0.8.2-solaris__20060930/configure 2006-09-13 09:44:11.000000000 +0200 +++ ./qemu-0.8.2-solaris__v9_stubs/configure 2006-10-05 11:47:42.903664400 +0200 @@ -24,9 +24,9 @@ cc="gcc" host_cc="gcc" ar="ar" -make="make" -install="install" -strip="strip" +make="gmake" +install="ginstall" +strip="gstrip" cpu=`uname -m` target_list="" case "$cpu" in @@ -51,7 +51,7 @@ s390) cpu="s390" ;; - sparc|sun4[muv]) + sparc|sun4[cdmuv]) cpu="sparc" ;; sparc64) @@ -98,6 +98,13 @@ build_acpi_tables="no" force_64bit="no" force_64bitflags="" +build_for_sparcv7="no" +build_for_sparcv7flags="" +build_for_sparcv8="no" +build_for_sparcv8flags="" +build_for_sparcv8plus="no" +build_for_sparcv8plusflags="" + uname_release="" # OS specific @@ -247,29 +254,45 @@ ;; --force-64bit) force_64bit="yes" - CFLAGS="$CFLAGS -m64 -mpreferred-stack-boundary=4 -fomit-frame-pointer" LDFLAGS="$LDFLAGS -m64" force_64bitflags="-m64" case "$cpu" in i386) - echo "Forcing 64-bit mode, changing CPU from $cpu to x86_64" + echo "Forcing 64-bit mode, changing HOST-CPU from $cpu to x86_64" cpu="x86_64" + CFLAGS="$CFLAGS -m64 -mpreferred-stack-boundary=4 -fomit-frame-pointer" ;; sparc*) - echo "Forcing 64-bit mode, changing CPU from $cpu to sparc64" + echo "Developers only: Forcing 64-bit mode, changing HOST-CPU from $cpu to sparc64" cpu="sparc64" + CFLAGS="$CFLAGS -m64 -fomit-frame-pointer" ;; *) echo "Forcing 64-bit mode" ;; esac ;; + --build_for_sparcv7) + build_for_sparcv7="yes" + CFLAGS="$CFLAGS -m32 -mcpu=v7 -fomit-frame-pointer" + LDFLAGS="$LDFLAGS -m32" + ;; + --build_for_sparcv8) + build_for_sparcv8="yes" + CFLAGS="$CFLAGS -m32 -mcpu=v8 -fomit-frame-pointer" + LDFLAGS="$LDFLAGS -m32" + ;; + --build_for_sparcv8plus) + build_for_sparcv8plus="yes" + CFLAGS="$CFLAGS -m32 -mcpu=ultrasparc -fomit-frame-pointer" + LDFLAGS="$LDFLAGS -m32" + ;; esac done # Checking for CFLAGS if test -z "$CFLAGS"; then - CFLAGS="-O2" + CFLAGS="-O1" fi if test x"$show_help" = x"yes" ; then @@ -314,6 +337,9 @@ echo " --enable-uname-release=R Return R for uname -r in usermode emulation" echo " --enable-iasl compilation of ACPI tables with the IASL compiler" echo " --force-64bit force 64-bit compilation (Solaris x86/x64 only)" +echo " --build_for_sparcv7 force compilation for sparcv7 HOST-CPU" +echo " --build_for_sparcv8 force compilation for sparcv8 HOST-CPU" +echo " --build_for_sparcv8plus force compilation for sparcv8plus HOST-CPU" echo "" echo "NOTE: The object files are build at the place where configure is launched" exit 1 @@ -489,7 +515,7 @@ int main( void ) { return SDL_Init (SDL_INIT_VIDEO); } EOF -if $cc $force_64bitflags -o $TMPE `$sdl_config --cflags 2> /dev/null` $TMPC `$sdl_config --libs 2> /dev/null` 2> /dev/null ; then +if $cc $force_64bitflags $build_for_sparcv7flags $build_for_sparcv8flags $build_for_sparcv8plusflags -o $TMPE `$sdl_config --cflags 2> /dev/null` $TMPC `$sdl_config --libs 2> /dev/null` 2> /dev/null ; then _sdlversion=`$sdl_config --version | sed 's/[^0-9]//g'` if test "$_sdlversion" -lt 121 ; then sdl_too_old=yes diff -Nurb ./qemu-0.8.2-solaris__20060930/cpu-all.h ./qemu-0.8.2-solaris__v9_stubs/cpu-all.h --- ./qemu-0.8.2-solaris__20060930/cpu-all.h 2006-07-22 19:23:34.000000000 +0200 +++ ./qemu-0.8.2-solaris__v9_stubs/cpu-all.h 2006-10-01 02:15:12.000000000 +0200 @@ -971,7 +971,7 @@ return val; } -#elif defined(__sparc_v9__) +#elif defined(__sparc__) static inline int64_t cpu_get_real_ticks (void) { diff -Nurb ./qemu-0.8.2-solaris__20060930/dyngen-exec.h ./qemu-0.8.2-solaris__v9_stubs/dyngen-exec.h --- ./qemu-0.8.2-solaris__20060930/dyngen-exec.h 2006-07-22 19:23:34.000000000 +0200 +++ ./qemu-0.8.2-solaris__v9_stubs/dyngen-exec.h 2006-10-05 13:37:58.665144200 +0200 @@ -38,7 +38,7 @@ // Linux/Sparc64 defines uint64_t #if !(defined (__sparc_v9__) && defined(__linux__)) /* XXX may be done for all 64 bits targets ? */ -#if defined (__x86_64__) || defined(__ia64) +#if defined(__x86_64__) || defined(__ia64) || defined(__sparc_v9__) 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__)) -#if defined (__x86_64__) || defined(__ia64) +#if defined(__x86_64__) || defined(__ia64) || defined(__sparc_v9__) typedef signed long int64_t; #else typedef signed long long int64_t; @@ -126,19 +126,25 @@ #define AREG2 "s1" #define AREG3 "s2" #endif + #ifdef __sparc__ #ifdef HOST_SOLARIS -#define AREG0 "g2" -#define AREG1 "g3" -#define AREG2 "g4" -#define AREG3 "g5" -#define AREG4 "g6" -#else -#ifdef __sparc_v9__ -#define AREG0 "g1" +#define AREG0 "g3" #define AREG1 "g4" #define AREG2 "g5" -#define AREG3 "g7" +#define AREG3 "g6" +/* #define AREG4 "l0" */ +/* Solaris sparcv8/v8plus versus sparcv9 ABI: g0 is always 0, g1 gets clobbered + * after function call, g2 cannot be used on v9 due to ABI and libm warning, g7 + * gets clobbered, g3 does _not_ give libm caused /usr/ccs/bin/ld MSG_STO_REGISTERG3 warning + * anymore (see http://cvs.opensolaris.org/source/raw/on/usr/src/cmd/sgs/libld/common/libld.sparc.msg), + * now that we manually define -D__sparc_v9__ + * inputs or outputs cannot be used at all, due to shifting rw, + * locals can potentially be used, if they are saved and restored each time + * (see cpu-exec.c) + * sparc-LinUX's ABI seems to be less restrictive here, just downloading a recent Aurora ... + */ + #else #define AREG0 "g6" #define AREG1 "g1" diff -Nurb ./qemu-0.8.2-solaris__20060930/dyngen.c ./qemu-0.8.2-solaris__v9_stubs/dyngen.c --- ./qemu-0.8.2-solaris__20060930/dyngen.c 2006-07-22 19:23:34.000000000 +0200 +++ ./qemu-0.8.2-solaris__v9_stubs/dyngen.c 2006-10-01 08:48:03.000000000 +0200 @@ -2270,6 +2270,38 @@ reloc_offset, reloc_offset, name, addend, reloc_offset); break; + + + + case R_SPARC_HH22: + fprintf(outfile, + " *(uint32_t *)(gen_code_ptr + %d) = " + "((*(uint32_t *)(gen_code_ptr + %d)) " + " & ~0x00000000) " + " | (((%s + %d) >> 42) & 0x00000000);\n", + reloc_offset, reloc_offset, name, addend); + break; + + case R_SPARC_LM22: + fprintf(outfile, + " *(uint32_t *)(gen_code_ptr + %d) = " + "((*(uint32_t *)(gen_code_ptr + %d)) " + " & ~0x00000000) " + " | (((%s + %d) >> 10) & 0x00000000);\n", + reloc_offset, reloc_offset, name, addend); + break; + + case R_SPARC_HM10: + fprintf(outfile, + " *(uint32_t *)(gen_code_ptr + %d) = " + "((*(uint32_t *)(gen_code_ptr + %d)) " + " & ~0x00000000) " + " | ((((%s + %d) >> 32 & 0x3ff)) & 0x00000000);\n", + reloc_offset, reloc_offset, name, addend); + break; + + + default: error("unsupported sparc64 relocation (%d) for symbol %s", type, name); } diff -Nurb ./qemu-0.8.2-solaris__20060930/elf.h ./qemu-0.8.2-solaris__v9_stubs/elf.h --- ./qemu-0.8.2-solaris__20060930/elf.h 2006-07-22 19:23:34.000000000 +0200 +++ ./qemu-0.8.2-solaris__v9_stubs/elf.h 2006-10-01 01:39:27.000000000 +0200 @@ -328,6 +328,9 @@ #define R_SPARC_11 31 #define R_SPARC_64 32 #define R_SPARC_OLO10 33 +#define R_SPARC_HH22 34 +#define R_SPARC_HM10 35 +#define R_SPARC_LM22 36 #define R_SPARC_WDISP16 40 #define R_SPARC_WDISP19 41 #define R_SPARC_7 43
_______________________________________________ Qemu-devel mailing list Qemu-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/qemu-devel