Unbreak large mem support by removing kqemu
PATCH 1/2 Unbreak large mem support by removing kqemu
kqemu introduces a number of restrictions on the i386 target. The worst is that it prevents large memory from working in the default build.
Furthermore, kqemu is fundamentally flawed in a number of ways. It relies on the TSC as a time source which will not be reliable on a multiple processor system in userspace. Since most modern processors are multicore, this severely limits the utility of kqemu.
kvm is a viable alternative for people looking to accelerate qemu and has the benefit of being supported by the upstream Linux kernel. If someone can implement work arounds to remove the restrictions introduced by kqemu, I'm happy to avoid and/or revert this patch.
N.B. kqemu will still function in the 0.11 series but this patch removes it from the 0.12 series.
Paul, please Ack or Nack this patch.
--- MAINTAINERS | 1 - Makefile.target | 1 - configure | 27 -- cpu-all.h | 6 - cpu-common.h | 5 - cpu-exec.c | 38 +-- exec-all.h | 35 -- exec.c | 91 +----- hw/pc.c | 12 +- ioport.c | 24 -- kqemu.c | 998 ----------------------------------------------- kqemu.h | 154 -------- monitor.c | 57 --- osdep.c | 121 ------ qemu-monitor.hx | 2 - qemu-options.hx | 19 - qemu-tech.texi | 4 +- softmmu_template.h | 6 - sysemu.h | 4 - target-i386/TODO | 1 - target-i386/cpu.h | 14 - target-i386/helper.c | 15 - target-i386/op_helper.c | 42 -- vl.c | 53 +--- 24 files changed, 8 insertions(+), 1722 deletions(-) delete mode 100644 kqemu.c delete mode 100644 kqemu.h
MAINTAINERS +0 -1
@@ -70,7 +70,6 @@ Generic Subsystems: Dynamic translator Fabrice Bellard Main loop Fabrice Bellard (new maintainer needed) TCG Fabrice Bellard -kqemu interface Fabrice Bellard IDE device ? SCSI device Paul Brook PCI layer ?
Makefile.target +0 -1
@@ -36,7 +36,6 @@ all: $(PROGS) ######################################################### # cpu emulator library libobj-y = exec.o translate-all.o cpu-exec.o translate.o host-utils.o -libobj-$(CONFIG_KQEMU) += kqemu.o libobj-y += tcg/tcg.o tcg/tcg-runtime.o libobj-$(CONFIG_SOFTFLOAT) += fpu/softfloat.o libobj-$(CONFIG_NOSOFTFLOAT) += fpu/softfloat-native.o
configure +0 -27
@@ -185,7 +185,6 @@ vnc_sasl="yes" bsd="no" linux="no" solaris="no" -kqemu="no" profiler="no" cocoa="no" softmmu="yes"
@@ -238,25 +237,16 @@ MINGW32*) GNU/kFreeBSD) audio_drv_list="oss" audio_possible_drivers="oss sdl esd pa" - if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then - kqemu="yes" - fi ;; FreeBSD) bsd="yes" audio_drv_list="oss" audio_possible_drivers="oss sdl esd pa" - if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then - kqemu="yes" - fi ;; DragonFly) bsd="yes" audio_drv_list="oss" audio_possible_drivers="oss sdl esd pa" - if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then - kqemu="yes" - fi aio="no" ;; NetBSD)
@@ -320,9 +310,6 @@ SunOS) exit 1 fi fi - if test "$solarisrev" -ge 9 ; then - kqemu="yes" - fi fi if test -f /usr/include/sys/soundcard.h ; then audio_drv_list="oss"
@@ -343,7 +330,6 @@ AIX) usb="linux" kvm="yes" if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then - kqemu="yes" audio_possible_drivers="$audio_possible_drivers fmod" fi ;;
@@ -358,9 +344,6 @@ if [ "$bsd" = "yes" ] ; then fi if test "$mingw32" = "yes" ; then - if [ "$cpu" = "i386" ] ; then - kqemu="yes" - fi EXESUF=".exe" QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS" LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
@@ -450,8 +433,6 @@ for opt do ;; --disable-vde) vde="no" ;; - --disable-kqemu) kqemu="no" - ;; --disable-xen) xen="no" ;; --disable-brlapi) brlapi="no"
@@ -597,9 +578,6 @@ echo " --interp-prefix=PREFIX where to find shared libraries, etc." echo " use %M for cpu name [$interp_prefix]" echo " --target-list=LIST set target list [$target_list]" echo "" -echo "kqemu kernel acceleration support:" -echo " --disable-kqemu disable kqemu support" -echo "" echo "Advanced options (experts only):" echo " --source-path=PATH path of source code [$source_path]" echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
@@ -1534,7 +1512,6 @@ fi if test -n "$sparc_cpu"; then echo "Target Sparc Arch $sparc_cpu" fi -echo "kqemu support $kqemu" echo "xen support $xen" echo "brlapi support $brlapi" echo "Documentation $build_docs"
@@ -2019,10 +1996,6 @@ case "$target_arch2" in if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then echo "CONFIG_XEN=y" >> $config_mak fi - if test $kqemu = "yes" -a "$target_softmmu" = "yes" - then - echo "CONFIG_KQEMU=y" >> $config_mak - fi esac case "$target_arch2" in i386|x86_64|ppcemb|ppc|ppc64)
cpu-all.h +0 -6
@@ -873,7 +873,6 @@ int cpu_memory_rw_debug(CPUState *env, target_ulong addr,#define VGA_DIRTY_FLAG 0x01#define CODE_DIRTY_FLAG 0x02 -#define KQEMU_DIRTY_FLAG 0x04#define MIGRATION_DIRTY_FLAG 0x08/* read dirty bit (return 0 or 1) */
@@ -1056,14 +1055,9 @@ static inline int64_t profile_getclock(void)return cpu_get_real_ticks (); } -extern int64_t kqemu_time, kqemu_time_start;extern int64_t qemu_time, qemu_time_start;extern int64_t tlb_flush_time; -extern int64_t kqemu_exec_count;extern int64_t dev_time; -extern int64_t kqemu_ret_int_count; -extern int64_t kqemu_ret_excp_count; -extern int64_t kqemu_ret_intr_count;#endif void cpu_inject_x86_mce(CPUState *cenv, int bank, uint64_t status,
cpu-common.h +0 -5
@@ -10,12 +10,7 @@#include "bswap.h" /* address in the RAM (different from a physical address) */ -#ifdef CONFIG_KQEMU -/* FIXME: This is wrong. */ -typedef uint32_t ram_addr_t ; -#else typedef unsigned long ram_addr_t ; -#endif /* memory API */
cpu-exec.c +1 -37
@@ -321,31 +321,6 @@ int cpu_exec(CPUState *env1) } env->exception_index =-1 ; } -#ifdef CONFIG_KQEMU -if (kqemu_is_ok (env) && env->interrupt_request ==0 && env->exit_request ==0 ) { -int ret; - env->eflags = env->eflags |helper_cc_compute_all (CC_OP ) | (DF &DF_MASK ); - ret =kqemu_cpu_exec (env); -/* put eflags in CPU temporary format */ -CC_SRC = env->eflags & (CC_O |CC_S |CC_Z |CC_A |CC_P |CC_C ); -DF =1 - (2 * ((env->eflags >>10 ) &1 )); -CC_OP =CC_OP_EFLAGS ; - env->eflags &= ~(DF_MASK |CC_O |CC_S |CC_Z |CC_A |CC_P |CC_C ); -if (ret ==1 ) { -/* exception */ -longjmp (env->jmp_env,1 ); - }else if (ret ==2 ) { -/* softmmu execution needed */ - }else { -if (env->interrupt_request !=0 || env->exit_request !=0 ) { -/* hardware interrupt will be executed just after */ - }else { -/* otherwise, we restart */ -longjmp (env->jmp_env,1 ); - } - } - } -#endif if (kvm_enabled ()) {kvm_cpu_exec (env);
@@ -623,11 +598,7 @@ int cpu_exec(CPUState *env1)spans two pages, we cannot safely do a direct jump. */ { -if (next_tb !=0 && -#ifdef CONFIG_KQEMU - (env->kqemu_enabled !=2 ) && -#endif - tb->page_addr[1 ] ==-1 ) { +if (next_tb !=0 && tb->page_addr[1 ] ==-1 ) {tb_add_jump ((TranslationBlock *)(next_tb & ~3 ), next_tb &3 , tb); } }
@@ -681,13 +652,6 @@ int cpu_exec(CPUState *env1) }/* reset soft MMU for next block (it can currently only be set by a memory fault) */ -#if defined(CONFIG_KQEMU ) -#define MIN_CYCLE_BEFORE_SWITCH (100 * 1000) -if (kqemu_is_ok (env) && - (cpu_get_time_fast () - env->last_io_time) >=MIN_CYCLE_BEFORE_SWITCH ) { -cpu_loop_exit (); - } -#endif }/* for(;;) */ }else {env_to_regs ();
exec-all.h +0 -35
@@ -348,41 +348,6 @@ static inline int can_do_io(CPUState *env) }#endif -#ifdef CONFIG_KQEMU -#define KQEMU_MODIFY_PAGE_MASK (0xff & ~(VGA_DIRTY_FLAG | CODE_DIRTY_FLAG)) - -#define MSR_QPI_COMMBASE 0xfabe0010 - -int kqemu_init (CPUState *env); -int kqemu_cpu_exec (CPUState *env); -void kqemu_flush_page (CPUState *env,target_ulong addr); -void kqemu_flush (CPUState *env,int global); -void kqemu_set_notdirty (CPUState *env,ram_addr_t ram_addr); -void kqemu_modify_page (CPUState *env,ram_addr_t ram_addr); -void kqemu_set_phys_mem (uint64_t start_addr,ram_addr_t size, -ram_addr_t phys_offset); -void kqemu_cpu_interrupt (CPUState *env); -void kqemu_record_dump (void ); - -extern uint32_t kqemu_comm_base; - -extern ram_addr_t kqemu_phys_ram_size; -extern uint8_t *kqemu_phys_ram_base; - -static inline int kqemu_is_ok (CPUState *env) -{ -return (env->kqemu_enabled && - (env->cr[0 ] &CR0_PE_MASK ) && - !(env->hflags &HF_INHIBIT_IRQ_MASK ) && - (env->eflags &IF_MASK ) && - !(env->eflags &VM_MASK ) && - (env->kqemu_enabled ==2 || - ((env->hflags &HF_CPL_MASK ) ==3 && - (env->eflags &IOPL_MASK ) !=IOPL_MASK ))); -} - -#endif -typedef void (CPUDebugExcpHandler )(CPUState *env);CPUDebugExcpHandler *cpu_set_debug_excp_handler (CPUDebugExcpHandler *handler);
exec.c +2 -89
170 lines not on this page · raw message
hw/pc.c +1 -11
@@ -122,17 +122,7 @@ static void ioportF0_write(void *opaque, uint32_t addr, uint32_t data)/* TSC handling */ uint64_t cpu_get_tsc (CPUX86State *env) { -/* Note: when using kqemu, it is more logical to return the host TSC -because kqemu does not trap the RDTSC instruction for -performance reasons */ -#ifdef CONFIG_KQEMU -if (env->kqemu_enabled) { -return cpu_get_real_ticks (); - } else -#endif - { -return cpu_get_ticks (); - } +return cpu_get_ticks (); }/* SMM support */
ioport.c +0 -24
@@ -196,30 +196,18 @@ void cpu_outb(CPUState *env, pio_addr_t addr, uint8_t val) {LOG_IOPORT ("outb: %04" FMT_pioaddr" %02" PRIx8"\n" , addr, val);ioport_write (0 , addr, val); -#ifdef CONFIG_KQEMU -if (env) - env->last_io_time =cpu_get_time_fast (); -#endif }void cpu_outw (CPUState *env,pio_addr_t addr,uint16_t val) {LOG_IOPORT ("outw: %04" FMT_pioaddr" %04" PRIx16"\n" , addr, val);ioport_write (1 , addr, val); -#ifdef CONFIG_KQEMU -if (env) - env->last_io_time =cpu_get_time_fast (); -#endif }void cpu_outl (CPUState *env,pio_addr_t addr,uint32_t val) {LOG_IOPORT ("outl: %04" FMT_pioaddr" %08" PRIx32"\n" , addr, val);ioport_write (2 , addr, val); -#ifdef CONFIG_KQEMU -if (env) - env->last_io_time =cpu_get_time_fast (); -#endif }uint8_t cpu_inb (CPUState *env,pio_addr_t addr)
@@ -227,10 +215,6 @@ uint8_t cpu_inb(CPUState *env, pio_addr_t addr)uint8_t val; val =ioport_read (0 , addr);LOG_IOPORT ("inb : %04" FMT_pioaddr" %02" PRIx8"\n" , addr, val); -#ifdef CONFIG_KQEMU -if (env) - env->last_io_time =cpu_get_time_fast (); -#endif return val; }
@@ -239,10 +223,6 @@ uint16_t cpu_inw(CPUState *env, pio_addr_t addr)uint16_t val; val =ioport_read (1 , addr);LOG_IOPORT ("inw : %04" FMT_pioaddr" %04" PRIx16"\n" , addr, val); -#ifdef CONFIG_KQEMU -if (env) - env->last_io_time =cpu_get_time_fast (); -#endif return val; }
@@ -251,9 +231,5 @@ uint32_t cpu_inl(CPUState *env, pio_addr_t addr)uint32_t val; val =ioport_read (2 , addr);LOG_IOPORT ("inl : %04" FMT_pioaddr" %08" PRIx32"\n" , addr, val); -#ifdef CONFIG_KQEMU -if (env) - env->last_io_time =cpu_get_time_fast (); -#endif return val; }
kqemu.c deleted +0 -998
998 lines not on this page · raw message
kqemu.h deleted +0 -154
154 lines not on this page · raw message
monitor.c +0 -57
83 lines not on this page · raw message
osdep.c +0 -121
138 lines not on this page · raw message
qemu-monitor.hx +0 -2
@@ -57,8 +57,6 @@ show virtual to physical memory mappings (i386 only) show the active virtual memory mappings (i386 only) @item info hpet show state of HPET (i386 only) -@item info kqemu -show KQEMU information @item info kvm show KVM information @item info usb
qemu-options.hx +0 -19
@@ -1414,25 +1414,6 @@ STEXI Set the filename for the BIOS. ETEXI -#ifdef CONFIG_KQEMU -DEF("kernel-kqemu", 0, QEMU_OPTION_kernel_kqemu, \ - "-kernel-kqemu enable KQEMU full virtualization (default is user mode only)\n") -#endif -STEXI -@item -kernel-kqemu -Enable KQEMU full virtualization (default is user mode only). -ETEXI - -#ifdef CONFIG_KQEMU -DEF("enable-kqemu", 0, QEMU_OPTION_enable_kqemu, \ - "-enable-kqemu enable KQEMU kernel module usage\n") -#endif -STEXI -@item -enable-kqemu -Enable KQEMU kernel module usage. KQEMU options are only available if -KQEMU support is enabled when compiling. -ETEXI - #ifdef CONFIG_KVM DEF("enable-kvm", 0, QEMU_OPTION_enable_kvm, \ "-enable-kvm enable KVM full virtualization support\n")
qemu-tech.texi +2 -2
@@ -116,8 +116,8 @@ QEMU full system emulation features: QEMU uses a full software MMU for maximum portability. @item -QEMU can optionally use an in-kernel accelerator, like kqemu and -kvm. The accelerators execute some of the guest code natively, while +QEMU can optionally use an in-kernel accelerator, like kvm. The accelerators +execute some of the guest code natively, while continuing to emulate the rest of the machine. @item
softmmu_template.h +0 -6
@@ -75,9 +75,6 @@ static inline DATA_TYPE glue(io_read, SUFFIX)(target_phys_addr_t physaddr, res |= (uint64_t )io_mem_read[index][2 ](io_mem_opaque[index], physaddr +4 ) <<32 ;#endif #endif /* SHIFT > 2 */ -#ifdef CONFIG_KQEMU - env->last_io_time =cpu_get_time_fast (); -#endif return res; }
@@ -220,9 +217,6 @@ static inline void glue(io_write, SUFFIX)(target_phys_addr_t physaddr, io_mem_write[index][2 ](io_mem_opaque[index], physaddr +4 , val >>32 );#endif #endif /* SHIFT > 2 */ -#ifdef CONFIG_KQEMU - env->last_io_time =cpu_get_time_fast (); -#endif } void REGPARM glue(glue(__st, SUFFIX), MMUSUFFIX)(target_ulong addr,
sysemu.h +0 -4
@@ -131,10 +131,6 @@ extern int semihosting_enabled;extern int old_param;extern int boot_menu; -#ifdef CONFIG_KQEMU -extern int kqemu_allowed; -#endif -#define MAX_NODES 64extern int nb_numa_nodes;extern uint64_t node_mem[MAX_NODES ];
target-i386/TODO +0 -1
@@ -30,4 +30,3 @@ Optimizations/Features: - evaluate x87 stack pointer statically - find a way to avoid translating several time the same TB if CR0.TS is set or not. -- move kqemu support outside target-i386.
target-i386/cpu.h +0 -14
@@ -682,11 +682,6 @@ typedef struct CPUX86State {uint64_t mask; } mtrr_var[8 ]; -#ifdef CONFIG_KQEMU -int kqemu_enabled; -int last_io_time; -#endif -/* For KVM */ uint64_t interrupt_bitmap[256 /64 ];uint32_t mp_state;
@@ -850,15 +845,6 @@ uint64_t cpu_get_tsc(CPUX86State *env);#define X86_DUMP_FPU 0x0001/* dump FPU state too */ #define X86_DUMP_CCOP 0x0002/* dump qemu flag cache */ -#ifdef CONFIG_KQEMU -static inline int cpu_get_time_fast (void ) -{ -int low, high; - asmvolatile ("rdtsc" :"=a" (low),"=d" (high)); -return low; -} -#endif -#define TARGET_PAGE_BITS 12#define cpu_init cpu_x86_init
target-i386/helper.c +0 -15
@@ -995,15 +995,11 @@ target_phys_addr_t cpu_get_phys_page_debug(CPUState *env, target_ulong addr)/* XXX: This value should match the one returned by CPUID * and in exec.c */ -#if defined(CONFIG_KQEMU ) -#define PHYS_ADDR_MASK 0xfffff000LL -#else # if defined(TARGET_X86_64 )# define PHYS_ADDR_MASK 0xfffffff000LL# else # define PHYS_ADDR_MASK 0xffffff000LL# endif -#endif /* return value: -1 = cannot handle fault
@@ -1743,21 +1739,13 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,/* XXX: This value must match the one used in the MMU code. */ if (env->cpuid_ext2_features &CPUID_EXT2_LM ) {/* 64 bit processor */ -#if defined(CONFIG_KQEMU ) - *eax =0x00003020 ;/* 48 bits virtual, 32 bits physical */ -#else /* XXX: The physical address space is limited to 42 bits in exec.c. */ *eax =0x00003028 ;/* 48 bits virtual, 40 bits physical */ -#endif }else { -#if defined(CONFIG_KQEMU ) - *eax =0x00000020 ;/* 32 bits physical */ -#else if (env->cpuid_features &CPUID_PSE36 ) *eax =0x00000024 ;/* 36 bits physical */ else *eax =0x00000020 ;/* 32 bits physical */ -#endif } *ebx =0 ; *ecx =0 ;
@@ -1833,9 +1821,6 @@ CPUX86State *cpu_x86_init(const char *cpu_model) }mce_init (env);cpu_reset (env); -#ifdef CONFIG_KQEMU -kqemu_init (env); -#endif qemu_init_vcpu (env);
target-i386/op_helper.c +0 -42
77 lines not on this page · raw message
vl.c +2 -51
98 lines not on this page · raw message
Signature · 1 line
1.6.2.5
PATCH 2/2 Only build osdep once
We no longer need hackery to work around kqemu
--- Makefile | 8 ++++---- Makefile.target | 2 +- osdep.c | 3 --- tool-osdep.c | 4 ---- 4 files changed, 5 insertions(+), 12 deletions(-) delete mode 100644 tool-osdep.c
Makefile +4 -4
@@ -54,7 +54,7 @@ recurse-all: $(SUBDIR_RULES) $(ROMSUBDIR_RULES) # block-obj-y is code used by both qemu system emulation and qemu-img block-obj-y = cutils.o cache-utils.o qemu-malloc.o qemu-option.o module.o -block-obj-y += nbd.o block.o aio.o aes.o +block-obj-y += nbd.o block.o aio.o aes.o osdep.o block-obj-$(CONFIG_AIO) += posix-aio-compat.o block-nested-y += cow.o qcow.o vdi.o vmdk.o cloop.o dmg.o bochs.o vpc.o vvfat.o
@@ -170,11 +170,11 @@ libqemu_user.a: $(user-obj-y) qemu-img.o: qemu-img-cmds.h -qemu-img$(EXESUF): qemu-img.o qemu-tool.o tool-osdep.o $(block-obj-y) +qemu-img$(EXESUF): qemu-img.o qemu-tool.o $(block-obj-y) -qemu-nbd$(EXESUF): qemu-nbd.o qemu-tool.o tool-osdep.o $(block-obj-y) +qemu-nbd$(EXESUF): qemu-nbd.o qemu-tool.o $(block-obj-y) -qemu-io$(EXESUF): qemu-io.o qemu-tool.o tool-osdep.o cmd.o $(block-obj-y) +qemu-io$(EXESUF): qemu-io.o qemu-tool.o cmd.o $(block-obj-y) qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx $(call quiet-command,sh $(SRC_PATH)/hxtool -h < $< > $@," GEN $@")
Makefile.target +1 -1
@@ -143,7 +143,7 @@ endif #CONFIG_BSD_USER # System emulator target ifdef CONFIG_SOFTMMU -obj-y = vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o machine.o \ +obj-y = vl.o monitor.o pci.o loader.o isa_mmio.o machine.o \ gdbstub.o gdbstub-xml.o msix.o ioport.o qemu-config.o # virtio has to be here due to weird dependency between PCI and virtio-net. # need to fix this properly
osdep.c +0 -3
@@ -33,9 +33,6 @@#include <sys/statvfs.h> #endif -/* FIXME: This file should be target independent. However it has kqemu -hacks, so must be built for every target. */ -/* Needed early for CONFIG_BSD etc. */ #include "config-host.h"
tool-osdep.c deleted +0 -4
@@ -1,4 +0,0 @@ -/* Hack to provide a version of osdep.o for qemu-img without conflicting with -the (kqemu) target specific osdep.o. */ -#include "osdep.c" -
Signature · 1 line
1.6.2.5
Quoted 8 lines
kqemu introduces a number of restrictions on the i386 target.
kvm is a viable alternative for people looking to accelerate qemu and has the benefit of being supported by the upstream Linux kernel. If someone can implement work arounds to remove the restrictions introduced by kqemu, I'm happy to avoid and/or revert this patch.
Paul, please Ack or Nack this patch.
Ok.
I think we've kept kqemu lying around in a semi-broken state long enough that we can demonstrate lack of active developer interest. Anyone that really cares can always retrieve it from git history and start from there.
Paul