[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 3/4] x86/mce: Translate passed-in GPA to host machine address



On Tue, Sep 15, 2015 at 11:14:26AM +0200, Egger, Christoph wrote:
> 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@xxxxxxxxx>
>
> 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);

Oh, I forgot it in this path and will add in next version.

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

I will fix it in the next version.

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

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.