Make target_phys_addr_t 64 bits unconditionally
PATCH 1/1 Make target_phys_addr_t 64 bits unconditionally
The hassle and compile time overhead of maintaining both 32-bit and 64-bit capable source isn't worth the tiny performance advantage which is seen on a minority of configurations. Switch to compiling libhw only once, with target_phys_addr_t unconditionally typedefed to uint64_t.
--- .gitignore | 1 + Makefile | 2 +- Makefile.hw | 1 - Makefile.target | 3 --- configure | 34 ++++------------------------------ cpu-common.h | 2 +- dma.h | 2 +- hw/hw.h | 2 +- hw/intel-hda.c | 8 +------- hw/rtl8139.c | 6 +----- monitor.c | 4 ---- target-ppc/mmu_helper.c | 4 +--- targphys.h | 19 +------------------ 13 files changed, 13 insertions(+), 75 deletions(-)
.gitignore +1 -0
@@ -12,6 +12,7 @@ trace-dtrace.dtrace *-linux-user *-bsd-user libdis* +libhw libhw32 libhw64 libuser
Makefile +1 -1
@@ -214,7 +214,7 @@ $(qga-obj-y) qemu-ga.o: $(QGALIB_GEN) qemu-ga$(EXESUF): qemu-ga.o $(qga-obj-y) $(tools-obj-y) $(qapi-obj-y) $(qobject-obj-y) $(version-obj-y) -QEMULIBS=libhw32 libhw64 libuser libdis libdis-user +QEMULIBS=libhw libuser libdis libdis-user clean: # avoid old build problems by removing potentially incorrect old files
Makefile.hw +0 -1
@@ -2,7 +2,6 @@ include ../config-host.mak include ../config-all-devices.mak -include config.mak include $(SRC_PATH)/rules.mak .PHONY: all
Makefile.target +0 -3
@@ -4,9 +4,6 @@ include ../config-host.mak include config-devices.mak include config-target.mak include $(SRC_PATH)/rules.mak -ifneq ($(HWDIR),) -include $(HWDIR)/config.mak -endif $(call set-vpath, $(SRC_PATH)) ifdef CONFIG_LINUX
configure +4 -30
@@ -3694,7 +3694,6 @@ TARGET_ABI_DIR="" case "$target_arch2" in i386) - target_phys_bits=64 ;; x86_64) TARGET_BASE_ARCH=i386
@@ -3702,7 +3701,6 @@ case "$target_arch2" in target_long_alignment=8 ;; alpha) - target_phys_bits=64 target_long_alignment=8 target_nptl="yes" ;;
@@ -3711,22 +3709,18 @@ case "$target_arch2" in bflt="yes" target_nptl="yes" gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml" - target_phys_bits=64 target_llong_alignment=4 target_libs_softmmu="$fdt_libs" ;; cris) target_nptl="yes" - target_phys_bits=32 ;; lm32) - target_phys_bits=32 target_libs_softmmu="$opengl_libs" ;; m68k) bflt="yes" gdb_xml_files="cf-core.xml cf-fp.xml" - target_phys_bits=32 target_int_alignment=2 target_long_alignment=2 target_llong_alignment=2
@@ -3735,36 +3729,30 @@ case "$target_arch2" in TARGET_ARCH=microblaze bflt="yes" target_nptl="yes" - target_phys_bits=32 target_libs_softmmu="$fdt_libs" ;; mips|mipsel) TARGET_ARCH=mips echo "TARGET_ABI_MIPSO32=y" >> $config_target_mak target_nptl="yes" - target_phys_bits=64 ;; mipsn32|mipsn32el) TARGET_ARCH=mipsn32 TARGET_BASE_ARCH=mips echo "TARGET_ABI_MIPSN32=y" >> $config_target_mak - target_phys_bits=64 ;; mips64|mips64el) TARGET_ARCH=mips64 TARGET_BASE_ARCH=mips echo "TARGET_ABI_MIPSN64=y" >> $config_target_mak - target_phys_bits=64 target_long_alignment=8 ;; or32) TARGET_ARCH=openrisc TARGET_BASE_ARCH=openrisc - target_phys_bits=32 ;; ppc) gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml" - target_phys_bits=64 target_nptl="yes" target_libs_softmmu="$fdt_libs" ;;
@@ -3772,7 +3760,6 @@ case "$target_arch2" in TARGET_BASE_ARCH=ppc TARGET_ABI_DIR=ppc gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml" - target_phys_bits=64 target_nptl="yes" target_libs_softmmu="$fdt_libs" ;;
@@ -3780,7 +3767,6 @@ case "$target_arch2" in TARGET_BASE_ARCH=ppc TARGET_ABI_DIR=ppc gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml" - target_phys_bits=64 target_long_alignment=8 target_libs_softmmu="$fdt_libs" ;;
@@ -3790,21 +3776,17 @@ case "$target_arch2" in TARGET_ABI_DIR=ppc echo "TARGET_ABI32=y" >> $config_target_mak gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml" - target_phys_bits=64 target_libs_softmmu="$fdt_libs" ;; sh4|sh4eb) TARGET_ARCH=sh4 bflt="yes" target_nptl="yes" - target_phys_bits=32 ;; sparc) - target_phys_bits=64 ;; sparc64) TARGET_BASE_ARCH=sparc - target_phys_bits=64 target_long_alignment=8 ;; sparc32plus)
@@ -3812,11 +3794,9 @@ case "$target_arch2" in TARGET_BASE_ARCH=sparc TARGET_ABI_DIR=sparc echo "TARGET_ABI32=y" >> $config_target_mak - target_phys_bits=64 ;; s390x) target_nptl="yes" - target_phys_bits=64 target_long_alignment=8 ;; unicore32)
@@ -3824,7 +3804,6 @@ case "$target_arch2" in ;; xtensa|xtensaeb) TARGET_ARCH=xtensa - target_phys_bits=32 ;; *) echo "Unsupported target CPU"
@@ -3859,7 +3838,6 @@ echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak case "$target_arch2" in i386|x86_64) if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then - target_phys_bits=64 echo "CONFIG_XEN=y" >> $config_target_mak if test "$xen_pci_passthrough" = yes; then echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
@@ -3899,11 +3877,10 @@ if test "$target_bigendian" = "yes" ; then echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak fi if test "$target_softmmu" = "yes" ; then - echo "TARGET_PHYS_ADDR_BITS=$target_phys_bits" >> $config_target_mak echo "CONFIG_SOFTMMU=y" >> $config_target_mak echo "LIBS+=$libs_softmmu $target_libs_softmmu" >> $config_target_mak - echo "HWDIR=../libhw$target_phys_bits" >> $config_target_mak - echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak + echo "HWDIR=../libhw" >> $config_target_mak + echo "subdir-$target: subdir-libhw" >> $config_host_mak if test "$smartcard_nss" = "yes" ; then echo "subdir-$target: subdir-libcacard" >> $config_host_mak fi
@@ -4145,11 +4122,8 @@ for rom in seabios vgabios ; do echo "LD=$ld" >> $config_mak done -for hwlib in 32 64; do - d=libhw$hwlib - symlink "$source_path/Makefile.hw" "$d/Makefile" - echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" > $d/config.mak -done +d=libhw +symlink "$source_path/Makefile.hw" "$d/Makefile" d=libuser symlink "$source_path/Makefile.user" "$d/Makefile"
cpu-common.h +1 -1
@@ -21,7 +21,7 @@ enum device_endian { };/* address in the RAM (different from a physical address) */ -#if defined(CONFIG_XEN_BACKEND ) &&TARGET_PHYS_ADDR_BITS ==64 +#if defined(CONFIG_XEN_BACKEND )typedef uint64_t ram_addr_t ;# define RAM_ADDR_MAX UINT64_MAX# define RAM_ADDR_FMT "%" PRIx64
dma.h +1 -1
@@ -31,7 +31,7 @@ struct QEMUSGList {DMAContext *dma; }; -#if defined(TARGET_PHYS_ADDR_BITS ) +#ifndef CONFIG_USER_ONLY /* * When an IOMMU is present, bus addresses become distinct from
hw/hw.h +1 -1
@@ -4,7 +4,7 @@#include "qemu-common.h" -#if defined(TARGET_PHYS_ADDR_BITS ) && !defined(NEED_CPU_H ) +#if !defined(CONFIG_USER_ONLY ) && !defined(NEED_CPU_H )#include "cpu-common.h" #endif
hw/intel-hda.c +1 -7
@@ -210,13 +210,7 @@ static target_phys_addr_t intel_hda_addr(uint32_t lbase, uint32_t ubase) {target_phys_addr_t addr; -#if TARGET_PHYS_ADDR_BITS ==32 - addr = lbase; -#else - addr = ubase; - addr <<=32 ; - addr |= lbase; -#endif + addr = ((uint64_t )ubase <<32 ) | lbase;return addr; }
hw/rtl8139.c +1 -5
@@ -774,11 +774,7 @@ static void rtl8139_write_buffer(RTL8139State *s, const void *buf, int size)#define MIN_BUF_SIZE 60static inline dma_addr_t rtl8139_addr64 (uint32_t low,uint32_t high) { -#if TARGET_PHYS_ADDR_BITS >32 -return low | ((target_phys_addr_t )high <<32 ); -#else -return low; -#endif +return low | ((uint64_t )high <<32 ); }/* Workaround for buggy guest driver such as linux who allocates rx
monitor.c +0 -4
@@ -3259,11 +3259,7 @@ static int64_t expr_unary(Monitor *mon)break ;default : errno =0 ; -#if TARGET_PHYS_ADDR_BITS >32 n =strtoull (pch, &p,0 ); -#else - n =strtoul (pch, &p,0 ); -#endif if (errno ==ERANGE ) {expr_error (mon,"number too large" ); }
target-ppc/mmu_helper.c +1 -3
@@ -1032,12 +1032,10 @@ static int ppcemb_tlb_check(CPUPPCState *env, ppcemb_tlb_t *tlb,return -1 ; } *raddrp = (tlb->RPN & mask) | (address & ~mask); -#if (TARGET_PHYS_ADDR_BITS >=36 )if (ext) {/* Extend the physical address to 36 bits */ - *raddrp |= (target_phys_addr_t)(tlb->RPN &0xF ) <<32 ; + *raddrp |= (uint64_t )(tlb->RPN &0xF ) <<32 ; } -#endif return 0 ; }
targphys.h +1 -18
@@ -3,25 +3,10 @@#ifndef TARGPHYS_H #define TARGPHYS_H -#ifdef TARGET_PHYS_ADDR_BITS +#define TARGET_PHYS_ADDR_BITS 64/* target_phys_addr_t is the type of a physical address (its size can be different from 'target_ulong'). */ -#if TARGET_PHYS_ADDR_BITS ==32 -typedef uint32_t target_phys_addr_t ; -#define TARGET_PHYS_ADDR_MAX UINT32_MAX -#define TARGET_FMT_plx "%08x" -/* Format strings for printing target_phys_addr_t types. -* These are recommended over the less flexible TARGET_FMT_plx, -* which is retained for the benefit of existing code. -*/ -#define TARGET_PRIdPHYS PRId32 -#define TARGET_PRIiPHYS PRIi32 -#define TARGET_PRIoPHYS PRIo32 -#define TARGET_PRIuPHYS PRIu32 -#define TARGET_PRIxPHYS PRIx32 -#define TARGET_PRIXPHYS PRIX32 -#elif TARGET_PHYS_ADDR_BITS ==64 typedef uint64_t target_phys_addr_t ;#define TARGET_PHYS_ADDR_MAX UINT64_MAX#define TARGET_FMT_plx "%016" PRIx64
@@ -31,7 +16,5 @@ typedef uint64_t target_phys_addr_t;#define TARGET_PRIuPHYS PRIu64#define TARGET_PRIxPHYS PRIx64#define TARGET_PRIXPHYS PRIX64 -#endif -#endif #endif
Signature · 1 line
1.7.12
Quoted 4 lines · Avi Kivity
The hassle and compile time overhead of maintaining both 32-bit and 64-bit capable source isn't worth the tiny performance advantage which is seen on a minority of configurations. Switch to compiling libhw only once, with
target_phys_addr_tunconditionally typedefed touint64_t.
Isn't it the real difference between qemu-system-i386 and qemu-system-x86_64, and why -i386 is quite a bit faster in TCG mode than -x86-64, as has been noted by Jan?
Just.. asking :)
Thanks,
/mjt
Quoted 7 lines · Michael Tokarev
Quoted 4 lines · Avi Kivity
The hassle and compile time overhead of maintaining both 32-bit and 64-bit capable source isn't worth the tiny performance advantage which is seen on a minority of configurations. Switch to compiling libhw only once, with
target_phys_addr_tunconditionally typedefed touint64_t.Isn't it the real difference between qemu-system-i386 and qemu-system-x86_64
No; today configure builds both -i386 and -x86_64 binaries with target_phys_addr_t a 64 bit type. The difference is in various things like (a) what size of registers are we emulating (b) how big is the physical and virtual address space (distinct from the type width) and (c) a bunch of stuff in the decoder for whether we actually allow the 64 bit insns.
-- PMM