All of lore.kernel.org
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@suse.de>
To: "Luis R. Rodriguez" <mcgrof@suse.com>
Cc: Michal Marek <mmarek@suse.cz>, Juergen Gross <jgross@suse.com>,
	Jason Douglas <jdouglas@suse.com>,
	stefano.stabellini@eu.citrix.com, Takashi Iwai <tiwai@suse.de>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	"Luis R. Rodriguez" <mcgrof@do-not-panic.com>,
	Henrique de Moraes Holschuh <hmh@debian.org>,
	david.vrabel@citrix.com, Jan Beulich <JBeulich@suse.com>,
	xen-devel@lists.xenproject.org, boris.ostrovsky@oracle.com,
	Olaf Hering <ohering@suse.de>
Subject: Re: [PATCH] misc/xenmicrocode: Upload /lib/firmware/<some blob> to the hypervisor
Date: Thu, 29 Jan 2015 20:15:16 +0100	[thread overview]
Message-ID: <20150129191516.GF25399@pd.tnic> (raw)
In-Reply-To: <20150129032105.GE19988@wotan.suse.de>

On Thu, Jan 29, 2015 at 04:21:05AM +0100, Luis R. Rodriguez wrote:
> How close?

As close as we can get but not closer - see the thing about updating
microcode on Intel hyperthreaded logical cores in the other mail.

We probably can do it in parallel if needed. But it hasn't been needed
until now.

> I've reviewed the implmentation a bit more on the Xen side. For early boot
> things look similar to what is done upstream on the kernel. For the run time
> update here's what Xen does in detail, elaborating a bit more on Andrew's
> summary of how it works.
> 
> The XENPF_microcode_update hypercall calls the general Xen microcode_update() which
> will do microcode_ops->start_update() (only AMD has this op for and it does
> svm_host_osvw_reset()) and finally it continues the hypercall by calling
> do_microcode_update() on the cpumask_first(&cpu_online_map) *always*. The
> mechanism that Xen uses to continue the hypercall is by using
> continue_hypercall_on_cpu(), if this returns 0 then it is guaranteed to run
> *at some in the future* on the given CPU. If preemption is enabled this
> could also mean the hypercall was preempted, and can be preempted later
> on the other CPU. This will in turn will do the same call but on the
> next CPU using continuation until it reaches the end of the CPU mask.
> The do_microcode_update() call itself calls ops->cpu_request_microcode()
> on each iteration which in turn should also do the ops->apply_microcode()
> once a microcode buffer on the file that fits is found. The buffers are
> kept in case of suspend / resume.

Yah, this is mostly fine except the preemption thing. If the guests get
to see an inconsistent state with a subset of the cores updated and the
rest not, then that is bad.

Not to mention the case when we have to late-update problematic
microcode which has to happen in parallel on each core. I haven't seen
one so far but we should be prepared.

> There is no tight loop here or locking of what other CPUs do while one is running
> work to update microcode. Tons of things can happen in between so some refinements
> seem desirable and likely this implementation does differ quite signifantly
> over the Linux kernel's legacy 'rescan' interface.

Well, we're not very strict there either but that works so far. We'll
change it if the need arises.

> Given this review, it seems folks should use xenmicrocode keeping in mind the
> above algorithm, and support wise folks should be ready to consider upgrades on
> microcode and possible issues / caveats from vendors on a case by case basis.

Right.

> From what I gather some folks have even considered tainting kernels when the
> sysfs rescan interface is used, I do wonder if this is worthy on Xen for this
> tool given the possible issues here... or am I just paranoid about this?
> It seems like this might be more severe of an issue for Xen as-is.

That would not be unnecesary.

So, I would try to do the application of the microcode in the hypervisor
as tight as possible. Maybe the hypercall could hand in the microcode
blob only and the hypervisor can "schedule" an update later, after
having frozen the guests.

In any case, we should strive for a parallel late update, simultaneously
on each core with no interruption. The kernel doesn't do that either but
it'll probably have to, one day.

I don't know whether this is possible at all in xen and whether doing
a simple sequential update method now and improving it later is easier
than doing it right and in parallel from the get-go. I'm talking
hypothetically here, I have no idea what actually is possible and doable
in xen.

HTH.

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--

  reply	other threads:[~2015-01-29 19:15 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-27 20:11 [PATCH] misc/xenmicrocode: Upload /lib/firmware/<some blob> to the hypervisor Luis R. Rodriguez
2015-01-27 21:25 ` Boris Ostrovsky
2015-01-27 21:54   ` Luis R. Rodriguez
2015-01-27 22:26 ` Andrew Cooper
2015-01-27 23:17   ` Borislav Petkov
2015-01-28  0:10     ` Andrew Cooper
2015-01-28  8:39       ` Borislav Petkov
2015-01-29  3:21         ` Luis R. Rodriguez
2015-01-29 19:15           ` Borislav Petkov [this message]
2015-01-30  1:13             ` Luis R. Rodriguez
2015-01-29 11:36         ` Henrique de Moraes Holschuh
2015-01-29 12:17           ` Borislav Petkov
2015-01-29 17:01             ` Henrique de Moraes Holschuh
2015-01-29 17:30               ` Borislav Petkov
2015-01-29 18:34                 ` Andrew Cooper
2015-01-29 20:12                   ` Konrad Rzeszutek Wilk
2015-01-30  0:29                     ` Andrew Cooper
2015-01-30 14:11                       ` Konrad Rzeszutek Wilk

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=20150129191516.GF25399@pd.tnic \
    --to=bp@suse.de \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=david.vrabel@citrix.com \
    --cc=hmh@debian.org \
    --cc=jdouglas@suse.com \
    --cc=jgross@suse.com \
    --cc=mcgrof@do-not-panic.com \
    --cc=mcgrof@suse.com \
    --cc=mmarek@suse.cz \
    --cc=ohering@suse.de \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=tiwai@suse.de \
    --cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.