* [PATCH 10/11] kvm, x86: unify sigbus handling, post2
@ 2010-10-14 8:54 ` Jin Dongming
0 siblings, 0 replies; 2+ messages in thread
From: Jin Dongming @ 2010-10-14 8:54 UTC (permalink / raw)
To: KVM list
Cc: Dean Nelson, Marcelo Tosatti, Avi Kivity, Huang Ying,
Hidetoshi Seto, qemu-devel@nongnu.org
Cleanup to finish unification.
Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Tested-by: Jin Dongming <jin.dongming@np.css.fujitsu.com>
---
qemu-kvm.c | 41 ++++++++++++-----------------------------
1 files changed, 12 insertions(+), 29 deletions(-)
diff --git a/qemu-kvm.c b/qemu-kvm.c
index d96394b..d2b2459 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -1222,45 +1222,24 @@ static void kvm_mce_inj_srao_broadcast(target_phys_addr_t paddr)
static void kvm_handle_sigbus(CPUState *env, int code, void *vaddr)
{
#if defined(KVM_CAP_MCE) && defined(TARGET_I386)
- /* env == NULL: when main thread received a SIGBUS */
- if (!env && vaddr && (code == BUS_MCEERR_AR || code == BUS_MCEERR_AO)) {
+ if (vaddr && (code == BUS_MCEERR_AO || code == BUS_MCEERR_AR)) {
ram_addr_t ram_addr;
target_phys_addr_t paddr;
+ CPUState *target_env;
/* Give up MCE forwarding if immediate action required on main thread */
- if (code == BUS_MCEERR_AR) {
+ if (!env && code == BUS_MCEERR_AR) {
goto out;
}
/* Check if recoverable MCE support is enabled */
- if (!(first_cpu->mcg_cap & MCG_SER_P)){
- goto out;
- }
-
- if (do_qemu_ram_addr_from_host(vaddr, &ram_addr) ||
- !kvm_physical_memory_addr_from_ram(kvm_state, ram_addr, &paddr)) {
- fprintf(stderr, "Hardware memory error for memory used by "
- "QEMU itself instead of guest system!: %llx\n",
- (unsigned long long)vaddr);
- return;
- }
- /* Broadcast SRAO UCR to all vcpu threads */
- kvm_mce_inj_srao_broadcast(paddr);
- return;
- }
-
- /* env != NULL: when vcpu thread received a SIGBUS */
- if (env && vaddr && (code == BUS_MCEERR_AR || code == BUS_MCEERR_AO)) {
- ram_addr_t ram_addr;
- unsigned long paddr;
-
- /* Check if recoverable MCE support is enabled */
- if (!(env->mcg_cap & MCG_SER_P)){
+ target_env = env ? env : first_cpu;
+ if (!target_env || !(target_env->mcg_cap & MCG_SER_P)) {
goto out;
}
/* If there is an MCE exception being processed, ignore this SRAO MCE */
- if (code == BUS_MCEERR_AO && kvm_mce_in_progress(env)) {
+ if (env && code == BUS_MCEERR_AO && kvm_mce_in_progress(env)) {
return;
}
@@ -1273,10 +1252,14 @@ static void kvm_handle_sigbus(CPUState *env, int code, void *vaddr)
}
if (code == BUS_MCEERR_AR) {
/* Fake an Intel architectural Data Load SRAR UCR */
- kvm_mce_inj_srar_dataload(env, paddr);
+ kvm_mce_inj_srar_dataload(target_env, paddr);
} else {
/* Fake an Intel architectural Memory scrubbing UCR */
- kvm_mce_inj_srao_memscrub(env, paddr);
+ if (env) {
+ kvm_mce_inj_srao_memscrub(target_env, paddr);
+ } else {
+ kvm_mce_inj_srao_broadcast(paddr);
+ }
}
return;
}
--
1.7.1.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* [Qemu-devel] [PATCH 10/11] kvm, x86: unify sigbus handling, post2
@ 2010-10-14 8:54 ` Jin Dongming
0 siblings, 0 replies; 2+ messages in thread
From: Jin Dongming @ 2010-10-14 8:54 UTC (permalink / raw)
To: KVM list
Cc: Hidetoshi Seto, Dean Nelson, Marcelo Tosatti,
qemu-devel@nongnu.org, Avi Kivity, Huang Ying
Cleanup to finish unification.
Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Tested-by: Jin Dongming <jin.dongming@np.css.fujitsu.com>
---
qemu-kvm.c | 41 ++++++++++++-----------------------------
1 files changed, 12 insertions(+), 29 deletions(-)
diff --git a/qemu-kvm.c b/qemu-kvm.c
index d96394b..d2b2459 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -1222,45 +1222,24 @@ static void kvm_mce_inj_srao_broadcast(target_phys_addr_t paddr)
static void kvm_handle_sigbus(CPUState *env, int code, void *vaddr)
{
#if defined(KVM_CAP_MCE) && defined(TARGET_I386)
- /* env == NULL: when main thread received a SIGBUS */
- if (!env && vaddr && (code == BUS_MCEERR_AR || code == BUS_MCEERR_AO)) {
+ if (vaddr && (code == BUS_MCEERR_AO || code == BUS_MCEERR_AR)) {
ram_addr_t ram_addr;
target_phys_addr_t paddr;
+ CPUState *target_env;
/* Give up MCE forwarding if immediate action required on main thread */
- if (code == BUS_MCEERR_AR) {
+ if (!env && code == BUS_MCEERR_AR) {
goto out;
}
/* Check if recoverable MCE support is enabled */
- if (!(first_cpu->mcg_cap & MCG_SER_P)){
- goto out;
- }
-
- if (do_qemu_ram_addr_from_host(vaddr, &ram_addr) ||
- !kvm_physical_memory_addr_from_ram(kvm_state, ram_addr, &paddr)) {
- fprintf(stderr, "Hardware memory error for memory used by "
- "QEMU itself instead of guest system!: %llx\n",
- (unsigned long long)vaddr);
- return;
- }
- /* Broadcast SRAO UCR to all vcpu threads */
- kvm_mce_inj_srao_broadcast(paddr);
- return;
- }
-
- /* env != NULL: when vcpu thread received a SIGBUS */
- if (env && vaddr && (code == BUS_MCEERR_AR || code == BUS_MCEERR_AO)) {
- ram_addr_t ram_addr;
- unsigned long paddr;
-
- /* Check if recoverable MCE support is enabled */
- if (!(env->mcg_cap & MCG_SER_P)){
+ target_env = env ? env : first_cpu;
+ if (!target_env || !(target_env->mcg_cap & MCG_SER_P)) {
goto out;
}
/* If there is an MCE exception being processed, ignore this SRAO MCE */
- if (code == BUS_MCEERR_AO && kvm_mce_in_progress(env)) {
+ if (env && code == BUS_MCEERR_AO && kvm_mce_in_progress(env)) {
return;
}
@@ -1273,10 +1252,14 @@ static void kvm_handle_sigbus(CPUState *env, int code, void *vaddr)
}
if (code == BUS_MCEERR_AR) {
/* Fake an Intel architectural Data Load SRAR UCR */
- kvm_mce_inj_srar_dataload(env, paddr);
+ kvm_mce_inj_srar_dataload(target_env, paddr);
} else {
/* Fake an Intel architectural Memory scrubbing UCR */
- kvm_mce_inj_srao_memscrub(env, paddr);
+ if (env) {
+ kvm_mce_inj_srao_memscrub(target_env, paddr);
+ } else {
+ kvm_mce_inj_srao_broadcast(paddr);
+ }
}
return;
}
--
1.7.1.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-10-14 8:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-14 8:54 [PATCH 10/11] kvm, x86: unify sigbus handling, post2 Jin Dongming
2010-10-14 8:54 ` [Qemu-devel] " Jin Dongming
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.