xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Egger <Christoph.Egger@amd.com>
To: "Liu, Jinsong" <jinsong.liu@intel.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
	"keir@xen.org" <keir@xen.org>,
	"Ian.Campbell@citrix.com" <Ian.Campbell@citrix.com>,
	Jan Beulich <JBeulich@suse.com>
Subject: Re: [PATCH 6] X86/MCE: update vMCE injection for AMD
Date: Thu, 27 Sep 2012 11:56:57 +0200	[thread overview]
Message-ID: <506422E9.3060100@amd.com> (raw)
In-Reply-To: <DE8DF0795D48FD4CA783C40EC829233533C32B@SHSMSX101.ccr.corp.intel.com>

On 09/27/12 11:45, Liu, Jinsong wrote:

>>>
>>> Got it, thanks! It's OK to me, but how about add sanity check and
>>> some comments like 
>>>
>>> ==================
>>> Xen/MCE: add sanity check and comments for vmce injection
>>>
>>> Add sanity check for input vcpu so that malicious value would not
>>> return 0. 
>>> Add comments since vcpu<0 (broadcast) is some implicit to code
>>> reader. 
>>
>>
>> Yeah, a like #define VMCE_INJECT_BROADCAST is also helpful.
>>
>>>
>>> Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
>>>
>>> diff -r adc7f057011e xen/arch/x86/cpu/mcheck/vmce.c
>>> --- a/xen/arch/x86/cpu/mcheck/vmce.c	Thu Sep 27 19:52:13 2012 +0800
>>> +++ b/xen/arch/x86/cpu/mcheck/vmce.c	Thu Sep 27 20:56:52 2012 +0800
>>>  @@ -341,10 +341,16 @@ /*
>>>   * for Intel MCE, broadcast vMCE to all vcpus
>>>   * for AMD MCE, only inject vMCE to vcpu0
>>> + *
>>> + * @ d, domain to which would inject vmce
>>> + * @ vcpu,
>>> + *   < 0, broadcast vMCE to all vcpus
>>> + *   >= 0, vcpu who would be injected vMCE
>>
>>
>> Better wording:
>>  >= 0, vcpu, the vMCE is injected to
>>
>> Christoph
>>
> 
> Fine to me, updated accordingly.
> 
> Thanks,
> Jinsong
> 
> ===============
> Xen/MCE: add sanity check and comments for vmce injection
> 
> Add sanity check for input vcpu so that malicious value would not return 0.
> Add comments since vcpu=-1 (broadcast) is some implicit to code reader.
> 
> Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
> Suggested_by: Christoph Egger <Christoph.Egger@amd.com>


Acked-by: Christoph Egger <Christoph.Egger@amd.com>

> 
> diff -r adc7f057011e xen/arch/x86/cpu/mcheck/mce_intel.c
> --- a/xen/arch/x86/cpu/mcheck/mce_intel.c	Thu Sep 27 19:52:13 2012 +0800
> +++ b/xen/arch/x86/cpu/mcheck/mce_intel.c	Fri Sep 28 01:25:19 2012 +0800
> @@ -360,7 +360,7 @@
>                  }
>  
>                  /* We will inject vMCE to DOMU*/
> -                if ( inject_vmce(d, -1) < 0 )
> +                if ( inject_vmce(d, VMCE_INJECT_BROADCAST) < 0 )
>                  {
>                      mce_printk(MCE_QUIET, "inject vMCE to DOM%d"
>                        " failed\n", d->domain_id);
> diff -r adc7f057011e xen/arch/x86/cpu/mcheck/vmce.c
> --- a/xen/arch/x86/cpu/mcheck/vmce.c	Thu Sep 27 19:52:13 2012 +0800
> +++ b/xen/arch/x86/cpu/mcheck/vmce.c	Fri Sep 28 01:25:19 2012 +0800
> @@ -341,14 +341,20 @@
>  /*
>   * for Intel MCE, broadcast vMCE to all vcpus
>   * for AMD MCE, only inject vMCE to vcpu0
> + *
> + * @ d, domain to which would inject vmce
> + * @ vcpu,
> + *   -1 (VMCE_INJECT_BROADCAST), broadcast vMCE to all vcpus
> + *   >= 0, vcpu, the vMCE is injected to
>   */
>  int inject_vmce(struct domain *d, int vcpu)
>  {
>      struct vcpu *v;
> +    int ret = -EINVAL;
>  
>      for_each_vcpu ( d, v )
>      {
> -        if ( vcpu >= 0 && v->vcpu_id != vcpu )
> +        if ( vcpu != VMCE_INJECT_BROADCAST && vcpu != v->vcpu_id )
>              continue;
>  
>          if ( (is_hvm_domain(d) ||
> @@ -358,19 +364,21 @@
>              mce_printk(MCE_VERBOSE, "MCE: inject vMCE to d%d:v%d\n",
>                         d->domain_id, v->vcpu_id);
>              vcpu_kick(v);
> +            ret = 0;
>          }
>          else
>          {
>              mce_printk(MCE_QUIET, "Failed to inject vMCE to d%d:v%d\n",
>                         d->domain_id, v->vcpu_id);
> -            return -EBUSY;
> +            ret = -EBUSY;
> +            break;
>          }
>  
>          if ( vcpu >= 0 )
> -            return 0;
> +            break;
>      }
>  
> -    return v ? -ESRCH : 0;
> +    return ret;
>  }
>  
>  int fill_vmsr_data(struct mcinfo_bank *mc_bank, struct domain *d,
> diff -r adc7f057011e xen/arch/x86/cpu/mcheck/vmce.h
> --- a/xen/arch/x86/cpu/mcheck/vmce.h	Thu Sep 27 19:52:13 2012 +0800
> +++ b/xen/arch/x86/cpu/mcheck/vmce.h	Fri Sep 28 01:25:19 2012 +0800
> @@ -18,6 +18,8 @@
>  
>  int fill_vmsr_data(struct mcinfo_bank *mc_bank, struct domain *d,
>      uint64_t gstatus);
> +
> +#define VMCE_INJECT_BROADCAST -1
>  int inject_vmce(struct domain *d, int vcpu);
>  
>  #endif



-- 
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85689 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632

      reply	other threads:[~2012-09-27  9:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-25  5:00 [PATCH 6] X86/MCE: update vMCE injection for AMD Liu, Jinsong
2012-09-25  9:06 ` Christoph Egger
2012-09-25 10:48   ` Jan Beulich
2012-09-25 11:54     ` Christoph Egger
2012-09-26  3:11       ` Liu, Jinsong
2012-09-26  7:34         ` Jan Beulich
2012-09-27  5:22           ` Liu, Jinsong
2012-09-27  8:54             ` Christoph Egger
2012-09-27  9:45               ` Liu, Jinsong
2012-09-27  9:56                 ` Christoph Egger [this message]

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=506422E9.3060100@amd.com \
    --to=christoph.egger@amd.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=jinsong.liu@intel.com \
    --cc=keir@xen.org \
    --cc=xen-devel@lists.xensource.com \
    /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).