From: Haozhong Zhang <haozhong.zhang@intel.com>
To: xen-devel@lists.xen.org
Cc: Haozhong Zhang <haozhong.zhang@intel.com>,
Wei Liu <wei.liu2@citrix.com>,
Ian Campbell <ian.campbell@citrix.com>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
Liu Jinsong <jinsong.liu@alibaba-inc.com>,
Christoph Egger <chegger@amazon.de>,
Ian Jackson <ian.jackson@eu.citrix.com>,
Jan Beulich <jbeulich@suse.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Keir Fraser <keir@xen.org>
Subject: [PATCH 3/4] x86/mce: Translate passed-in GPA to host machine address
Date: Tue, 15 Sep 2015 16:29:39 +0800 [thread overview]
Message-ID: <1442305780-12790-4-git-send-email-haozhong.zhang@intel.com> (raw)
In-Reply-To: <1442305780-12790-1-git-send-email-haozhong.zhang@intel.com>
This patch adds a new flag MC_MSRINJ_F_GPADDR to
xen_mc_msrinject.mcinj_flags, and makes do_mca() to translate the
guest physical address passed-in through
xen_mc_msrinject.mcinj_msr[i].value to the host machine address if
this flag is present.
Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
---
xen/arch/x86/cpu/mcheck/mce.c | 33 +++++++++++++++++++++++++++++++++
xen/include/public/arch-x86/xen-mca.h | 5 ++++-
2 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/xen/arch/x86/cpu/mcheck/mce.c b/xen/arch/x86/cpu/mcheck/mce.c
index 561257d..343d9d2 100644
--- a/xen/arch/x86/cpu/mcheck/mce.c
+++ b/xen/arch/x86/cpu/mcheck/mce.c
@@ -21,6 +21,7 @@
#include <asm/processor.h>
#include <asm/system.h>
#include <asm/msr.h>
+#include <asm/p2m.h>
#include "mce.h"
#include "barrier.h"
@@ -1422,6 +1423,38 @@ long do_mca(XEN_GUEST_HANDLE_PARAM(xen_mc_t) u_xen_mc)
if (mc_msrinject->mcinj_count == 0)
return 0;
+ if (mc_msrinject->mcinj_flags & MC_MSRINJ_F_GPADDR) {
+ struct domain *d;
+ struct mcinfo_msr *msr;
+ int i;
+ uint64_t gaddr, gpfn, mfn, haddr;
+ p2m_type_t t;
+
+ d = get_domain_by_id(mc_msrinject->mcinj_domid);
+ if (d == NULL)
+ return x86_mcerr("do_mca inject: illegal domain id", -EINVAL);
+
+ for (i = 0, msr = &mc_msrinject->mcinj_msr[0];
+ i < mc_msrinject->mcinj_count; i++, msr++) {
+ gaddr = msr->value;
+ gpfn = gaddr >> PAGE_SHIFT;
+ mfn = mfn_x(get_gfn(d, gpfn, &t));
+
+ if (mfn == INVALID_MFN) {
+ put_domain(d);
+ return x86_mcerr("do_mca inject: illegal MSR value",
+ -EINVAL);
+ }
+
+ haddr = (mfn << PAGE_SHIFT) | (gaddr & (PAGE_SIZE - 1));
+ msr->value = haddr;
+
+ put_gfn(d, gpfn);
+ }
+
+ put_domain(d);
+ }
+
if (!x86_mc_msrinject_verify(mc_msrinject))
return x86_mcerr("do_mca inject: illegal MSR", -EINVAL);
diff --git a/xen/include/public/arch-x86/xen-mca.h b/xen/include/public/arch-x86/xen-mca.h
index 2422b76..33c1a84 100644
--- a/xen/include/public/arch-x86/xen-mca.h
+++ b/xen/include/public/arch-x86/xen-mca.h
@@ -392,12 +392,15 @@ struct xen_mc_msrinject {
uint32_t mcinj_cpunr; /* target processor id */
uint32_t mcinj_flags; /* see MC_MSRINJ_F_* below */
uint32_t mcinj_count; /* 0 .. count-1 in array are valid */
- uint32_t _pad0;
+ domid_t mcinj_domid; /* valid only if MC_MSRINJ_F_GPADDR presents
+ in mcinj_flags */
+ uint16_t _pad0;
struct mcinfo_msr mcinj_msr[MC_MSRINJ_MAXMSRS];
};
/* Flags for mcinj_flags above; bits 16-31 are reserved */
#define MC_MSRINJ_F_INTERPOSE 0x1
+#define MC_MSRINJ_F_GPADDR 0x2
#define XEN_MC_mceinject 5
struct xen_mc_mceinject {
--
2.4.8
next prev parent reply other threads:[~2015-09-15 8:29 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-15 8:29 [PATCH 0/4] Fix tools/xen-mceinj to handle >=4GB guest memory Haozhong Zhang
2015-09-15 8:29 ` [PATCH 1/4] x86/mce: Fix code style Haozhong Zhang
2015-09-15 8:47 ` Egger, Christoph
2015-09-15 13:13 ` Jan Beulich
2015-09-15 13:19 ` Haozhong Zhang
2015-09-15 8:29 ` [PATCH 2/4] tools/mceinject: " Haozhong Zhang
2015-09-15 8:48 ` Egger, Christoph
2015-09-15 10:15 ` Ian Campbell
2015-09-15 13:11 ` Wei Liu
2015-09-15 8:29 ` Haozhong Zhang [this message]
2015-09-15 9:14 ` [PATCH 3/4] x86/mce: Translate passed-in GPA to host machine address Egger, Christoph
2015-09-15 9:48 ` Haozhong Zhang
2015-09-15 13:24 ` Jan Beulich
2015-09-15 13:42 ` Haozhong Zhang
2015-09-15 13:47 ` Jan Beulich
2015-09-15 13:51 ` Haozhong Zhang
2015-09-15 13:50 ` Andrew Cooper
2015-09-16 0:38 ` Haozhong Zhang
2015-09-15 8:29 ` [PATCH 4/4] tools/xen-mceinj: Pass in GPA when injecting through MSR_MCI_ADDR Haozhong Zhang
2015-09-15 10:02 ` Wei Liu
2015-09-15 10:08 ` Egger, Christoph
2015-09-15 10:16 ` Wei Liu
2015-09-15 10:17 ` Egger, Christoph
2015-09-15 10:28 ` Haozhong Zhang
2015-09-15 10:34 ` Egger, Christoph
2015-09-15 10:20 ` Ian Campbell
2015-09-15 10:38 ` Haozhong Zhang
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=1442305780-12790-4-git-send-email-haozhong.zhang@intel.com \
--to=haozhong.zhang@intel.com \
--cc=andrew.cooper3@citrix.com \
--cc=chegger@amazon.de \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=jinsong.liu@alibaba-inc.com \
--cc=keir@xen.org \
--cc=stefano.stabellini@eu.citrix.com \
--cc=wei.liu2@citrix.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).