[patch 5/5] kvm-tpr-opt: delete CPUState field

Marcelo Tosatti
2011-08-01T15:29:17Z

[-- Attachment #1: kvmtpr-remove-cpustate-field --]
[-- Type: text/plain, Size: 3095 bytes --]

The information can be inferred from CPU_PUT_FULL_STATE and
bios_enabled.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Index: qemu-kvm/kvm-tpr-opt.c
===================================================================
--- qemu-kvm.orig/kvm-tpr-opt.c
+++ qemu-kvm/kvm-tpr-opt.c
@@ -218,7 +218,7 @@ static int get_pcr_cpu(CPUState *env)
return (int)b;
}

-int kvm_tpr_enable_vapic(CPUState *env)
+static int tpr_enable_vapic(CPUState *env)
{
static uint8_t one = 1;
int pcr_cpu = get_pcr_cpu(env);
@@ -228,11 +228,17 @@ int kvm_tpr_enable_vapic(CPUState *env)

kvm_enable_vapic(env, vapic_phys + (pcr_cpu << 7));
cpu_physical_memory_write_rom(vapic_phys + (pcr_cpu << 7) + 4, &one, 1);
- env->kvm_vcpu_update_vapic = 0;
bios_enabled = 1;
return 1;
}

+void kvm_tpr_enable_vapic(CPUState *env)
+{
+ if (!bios_enabled)
+ return;
+ tpr_enable_vapic(env);
+}
+
static void patch_call(CPUState *env, uint64_t rip, uint32_t target)
{
uint32_t offset;
@@ -293,7 +299,7 @@ void kvm_tpr_access_report(CPUState *env
return;
if (!bios_is_mapped(env, rip))
return;
- if (!kvm_tpr_enable_vapic(env))
+ if (!tpr_enable_vapic(env))
return;
patch_instruction(env, rip);
}
@@ -326,13 +332,6 @@ static int tpr_load(QEMUFile *f, void *s
qemu_get_be32s(f, &vapic_phys);
qemu_get_be32s(f, &vbios_desc_phys);

- if (bios_enabled) {
- CPUState *env = first_cpu->next_cpu;
-
- for (env = first_cpu; env != NULL; env = env->next_cpu)
- env->kvm_vcpu_update_vapic = 1;
- }
-
return 0;
}

@@ -367,7 +366,7 @@ static void vtpr_ioport_write(void *opaq
}
bios_enabled = 1;
update_vbios_real_tpr();
- kvm_tpr_enable_vapic(env);
+ tpr_enable_vapic(env);
}

static void kvm_tpr_opt_setup(void)
Index: qemu-kvm/qemu-kvm.h
===================================================================
--- qemu-kvm.orig/qemu-kvm.h
+++ qemu-kvm/qemu-kvm.h
@@ -265,6 +265,6 @@ extern int kvm_pit_reinject;
extern unsigned int kvm_shadow_memory;

int kvm_handle_tpr_access(CPUState *env);
-int kvm_tpr_enable_vapic(CPUState *env);
+void kvm_tpr_enable_vapic(CPUState *env);

#endif
Index: qemu-kvm/target-i386/cpu.h
===================================================================
--- qemu-kvm.orig/target-i386/cpu.h
+++ qemu-kvm/target-i386/cpu.h
@@ -759,8 +759,6 @@ typedef struct CPUX86State {
uint16_t fptag_vmstate;
uint16_t fpregs_format_vmstate;

- int kvm_vcpu_update_vapic;
-
uint64_t xstate_bv;
XMMReg ymmh_regs[CPU_NB_REGS];

Index: qemu-kvm/target-i386/kvm.c
===================================================================
--- qemu-kvm.orig/target-i386/kvm.c
+++ qemu-kvm/target-i386/kvm.c
@@ -1451,9 +1451,7 @@ int kvm_arch_put_registers(CPUState *env
return ret;
}
if (level == KVM_PUT_FULL_STATE) {
- if (env->kvm_vcpu_update_vapic) {
- kvm_tpr_enable_vapic(env);
- }
+ kvm_tpr_enable_vapic(env);
}
/* must be last */
ret = kvm_guest_debug_workarounds(env);