0a122b
From a573bf83cd8f541f3129a53238ee7c2e9ad61ff8 Mon Sep 17 00:00:00 2001
0a122b
From: Paolo Bonzini <pbonzini@redhat.com>
0a122b
Date: Wed, 26 Mar 2014 12:30:43 +0100
0a122b
Subject: [PATCH 49/49] fix machine-check propagation
0a122b
MIME-Version: 1.0
0a122b
Content-Type: text/plain; charset=UTF-8
0a122b
Content-Transfer-Encoding: 8bit
0a122b
0a122b
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
0a122b
Message-id: <1395837043-17408-1-git-send-email-pbonzini@redhat.com>
0a122b
Patchwork-id: 58256
0a122b
O-Subject: [RHEL 7.0 qemu-kvm PATCH] fix machine-check propagation
0a122b
Bugzilla: 740107
0a122b
RH-Acked-by: Marcel Apfelbaum <marcel.a@redhat.com>
0a122b
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
0a122b
RH-Acked-by: Dr. David Alan Gilbert (git) <dgilbert@redhat.com>
0a122b
0a122b
From: Dean Nelson <dnelson@redhat.com>
0a122b
0a122b
Bugzilla: 740107
0a122b
0a122b
Upstream status: fixed by a big patch that should not be backported
0a122b
0a122b
Brew build: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=7257203
0a122b
0a122b
Machine-check propagation was broken by this commit
0a122b
0a122b
    commit a60f24b56b07f46453424263b276b0879c25c4e6
0a122b
    Author: Andreas Färber <afaerber@suse.de>
0a122b
    Date:   Sat Dec 1 05:35:08 2012 +0100
0a122b
0a122b
    cpu: Move kvm_state field into CPUState
0a122b
0a122b
    Adapt some functions to take CPUState / {PowerPC,S390}CPU argument.
0a122b
0a122b
    Signed-off-by: Andreas Färber <afaerber@suse.de>
0a122b
0a122b
due to a typo.  In RHEL7, first_cpu is an "env" so you need ENV_GET_CPU
0a122b
to convert it to a "cpu" and fish out the kvm_state.  ENV_GET_CPU is
0a122b
basically a "container_of" type of operation.  Instead, CPU was being used
0a122b
(which is just a cast).
0a122b
0a122b
Upstream, everything was fixed magically when first_cpu was changed
0a122b
from "env" to "cpu" in commit 182735e (cpu: Make first_cpu and next_cpu
0a122b
CPUState, 2013-05-29).
0a122b
0a122b
This patch fixes the bug by using the right cast.  All the work was done
0a122b
by Dean Nelson.
0a122b
0a122b
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
0a122b
---
0a122b
 target-i386/kvm.c | 2 +-
0a122b
 1 file changed, 1 insertion(+), 1 deletion(-)
0a122b
0a122b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
---
0a122b
 target-i386/kvm.c |    2 +-
0a122b
 1 files changed, 1 insertions(+), 1 deletions(-)
0a122b
0a122b
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
0a122b
index ba2cd7f..6b250f5 100644
0a122b
--- a/target-i386/kvm.c
0a122b
+++ b/target-i386/kvm.c
0a122b
@@ -357,7 +357,7 @@ int kvm_arch_on_sigbus(int code, void *addr)
0a122b
 
0a122b
         /* Hope we are lucky for AO MCE */
0a122b
         if (qemu_ram_addr_from_host(addr, &ram_addr) ||
0a122b
-            !kvm_physical_memory_addr_from_host(CPU(first_cpu)->kvm_state,
0a122b
+            !kvm_physical_memory_addr_from_host(ENV_GET_CPU(first_cpu)->kvm_state,
0a122b
                                                 addr, &paddr)) {
0a122b
             fprintf(stderr, "Hardware memory error for memory used by "
0a122b
                     "QEMU itself instead of guest system!: %p\n", addr);
0a122b
-- 
0a122b
1.7.1
0a122b