From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938826AbcIGLgp (ORCPT ); Wed, 7 Sep 2016 07:36:45 -0400 Received: from mail.skyhub.de ([78.46.96.112]:56282 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750954AbcIGLgm (ORCPT ); Wed, 7 Sep 2016 07:36:42 -0400 Date: Wed, 7 Sep 2016 13:36:40 +0200 From: Borislav Petkov To: Sebastian Andrzej Siewior Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Ingo Molnar , rt@linutronix.de, tglx@linutronix.de Subject: Re: [PATCH 06/21] x86: microcode: Convert to hotplug state machine Message-ID: <20160907113640.i27zhdoo3eszdlcw@pd.tnic> References: <20160906170457.32393-1-bigeasy@linutronix.de> <20160906170457.32393-7-bigeasy@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20160906170457.32393-7-bigeasy@linutronix.de> User-Agent: NeoMutt/ (1.7.0) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 06, 2016 at 07:04:42PM +0200, Sebastian Andrzej Siewior wrote: > Install the callbacks via the state machine. There is little hackery with > mc_cpu_dead() which should only be called if CPU_UP failed durin resume. > This change may not fully represent the current behaviour. The current code > also behaves different if the CPU does not come up in the _cpu_up() state vs > one of the CPU_ONLINE notifier returned an error. Not sure what kind of a > problem is solved here. You mean this: /* The CPU refused to come up during a system resume */ if (action == CPU_UP_CANCELED_FROZEN) microcode_fini_cpu(cpu); ? It clears internal state, i.e., invalidates the current microcode patch. > > Cc: Borislav Petkov > Signed-off-by: Sebastian Andrzej Siewior > --- > arch/x86/kernel/cpu/microcode/core.c | 71 +++++++++++++++--------------------- > include/linux/cpuhotplug.h | 1 + > 2 files changed, 30 insertions(+), 42 deletions(-) > > diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c > index df04b2d033f6..4fc67b51e22e 100644 > --- a/arch/x86/kernel/cpu/microcode/core.c > +++ b/arch/x86/kernel/cpu/microcode/core.c ... > -static struct notifier_block mc_cpu_notifier = { > - .notifier_call = mc_cpu_callback, > -}; > +static int mc_cpu_down_prep(unsigned int cpu) > +{ > + struct device *dev; > + > + dev = get_cpu_device(cpu); > + /* Suspend is in progress, only remove the interface */ > + sysfs_remove_group(&dev->kobj, &mc_attr_group); > + pr_debug("CPU%d removed\n", cpu); > + return 0; > +} > + > +static int mc_cpu_dead(unsigned int cpu) > +{ > +#ifdef CONFIG_SMP > + if (cpuhp_tasks_frozen) > + microcode_fini_cpu(cpu); > +#endif > + return 0; > +} If this is corresponding to CPU_DEAD, then I'd like to point to that comment: /* * case CPU_DEAD: * * When a CPU goes offline, don't free up or invalidate the copy of * the microcode in kernel memory, so that we can reuse it when the * CPU comes back online without unnecessarily requesting the userspace * for it again. */ IOW, you don't need mc_cpu_dead(). -- Regards/Gruss, Boris. ECO tip #101: Trim your mails when you reply.