* 255 kvm_msr_entry structs */
#define MSR_BUF_SIZE 4096
-#ifndef BUS_MCEERR_AR
-#define BUS_MCEERR_AR 4
-#endif
-#ifndef BUS_MCEERR_AO
-#define BUS_MCEERR_AO 5
-#endif
-
const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
KVM_CAP_INFO(SET_TSS_ADDR),
KVM_CAP_INFO(EXT_CPUID),
exit(1);
}
-int kvm_arch_on_sigbus_vcpu(CPUState *c, int code, void *addr)
+void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, void *addr)
{
X86CPU *cpu = X86_CPU(c);
CPUX86State *env = &cpu->env;
ram_addr_t ram_addr;
hwaddr paddr;
- if (code != BUS_MCEERR_AR && code != BUS_MCEERR_AO) {
- return 1;
- }
-
- /* Because the MCE happened while running the VCPU, KVM could have
- * injected action required MCEs too. Action optional MCEs should
- * be delivered to the main thread, which qemu_init_sigbus identifies
- * as the "early kill" thread, but if we get one for whatever reason
- * we just handle it just like the main thread would.
+ /* If we get an action required MCE, it has been injected by KVM
+ * while the VM was running. An action optional MCE instead should
+ * be coming from the main thread, which qemu_init_sigbus identifies
+ * as the "early kill" thread.
*/
+ assert(code == BUS_MCEERR_AR || code == BUS_MCEERR_AO);
+
if ((env->mcg_cap & MCG_SER_P) && addr) {
ram_addr = qemu_ram_addr_from_host(addr);
if (ram_addr != RAM_ADDR_INVALID &&
kvm_physical_memory_addr_from_host(c->kvm_state, addr, &paddr)) {
kvm_hwpoison_page_add(ram_addr);
kvm_mce_inject(cpu, paddr, code);
- return 0;
+ return;
}
fprintf(stderr, "Hardware memory error for memory used by "
}
/* Hope we are lucky for AO MCE */
- return 0;
-}
-
-int kvm_arch_on_sigbus(int code, void *addr)
-{
- X86CPU *cpu = X86_CPU(first_cpu);
-
- if (code != BUS_MCEERR_AR && code != BUS_MCEERR_AO) {
- return 1;
- }
-
- if (code == BUS_MCEERR_AR) {
- hardware_memory_error();
- }
-
- /* Hope we are lucky for AO MCE */
- if ((cpu->env.mcg_cap & MCG_SER_P) && addr) {
- ram_addr_t ram_addr;
- hwaddr paddr;
-
- ram_addr = qemu_ram_addr_from_host(addr);
- if (ram_addr != RAM_ADDR_INVALID &&
- kvm_physical_memory_addr_from_host(first_cpu->kvm_state,
- addr, &paddr)) {
- kvm_hwpoison_page_add(ram_addr);
- kvm_mce_inject(X86_CPU(first_cpu), paddr, code);
- }
-
- fprintf(stderr, "Hardware memory error for memory used by "
- "QEMU itself instead of guest system!: %p\n", addr);
- }
- return 0;
}
static int kvm_inject_mce_oldstyle(X86CPU *cpu)