From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Aravind Gopalakrishnan <aravind.gopalakrishnan@amd.com>,
jbeulich@suse.com, keir@xen.org, boris.ostrovsky@oracle.com
Cc: xen-devel@lists.xen.org
Subject: Re: [PATCH 2/2] x86, amd_ucode: Safeguard against #GP
Date: Wed, 30 Jul 2014 17:29:40 +0100 [thread overview]
Message-ID: <53D91D74.5080608@citrix.com> (raw)
In-Reply-To: <1406736790-13283-1-git-send-email-aravind.gopalakrishnan@amd.com>
On 30/07/14 17:13, Aravind Gopalakrishnan wrote:
> When HW tries to load a corrupted patch, it generates #GP
> and depending on 'noreboot' parameter on grub, the system
> is either stuck in a reboot loop or is hung. Use wrmsr_safe
> instead of wrmsrl so that we fail to load microcode gracefully.
>
> Signed-off-by: Aravind Gopalakrishnan <aravind.gopalakrishnan@amd.com>
> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> xen/arch/x86/microcode_amd.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/xen/arch/x86/microcode_amd.c b/xen/arch/x86/microcode_amd.c
> index a2bdd20..57646c4 100644
> --- a/xen/arch/x86/microcode_amd.c
> +++ b/xen/arch/x86/microcode_amd.c
> @@ -193,6 +193,7 @@ static int apply_microcode(int cpu)
> uint32_t rev;
> struct microcode_amd *mc_amd = uci->mc.mc_amd;
> struct microcode_header_amd *hdr;
> + int hw_err;
>
> /* We should bind the task to the CPU */
> BUG_ON(raw_smp_processor_id() != cpu);
> @@ -206,7 +207,7 @@ static int apply_microcode(int cpu)
>
> spin_lock_irqsave(µcode_update_lock, flags);
>
> - wrmsrl(MSR_AMD_PATCHLOADER, (unsigned long)hdr);
> + hw_err = wrmsr_safe(MSR_AMD_PATCHLOADER, (unsigned long)hdr);
>
> /* get patch id after patching */
> rdmsrl(MSR_AMD_PATCHLEVEL, rev);
> @@ -214,7 +215,7 @@ static int apply_microcode(int cpu)
> spin_unlock_irqrestore(µcode_update_lock, flags);
>
> /* check current patch id and patch's id for match */
> - if ( rev != hdr->patch_id )
> + if ( hw_err || (rev != hdr->patch_id) )
> {
> printk(KERN_ERR "microcode: CPU%d update from revision "
> "%#x to %#x failed\n", cpu, rev, hdr->patch_id);
prev parent reply other threads:[~2014-07-30 16:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-30 16:13 [PATCH 2/2] x86, amd_ucode: Safeguard against #GP Aravind Gopalakrishnan
2014-07-30 16:29 ` Andrew Cooper [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=53D91D74.5080608@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=aravind.gopalakrishnan@amd.com \
--cc=boris.ostrovsky@oracle.com \
--cc=jbeulich@suse.com \
--cc=keir@xen.org \
--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 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).