Suggested stubs for coming a bit closer to functional native sparcv9 HOST support:
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 0xf0000x0001: movl_T1_imu 0xe05b0x0002: movl_seg_T0_vm 0x4c0x0003: movl_T0_T10x0004: jmp_T00x0005: movl_T0_00x0006: exit_tb0x0007: end
AFTER FLAGS OPT:0x0000: movl_T0_im 0xf0000x0001: movl_T1_imu 0xe05b0x0002: movl_seg_T0_vm 0x4c0x0003: movl_T0_T10x0004: jmp_T00x0005: movl_T0_00x0006: exit_tb0x0007: 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
qemu-0.8.2-solaris__v9_stubs/Makefile renamed from qemu-0.8.2-solaris__20060930/Makefile +2 -2
@@ -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=
qemu-0.8.2-solaris__v9_stubs/Makefile.target renamed from qemu-0.8.2-solaris__20060930/Makefile.target +8 -5
@@ -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)
qemu-0.8.2-solaris__v9_stubs/configure renamed from qemu-0.8.2-solaris__20060930/configure +35 -9
99 lines not on this page · raw message
qemu-0.8.2-solaris__v9_stubs/cpu-all.h renamed from qemu-0.8.2-solaris__20060930/cpu-all.h +1 -1
@@ -971,7 +971,7 @@ return val; } -#elif defined(__sparc_v9__) +#elif defined(__sparc__)static inline int64_t cpu_get_real_ticks (void ) {
qemu-0.8.2-solaris__v9_stubs/dyngen-exec.h renamed from qemu-0.8.2-solaris__20060930/dyngen-exec.h +17 -11
@@ -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"
qemu-0.8.2-solaris__v9_stubs/dyngen.c renamed from qemu-0.8.2-solaris__20060930/dyngen.c +32 -0
@@ -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); }
qemu-0.8.2-solaris__v9_stubs/elf.h renamed from qemu-0.8.2-solaris__20060930/elf.h +3 -0
@@ -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