mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Gabriel C <nix.or.die@gmail.com>
To: Borislav Petkov <bp@suse.de>
Cc: Jim Bos <jim876@xs4all.nl>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: Builtin microcode does nothing..
Date: Thu, 26 May 2016 13:52:22 +0200	[thread overview]
Message-ID: <98e7ce54-0ed3-e2e1-db13-f6be765ba1d6@gmail.com> (raw)
In-Reply-To: <20160526100353.GA30784@pd.tnic>


On 26.05.2016 12:03, Borislav Petkov wrote:
> On Thu, May 26, 2016 at 01:36:51AM +0200, Gabriel C wrote:
>>   Hangs on the second box too also..
> Ok, please try the diff below ontop to see if it fixes your issue.
>
> Looks like I'd need to rewrite the figuring out where the microcode data
> is. Currently, it is ugly and error prone.

  With this patch ontop your your tip brach all is fine.
  Tested on both server and both are up and running.


>
> ---
> diff --git a/arch/x86/include/asm/microcode.h b/arch/x86/include/asm/microcode.h
> index 01c2d14ec05f..4bee5bdbaf2c 100644
> --- a/arch/x86/include/asm/microcode.h
> +++ b/arch/x86/include/asm/microcode.h
> @@ -143,8 +143,13 @@ static inline bool
>   get_builtin_firmware(struct cpio_data *cd, const char *name)	{ return false; }
>   #endif
>   
> +static bool initrd_valid;
> +
>   static inline unsigned long get_initrd_start(void)
>   {
> +	if (!initrd_valid)
> +		return 0;
> +
>   #ifdef CONFIG_BLK_DEV_INITRD
>   	return initrd_start;
>   #else
> @@ -154,6 +159,9 @@ static inline unsigned long get_initrd_start(void)
>   
>   static inline unsigned long get_initrd_start_addr(void)
>   {
> +	if (!initrd_valid)
> +		return 0;
> +
>   #ifdef CONFIG_BLK_DEV_INITRD
>   #ifdef CONFIG_X86_32
>   	unsigned long *initrd_start_p = (unsigned long *)__pa_nodebug(&initrd_start);
> diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
> index 43f7caff4749..7ed06c397e2b 100644
> --- a/arch/x86/kernel/cpu/microcode/intel.c
> +++ b/arch/x86/kernel/cpu/microcode/intel.c
> @@ -55,6 +55,8 @@ static struct mc_saved_data {
>   	struct microcode_intel **mc_saved;
>   } mc_saved_data;
>   
> +static bool initrd_valid;
> +
>   /* Go through saved patches and find the one suitable for the current CPU. */
>   static enum ucode_state
>   find_microcode_patch(struct microcode_intel **saved,
> @@ -533,12 +535,10 @@ static bool __init load_builtin_intel_microcode(struct cpio_data *cp)
>   
>   static __init enum ucode_state
>   scan_microcode(struct mc_saved_data *mcs, unsigned long *mc_ptrs,
> -	       unsigned long *start, unsigned long size,
> +	       unsigned long start, unsigned long size,
>   	       struct ucode_cpu_info *uci)
>   {
> -	struct cpio_data cd;
> -	cd.data = NULL;
> -	cd.size = 0;
> +	struct cpio_data cd = { NULL, 0, "" };
>   
>   	/* try built-in microcode first */
>   	if (load_builtin_intel_microcode(&cd))
> @@ -547,21 +547,23 @@ scan_microcode(struct mc_saved_data *mcs, unsigned long *mc_ptrs,
>   		 * the boot loader, by mistake or simply forgotten there. That's
>   		 * fine, we ignore it since we've found builtin microcode.
>   		 */
> -		*start = 0;
> +		initrd_valid = false;
>   	else {
>   #ifdef CONFIG_BLK_DEV_INITRD
>   		static __initdata char ucode_name[] = "kernel/x86/microcode/GenuineIntel.bin";
>   		char *p = IS_ENABLED(CONFIG_X86_32) ? (char *)__pa_nodebug(ucode_name)
>   						    : ucode_name;
>   
> -		cd = find_cpio_data(p, (void *)*start, size, NULL);
> -		if (!cd.data)
> +		cd = find_cpio_data(p, (void *)start, size, NULL);
> +		if (cd.data)
> +			initrd_valid = true;
> +		else
>   #endif
>   			return UCODE_ERROR;
>   	}
>   
> -	return get_matching_model_microcode(*start, cd.data, cd.size,
> -					    mcs, mc_ptrs, uci);
> +	return get_matching_model_microcode(initrd_valid ? start : 0,
> +					    cd.data, cd.size, mcs, mc_ptrs, uci);
>   }
>   
>   /*
> @@ -703,20 +705,16 @@ static void __init
>   _load_ucode_intel_bsp(struct mc_saved_data *mcs, unsigned long *mc_ptrs,
>   		      unsigned long start, unsigned long size)
>   {
> -	unsigned long _start = start;
>   	struct ucode_cpu_info uci;
>   	enum ucode_state ret;
>   
>   	collect_cpu_info_early(&uci);
>   
> -	ret = scan_microcode(mcs, mc_ptrs, &_start, size, &uci);
> +	ret = scan_microcode(mcs, mc_ptrs, start, size, &uci);
>   	if (ret != UCODE_OK)
>   		return;
>   
> -	/* Pass updated starting address of blobs to the next routine.  */
> -	start = _start;
> -
> -	ret = load_microcode(mcs, mc_ptrs, start, &uci);
> +	ret = load_microcode(mcs, mc_ptrs, initrd_valid ? start : 0, &uci);
>   	if (ret != UCODE_OK)
>   		return;
>   
>
>

  reply	other threads:[~2016-05-26 11:52 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-20 10:08 Gabriel C
2016-05-20 10:23 ` Borislav Petkov
2016-05-20 16:03 ` Gabriel C
2016-05-21  0:20 ` Gabriel C
2016-05-21  2:59   ` Gabriel C
2016-05-21  7:51     ` Borislav Petkov
2016-05-25  9:31       ` Borislav Petkov
2016-05-25 13:48         ` Jim Bos
2016-05-25 14:57           ` Borislav Petkov
2016-05-25 21:29         ` Gabriel C
2016-05-25 21:38           ` Borislav Petkov
2016-05-25 21:50             ` Gabriel C
2016-05-25 23:36               ` Gabriel C
2016-05-26 10:03                 ` Borislav Petkov
2016-05-26 11:52                   ` Gabriel C [this message]
2016-05-26 12:46                     ` Borislav Petkov
2016-06-03  8:02                       ` Borislav Petkov
2016-06-04  0:37                         ` Gabriel C
2016-06-04  6:35                           ` Borislav Petkov
2016-05-21  7:45   ` Borislav Petkov
     [not found] <CAEJqkgjFWak5fUc_zR4v-BDgAnjU0NtRfUDDPaEVGjjbEZoqUQ@mail.gmail.com>
2016-05-20  8:36 ` Borislav Petkov
  -- strict thread matches above, loose matches on Subject: below --
2016-05-20  0:55 Gabriel C

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=98e7ce54-0ed3-e2e1-db13-f6be765ba1d6@gmail.com \
    --to=nix.or.die@gmail.com \
    --cc=bp@suse.de \
    --cc=jim876@xs4all.nl \
    --cc=linux-kernel@vger.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

all inboxes | Powered by JetHome®