kvm: get/set PV EOI MSR
Support get/set of new PV EOI MSR, for migration. Add an optional section for MSR value - send it out in case MSR was changed from the default value (0). Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
651682dcf5
commit
bc9a839d56
@ -699,6 +699,7 @@ typedef struct CPUX86State {
|
||||
uint64_t system_time_msr;
|
||||
uint64_t wall_clock_msr;
|
||||
uint64_t async_pf_en_msr;
|
||||
uint64_t pv_eoi_en_msr;
|
||||
|
||||
uint64_t tsc;
|
||||
uint64_t tsc_deadline;
|
||||
|
@ -63,6 +63,7 @@ static bool has_msr_star;
|
||||
static bool has_msr_hsave_pa;
|
||||
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 int lm_capable_kernel;
|
||||
|
||||
@ -455,6 +456,8 @@ int kvm_arch_init_vcpu(CPUX86State *env)
|
||||
|
||||
has_msr_async_pf_en = c->eax & (1 << KVM_FEATURE_ASYNC_PF);
|
||||
|
||||
has_msr_pv_eoi_en = c->eax & (1 << KVM_FEATURE_PV_EOI);
|
||||
|
||||
cpu_x86_cpuid(env, 0, 0, &limit, &unused, &unused, &unused);
|
||||
|
||||
for (i = 0; i <= limit; i++) {
|
||||
@ -1017,6 +1020,10 @@ static int kvm_put_msrs(CPUX86State *env, int level)
|
||||
kvm_msr_entry_set(&msrs[n++], MSR_KVM_ASYNC_PF_EN,
|
||||
env->async_pf_en_msr);
|
||||
}
|
||||
if (has_msr_pv_eoi_en) {
|
||||
kvm_msr_entry_set(&msrs[n++], MSR_KVM_PV_EOI_EN,
|
||||
env->pv_eoi_en_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);
|
||||
@ -1259,6 +1266,9 @@ static int kvm_get_msrs(CPUX86State *env)
|
||||
if (has_msr_async_pf_en) {
|
||||
msrs[n++].index = MSR_KVM_ASYNC_PF_EN;
|
||||
}
|
||||
if (has_msr_pv_eoi_en) {
|
||||
msrs[n++].index = MSR_KVM_PV_EOI_EN;
|
||||
}
|
||||
|
||||
if (env->mcg_cap) {
|
||||
msrs[n++].index = MSR_MCG_STATUS;
|
||||
@ -1338,6 +1348,9 @@ static int kvm_get_msrs(CPUX86State *env)
|
||||
case MSR_KVM_ASYNC_PF_EN:
|
||||
env->async_pf_en_msr = msrs[i].data;
|
||||
break;
|
||||
case MSR_KVM_PV_EOI_EN:
|
||||
env->pv_eoi_en_msr = msrs[i].data;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -279,6 +279,13 @@ static bool async_pf_msr_needed(void *opaque)
|
||||
return cpu->async_pf_en_msr != 0;
|
||||
}
|
||||
|
||||
static bool pv_eoi_msr_needed(void *opaque)
|
||||
{
|
||||
CPUX86State *cpu = opaque;
|
||||
|
||||
return cpu->pv_eoi_en_msr != 0;
|
||||
}
|
||||
|
||||
static const VMStateDescription vmstate_async_pf_msr = {
|
||||
.name = "cpu/async_pf_msr",
|
||||
.version_id = 1,
|
||||
@ -290,6 +297,17 @@ static const VMStateDescription vmstate_async_pf_msr = {
|
||||
}
|
||||
};
|
||||
|
||||
static const VMStateDescription vmstate_pv_eoi_msr = {
|
||||
.name = "cpu/async_pv_eoi_msr",
|
||||
.version_id = 1,
|
||||
.minimum_version_id = 1,
|
||||
.minimum_version_id_old = 1,
|
||||
.fields = (VMStateField []) {
|
||||
VMSTATE_UINT64(pv_eoi_en_msr, CPUX86State),
|
||||
VMSTATE_END_OF_LIST()
|
||||
}
|
||||
};
|
||||
|
||||
static bool fpop_ip_dp_needed(void *opaque)
|
||||
{
|
||||
CPUX86State *env = opaque;
|
||||
@ -453,6 +471,9 @@ static const VMStateDescription vmstate_cpu = {
|
||||
{
|
||||
.vmsd = &vmstate_async_pf_msr,
|
||||
.needed = async_pf_msr_needed,
|
||||
} , {
|
||||
.vmsd = &vmstate_pv_eoi_msr,
|
||||
.needed = pv_eoi_msr_needed,
|
||||
} , {
|
||||
.vmsd = &vmstate_fpop_ip_dp,
|
||||
.needed = fpop_ip_dp_needed,
|
||||
|
Loading…
Reference in New Issue
Block a user