summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kvm-tpr-opt.c15
-rw-r--r--qemu-kvm-x86.c3
-rw-r--r--qemu-kvm.h2
-rw-r--r--target-i386/cpu.h2
4 files changed, 18 insertions, 4 deletions
diff --git a/kvm-tpr-opt.c b/kvm-tpr-opt.c
index 89256d4c4..bf9c9a06e 100644
--- a/kvm-tpr-opt.c
+++ b/kvm-tpr-opt.c
@@ -233,7 +233,7 @@ static int get_pcr_cpu(CPUState *env)
return (int)b;
}
-static int enable_vapic(CPUState *env)
+int kvm_tpr_enable_vapic(CPUState *env)
{
static uint8_t one = 1;
int pcr_cpu = get_pcr_cpu(env);
@@ -243,8 +243,15 @@ static int enable_vapic(CPUState *env)
kvm_enable_vapic(env, vapic_phys + (pcr_cpu << 7));
cpu_physical_memory_rw(vapic_phys + (pcr_cpu << 7) + 4, &one, 1, 1);
+ env->update_vapic = 0;
bios_enabled = 1;
+ return 1;
+}
+static int enable_vapic(CPUState *env)
+{
+ bios_enabled = 1;
+ env->update_vapic = 1;
return 1;
}
@@ -307,7 +314,7 @@ void kvm_tpr_access_report(CPUState *env, uint64_t rip, int is_write)
return;
if (!bios_is_mapped(env, rip))
return;
- if (!enable_vapic(env))
+ if (!kvm_tpr_enable_vapic(env))
return;
patch_instruction(env, rip);
}
@@ -316,7 +323,7 @@ void kvm_tpr_vcpu_start(CPUState *env)
{
kvm_enable_tpr_access_reporting(env);
if (bios_enabled)
- enable_vapic(env);
+ kvm_tpr_enable_vapic(env);
}
static void tpr_save(QEMUFile *f, void *s)
@@ -391,7 +398,7 @@ static void vtpr_ioport_write(void *opaque, uint32_t addr, uint32_t val)
}
bios_enabled = 1;
update_vbios_real_tpr();
- enable_vapic(env);
+ kvm_tpr_enable_vapic(env);
}
void kvm_tpr_opt_setup(void)
diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
index 1f0d37a75..7b7bc0f43 100644
--- a/qemu-kvm-x86.c
+++ b/qemu-kvm-x86.c
@@ -1401,6 +1401,9 @@ int kvm_arch_halt(CPUState *env)
int kvm_arch_pre_run(CPUState *env, struct kvm_run *run)
{
+ if (env->update_vapic) {
+ kvm_tpr_enable_vapic(env);
+ }
if (!kvm_irqchip_in_kernel())
kvm_set_cr8(env, cpu_get_apic_tpr(env));
return 0;
diff --git a/qemu-kvm.h b/qemu-kvm.h
index 74f374659..a81ff12f0 100644
--- a/qemu-kvm.h
+++ b/qemu-kvm.h
@@ -1161,6 +1161,8 @@ int kvm_vm_ioctl(KVMState *s, int type, ...);
int kvm_vcpu_ioctl(CPUState *env, int type, ...);
int kvm_check_extension(KVMState *s, unsigned int ext);
+int kvm_tpr_enable_vapic(CPUState *env);
+
#endif
#endif
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 31412a803..eddb4bd69 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -732,6 +732,8 @@ typedef struct CPUX86State {
uint16_t fpus_vmstate;
uint16_t fptag_vmstate;
uint16_t fpregs_format_vmstate;
+
+ int update_vapic;
} CPUX86State;
CPUX86State *cpu_x86_init(const char *cpu_model);