mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: "Yu, Fenghua" <fenghua.yu@intel.com>,
	Borislav Petkov <bp@alien8.de>,
	Torsten Kaiser <just.for.lkml@googlemail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Jacob Shin <jacob.shin@amd.com>,
	Johannes Hirte <johannes.hirte@fem.tu-ilmenau.de>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH 3/5] x86, AMD: cleanup: merge common code in early microcode loading
Date: Wed, 07 Aug 2013 19:22:39 -0700	[thread overview]
Message-ID: <78b1bca9-80bb-4e60-af3a-738424babfd0@email.android.com> (raw)
In-Reply-To: <3E5A0FA7E9CA944F9D5414FEC6C712205A53B73A@ORSMSX106.amr.corp.intel.com>

How much does this matter?

"Yu, Fenghua" <fenghua.yu@intel.com> wrote:
>> From: Yu, Fenghua
>> Sent: Wednesday, August 07, 2013 3:46 PM
>> 
>> > From: Borislav Petkov [mailto:bp@alien8.de]
>> > Sent: Wednesday, July 24, 2013 6:33 AM
>> > On Tue, Jul 23, 2013 at 11:00:26PM +0200, Torsten Kaiser wrote:
>> > > Extract common checks and initialisations from load_ucode_ap()
>and
>> > > save_microcode_in_initrd_amd() to load_microcode_amd_early().
>> > > load_ucode_ap() gets a quick exit for !cpu, because for the BSP
>> there
>> > is
>> > > already a different function dealing with its update.
>> > >
>> > > The original code already didn't anything, because without
>> > load_microcode_amd()
>> > > getting called apply_microcode_amd() could not do anything.
>> > >
>> > > Signed-off-by: Torsten Kaiser <just.for.lkml@googlemail.com>
>> > >
>> > > --- a/arch/x86/kernel/microcode_amd_early.c	2013-07-22
>> > 06:22:32.000000000 +0200
>> > > +++ b/arch/x86/kernel/microcode_amd_early.c	2013-07-23
>> > 20:00:04.889508712 +0200
>> > > @@ -196,6 +196,23 @@ void __init load_ucode_amd_bsp(void)
>> > >  	apply_ucode_in_initrd(cd.data, cd.size);
>> > >  }
>> > >
>> > > +static int load_microcode_amd_early(void)
>> > > +{
>> > > +	enum ucode_state ret;
>> > > +	void *ucode;
>> > > +
>> > > +	if (ucode_loaded || !ucode_size || !initrd_start)
>> > > +		return 0;
>> > > +
>> > > +	ucode = (void *)(initrd_start + ucode_offset);
>> > > +	ret = load_microcode_amd(0, ucode, ucode_size);
>> > > +	if (ret != UCODE_OK)
>> > > +		return -EINVAL;
>> > > +
>> > > +	ucode_loaded = true;
>> > > +	return 0;
>> > > +}
>> > > +
>> > >  #ifdef CONFIG_X86_32
>> > >  u8 amd_bsp_mpb[MPB_MAX_SIZE];
>> > >
>> > > @@ -258,17 +275,13 @@ void load_ucode_amd_ap(void)
>> > >
>> > >  	collect_cpu_info_amd_early(&cpu_data(cpu), ucode_cpu_info +
>cpu);
>> > >
>> > > -	if (cpu && !ucode_loaded) {
>> > > -		void *ucode;
>> > > -
>> > > -		if (!ucode_size || !initrd_start)
>> > > -			return;
>> > > +	/* BSP via load_ucode_amd_bsp() */
>> > > +	if (!cpu)
>> > > +		return;
>> >
>> > Ok, this is really misleading. Fenghua, what's the reason for
>calling
>> > load_ucode_ap() on the BSP too?
>> >
>> > We have on the one hand:
>> >
>> > x86_64_start_kernel
>> > |->load_ucode_bsp
>> >
>> > and on the other:
>> >
>> > x86_64_start_kernel
>> > |-> x86_64_start_reservations
>> >     |-> start_kernel
>> >         |-> trap_init
>> > 	    |-> cpu_init
>> > 	        |-> load_ucode_ap()
>> >
>> > so we attempt to load the ucode twice on the BSP.
>> >
>> 
>> You are right. Though the second time loading attempt will not find a
>> valid/newer ucode patch to update. So this won't cause a real/serious
>> problem. But we had better to fix this anyway.
>> 
>> > IMO, we should do this in cpu_init:
>> >
>> > 	if (cpu)
>> > 		load_ucode_ap();
>> >
>> > no?
>> 
>> This check won't work when CPU0 is hot added. So we need to find a
>> better way to fix this.
>> 
>
>Maybe need to change the check as follows to take care of CPU0 hot add
>case?
>
>if ((cpu && system_state == SYSTEM_BOOTING) || (system_state ==
>SYSTEM_RUNNING))
>	load_ucode_ap();
>
>Thanks.
>
>-Fenghua

-- 
Sent from my mobile phone. Please excuse brevity and lack of formatting.

  reply	other threads:[~2013-08-08  2:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-23 21:00 Torsten Kaiser
2013-07-24 13:32 ` Borislav Petkov
2013-08-07 22:46   ` Yu, Fenghua
2013-08-07 23:34   ` Yu, Fenghua
2013-08-08  2:22     ` H. Peter Anvin [this message]
2013-08-08 10:02       ` Borislav Petkov
2013-08-08 18:28         ` Borislav Petkov
2013-08-09 18:44           ` Yu, Fenghua
2013-08-08 17:49     ` Borislav Petkov
2013-08-09 18:38       ` Yu, Fenghua

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=78b1bca9-80bb-4e60-af3a-738424babfd0@email.android.com \
    --to=hpa@zytor.com \
    --cc=bp@alien8.de \
    --cc=fenghua.yu@intel.com \
    --cc=jacob.shin@amd.com \
    --cc=johannes.hirte@fem.tu-ilmenau.de \
    --cc=just.for.lkml@googlemail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    /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

Powered by JetHome