xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@novell.com>
To: Jinsong Liu <jinsong.liu@intel.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
	Keir Fraser <keir.xen@gmail.com>, Xin Li <xin.li@intel.com>,
	Yunhong Jiang <yunhong.jiang@intel.com>
Subject: Re: [PATCH 4] MCA physical address check when calculate domain
Date: Mon, 09 May 2011 10:16:08 +0100	[thread overview]
Message-ID: <4DC7CCF802000078000405A1@vpn.id2.novell.com> (raw)
In-Reply-To: <BC00F5384FCFC9499AF06F92E8B78A9E2075FE9CD0@shsmsx502.ccr.corp.intel.com>

>>> On 07.05.11 at 22:29, "Liu, Jinsong" <jinsong.liu@intel.com> wrote:
> MCA physical address check when calculate domain
> 
> Bank addr maybe invalid, or 
> Bank addr maybe physical/memory/linear address or segment offset.
> This patch add mca MCi_STATUS_MISCV/MCi_STATUS_ADDRV check, and add physical 
> address verify,
> so that it work safe when calculate domain.
> 
> Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
> 
> diff -r e4e1efda200f xen/arch/x86/cpu/mcheck/mce.c
> --- a/xen/arch/x86/cpu/mcheck/mce.c	Thu May 05 13:54:29 2011 +0800
> +++ b/xen/arch/x86/cpu/mcheck/mce.c	Fri May 06 13:56:21 2011 +0800
> @@ -151,7 +151,6 @@ static struct mcinfo_bank *mca_init_bank
>                                           struct mc_info *mi, int bank)
>  {
>      struct mcinfo_bank *mib;
> -    uint64_t addr=0, misc = 0;
>  
>      if (!mi)
>          return NULL;
> @@ -170,22 +169,23 @@ static struct mcinfo_bank *mca_init_bank
>      mib->common.size = sizeof (struct mcinfo_bank);
>      mib->mc_bank = bank;
>  
> -    addr = misc = 0;
>      if (mib->mc_status & MCi_STATUS_MISCV)
>          mib->mc_misc = mca_rdmsr(MSR_IA32_MCx_MISC(bank));
>  
>      if (mib->mc_status & MCi_STATUS_ADDRV)
> -    {
>          mib->mc_addr = mca_rdmsr(MSR_IA32_MCx_ADDR(bank));
>  
> -        if (mfn_valid(paddr_to_pfn(mib->mc_addr))) {
> -            struct domain *d;
> +    if ((mib->mc_status & MCi_STATUS_MISCV) &&
> +        (mib->mc_status & MCi_STATUS_ADDRV) &&
> +        ((mib->mc_misc & MCi_MISC_ADDRMOD_MASK) == MCi_MISC_PHYSMOD) && 
> +          mfn_valid(paddr_to_pfn(mib->mc_addr)))
> +    {
> +        struct domain *d;
>  
> -            d = maddr_get_owner(mib->mc_addr);
> -            if (d != NULL && (who == MCA_POLLER ||
> -                              who == MCA_CMCI_HANDLER))
> -                mib->mc_domid = d->domain_id;
> -        }
> +        d = maddr_get_owner(mib->mc_addr);
> +        if (d != NULL && (who == MCA_POLLER ||
> +                          who == MCA_CMCI_HANDLER))
> +            mib->mc_domid = d->domain_id;

This wasn't very logical before, and would probably be good if it
got changed while you re-structure it anyway: Rather than
calling maddr_get_owner() and *then* checking "who", that
check should be added to the other surrounding ones, thus
avoiding the possibly pointless call.

Further I wonder whether there aren't more cases for which the
domain ID could be set, as well as whether the !MISCV case
shouldn't also assume the address to be physical. Wouldn't that
be the case e.g. on older CPUs?

Jan

>      }
>  
>      if (who == MCA_CMCI_HANDLER) {

  reply	other threads:[~2011-05-09  9:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-07 20:29 [PATCH 4] MCA physical address check when calculate domain Liu, Jinsong
2011-05-09  9:16 ` Jan Beulich [this message]
2011-05-10  6:38   ` Liu, Jinsong
2011-05-10  8:32     ` Jan Beulich
2011-05-10 10:46       ` Liu, Jinsong
2011-05-10 13:09         ` Jan Beulich
2011-05-11  7:21           ` Liu, Jinsong
2011-05-11 18:11             ` Luck, Tony

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=4DC7CCF802000078000405A1@vpn.id2.novell.com \
    --to=jbeulich@novell.com \
    --cc=jinsong.liu@intel.com \
    --cc=keir.xen@gmail.com \
    --cc=xen-devel@lists.xensource.com \
    --cc=xin.li@intel.com \
    --cc=yunhong.jiang@intel.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).