public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joel Schopp <joel.schopp@amd.com>
To: <jesse.larrew@amd.com>, <x86@kernel.org>
Cc: Tony Luck <tony.luck@intel.com>, Borislav Petkov <bp@alien8.de>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	<linux-edac@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] mce: use safe MSR accesses
Date: Fri, 13 Mar 2015 11:51:17 -0500	[thread overview]
Message-ID: <55031585.2030908@amd.com> (raw)
In-Reply-To: <1426262619-5016-1-git-send-email-jesse.larrew@amd.com>


On 03/13/2015 11:03 AM, jesse.larrew@amd.com wrote:
> From: Jesse Larrew <jesse.larrew@amd.com>
>
> Certain MSRs are only relevant to a kernel in host mode, and kvm had
> chosen not to implement these MSRs at all for guests. If a guest kernel
> ever tried to access these MSRs, the result was a general protection
> fault.
>
> KVM will be separately patched to return 0 when these MSRs are read,
> and this patch ensures that MSR accesses are tolerant of exceptions.
>
> Signed-off-by: Jesse Larrew <jesse.larrew@amd.com>
> ---
>  arch/x86/kernel/cpu/mcheck/mce.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
> index 61a9668ce..2737ced 100644
> --- a/arch/x86/kernel/cpu/mcheck/mce.c
> +++ b/arch/x86/kernel/cpu/mcheck/mce.c
> @@ -1540,7 +1540,7 @@ static int __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c)
>  		 if (c->x86 == 0x15 &&
>  		     (c->x86_model >= 0x10 && c->x86_model <= 0x1f)) {
>  			 int i;
> -			 u64 val, hwcr;
> +			 u64 hwcr;
>  			 bool need_toggle;
>  			 u32 msrs[] = {
>  				0x00000413, /* MC4_MISC0 */
> @@ -1556,13 +1556,8 @@ static int __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c)
>  				 wrmsrl(MSR_K7_HWCR, hwcr | BIT(18));
>  
>  			 for (i = 0; i < ARRAY_SIZE(msrs); i++) {
> -				 rdmsrl(msrs[i], val);
> -
> -				 /* CntP bit set? */
> -				 if (val & BIT_64(62)) {
> -					val &= ~BIT_64(62);
> -					wrmsrl(msrs[i], val);
> -				 }
> +				 /* Clear CntP bit safely */
> +				 msr_clear_bit(msrs[i], 62);
>  			 }
>  
>  			 /* restore old settings */
I like it.

Reviewed-by: Joel Schopp <joel.schopp@amd.com>

  parent reply	other threads:[~2015-03-13 16:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-13 16:03 [PATCH v2] mce: use safe MSR accesses jesse.larrew
2015-03-13 16:29 ` Luck, Tony
2015-03-13 16:51 ` Joel Schopp [this message]
2015-03-13 22:22 ` Borislav Petkov

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=55031585.2030908@amd.com \
    --to=joel.schopp@amd.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=jesse.larrew@amd.com \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.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