aboutsummaryrefslogtreecommitdiffstats
path: root/xen/arch/x86/cpu
diff options
context:
space:
mode:
authorLiu, Jinsong <jinsong.liu@intel.com>2012-09-26 12:05:10 +0200
committerLiu, Jinsong <jinsong.liu@intel.com>2012-09-26 12:05:10 +0200
commit513e591c04d9d4f9ffe9ec282daaba798c30c176 (patch)
treee585cd3df7fa4c3dbf816fd1e9d9f716fbe02e17 /xen/arch/x86/cpu
parent975b5bdf27031adef6587bb5c92b7a5800e051f1 (diff)
downloadxen-513e591c04d9d4f9ffe9ec282daaba798c30c176.tar.gz
xen-513e591c04d9d4f9ffe9ec282daaba798c30c176.tar.bz2
xen-513e591c04d9d4f9ffe9ec282daaba798c30c176.zip
x86: vMCE injection
In our test for win8 guest mce, we find a bug that no matter what SRAO/SRAR error xen inject to win8 guest, it always reboot. The root cause is, current Xen vMCE logic inject vMCE# only to vcpu0, this is not correct for Intel MCE (Under Intel arch, h/w generate MCE# to all CPUs). This patch fixes vMCE injection bug, injecting vMCE# to all vcpus on Intel platforms. Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com> - increase flexibility be making new second argument of inject_vmce() a VCPU ID rather than just a boolean Acked-by: Christoph Egger <Christoph.Egger@amd.com> (on just this change) - fix condition evaluation order in inject_vmce() Signed-off-by: Jan Beulich <jbeulich@suse.com> Committed-by: Jan Beulich <jbeulich@suse.com>
Diffstat (limited to 'xen/arch/x86/cpu')
-rw-r--r--xen/arch/x86/cpu/mcheck/mce.h2
-rw-r--r--xen/arch/x86/cpu/mcheck/mce_intel.c2
-rw-r--r--xen/arch/x86/cpu/mcheck/vmce.c60
3 files changed, 26 insertions, 38 deletions
diff --git a/xen/arch/x86/cpu/mcheck/mce.h b/xen/arch/x86/cpu/mcheck/mce.h
index d9b0647661..5b33934851 100644
--- a/xen/arch/x86/cpu/mcheck/mce.h
+++ b/xen/arch/x86/cpu/mcheck/mce.h
@@ -168,7 +168,7 @@ void x86_mcinfo_dump(struct mc_info *mi);
int fill_vmsr_data(struct mcinfo_bank *mc_bank, struct domain *d,
uint64_t gstatus);
-int inject_vmce(struct domain *d);
+int inject_vmce(struct domain *d, int vcpu);
static inline int mce_vendor_bank_msr(const struct vcpu *v, uint32_t msr)
{
diff --git a/xen/arch/x86/cpu/mcheck/mce_intel.c b/xen/arch/x86/cpu/mcheck/mce_intel.c
index 993ec4ce56..2f7709bd06 100644
--- a/xen/arch/x86/cpu/mcheck/mce_intel.c
+++ b/xen/arch/x86/cpu/mcheck/mce_intel.c
@@ -359,7 +359,7 @@ static void intel_memerr_dhandler(
}
/* We will inject vMCE to DOMU*/
- if ( inject_vmce(d) < 0 )
+ if ( inject_vmce(d, -1) < 0 )
{
mce_printk(MCE_QUIET, "inject vMCE to DOM%d"
" failed\n", d->domain_id);
diff --git a/xen/arch/x86/cpu/mcheck/vmce.c b/xen/arch/x86/cpu/mcheck/vmce.c
index 4ae2853e61..1432870e53 100644
--- a/xen/arch/x86/cpu/mcheck/vmce.c
+++ b/xen/arch/x86/cpu/mcheck/vmce.c
@@ -324,51 +324,39 @@ static int vmce_load_vcpu_ctxt(struct domain *d, hvm_domain_context_t *h)
HVM_REGISTER_SAVE_RESTORE(VMCE_VCPU, vmce_save_vcpu_ctxt,
vmce_load_vcpu_ctxt, 1, HVMSR_PER_VCPU);
-int inject_vmce(struct domain *d)
+/*
+ * for Intel MCE, broadcast vMCE to all vcpus
+ * for AMD MCE, only inject vMCE to vcpu0
+ */
+int inject_vmce(struct domain *d, int vcpu)
{
- int cpu = smp_processor_id();
+ struct vcpu *v;
- /* PV guest and HVM guest have different vMCE# injection methods. */
- if ( !test_and_set_bool(d->vcpu[0]->mce_pending) )
+ for_each_vcpu ( d, v )
{
- if ( d->is_hvm )
+ if ( vcpu >= 0 && v->vcpu_id != vcpu )
+ continue;
+
+ if ( (is_hvm_domain(d) ||
+ guest_has_trap_callback(d, v->vcpu_id, TRAP_machine_check)) &&
+ !test_and_set_bool(v->mce_pending) )
{
- mce_printk(MCE_VERBOSE, "MCE: inject vMCE to HVM DOM %d\n",
- d->domain_id);
- vcpu_kick(d->vcpu[0]);
+ mce_printk(MCE_VERBOSE, "MCE: inject vMCE to d%d:v%d\n",
+ d->domain_id, v->vcpu_id);
+ vcpu_kick(v);
}
else
{
- mce_printk(MCE_VERBOSE, "MCE: inject vMCE to PV DOM%d\n",
- d->domain_id);
- if ( guest_has_trap_callback(d, 0, TRAP_machine_check) )
- {
- cpumask_copy(d->vcpu[0]->cpu_affinity_tmp,
- d->vcpu[0]->cpu_affinity);
- mce_printk(MCE_VERBOSE, "MCE: CPU%d set affinity, old %d\n",
- cpu, d->vcpu[0]->processor);
- vcpu_set_affinity(d->vcpu[0], cpumask_of(cpu));
- vcpu_kick(d->vcpu[0]);
- }
- else
- {
- mce_printk(MCE_VERBOSE,
- "MCE: Kill PV guest with No MCE handler\n");
- domain_crash(d);
- }
+ mce_printk(MCE_QUIET, "Failed to inject vMCE to d%d:v%d\n",
+ d->domain_id, v->vcpu_id);
+ return -EBUSY;
}
+
+ if ( vcpu >= 0 )
+ return 0;
}
- else
- {
- /* new vMCE comes while first one has not been injected yet,
- * in this case, inject fail. [We can't lose this vMCE for
- * the mce node's consistency].
- */
- mce_printk(MCE_QUIET, "There's a pending vMCE waiting to be injected "
- " to this DOM%d!\n", d->domain_id);
- return -1;
- }
- return 0;
+
+ return v ? -ESRCH : 0;
}
int fill_vmsr_data(struct mcinfo_bank *mc_bank, struct domain *d,