xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Aravind Gopalakrishnan <aravind.gopalakrishnan@amd.com>
To: Jan Beulich <JBeulich@suse.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Thomas.Lendacky@amd.com, keir@xen.org,
	Suravee.Suthikulpanit@amd.com, xen-devel@lists.xen.org
Subject: Re: [PATCH] x86, amd_ucode: Verify max allowed patch size before apply
Date: Mon, 28 Apr 2014 10:48:12 -0500	[thread overview]
Message-ID: <535E783C.50102@amd.com> (raw)
In-Reply-To: <535E324E020000780000CB4D@nat28.tlf.novell.com>

On 4/28/2014 3:49 AM, Jan Beulich wrote:
>>>> On 25.04.14 at 22:30, <andrew.cooper3@citrix.com> wrote:
>> On 25/04/14 20:48, Aravind Gopalakrishnan wrote:
>>> Could someone please help me understand why there are two initcalls -
>>> 'microcode_presmp_init' && 'microcode_init'
>>> that perform the same tasks?
>>>
>>> It results in these functions - 'collect_cpu_info',
>>> 'cpu_request_microcode' to run a second time through 'microcode_init'
>>> when we have already accomplished the job of updating cpu with
>>> microcode patches
>>> through 'microcode_presmp_init' and 'microcode_resume_cpu'
>>>
>>> If there is particular reason for 'microcode_init''s existence, then
>>> I'll modify the patch so that the error handling around 'microcode_fits'
>>> is not altered. But if not, then I simply have to just remove the
>>> 'break' statement.
>> Good grief this looks mad.  Ignoring for a moment what the code actually
>> does, lets consider what it should do.
>>
>> The administrator has an option of providing a microcode blob in a
>> multiboot module, and instructing Xen where to look.  In this case if a
>> valid blob is found, Xen will want to load the microcode ASAP and cache
>> it for the other processors.  This can be done as early as is suitable
>> on the BSP.
>>
>> The administrator has an option of providing a microcode blob by
>> hypercall (either automatically as part of their kernel microcode
>> patching code, or perhaps from a userspace tool in dom0).  For a valid
>> blob, Xen will want to cache it and apply to all active processors.
>> This can be done by whichever cpu processes the hypercall.
>>
>> At any point, a new cpu coming online (AP boot, S3 etc) should look at
>> the cached microcode and try to load it.
>>
>>
>> So it would occur to me to have something such as as presmp initcall
>> which sets up a cpunotifier for any cpu coming online.  It checks to see
>> whether there are any blobs provided at boot, tries to load them and
>> caches the best result.  The hypercall tries to apply the blob from
>> userspace and if successful, caches the new microcode and instructs all
>> other cpus to load this new microcode.
>>
>> I dont see a need for two initcalls in the slightest, nor do I see a
>> need for using tasklets on boot.  If the earlier initcall hasn't found
>> any microcode in a multiboot module then there will be nothing for the
>> latter one to do.  If the earlier did find microcode, then it should be
>> applied automatically whenever a new cpu comes up, rather than when
>> explicitly prodded by the later initcall.
> The code indeed looks more complicated than one would think it
> needs to be, but simplifying it would likely require adding another,
> later CPU notification that is being issued _on_ the CPU being
> brought up, or an IPI issued from e.g. the CPU_ONLINE callback
> (but I'm rather uncertain about it being a good idea to do the ucode
> update in an interrupt handler). The whole purpose of the later
> initcall and the use of a tasklet there is to have a vehicle to get code
> executed _on_ the new CPU, with CPU_STARTING being too early to
> hook onto.
>
>
Okay, So let me just modify the patch to make sure I don't change 
original behavior.
and worry about simplifying this code at a later time..

Will send out a V2..

Thanks Jan, Andrew
-Aravind

  reply	other threads:[~2014-04-28 15:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-24 19:54 [PATCH] x86, amd_ucode: Verify max allowed patch size before apply Aravind Gopalakrishnan
2014-04-24 20:26 ` Andrew Cooper
2014-04-25 19:48   ` Aravind Gopalakrishnan
2014-04-25 20:30     ` Andrew Cooper
2014-04-28  8:49       ` Jan Beulich
2014-04-28 15:48         ` Aravind Gopalakrishnan [this message]
2014-04-25  7:00 ` Jan Beulich
2014-04-25 19:48   ` Aravind Gopalakrishnan
2014-04-28  7:21     ` Jan Beulich

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=535E783C.50102@amd.com \
    --to=aravind.gopalakrishnan@amd.com \
    --cc=JBeulich@suse.com \
    --cc=Suravee.Suthikulpanit@amd.com \
    --cc=Thomas.Lendacky@amd.com \
    --cc=andrew.cooper3@citrix.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).