target-i386: kvm: Use env->mcg_cap when setting up MCE
When setting up MCE, instead of using the MCE_*_DEF macros directly, just filter the existing env->mcg_cap value. As env->mcg_cap is already initialized as MCE_CAP_DEF|MCE_BANKS_DEF at target-i386/cpu.c:mce_init(), this doesn't change any behavior. But it will allow us to change mce_init() in the future, to implement different defaults depending on CPU model, machine-type or command-line parameters. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <1448471956-66873-9-git-send-email-pbonzini@redhat.com>
This commit is contained in:
parent
49b69cbfcd
commit
2590f15b13
@ -286,6 +286,8 @@
|
|||||||
#define MCE_CAP_DEF (MCG_CTL_P|MCG_SER_P)
|
#define MCE_CAP_DEF (MCG_CTL_P|MCG_SER_P)
|
||||||
#define MCE_BANKS_DEF 10
|
#define MCE_BANKS_DEF 10
|
||||||
|
|
||||||
|
#define MCG_CAP_BANKS_MASK 0xff
|
||||||
|
|
||||||
#define MCG_STATUS_RIPV (1ULL<<0) /* restart ip valid */
|
#define MCG_STATUS_RIPV (1ULL<<0) /* restart ip valid */
|
||||||
#define MCG_STATUS_EIPV (1ULL<<1) /* ip points to correct instruction */
|
#define MCG_STATUS_EIPV (1ULL<<1) /* ip points to correct instruction */
|
||||||
#define MCG_STATUS_MCIP (1ULL<<2) /* machine check in progress */
|
#define MCG_STATUS_MCIP (1ULL<<2) /* machine check in progress */
|
||||||
|
@ -784,21 +784,18 @@ int kvm_arch_init_vcpu(CPUState *cs)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (banks < MCE_BANKS_DEF) {
|
if (banks < (env->mcg_cap & MCG_CAP_BANKS_MASK)) {
|
||||||
error_report("kvm: Unsupported MCE bank count (QEMU = %d, KVM = %d)",
|
error_report("kvm: Unsupported MCE bank count (QEMU = %d, KVM = %d)",
|
||||||
MCE_BANKS_DEF, banks);
|
(int)(env->mcg_cap & MCG_CAP_BANKS_MASK), banks);
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
mcg_cap &= MCE_CAP_DEF;
|
env->mcg_cap &= mcg_cap | MCG_CAP_BANKS_MASK;
|
||||||
mcg_cap |= MCE_BANKS_DEF;
|
ret = kvm_vcpu_ioctl(cs, KVM_X86_SETUP_MCE, &env->mcg_cap);
|
||||||
ret = kvm_vcpu_ioctl(cs, KVM_X86_SETUP_MCE, &mcg_cap);
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
fprintf(stderr, "KVM_X86_SETUP_MCE: %s", strerror(-ret));
|
fprintf(stderr, "KVM_X86_SETUP_MCE: %s", strerror(-ret));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
env->mcg_cap = mcg_cap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qemu_add_vm_change_state_handler(cpu_update_state, env);
|
qemu_add_vm_change_state_handler(cpu_update_state, env);
|
||||||
|
Loading…
Reference in New Issue
Block a user