qemu-kvm: enable get/set vcpu events on reset and migration
qemu-kvm should reset and save/restore vcpu events.
kvm.h +5 -0
@@ -52,6 +52,9 @@ int kvm_set_migration_log(int enable);int kvm_has_sync_mmu (void );#endif /* KVM_UPSTREAM */ int kvm_has_vcpu_events (void ); +int kvm_put_vcpu_events (CPUState *env); +int kvm_get_vcpu_events (CPUState *env); +#ifdef KVM_UPSTREAM void kvm_setup_guest_memory (void *start,size_t size);
@@ -96,7 +99,9 @@ int kvm_arch_init(KVMState *s, int smp_cpus);int kvm_arch_init_vcpu (CPUState *env); +#endif void kvm_arch_reset_vcpu (CPUState *env); +#ifdef KVM_UPSTREAM struct kvm_guest_debug ;struct kvm_debug_exit_arch ;
qemu-kvm-x86.c +2 -1
@@ -1457,8 +1457,9 @@ void kvm_arch_push_nmi(void *opaque)void kvm_arch_cpu_reset (CPUState *env) { - env->interrupt_injected =-1 ; +kvm_arch_reset_vcpu (env);kvm_arch_load_regs (env); +kvm_put_vcpu_events (env);if (!cpu_is_bsp (env)) {if (kvm_irqchip_in_kernel ()) {#ifdef KVM_CAP_MP_STATE
qemu-kvm.c +5 -0
@@ -2187,6 +2187,11 @@ static int kvm_create_context(void)return r; } + kvm_state->vcpu_events =0 ; +#ifdef KVM_CAP_VCPU_EVENTS + kvm_state->vcpu_events =kvm_check_extension (kvm_state,KVM_CAP_VCPU_EVENTS ); +#endif +kvm_init_ap ();if (kvm_irqchip) {if (!qemu_kvm_has_gsi_routing ()) {
target-i386/kvm.c +6 -2
@@ -285,6 +285,7 @@ int kvm_arch_init_vcpu(CPUState *env) return kvm_vcpu_ioctl(env, KVM_SET_CPUID2, &cpuid_data); } +#endif void kvm_arch_reset_vcpu (CPUState *env) { env->exception_injected =-1 ;
@@ -292,6 +293,7 @@ void kvm_arch_reset_vcpu(CPUState *env) env->nmi_injected =0 ; env->nmi_pending =0 ; } +#ifdef KVM_UPSTREAM static int kvm_has_msr_star (CPUState *env) {
@@ -776,8 +778,9 @@ static int kvm_get_mp_state(CPUState *env) env->mp_state = mp_state.mp_state; return 0; } +#endif -static int kvm_put_vcpu_events (CPUState *env) +int kvm_put_vcpu_events (CPUState *env) {#ifdef KVM_CAP_VCPU_EVENTS struct kvm_vcpu_events events;
@@ -807,7 +810,7 @@ static int kvm_put_vcpu_events(CPUState *env)#endif } -static int kvm_get_vcpu_events (CPUState *env) +int kvm_get_vcpu_events (CPUState *env) {#ifdef KVM_CAP_VCPU_EVENTS struct kvm_vcpu_events events;
@@ -844,6 +847,7 @@ static int kvm_get_vcpu_events(CPUState *env)return 0 ; } +#ifdef KVM_UPSTREAM int kvm_arch_put_registers (CPUState *env) {int ret;
target-i386/machine.c +2 -0
@@ -324,6 +324,7 @@ static void cpu_pre_save(void *opaque)cpu_synchronize_state (env);kvm_save_mpstate (env); +kvm_get_vcpu_events (env);/* FPU */ env->fpus_vmstate = (env->fpus & ~0x3800 ) | (env->fpstt &0x7 ) <<11 ;
@@ -374,6 +375,7 @@ static int cpu_post_load(void *opaque, int version_id)kvm_load_tsc (env);kvm_load_mpstate (env); +kvm_put_vcpu_events (env); }return 0 ;
Quoted 120 lines · Marcelo Tosatti
qemu-kvm should reset and save/restore vcpu events.
Signed-off-by Marcelo Tosatti <[email protected]>kvm.h +5
-0@@ -52,6 +52,9 @@ int kvm_set_migration_log(int enable);int kvm_has_sync_mmu (void );#endif /* KVM_UPSTREAM */ int kvm_has_vcpu_events (void ); +int kvm_put_vcpu_events (CPUState *env); +int kvm_get_vcpu_events (CPUState *env); +#ifdef KVM_UPSTREAM void kvm_setup_guest_memory (void *start,size_t size);@@ -96,7 +99,9 @@ int kvm_arch_init(KVMState *s, int smp_cpus);int kvm_arch_init_vcpu (CPUState *env); +#endif void kvm_arch_reset_vcpu (CPUState *env); +#ifdef KVM_UPSTREAM struct kvm_guest_debug ;struct kvm_debug_exit_arch ;qemu-kvm-x86.c +2
-1@@ -1457,8 +1457,9 @@ void kvm_arch_push_nmi(void *opaque)void kvm_arch_cpu_reset (CPUState *env) { - env->interrupt_injected =-1 ; +kvm_arch_reset_vcpu (env);kvm_arch_load_regs (env); +kvm_put_vcpu_events (env);if (!cpu_is_bsp (env)) {if (kvm_irqchip_in_kernel ()) {#ifdef KVM_CAP_MP_STATE qemu-kvm.c +5
-0@@ -2187,6 +2187,11 @@ static int kvm_create_context(void)return r; } + kvm_state->vcpu_events =0 ; +#ifdef KVM_CAP_VCPU_EVENTS + kvm_state->vcpu_events =kvm_check_extension (kvm_state,KVM_CAP_VCPU_EVENTS ); +#endif +kvm_init_ap ();if (kvm_irqchip) {if (!qemu_kvm_has_gsi_routing ()) {target-i386/kvm.c +6
-2@@ -285,6 +285,7 @@ int kvm_arch_init_vcpu(CPUState *env) return kvm_vcpu_ioctl(env, KVM_SET_CPUID2, &cpuid_data); } +#endif void kvm_arch_reset_vcpu (CPUState *env) { env->exception_injected =-1 ;@@ -292,6 +293,7 @@ void kvm_arch_reset_vcpu(CPUState *env) env->nmi_injected =0 ; env->nmi_pending =0 ; } +#ifdef KVM_UPSTREAM static int kvm_has_msr_star (CPUState *env) {@@ -776,8 +778,9 @@ static int kvm_get_mp_state(CPUState *env) env->mp_state = mp_state.mp_state; return 0; } +#endif -static int kvm_put_vcpu_events (CPUState *env) +int kvm_put_vcpu_events (CPUState *env) {#ifdef KVM_CAP_VCPU_EVENTS struct kvm_vcpu_events events;@@ -807,7 +810,7 @@ static int kvm_put_vcpu_events(CPUState *env)#endif } -static int kvm_get_vcpu_events (CPUState *env) +int kvm_get_vcpu_events (CPUState *env) {#ifdef KVM_CAP_VCPU_EVENTS struct kvm_vcpu_events events;@@ -844,6 +847,7 @@ static int kvm_get_vcpu_events(CPUState *env)return 0 ; } +#ifdef KVM_UPSTREAM int kvm_arch_put_registers (CPUState *env) {int ret;target-i386/machine.c +1
-0@@ -324,6 +324,7 @@ static void cpu_pre_save(void *opaque)cpu_synchronize_state (env);kvm_save_mpstate (env); +kvm_get_vcpu_events (env);/* FPU */ env->fpus_vmstate = (env->fpus & ~0x3800 ) | (env->fpstt &0x7 ) <<11 ;
target-i386/machine.c static int cpu_post_load(void *opaque, int version_id) · line 378
Quoted 4 lines
target-i386/machine.c +1
-0@@ -374,6 +375,7 @@ static int cpu_post_load(void *opaque, int version_id)kvm_load_tsc (env);kvm_load_mpstate (env); +kvm_put_vcpu_events (env);
The last two hunks will cause the same !CONFIG_KVM breakages qemu-kvm's mpstate used to as well. You may either fix it up temporarily or wait for my refactoring that is now scheduled with highest priority (should be ready today or tomorrow).
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
Quoted 5 lines
The last two hunks will cause the same !CONFIG_KVM breakages qemu-kvm's mpstate used to as well. You may either fix it up temporarily or wait for my refactoring that is now scheduled with highest priority (should be ready today or tomorrow).
It needs to go in 0.12-stable, so we'll have to leave with it.
Feel free to revert from master when refactoring.
Gleb/Glauber can you review please.
----
qemu-kvm should reset and save/restore vcpu events.
kvm.h +5 -0
@@ -52,6 +52,9 @@ int kvm_set_migration_log(int enable);int kvm_has_sync_mmu (void );#endif /* KVM_UPSTREAM */ int kvm_has_vcpu_events (void ); +int kvm_put_vcpu_events (CPUState *env); +int kvm_get_vcpu_events (CPUState *env); +#ifdef KVM_UPSTREAM void kvm_setup_guest_memory (void *start,size_t size);
@@ -96,7 +99,9 @@ int kvm_arch_init(KVMState *s, int smp_cpus);int kvm_arch_init_vcpu (CPUState *env); +#endif void kvm_arch_reset_vcpu (CPUState *env); +#ifdef KVM_UPSTREAM struct kvm_guest_debug ;struct kvm_debug_exit_arch ;
qemu-kvm-x86.c +2 -1
@@ -1457,8 +1457,9 @@ void kvm_arch_push_nmi(void *opaque)void kvm_arch_cpu_reset (CPUState *env) { - env->interrupt_injected =-1 ; +kvm_arch_reset_vcpu (env);kvm_arch_load_regs (env); +kvm_put_vcpu_events (env);if (!cpu_is_bsp (env)) {if (kvm_irqchip_in_kernel ()) {#ifdef KVM_CAP_MP_STATE
qemu-kvm.c +5 -0
@@ -2187,6 +2187,11 @@ static int kvm_create_context(void)return r; } + kvm_state->vcpu_events =0 ; +#ifdef KVM_CAP_VCPU_EVENTS + kvm_state->vcpu_events =kvm_check_extension (kvm_state,KVM_CAP_VCPU_EVENTS ); +#endif +kvm_init_ap ();if (kvm_irqchip) {if (!qemu_kvm_has_gsi_routing ()) {
target-i386/kvm.c +6 -2
@@ -285,6 +285,7 @@ int kvm_arch_init_vcpu(CPUState *env) return kvm_vcpu_ioctl(env, KVM_SET_CPUID2, &cpuid_data); } +#endif void kvm_arch_reset_vcpu (CPUState *env) { env->exception_injected =-1 ;
@@ -292,6 +293,7 @@ void kvm_arch_reset_vcpu(CPUState *env) env->nmi_injected =0 ; env->nmi_pending =0 ; } +#ifdef KVM_UPSTREAM static int kvm_has_msr_star (CPUState *env) {
@@ -776,8 +778,9 @@ static int kvm_get_mp_state(CPUState *env) env->mp_state = mp_state.mp_state; return 0; } +#endif -static int kvm_put_vcpu_events (CPUState *env) +int kvm_put_vcpu_events (CPUState *env) {#ifdef KVM_CAP_VCPU_EVENTS struct kvm_vcpu_events events;
@@ -807,7 +810,7 @@ static int kvm_put_vcpu_events(CPUState *env)#endif } -static int kvm_get_vcpu_events (CPUState *env) +int kvm_get_vcpu_events (CPUState *env) {#ifdef KVM_CAP_VCPU_EVENTS struct kvm_vcpu_events events;
@@ -844,6 +847,7 @@ static int kvm_get_vcpu_events(CPUState *env)return 0 ; } +#ifdef KVM_UPSTREAM int kvm_arch_put_registers (CPUState *env) {int ret;
target-i386/machine.c +5 -1
@@ -323,7 +323,10 @@ static void cpu_pre_save(void *opaque)int i;cpu_synchronize_state (env); -kvm_save_mpstate (env); +if (kvm_enabled ()) { +kvm_save_mpstate (env); +kvm_get_vcpu_events (env); + }/* FPU */ env->fpus_vmstate = (env->fpus & ~0x3800 ) | (env->fpstt &0x7 ) <<11 ;
@@ -374,6 +377,7 @@ static int cpu_post_load(void *opaque, int version_id)kvm_load_tsc (env);kvm_load_mpstate (env); +kvm_put_vcpu_events (env); }return 0 ;
Quoted 7 lines · Marcelo Tosatti
Quoted 4 lines
The last two hunks will cause the same !CONFIG_KVM breakages qemu-kvm's mpstate used to as well. You may either fix it up temporarily or wait for my refactoring that is now scheduled with highest priority (should be ready today or tomorrow).
It needs to go in 0.12-stable, so we'll have to leave with it.
One additional patch is required to account for the new event flags, also for upstream. Will post it in a minute.
Quoted 15 lines
Feel free to revert from master when refactoring.
Gleb/Glauber can you review please.
----
qemu-kvm should reset and save/restore vcpu events.
Signed-off-by Marcelo Tosatti <[email protected]>kvm.h +0
-0
kvm.h int kvm_set_migration_log(int enable); · line 57
Quoted 6 lines
kvm.h +3
-0@@ -52,6 +52,9 @@ int kvm_set_migration_log(int enable);int kvm_has_sync_mmu (void );#endif /* KVM_UPSTREAM */ int kvm_has_vcpu_events (void ); +int kvm_put_vcpu_events (CPUState *env); +int kvm_get_vcpu_events (CPUState *env); +
Such hunks were better off in qemu-kvm.h, but this one is not the first here.
Quoted 109 lines
kvm.h +2
-0#ifdef KVM_UPSTREAM void kvm_setup_guest_memory (void *start,size_t size);@@ -96,7 +99,9 @@ int kvm_arch_init(KVMState *s, int smp_cpus);int kvm_arch_init_vcpu (CPUState *env); +#endif void kvm_arch_reset_vcpu (CPUState *env); +#ifdef KVM_UPSTREAM struct kvm_guest_debug ;struct kvm_debug_exit_arch ;qemu-kvm-x86.c +2
-1@@ -1457,8 +1457,9 @@ void kvm_arch_push_nmi(void *opaque)void kvm_arch_cpu_reset (CPUState *env) { - env->interrupt_injected =-1 ; +kvm_arch_reset_vcpu (env);kvm_arch_load_regs (env); +kvm_put_vcpu_events (env);if (!cpu_is_bsp (env)) {if (kvm_irqchip_in_kernel ()) {#ifdef KVM_CAP_MP_STATE qemu-kvm.c +5
-0@@ -2187,6 +2187,11 @@ static int kvm_create_context(void)return r; } + kvm_state->vcpu_events =0 ; +#ifdef KVM_CAP_VCPU_EVENTS + kvm_state->vcpu_events =kvm_check_extension (kvm_state,KVM_CAP_VCPU_EVENTS ); +#endif +kvm_init_ap ();if (kvm_irqchip) {if (!qemu_kvm_has_gsi_routing ()) {target-i386/kvm.c +6
-2@@ -285,6 +285,7 @@ int kvm_arch_init_vcpu(CPUState *env) return kvm_vcpu_ioctl(env, KVM_SET_CPUID2, &cpuid_data); } +#endif void kvm_arch_reset_vcpu (CPUState *env) { env->exception_injected =-1 ;@@ -292,6 +293,7 @@ void kvm_arch_reset_vcpu(CPUState *env) env->nmi_injected =0 ; env->nmi_pending =0 ; } +#ifdef KVM_UPSTREAM static int kvm_has_msr_star (CPUState *env) {@@ -776,8 +778,9 @@ static int kvm_get_mp_state(CPUState *env) env->mp_state = mp_state.mp_state; return 0; } +#endif -static int kvm_put_vcpu_events (CPUState *env) +int kvm_put_vcpu_events (CPUState *env) {#ifdef KVM_CAP_VCPU_EVENTS struct kvm_vcpu_events events;@@ -807,7 +810,7 @@ static int kvm_put_vcpu_events(CPUState *env)#endif } -static int kvm_get_vcpu_events (CPUState *env) +int kvm_get_vcpu_events (CPUState *env) {#ifdef KVM_CAP_VCPU_EVENTS struct kvm_vcpu_events events;@@ -844,6 +847,7 @@ static int kvm_get_vcpu_events(CPUState *env)return 0 ; } +#ifdef KVM_UPSTREAM int kvm_arch_put_registers (CPUState *env) {int ret;target-i386/machine.c +4
-1@@ -323,7 +323,10 @@ static void cpu_pre_save(void *opaque)int i;cpu_synchronize_state (env); -kvm_save_mpstate (env); +if (kvm_enabled ()) { +kvm_save_mpstate (env); +kvm_get_vcpu_events (env); + }/* FPU */ env->fpus_vmstate = (env->fpus & ~0x3800 ) | (env->fpstt &0x7 ) <<11 ;
target-i386/machine.c static int cpu_post_load(void *opaque, int version_id) · line 383
Quoted 7 lines
target-i386/machine.c +1
-0@@ -374,6 +377,7 @@ static int cpu_post_load(void *opaque, int version_id)kvm_load_tsc (env);kvm_load_mpstate (env); +kvm_put_vcpu_events (env); }return 0 ;
Otherwise builds and works fine here.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
target-i386/machine.c static int cpu_post_load(void *opaque, int version_id) · line 379
Quoted 6 lines · Marcelo Tosatti
target-i386/machine.c +1
-0@@ -374,6 +375,7 @@ static int cpu_post_load(void *opaque, int version_id)kvm_load_tsc (env);kvm_load_mpstate (env); +kvm_put_vcpu_events (env); }
It is confusing to call functions load/save for some state and put/get for others, but the function kvm_put_vcpu_events() is called upstream this way :(
Otherwise looks OK.
--
Gleb.
Quoted 10 lines · Gleb Natapov
target-i386/machine.c static int cpu_post_load(void *opaque, int version_id) · line 379
Quoted 6 lines · Marcelo Tosatti
target-i386/machine.c +1
-0@@ -374,6 +375,7 @@ static int cpu_post_load(void *opaque, int version_id)kvm_load_tsc (env);kvm_load_mpstate (env); +kvm_put_vcpu_events (env); }It is confusing to call functions load/save for some state and put/get for others, but the function
kvm_put_vcpu_events()is called upstream this way :(
It's temporary, 0.12-only. load/save (and a lot more) will disappear once we completed merging with upstream code.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux