From: Haozhong Zhang <haozhong.zhang@intel.com>
To: xen-devel@lists.xen.org
Cc: Haozhong Zhang <haozhong.zhang@intel.com>,
Christoph Egger <chegger@amazon.de>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Jan Beulich <jbeulich@suse.com>,
Liu Jinsong <jinsong.liu@alibaba-inc.com>
Subject: [PATCH 09/19] x86/vmce: fill MSR_IA32_MCG_STATUS on all vcpus in broadcast case
Date: Fri, 17 Feb 2017 14:39:26 +0800 [thread overview]
Message-ID: <20170217063936.13208-10-haozhong.zhang@intel.com> (raw)
In-Reply-To: <20170217063936.13208-1-haozhong.zhang@intel.com>
The current implementation only fills MC MSRs on vcpu0 and leaves MC
MSRs on other vcpus empty in the broadcast case. When guest reads 0
from MSR_IA32_MCG_STATUS on vcpuN (N > 0), it may think it's not
possible to recover the execution on that vcpu and then get panic,
although MSR_IA32_MCG_STATUS filled on vcpu0 may imply the injected
vMCE is actually recoverable. To avoid such unnecessary guest panic,
set MSR_IA32_MCG_STATUS on vcpuN (N > 0) to MCG_STATUS_MCIP |
MCG_STATUS_RIPV.
Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
---
Cc: Christoph Egger <chegger@amazon.de>
Cc: Liu Jinsong <jinsong.liu@alibaba-inc.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
---
xen/arch/x86/cpu/mcheck/mcaction.c | 14 ++++----
xen/arch/x86/cpu/mcheck/vmce.c | 67 +++++++++++++++++++++++++-------------
xen/arch/x86/cpu/mcheck/vmce.h | 2 +-
3 files changed, 53 insertions(+), 30 deletions(-)
diff --git a/xen/arch/x86/cpu/mcheck/mcaction.c b/xen/arch/x86/cpu/mcheck/mcaction.c
index cc90e7c..8b2b834 100644
--- a/xen/arch/x86/cpu/mcheck/mcaction.c
+++ b/xen/arch/x86/cpu/mcheck/mcaction.c
@@ -88,21 +88,21 @@ mc_memerr_dhandler(struct mca_binfo *binfo,
goto vmce_failed;
}
+ if ( boot_cpu_data.x86_vendor == X86_VENDOR_INTEL )
+ vmce_vcpuid = VMCE_INJECT_BROADCAST;
+ else
+ vmce_vcpuid = global->mc_vcpuid;
+
bank->mc_addr = gfn << PAGE_SHIFT |
(bank->mc_addr & (PAGE_SIZE -1 ));
- if ( fill_vmsr_data(bank, d,
- global->mc_gstatus) == -1 )
+ if ( fill_vmsr_data(bank, d, global->mc_gstatus,
+ vmce_vcpuid == VMCE_INJECT_BROADCAST) == -1 )
{
mce_printk(MCE_QUIET, "Fill vMCE# data for DOM%d "
"failed\n", bank->mc_domid);
goto vmce_failed;
}
- if ( boot_cpu_data.x86_vendor == X86_VENDOR_INTEL )
- vmce_vcpuid = VMCE_INJECT_BROADCAST;
- else
- vmce_vcpuid = global->mc_vcpuid;
-
/* We will inject vMCE to DOMU*/
if ( inject_vmce(d, vmce_vcpuid) < 0 )
{
diff --git a/xen/arch/x86/cpu/mcheck/vmce.c b/xen/arch/x86/cpu/mcheck/vmce.c
index d83a3f2..456d6f3 100644
--- a/xen/arch/x86/cpu/mcheck/vmce.c
+++ b/xen/arch/x86/cpu/mcheck/vmce.c
@@ -386,36 +386,59 @@ int inject_vmce(struct domain *d, int vcpu)
return ret;
}
+static int vcpu_fill_mc_msrs(struct vcpu *v, uint64_t mcg_status,
+ uint64_t mci_status, uint64_t mci_addr,
+ uint64_t mci_misc)
+{
+ if ( v->arch.vmce.mcg_status & MCG_STATUS_MCIP )
+ {
+ mce_printk(MCE_QUIET, "MCE: %pv: guest has not handled previous"
+ " vMCE yet!\n", v);
+ return -EBUSY;
+ }
+
+ spin_lock(&v->arch.vmce.lock);
+
+ v->arch.vmce.mcg_status = mcg_status;
+ /*
+ * 1. Skip bank 0 to avoid 'bank 0 quirk' of old processors
+ * 2. Filter MCi_STATUS MSCOD model specific error code to guest
+ */
+ v->arch.vmce.bank[1].mci_status = mci_status & MCi_STATUS_MSCOD_MASK;
+ v->arch.vmce.bank[1].mci_addr = mci_addr;
+ v->arch.vmce.bank[1].mci_misc = mci_misc;
+
+ spin_unlock(&v->arch.vmce.lock);
+
+ return 0;
+}
+
int fill_vmsr_data(struct mcinfo_bank *mc_bank, struct domain *d,
- uint64_t gstatus)
+ uint64_t gstatus, bool broadcast)
{
struct vcpu *v = d->vcpu[0];
+ int ret;
- if ( mc_bank->mc_domid != (uint16_t)~0 )
- {
- if ( v->arch.vmce.mcg_status & MCG_STATUS_MCIP )
- {
- mce_printk(MCE_QUIET, "MCE: guest has not handled previous"
- " vMCE yet!\n");
- return -1;
- }
-
- spin_lock(&v->arch.vmce.lock);
+ if ( mc_bank->mc_domid == (uint16_t)~0 )
+ return -EINVAL;
- v->arch.vmce.mcg_status = gstatus;
- /*
- * 1. Skip bank 0 to avoid 'bank 0 quirk' of old processors
- * 2. Filter MCi_STATUS MSCOD model specific error code to guest
- */
- v->arch.vmce.bank[1].mci_status = mc_bank->mc_status &
- MCi_STATUS_MSCOD_MASK;
- v->arch.vmce.bank[1].mci_addr = mc_bank->mc_addr;
- v->arch.vmce.bank[1].mci_misc = mc_bank->mc_misc;
+ ret = vcpu_fill_mc_msrs(v, gstatus, mc_bank->mc_status,
+ mc_bank->mc_addr, mc_bank->mc_misc);
+ if ( ret || !broadcast )
+ goto out;
- spin_unlock(&v->arch.vmce.lock);
+ for_each_vcpu ( d, v )
+ {
+ if ( v == d->vcpu[0] )
+ continue;
+ ret = vcpu_fill_mc_msrs(v, MCG_STATUS_MCIP | MCG_STATUS_RIPV,
+ 0, 0, 0);
+ if ( ret )
+ break;
}
- return 0;
+ out:
+ return ret;
}
/* It's said some ram is setup as mmio_direct for UC cache attribute */
diff --git a/xen/arch/x86/cpu/mcheck/vmce.h b/xen/arch/x86/cpu/mcheck/vmce.h
index 163ce3c..74f6381 100644
--- a/xen/arch/x86/cpu/mcheck/vmce.h
+++ b/xen/arch/x86/cpu/mcheck/vmce.h
@@ -17,7 +17,7 @@ int vmce_amd_rdmsr(const struct vcpu *, uint32_t msr, uint64_t *val);
int vmce_amd_wrmsr(struct vcpu *, uint32_t msr, uint64_t val);
int fill_vmsr_data(struct mcinfo_bank *mc_bank, struct domain *d,
- uint64_t gstatus);
+ uint64_t gstatus, bool broadcast);
#define VMCE_INJECT_BROADCAST (-1)
int inject_vmce(struct domain *d, int vcpu);
--
2.10.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-02-17 6:39 UTC|newest]
Thread overview: 78+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-17 6:39 [PATCH 00/19] MCE code cleanup and add LMCE support Haozhong Zhang
2017-02-17 6:39 ` [PATCH 01/19] x86/mce: fix indentation style in xen-mca.h and mce.h Haozhong Zhang
2017-02-17 9:49 ` Jan Beulich
2017-02-17 6:39 ` [PATCH 02/19] x86/mce: remove declarations of non-existing functions in mce.h Haozhong Zhang
2017-02-17 9:50 ` Jan Beulich
2017-02-17 6:39 ` [PATCH 03/19] x86/mce: remove unnecessary braces around intel_get_extended_msrs() Haozhong Zhang
2017-02-17 9:51 ` Jan Beulich
2017-02-17 6:39 ` [PATCH 04/19] xen/mce: remove unused x86_mcinfo_add() Haozhong Zhang
2017-02-17 9:55 ` Jan Beulich
2017-02-20 1:52 ` Haozhong Zhang
2017-02-20 9:00 ` Jan Beulich
2017-02-20 9:10 ` Haozhong Zhang
2017-02-17 6:39 ` [PATCH 05/19] x86/mce: merge loops to get Intel extended MC MSR Haozhong Zhang
2017-02-17 9:58 ` Jan Beulich
2017-02-20 1:11 ` Haozhong Zhang
2017-02-17 6:39 ` [PATCH 06/19] x86/mce: merge intel_default_mce_dhandler/uhandler() Haozhong Zhang
2017-02-17 10:01 ` Jan Beulich
2017-02-20 2:40 ` Haozhong Zhang
2017-02-17 6:39 ` [PATCH 07/19] x86/vmce: include domain/vcpu id in debug messages Haozhong Zhang
2017-02-17 10:03 ` Jan Beulich
2017-02-17 6:39 ` [PATCH 08/19] x86/mce: set mcinfo_comm.type and .size in x86_mcinfo_reserve() Haozhong Zhang
2017-02-17 10:07 ` Jan Beulich
2017-02-20 2:48 ` Haozhong Zhang
2017-02-20 9:02 ` Jan Beulich
2017-02-20 9:11 ` Haozhong Zhang
2017-02-17 6:39 ` Haozhong Zhang [this message]
2017-02-17 10:21 ` [PATCH 09/19] x86/vmce: fill MSR_IA32_MCG_STATUS on all vcpus in broadcast case Jan Beulich
2017-02-20 4:36 ` Haozhong Zhang
2017-02-20 9:04 ` Jan Beulich
2017-02-20 9:12 ` Haozhong Zhang
2017-02-17 6:39 ` [PATCH 10/19] x86/mce: always write 0 to MSR_IA32_MCG_STATUS on Intel CPU Haozhong Zhang
2017-02-17 10:26 ` Jan Beulich
2017-02-17 15:01 ` Boris Ostrovsky
2017-02-17 15:13 ` Jan Beulich
2017-02-17 15:38 ` Boris Ostrovsky
2017-02-17 6:39 ` [PATCH 11/19] tools/xen-mceinj: fix the type of cpu number Haozhong Zhang
2017-02-17 10:08 ` Jan Beulich
2017-02-20 2:49 ` Haozhong Zhang
2017-02-20 12:29 ` Wei Liu
2017-02-17 6:39 ` [PATCH 12/19] x86/mce: handle LMCE locally Haozhong Zhang
2017-02-22 13:53 ` Jan Beulich
2017-02-23 3:06 ` Haozhong Zhang
2017-02-23 7:42 ` Jan Beulich
2017-02-23 8:38 ` Haozhong Zhang
2017-02-17 6:39 ` [PATCH 13/19] x86/mce_intel: detect and enable LMCE on Intel host Haozhong Zhang
2017-02-22 15:10 ` Jan Beulich
2017-02-23 3:16 ` Haozhong Zhang
2017-02-23 7:45 ` Jan Beulich
2017-02-17 6:39 ` [PATCH 14/19] x86/vmx: expose LMCE feature via guest MSR_IA32_FEATURE_CONTROL Haozhong Zhang
2017-02-22 15:20 ` Jan Beulich
2017-02-23 4:10 ` Haozhong Zhang
2017-02-17 6:39 ` [PATCH 15/19] x86/vmce: emulate MSR_IA32_MCG_EXT_CTL Haozhong Zhang
2017-02-22 15:36 ` Jan Beulich
2017-02-23 4:26 ` Haozhong Zhang
2017-02-23 7:53 ` Jan Beulich
2017-02-23 8:54 ` Haozhong Zhang
2017-02-23 9:04 ` Jan Beulich
2017-02-17 6:39 ` [PATCH 16/19] x86/vmce: enable injecting LMCE to guest on Intel host Haozhong Zhang
2017-02-22 15:48 ` Jan Beulich
2017-02-23 4:48 ` Haozhong Zhang
2017-02-23 8:21 ` Jan Beulich
2017-02-17 6:39 ` [PATCH 17/19] x86/vmce, tools/libxl: expose LMCE capability in guest MSR_IA32_MCG_CAP Haozhong Zhang
2017-02-20 12:32 ` Wei Liu
2017-02-20 12:38 ` Jan Beulich
2017-02-20 14:12 ` Wei Liu
2017-02-20 23:55 ` Haozhong Zhang
2017-02-22 15:55 ` Jan Beulich
2017-02-23 5:07 ` Haozhong Zhang
2017-02-17 6:39 ` [PATCH 18/19] xen/mce: add support of vLMCE injection to XEN_MC_inject_v2 Haozhong Zhang
2017-02-22 15:59 ` Jan Beulich
2017-02-23 5:14 ` Haozhong Zhang
2017-02-23 8:26 ` Jan Beulich
2017-02-23 9:14 ` Haozhong Zhang
2017-02-23 9:22 ` Jan Beulich
2017-02-17 6:39 ` [PATCH 19/19] tools/xen-mceinj: support injecting LMCE Haozhong Zhang
2017-02-20 12:53 ` Wei Liu
2017-02-20 23:50 ` Haozhong Zhang
2017-02-21 9:18 ` Wei Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170217063936.13208-10-haozhong.zhang@intel.com \
--to=haozhong.zhang@intel.com \
--cc=andrew.cooper3@citrix.com \
--cc=chegger@amazon.de \
--cc=jbeulich@suse.com \
--cc=jinsong.liu@alibaba-inc.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).