From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konrad Rzeszutek Wilk Subject: Re: [PATCH 2/2] microcode: Check whether the microcode is correct. Date: Wed, 25 Sep 2013 11:57:00 -0400 Message-ID: <20130925155700.GA6760@phenom.dumpdata.com> References: <1380122984-6555-1-git-send-email-konrad.wilk@oracle.com> <1380122984-6555-3-git-send-email-konrad.wilk@oracle.com> <524303CE.2060404@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VOrSg-0007ru-EX for xen-devel@lists.xenproject.org; Wed, 25 Sep 2013 15:57:10 +0000 Content-Disposition: inline In-Reply-To: <524303CE.2060404@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andrew Cooper Cc: xen-devel@lists.xenproject.org, david.vrabel@citrix.com, jbeulich@suse.com List-Id: xen-devel@lists.xenproject.org On Wed, Sep 25, 2013 at 04:39:58PM +0100, Andrew Cooper wrote: > On 25/09/13 16:29, Konrad Rzeszutek Wilk wrote: > > We do the microcode code update in two steps - the presmp: > > 'microcode_presmp_init' and when CPUs are brought up: > > 'microcode_init'. The earlier performs the microcode update > > on the BSP - but unfortunately it does not check whether the > > update failed. Which means that we might try later to update > > a incorrect payload on the rest of CPUs. > > > > This patch handles this odd situation. > > > > Signed-off-by: Konrad Rzeszutek Wilk > > [v2: Redid it as we are not doing scan and at the same time] .. snip.. > > coding style. > > Once fixed, Reviewed-by: Andrew Cooper Here it is. Thank you for your time looking at the patch! >>From eac253b28a6818ec9816526f420089bbefb29c7c Mon Sep 17 00:00:00 2001 From: Konrad Rzeszutek Wilk Date: Thu, 18 Jul 2013 23:44:08 -0400 Subject: [PATCH 2/2] microcode: Check whether the microcode is correct. We do the microcode code update in two steps - the presmp: 'microcode_presmp_init' and when CPUs are brought up: 'microcode_init'. The earlier performs the microcode update on the BSP - but unfortunately it does not check whether the update failed. Which means that we might try later to update a incorrect payload on the rest of CPUs. This patch handles this odd situation. Signed-off-by: Konrad Rzeszutek Wilk [v2: Redid it as we are not doing scan and at the same time] [v3: Fixed coding style, else was not on its own line] Reviewed-by: Andrew Cooper --- xen/arch/x86/microcode.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/microcode.c b/xen/arch/x86/microcode.c index e6344cf..091d5d1 100644 --- a/xen/arch/x86/microcode.c +++ b/xen/arch/x86/microcode.c @@ -418,6 +418,7 @@ static int __init microcode_presmp_init(void) { void *data; size_t len; + int rc = 0; if ( ucode_blob.size ) { @@ -430,10 +431,24 @@ static int __init microcode_presmp_init(void) data = ucode_mod_map(&ucode_mod); } if ( data ) - microcode_update_cpu(data, len); + rc = microcode_update_cpu(data, len); + else + rc = -ENOMEM; if ( !ucode_blob.size ) ucode_mod_map(NULL); + + if ( rc ) + { + if ( ucode_blob.size ) + { + xfree(ucode_blob.data); + ucode_blob.size = 0; + ucode_blob.data = NULL; + } + else + ucode_mod.mod_end = 0; + } } register_cpu_notifier(µcode_percpu_nfb); -- 1.8.3.1