All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Egger, Christoph" <chegger@amazon.de>
To: Haozhong Zhang <haozhong.zhang@intel.com>, xen-devel@lists.xen.org
Cc: 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>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	Jan Beulich <jbeulich@suse.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Keir Fraser <keir@xen.org>
Subject: Re: [PATCH 3/4] x86/mce: Translate passed-in GPA to host machine address
Date: Tue, 15 Sep 2015 11:14:26 +0200	[thread overview]
Message-ID: <55F7E172.6080904@amazon.de> (raw)
In-Reply-To: <1442305780-12790-4-git-send-email-haozhong.zhang@intel.com>

On 2015/09/15 10:29, Haozhong Zhang wrote:
> 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>

Comments inline.

> ---
>  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_gfn(d, gpfn);

> +                    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 */

wording. I prefer "s/presents/is present/"

> +    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 {
> 

Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrer: Dr. Ralf Herbrich, Christian Schlaeger
Ust-ID: DE289237879
Eingetragen am Amtsgericht Charlottenburg HRB 149173 B

  reply	other threads:[~2015-09-15  9:14 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 ` [PATCH 3/4] x86/mce: Translate passed-in GPA to host machine address Haozhong Zhang
2015-09-15  9:14   ` Egger, Christoph [this message]
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=55F7E172.6080904@amazon.de \
    --to=chegger@amazon.de \
    --cc=andrew.cooper3@citrix.com \
    --cc=haozhong.zhang@intel.com \
    --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 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.