target-i386: kvm: save/restore steal time MSR
PATCH 1/1 target-i386: kvm: save/restore steal time MSR
Read and write steal time MSR, so that reporting is functional across migration.
Signed-off-by Marcelo Tosatti <[email protected]>
target-i386/cpu.h +1 -0
@@ -792,6 +792,7 @@ typedef struct CPUX86State {#endif uint64_t system_time_msr;uint64_t wall_clock_msr; +uint64_t steal_time_msr;uint64_t async_pf_en_msr;uint64_t pv_eoi_en_msr;
target-i386/kvm.c +13 -0
@@ -68,6 +68,7 @@ static bool has_msr_tsc_deadline;static bool has_msr_async_pf_en;static bool has_msr_pv_eoi_en;static bool has_msr_misc_enable; +static bool has_msr_kvm_steal_time;static int lm_capable_kernel;bool kvm_allows_irq0_override (void )
@@ -507,6 +508,8 @@ int kvm_arch_init_vcpu(CPUState *cs) has_msr_pv_eoi_en = c->eax & (1 <<KVM_FEATURE_PV_EOI ); + has_msr_kvm_steal_time = c->eax & (1 <<KVM_FEATURE_STEAL_TIME ); +cpu_x86_cpuid (env,0 ,0 , &limit, &unused, &unused, &unused);for (i =0 ; i <= limit; i++) {
@@ -1107,6 +1110,10 @@ static int kvm_put_msrs(X86CPU *cpu, int level)kvm_msr_entry_set (&msrs[n++],MSR_KVM_PV_EOI_EN , env->pv_eoi_en_msr); } +if (has_msr_kvm_steal_time) { +kvm_msr_entry_set (&msrs[n++],MSR_KVM_STEAL_TIME , + env->steal_time_msr); + }if (hyperv_hypercall_available ()) {kvm_msr_entry_set (&msrs[n++],HV_X64_MSR_GUEST_OS_ID ,0 );kvm_msr_entry_set (&msrs[n++],HV_X64_MSR_HYPERCALL ,0 );
@@ -1360,6 +1367,9 @@ static int kvm_get_msrs(X86CPU *cpu)if (has_msr_pv_eoi_en) { msrs[n++].index =MSR_KVM_PV_EOI_EN ; } +if (has_msr_kvm_steal_time) { + msrs[n++].index =MSR_KVM_STEAL_TIME ; + }if (env->mcg_cap) { msrs[n++].index =MSR_MCG_STATUS ;
@@ -1445,6 +1455,9 @@ static int kvm_get_msrs(X86CPU *cpu)case MSR_KVM_PV_EOI_EN : env->pv_eoi_en_msr = msrs[i].data;break ; +case MSR_KVM_STEAL_TIME : + env->steal_time_msr = msrs[i].data; +break ; } }
target-i386/machine.c +21 -0
@@ -287,6 +287,24 @@ static bool pv_eoi_msr_needed(void *opaque)return cpu->pv_eoi_en_msr !=0 ; } +static bool steal_time_msr_needed (void *opaque) +{ +CPUX86State *cpu = opaque; + +return cpu->steal_time_msr !=0 ; +} + +static const VMStateDescription vmstate_steal_time_msr = { + .name ="cpu/steal_time_msr" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_UINT64 (steal_time_msr, CPUX86State), +VMSTATE_END_OF_LIST () + } +}; +static const VMStateDescription vmstate_async_pf_msr = { .name ="cpu/async_pf_msr" , .version_id =1 ,
@@ -494,6 +512,9 @@ static const VMStateDescription vmstate_cpu = { .vmsd = &vmstate_pv_eoi_msr, .needed = pv_eoi_msr_needed, } , { + .vmsd = &vmstate_steal_time_msr, + .needed = steal_time_msr_needed, + } , { .vmsd = &vmstate_fpop_ip_dp, .needed = fpop_ip_dp_needed, }, {
Quoted 6 lines · Marcelo Tosatti
Read and write steal time MSR, so that reporting is functional across migration.
Signed-off-by Marcelo Tosatti <[email protected]>
Reviewed-by Gleb Natapov <[email protected]>
Quoted 94 lines
target-i386/cpu.h +1
-0@@ -792,6 +792,7 @@ typedef struct CPUX86State {#endif uint64_t system_time_msr;uint64_t wall_clock_msr; +uint64_t steal_time_msr;uint64_t async_pf_en_msr;uint64_t pv_eoi_en_msr;target-i386/kvm.c +13
-0@@ -68,6 +68,7 @@ static bool has_msr_tsc_deadline;static bool has_msr_async_pf_en;static bool has_msr_pv_eoi_en;static bool has_msr_misc_enable; +static bool has_msr_kvm_steal_time;static int lm_capable_kernel;bool kvm_allows_irq0_override (void )@@ -507,6 +508,8 @@ int kvm_arch_init_vcpu(CPUState *cs) has_msr_pv_eoi_en = c->eax & (1 <<KVM_FEATURE_PV_EOI ); + has_msr_kvm_steal_time = c->eax & (1 <<KVM_FEATURE_STEAL_TIME ); +cpu_x86_cpuid (env,0 ,0 , &limit, &unused, &unused, &unused);for (i =0 ; i <= limit; i++) {@@ -1107,6 +1110,10 @@ static int kvm_put_msrs(X86CPU *cpu, int level)kvm_msr_entry_set (&msrs[n++],MSR_KVM_PV_EOI_EN , env->pv_eoi_en_msr); } +if (has_msr_kvm_steal_time) { +kvm_msr_entry_set (&msrs[n++],MSR_KVM_STEAL_TIME , + env->steal_time_msr); + }if (hyperv_hypercall_available ()) {kvm_msr_entry_set (&msrs[n++],HV_X64_MSR_GUEST_OS_ID ,0 );kvm_msr_entry_set (&msrs[n++],HV_X64_MSR_HYPERCALL ,0 );@@ -1360,6 +1367,9 @@ static int kvm_get_msrs(X86CPU *cpu)if (has_msr_pv_eoi_en) { msrs[n++].index =MSR_KVM_PV_EOI_EN ; } +if (has_msr_kvm_steal_time) { + msrs[n++].index =MSR_KVM_STEAL_TIME ; + }if (env->mcg_cap) { msrs[n++].index =MSR_MCG_STATUS ;@@ -1445,6 +1455,9 @@ static int kvm_get_msrs(X86CPU *cpu)case MSR_KVM_PV_EOI_EN : env->pv_eoi_en_msr = msrs[i].data;break ; +case MSR_KVM_STEAL_TIME : + env->steal_time_msr = msrs[i].data; +break ; } }target-i386/machine.c +18
-0@@ -287,6 +287,24 @@ static bool pv_eoi_msr_needed(void *opaque)return cpu->pv_eoi_en_msr !=0 ; } +static bool steal_time_msr_needed (void *opaque) +{ +CPUX86State *cpu = opaque; + +return cpu->steal_time_msr !=0 ; +} + +static const VMStateDescription vmstate_steal_time_msr = { + .name ="cpu/steal_time_msr" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_UINT64 (steal_time_msr, CPUX86State), +VMSTATE_END_OF_LIST () + } +}; +static const VMStateDescription vmstate_async_pf_msr = { .name ="cpu/async_pf_msr" , .version_id =1 ,
target-i386/machine.c static const VMStateDescription vmstate_cpu = { · line 520
Quoted 9 lines
target-i386/machine.c +3
-0@@ -494,6 +512,9 @@ static const VMStateDescription vmstate_cpu = { .vmsd = &vmstate_pv_eoi_msr, .needed = pv_eoi_msr_needed, } , { + .vmsd = &vmstate_steal_time_msr, + .needed = steal_time_msr_needed, + } , { .vmsd = &vmstate_fpop_ip_dp, .needed = fpop_ip_dp_needed, }, {
--
Gleb.
Gleb Natapov
AppliedQuoted 6 lines · Marcelo Tosatti
Read and write steal time MSR, so that reporting is functional across migration.
Signed-off-by Marcelo Tosatti <[email protected]>
Applied, thanks.
Quoted 94 lines
target-i386/cpu.h +1
-0@@ -792,6 +792,7 @@ typedef struct CPUX86State {#endif uint64_t system_time_msr;uint64_t wall_clock_msr; +uint64_t steal_time_msr;uint64_t async_pf_en_msr;uint64_t pv_eoi_en_msr;target-i386/kvm.c +13
-0@@ -68,6 +68,7 @@ static bool has_msr_tsc_deadline;static bool has_msr_async_pf_en;static bool has_msr_pv_eoi_en;static bool has_msr_misc_enable; +static bool has_msr_kvm_steal_time;static int lm_capable_kernel;bool kvm_allows_irq0_override (void )@@ -507,6 +508,8 @@ int kvm_arch_init_vcpu(CPUState *cs) has_msr_pv_eoi_en = c->eax & (1 <<KVM_FEATURE_PV_EOI ); + has_msr_kvm_steal_time = c->eax & (1 <<KVM_FEATURE_STEAL_TIME ); +cpu_x86_cpuid (env,0 ,0 , &limit, &unused, &unused, &unused);for (i =0 ; i <= limit; i++) {@@ -1107,6 +1110,10 @@ static int kvm_put_msrs(X86CPU *cpu, int level)kvm_msr_entry_set (&msrs[n++],MSR_KVM_PV_EOI_EN , env->pv_eoi_en_msr); } +if (has_msr_kvm_steal_time) { +kvm_msr_entry_set (&msrs[n++],MSR_KVM_STEAL_TIME , + env->steal_time_msr); + }if (hyperv_hypercall_available ()) {kvm_msr_entry_set (&msrs[n++],HV_X64_MSR_GUEST_OS_ID ,0 );kvm_msr_entry_set (&msrs[n++],HV_X64_MSR_HYPERCALL ,0 );@@ -1360,6 +1367,9 @@ static int kvm_get_msrs(X86CPU *cpu)if (has_msr_pv_eoi_en) { msrs[n++].index =MSR_KVM_PV_EOI_EN ; } +if (has_msr_kvm_steal_time) { + msrs[n++].index =MSR_KVM_STEAL_TIME ; + }if (env->mcg_cap) { msrs[n++].index =MSR_MCG_STATUS ;@@ -1445,6 +1455,9 @@ static int kvm_get_msrs(X86CPU *cpu)case MSR_KVM_PV_EOI_EN : env->pv_eoi_en_msr = msrs[i].data;break ; +case MSR_KVM_STEAL_TIME : + env->steal_time_msr = msrs[i].data; +break ; } }target-i386/machine.c +18
-0@@ -287,6 +287,24 @@ static bool pv_eoi_msr_needed(void *opaque)return cpu->pv_eoi_en_msr !=0 ; } +static bool steal_time_msr_needed (void *opaque) +{ +CPUX86State *cpu = opaque; + +return cpu->steal_time_msr !=0 ; +} + +static const VMStateDescription vmstate_steal_time_msr = { + .name ="cpu/steal_time_msr" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_UINT64 (steal_time_msr, CPUX86State), +VMSTATE_END_OF_LIST () + } +}; +static const VMStateDescription vmstate_async_pf_msr = { .name ="cpu/async_pf_msr" , .version_id =1 ,
target-i386/machine.c static const VMStateDescription vmstate_cpu = { · line 520
Quoted 9 lines
target-i386/machine.c +3
-0@@ -494,6 +512,9 @@ static const VMStateDescription vmstate_cpu = { .vmsd = &vmstate_pv_eoi_msr, .needed = pv_eoi_msr_needed, } , { + .vmsd = &vmstate_steal_time_msr, + .needed = steal_time_msr_needed, + } , { .vmsd = &vmstate_fpop_ip_dp, .needed = fpop_ip_dp_needed, }, {
--
Gleb.