From 3038d10cc78d94a1da1a8bdf031578deaaf5297e Mon Sep 17 00:00:00 2001 From: Zhang Xiantao Date: Sun, 6 Jan 2008 18:14:56 +0800 Subject: [PATCH] kvm: qemu: move tpr-patch routine to qemu-kvm-x86.c Since tpr patching routine only needed in x86 side, moving it qemu-kvm-arch. Signed-off-by: Zhang Xiantao Signed-off-by: Avi Kivity --- qemu/Makefile.target | 6 +++--- qemu/qemu-kvm-x86.c | 8 ++++++++ qemu/qemu-kvm.c | 11 ++++------- qemu/qemu-kvm.h | 2 ++ 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/qemu/Makefile.target b/qemu/Makefile.target index 289cd18c..bb7be0f6 100644 --- a/qemu/Makefile.target +++ b/qemu/Makefile.target @@ -299,7 +299,7 @@ OBJS+= libqemu.a # cpu emulator library LIBOBJS=exec.o kqemu.o qemu-kvm.o translate-op.o translate-all.o cpu-exec.o\ - translate.o op.o host-utils.o qemu-kvm-helper.o kvm-tpr-opt.o + translate.o op.o host-utils.o qemu-kvm-helper.o ifdef CONFIG_SOFTFLOAT LIBOBJS+=fpu/softfloat.o else @@ -309,12 +309,12 @@ CPPFLAGS+=-I$(SRC_PATH)/fpu ifeq ($(TARGET_ARCH), i386) LIBOBJS+=helper.o helper2.o -LIBOBJS+=qemu-kvm-x86.o +LIBOBJS+=qemu-kvm-x86.o kvm-tpr-opt.o endif ifeq ($(TARGET_ARCH), x86_64) LIBOBJS+=helper.o helper2.o -LIBOBJS+=qemu-kvm-x86.o +LIBOBJS+=qemu-kvm-x86.o kvm-tpr-opt.o endif ifeq ($(TARGET_BASE_ARCH), ppc) diff --git a/qemu/qemu-kvm-x86.c b/qemu/qemu-kvm-x86.c index d86fec30..c79ca369 100644 --- a/qemu/qemu-kvm-x86.c +++ b/qemu/qemu-kvm-x86.c @@ -625,4 +625,12 @@ void kvm_arch_update_regs_for_sipi(CPUState *env) env->eip = 0; kvm_arch_load_regs(env); } + +int handle_tpr_access(void *opaque, int vcpu, + uint64_t rip, int is_write) +{ + kvm_tpr_access_report(cpu_single_env, rip, is_write); + return 0; +} + #endif diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c index 9aee9035..8e1ba7a3 100644 --- a/qemu/qemu-kvm.c +++ b/qemu/qemu-kvm.c @@ -327,7 +327,9 @@ static int kvm_main_loop_cpu(CPUState *env) env->ready_for_interrupt_injection = 1; cpu_single_env = env; +#ifdef TARGET_I386 kvm_tpr_opt_setup(env); +#endif while (1) { while (!has_work(env)) kvm_main_loop_wait(env, 10); @@ -512,13 +514,6 @@ static int kvm_shutdown(void *opaque, int vcpu) return 1; } -static int handle_tpr_access(void *opaque, int vcpu, - uint64_t rip, int is_write) -{ - kvm_tpr_access_report(cpu_single_env, rip, is_write); - return 0; -} - static struct kvm_callbacks qemu_kvm_ops = { .debug = kvm_debug, .inb = kvm_inb, @@ -535,7 +530,9 @@ static struct kvm_callbacks qemu_kvm_ops = { .try_push_interrupts = try_push_interrupts, .post_kvm_run = post_kvm_run, .pre_kvm_run = pre_kvm_run, +#ifdef TARGET_I386 .tpr_access = handle_tpr_access, +#endif }; int kvm_qemu_init() diff --git a/qemu/qemu-kvm.h b/qemu/qemu-kvm.h index ca3132a2..e4aeb3ab 100644 --- a/qemu/qemu-kvm.h +++ b/qemu/qemu-kvm.h @@ -45,6 +45,8 @@ extern int kvm_irqchip; void kvm_tpr_opt_setup(CPUState *env); void kvm_tpr_access_report(CPUState *env, uint64_t rip, int is_write); +int handle_tpr_access(void *opaque, int vcpu, + uint64_t rip, int is_write); #define ALIGN(x, y) (((x)+(y)-1) & ~((y)-1)) #define BITMAP_SIZE(m) (ALIGN(((m)>>TARGET_PAGE_BITS), HOST_LONG_BITS) / 8) -- 2.11.4.GIT