linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Borislav Petkov <bp@suse.de>
Cc: Ingo Molnar <mingo@kernel.org>,
	linux-kernel@vger.kernel.org,
	Mika Westerberg <mika.westerberg@linux.intel.com>
Subject: Re: [PATCH 1/1] x86/microcode: vsnprintf() might be unavailable
Date: Tue, 02 Jun 2015 19:46:29 +0300	[thread overview]
Message-ID: <1433263589.26331.40.camel@linux.intel.com> (raw)
In-Reply-To: <1433257003-159485-1-git-send-email-andriy.shevchenko@linux.intel.com>


[+ Mika, who also somehow involved in the investigation]

On Tue, 2015-06-02 at 17:56 +0300, Andy Shevchenko wrote:
> On Intel CPUs with x32 kernels we call load_builtin_intel_microcode() from
> head_32.S on quite earlier stage. At that point sprintf() might be out of scope
> to be called. As a result the 32-bit kernel does not boot on Intel CPUs. It has
> been tested on Braswell and Merrifield.
> 

Small update below.

> The patch changes sprintf() call to plain code which does the same in this
> particular case.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  arch/x86/kernel/cpu/microcode/intel_early.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/microcode/intel_early.c b/arch/x86/kernel/cpu/microcode/intel_early.c
> index 10dff3f..a250f41 100644
> --- a/arch/x86/kernel/cpu/microcode/intel_early.c
> +++ b/arch/x86/kernel/cpu/microcode/intel_early.c
> @@ -523,9 +523,9 @@ EXPORT_SYMBOL_GPL(save_mc_for_early);
>  
>  static bool __init load_builtin_intel_microcode(struct cpio_data *cp)
>  {
> -	u32 eax = 0x00000001, ebx, ecx = 0, edx;
> -	int family, model, stepping;
> -	char name[30];
> +	unsigned int eax = 0x00000001, ebx, ecx = 0, edx;
> +	unsigned int family, model, stepping;

Change types to be in align with function prototypes.

> +	char name[30] = "intel-ucode", *p = name + 11;
>  
>  	native_cpuid(&eax, &ebx, &ecx, &edx);
>  
> @@ -533,7 +533,12 @@ static bool __init load_builtin_intel_microcode(struct cpio_data *cp)
>  	model    = x86_model(eax);
>  	stepping = eax & 0xf;
>  
> -	sprintf(name, "intel-ucode/%02x-%02x-%02x", family, model, stepping);
> +	*p++ = '/';
> +	p = hex_byte_pack(p, family);
> +	*p++ = '-';
> +	p = hex_byte_pack(p, model);
> +	*p++ = '-';
> +	p = hex_byte_pack(p, stepping);
>  

Forgot to add *p = '\0'; here, but it doesn't really mater for the idea.

What I would like to tell that if I move 'call load_ucode_bsp' after
paging is done, it seems sprintf() starts working nicely. So, I don't
know which fix is better (or neither), and wondering if we need to fix
AMD part.

Please, share your opinions, suggestions.

P.S. It would be really nice to get an expert / detailed explanation
what is going on there.

>  	return get_builtin_firmware(cp, name);
>  }

-- 
Andy Shevchenko <andriy.shevchenko@intel.com>
Intel Finland Oy


      parent reply	other threads:[~2015-06-02 16:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-02 14:56 [PATCH 1/1] x86/microcode: vsnprintf() might be unavailable Andy Shevchenko
2015-06-02 16:24 ` Borislav Petkov
2015-06-02 16:49   ` Andy Shevchenko
2015-06-02 17:00     ` Borislav Petkov
2015-06-02 17:31       ` Andy Shevchenko
2015-06-03 10:56         ` Borislav Petkov
2015-06-03 15:27           ` Andy Shevchenko
2015-06-03 17:49             ` Shevchenko, Andriy
2015-06-03 21:13               ` Borislav Petkov
2015-06-04  9:21                 ` [PATCH] x86/microcode: Disable builtin microcode loading on 32-bit for now Borislav Petkov
2015-06-04  9:47                   ` Shevchenko, Andriy
2015-06-02 16:46 ` Andy Shevchenko [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=1433263589.26331.40.camel@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=bp@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=mingo@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;
as well as URLs for NNTP newsgroup(s).