ia64-enablement patch
The patch below makes qemu work on ia64 linux. Most of the patch is straight-forward, but there are perhaps some controversial bits and pieces (in particular the linux-user/syscall.c changes need consideration). I'm mostly throwing this out there to get some reactions. If it looks generally OK, I can split it up into separate pieces (generic cleanups & bug fixes, syscall-cleanup, ia64-specific stuff).
I haven't done a huge amount of testing. i386-softmmu/qemu boots the minimal linux.img fine and Mandrake/x86 seems to be booting too. i386-user/qemu runs basic x86 binaries such as "ls" and "nvi" fine, but more complex stuff fails possibly because of lack of futex. I wasn't able to test any other target architectures for lack of images (the only non-x86 image I found was for PPC and for some reason ppc-softmmu/qemu didn't get built for me.
Enjoy,
--david
Index: Makefile.target
===================================================================
RCS file: /cvsroot/qemu/qemu/Makefile.target,v
retrieving revision 1.57
Makefile.target +6 -0
@@ -184,7 +185,9 @@ endif ifeq ($(ARCH),ia64) +CFLAGS += -mno-sdata OP_CFLAGS=$(CFLAGS) +LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld endif ifeq ($(ARCH),arm)
@@ -368,6 +371,10 @@ VL_LDFLAGS+=-p endif +ifeq ($(ARCH),ia64) +VL_LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld +endif + $(QEMU_SYSTEM): $(VL_OBJS) libqemu.a $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(VL_LIBS)
Index: cpu-exec.c
===================================================================
RCS file: /cvsroot/qemu/qemu/cpu-exec.c,v
retrieving revision 1.50
cpu-exec.c +43 -0
55 lines not on this page · raw message
Index: disas.c
===================================================================
RCS file: /cvsroot/qemu/qemu/disas.c,v
retrieving revision 1.19
disas.c +6 -3
@@ -143,7 +143,8 @@#elif defined(TARGET_PPC ) print_insn = print_insn_ppc;#else -fprintf (out,"Asm output not supported on this arch\n" ); +fprintf (out,"0x" TARGET_FMT_lx +": Asm output not supported on this arch\n" , code);return ;#endif
@@ -202,7 +203,8 @@#elif defined(__arm__) print_insn = print_insn_arm;#else -fprintf (out,"Asm output not supported on this arch\n" ); +fprintf (out,"0x%lx: Asm output not supported on this arch\n" , + (long ) code);return ;#endif for (pc = (unsigned long )code; pc < (unsigned long )code + size; pc += count) {
@@ -311,7 +313,8 @@#elif defined(TARGET_PPC ) print_insn = print_insn_ppc;#else -term_printf ("Asm output not supported on this arch\n" ); +term_printf ("0x" TARGET_FMT_lx +": Asm output not supported on this arch\n" , pc);return ;#endif
Index: dyngen-exec.h
===================================================================
RCS file: /cvsroot/qemu/qemu/dyngen-exec.h,v
retrieving revision 1.20
dyngen-exec.h +8 -6
@@ -29,7 +29,7 @@typedef unsigned short uint16_t ;typedef unsigned int uint32_t ;/* XXX may be done for all 64 bits targets ? */ -#if defined (__x86_64__) +#if defined (__x86_64__) || defined(__ia64)typedef unsigned long uint64_t ;#else typedef unsigned long long uint64_t ;
@@ -38,7 +38,7 @@typedef signed char int8_t ;typedef signed short int16_t ;typedef signed int int32_t ; -#if defined (__x86_64__) +#if defined (__x86_64__) || defined(__ia64)typedef signed long int64_t ;#else typedef signed long long int64_t ;
@@ -159,10 +159,10 @@#define AREG4 "%d5"#endif #ifdef __ia64__ -#define AREG0 "r27" -#define AREG1 "r24" -#define AREG2 "r25" -#define AREG3 "r26" +#define AREG0 "r7" +#define AREG1 "r4" +#define AREG2 "r5" +#define AREG3 "r6"#endif /* force GCC to generate only one epilog at the end of the function */
@@ -234,6 +234,8 @@#endif #ifdef __ia64__#define EXIT_TB () asm volatile ("br.ret.sptk.many b0;;") +#define GOTO_LABEL_PARAM (n) asm volatile ("br.sptk.many " \ + ASM_NAME(__op_gen_label) #n)#endif #ifdef __sparc__#define EXIT_TB () asm volatile ("jmpl %i0 + 8, %g0\n" \
Index: dyngen.c
===================================================================
RCS file: /cvsroot/qemu/qemu/dyngen.c,v
retrieving revision 1.37
dyngen.c +186 -18
252 lines not on this page · raw message
Index: dyngen.h
===================================================================
RCS file: /cvsroot/qemu/qemu/dyngen.h,v
retrieving revision 1.7
dyngen.h +220 -0
229 lines not on this page · raw message
Index: exec-all.h
===================================================================
RCS file: /cvsroot/qemu/qemu/exec-all.h,v
retrieving revision 1.28
exec-all.h +11 -0
@@ -125,6 +125,8 @@#if defined(__alpha__)#define CODE_GEN_BUFFER_SIZE (2 * 1024 * 1024) +#elif defined(__ia64) +#define CODE_GEN_BUFFER_SIZE (4 * 1024 * 1024)/* range of addl */ #elif defined(__powerpc__)#define CODE_GEN_BUFFER_SIZE (6 * 1024 * 1024)#else
@@ -486,6 +488,15 @@ }#endif +#ifdef __ia64 +#include <ia64intrin.h> + +static inline int testandset (int *p) +{ +return __sync_lock_test_and_set (p,1 ); +} +#endif +typedef int spinlock_t ;#define SPIN_LOCK_UNLOCKED 0
Index: exec.c
===================================================================
RCS file: /cvsroot/qemu/qemu/exec.c,v
retrieving revision 1.57
exec.c +1 -1
@@ -58,7 +58,7 @@/* any access to the tbs or the page table must use this lock */ spinlock_t tb_lock =SPIN_LOCK_UNLOCKED ; -uint8_t code_gen_buffer[CODE_GEN_BUFFER_SIZE ]; +uint8_t code_gen_buffer[CODE_GEN_BUFFER_SIZE] __attribute__((aligned (32)));uint8_t *code_gen_ptr;int phys_ram_size;
Index: qemu-img.c
===================================================================
RCS file: /cvsroot/qemu/qemu/qemu-img.c,v
retrieving revision 1.5
qemu-img.c +4 -4
@@ -165,7 +165,7 @@int i;if (size <=999 ) { -snprintf (buf, buf_size,"%lld" , size); +snprintf (buf, buf_size,"%lld" , (long long ) size); }else { base =1024 ;for (i =0 ; i <NB_SUFFIXES ; i++) {
@@ -176,7 +176,7 @@break ; }else if (size < (1000 * base) || i == (NB_SUFFIXES -1 )) {snprintf (buf, buf_size,"%lld%c" , - (size + (base >>1 )) / base, + (long long ) ((size + (base >>1 )) / base), suffixes[i]);break ; }
@@ -369,7 +369,7 @@printf (", backing_file=%s" , base_filename); } -printf (", size=%lld kB\n" , size /1024 ); +printf (", size=%lld kB\n" , (long long ) (size /1024 )); ret =bdrv_create (drv, filename, size /512 , base_filename, encrypted);if (ret <0 ) {if (ret == -ENOTSUP ) {
@@ -666,7 +666,7 @@"virtual size: %s (%lld bytes)\n" "disk size: %s\n" , filename, fmt_name, size_buf, - total_sectors *512 , + (long long ) (total_sectors *512 ), dsize_buf);if (bdrv_is_encrypted (bs))printf ("encrypted: yes\n" );
Index: translate-all.c
===================================================================
RCS file: /cvsroot/qemu/qemu/translate-all.c,v
retrieving revision 1.10
translate-all.c +1 -1
@@ -88,7 +88,7 @@fprintf (logfile,"0x%04x: %s" , (int )(opc_ptr - opc_buf -1 ), op_str[c]);for (i =0 ; i < n; i++) { -fprintf (logfile," 0x%x" , opparam_ptr[i]); +fprintf (logfile," 0x%lx" , opparam_ptr[i]); }fprintf (logfile,"\n" );if (c == INDEX_op_end)
Index: vl.c
===================================================================
RCS file: /cvsroot/qemu/qemu/vl.c,v
retrieving revision 1.120
vl.c +9 -0
@@ -509,6 +509,15 @@ return val; } +#elif defined(__ia64) + +int64_t cpu_get_real_ticks (void ) +{ +int64_t val; + asmvolatile ("mov %0 = ar.itc" :"=r" (val) ::"memory" ); +return val; +} +#else #error unsupported CPU#endif
Index: linux-user/mmap.c
===================================================================
RCS file: /cvsroot/qemu/qemu/linux-user/mmap.c,v
retrieving revision 1.7
mmap.c +4 -2
@@ -152,7 +152,8 @@ int flags, int fd, unsigned long offset) { unsigned long ret, end, host_start, host_end, retaddr, host_offset, host_len; -#if defined(__alpha__) || defined(__sparc__) || defined(__x86_64__) +#if defined(__alpha__) || defined(__sparc__) || defined(__x86_64__) || \ + defined(__ia64)static unsigned long last_start =0x40000000 ;#endif
@@ -191,7 +192,8 @@ host_start = start & qemu_host_page_mask;if (!(flags &MAP_FIXED )) { -#if defined(__alpha__) || defined(__sparc__) || defined(__x86_64__) +#if defined(__alpha__) || defined(__sparc__) || defined(__x86_64__) || \ + defined(__ia64)/* tell the kenel to search at the same place as i386 */ if (host_start ==0 ) { host_start = last_start;
Index: linux-user/signal.c
===================================================================
RCS file: /cvsroot/qemu/qemu/linux-user/signal.c,v retrieving revision 1.27
signal.c +26 -31
111 lines not on this page · raw message
Index: linux-user/syscall.c
===================================================================
RCS file: /cvsroot/qemu/qemu/linux-user/syscall.c,v retrieving revision 1.57
syscall.c +62 -157
256 lines not on this page · raw message
Index: target-i386/cpu.h
===================================================================
RCS file: /cvsroot/qemu/qemu/target-i386/cpu.h,v
retrieving revision 1.27
cpu.h +2 -1
@@ -397,7 +397,8 @@#endif typedef struct CPUX86State { -#if TARGET_LONG_BITS > HOST_LONG_BITS +//#if TARGET_LONG_BITS > HOST_LONG_BITS +#if TARGET_LONG_BITS != 32 /* temporaries if we cannot store them in host registers */ target_ulong t0, t1, t2; #endif
Index: target-sparc/translate.c
===================================================================
RCS file: /cvsroot/qemu/qemu/target-sparc/translate.c,v retrieving revision 1.17
translate.c +2 -2
@@ -1690,7 +1690,7 @@ }#if defined(CONFIG_USER_ONLY ) -target_phys_addr_t cpu_get_phys_page_debug (CPUState *env,target_ulong addr) +target_ulong cpu_get_phys_page_debug (CPUState *env,target_ulong addr) {return addr; }
@@ -1700,7 +1700,7 @@ int *access_index, target_ulong address, int rw, int is_user); -target_phys_addr_t cpu_get_phys_page_debug (CPUState *env,target_ulong addr) +target_ulong cpu_get_phys_page_debug (CPUState *env,target_ulong addr) {target_phys_addr_t phys_addr;int prot, access_index;
ia64.ld new file +211 -0
211 lines not on this page · raw message