mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
To: Borislav Petkov <bp@amd64.org>
Cc: Tejun Heo <tj@kernel.org>, "Rafael J. Wysocki" <rjw@sisk.pl>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	"pavel@ucw.cz" <pavel@ucw.cz>,
	"len.brown@intel.com" <len.brown@intel.com>,
	"mingo@elte.hu" <mingo@elte.hu>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"suresh.b.siddha@intel.com" <suresh.b.siddha@intel.com>,
	"lucas.demarchi@profusion.mobi" <lucas.demarchi@profusion.mobi>,
	"rusty@rustcorp.com.au" <rusty@rustcorp.com.au>,
	"rdunlap@xenotime.net" <rdunlap@xenotime.net>,
	"vatsa@linux.vnet.ibm.com" <vatsa@linux.vnet.ibm.com>,
	"ashok.raj@intel.com" <ashok.raj@intel.com>,
	"tigran@aivazian.fsnet.co.uk" <tigran@aivazian.fsnet.co.uk>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"hpa@zytor.com" <hpa@zytor.com>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>
Subject: Re: [PATCH v2 2/3] Mutually exclude cpu online and suspend/hibernate
Date: Thu, 13 Oct 2011 22:59:37 +0530	[thread overview]
Message-ID: <4E972001.3080204@linux.vnet.ibm.com> (raw)
In-Reply-To: <20111013170153.GB3064@aftab>

On 10/13/2011 10:31 PM, Borislav Petkov wrote:
> On Thu, Oct 13, 2011 at 12:06:02PM -0400, Tejun Heo wrote:
>> I hate to sound like a broken recorder but the above patch isn't
>> strictly correct for hot-swap cases, right?
> 
> hpa is working on a ucode loading solution which will take care of your
> hotswap case too.
> 

Tejun, I have written a patch below (untested) that does what you said.
So Boris, hpa's work would make such a patch unnecessary is it?

Thanks,
Srivatsa S. Bhat

---

 arch/x86/kernel/microcode_core.c |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
index f924280..849ae2d 100644
--- a/arch/x86/kernel/microcode_core.c
+++ b/arch/x86/kernel/microcode_core.c
@@ -155,6 +155,27 @@ static int collect_cpu_info(int cpu)
 	return ret;
 }
 
+/*
+ * Compare the microcode revision that the kernel has in memory
+ * for this cpu and the microcode revision that we need to apply
+ * on this cpu. If they match, return 0, else return -1.
+ */
+static int compare_cpu_with_microcode(int cpu)
+{
+	struct ucode_cpu_info *uci_mem = ucode_cpu_info + cpu;
+	struct ucode_cpu_info uci_cpu;
+	int ret;
+
+	ret = collect_cpu_info_on_target(cpu, &uci_cpu->cpu_sig);
+	if(!ret) {
+		if (!(uci_mem->cpu_sig->sig == uci_cpu->cpu_sig->sig &&
+		      uci_mem->cpu_sig->pf == uci_cpu->cpu_sig->pf &&
+		      uci_mem->cpu_sig->rev == uci_cpu->cpu_sig->rev))
+			ret = -1;
+	}
+	return ret;
+}
+
 struct apply_microcode_ctx {
 	int err;
 };
@@ -397,6 +418,18 @@ static enum ucode_state microcode_update_cpu(int cpu)
 	struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
 	enum ucode_state ustate;
 
+	/*
+	 * If the CPU on which we are going to update the
+	 * microcode and the microcode which we currently
+	 * have in kernel memory are incompatible, then
+	 * invalidate the microcode that we have (and also
+	 * free its memory), so that we can get the required
+	 * microcode afresh.
+	 */
+	if (compare_cpu_with_microcode(cpu)) {
+		microcode_fini_cpu(cpu);
+	}
+
 	if (uci->valid)
 		ustate = microcode_resume_cpu(cpu);
 	else


  reply	other threads:[~2011-10-13 17:29 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-10 12:31 [PATCH v2 0/3] Freezer, CPU hotplug, x86 Microcode: Fix task freezing failures Srivatsa S. Bhat
2011-10-10 12:32 ` [PATCH v2 1/3] Introduce helper functions Srivatsa S. Bhat
2011-10-10 12:33 ` [PATCH v2 2/3] Mutually exclude cpu online and suspend/hibernate Srivatsa S. Bhat
2011-10-10 12:45   ` Srivatsa S. Bhat
2011-10-10 14:26     ` Peter Zijlstra
2011-10-10 15:16       ` Srivatsa S. Bhat
2011-10-11 20:32         ` Srivatsa S. Bhat
2011-10-11 21:56           ` Rafael J. Wysocki
2011-10-12  3:57             ` Srivatsa S. Bhat
2011-10-12 19:31               ` Rafael J. Wysocki
2011-10-12 21:25                 ` Srivatsa S. Bhat
2011-10-12 22:09                   ` Rafael J. Wysocki
2011-10-13 15:42                     ` Srivatsa S. Bhat
2011-10-13 16:06                       ` Tejun Heo
2011-10-13 17:01                         ` Borislav Petkov
2011-10-13 17:29                           ` Srivatsa S. Bhat [this message]
2011-10-19 17:29                             ` Srivatsa S. Bhat
2011-10-13 18:03                           ` Alan Stern
2011-10-13 19:07                             ` Rafael J. Wysocki
2011-10-13 19:08                         ` Rafael J. Wysocki
2011-10-10 15:25       ` Alan Stern
2011-10-10 17:00     ` Tejun Heo
2011-10-11  9:18       ` Peter Zijlstra
2011-10-11  9:37         ` Srivatsa S. Bhat
2011-10-10 12:33 ` [PATCH v2 3/3] Update documentation Srivatsa S. Bhat
2011-10-10 15:23 ` [PATCH v2 0/3] Freezer, CPU hotplug, x86 Microcode: Fix task freezing failures Alan Stern
2011-10-10 15:32   ` Srivatsa S. Bhat
2011-10-10 16:53     ` Borislav Petkov
2011-10-10 17:14       ` Pavel Machek
2011-10-10 17:30       ` Srivatsa S. Bhat
2011-10-10 17:53         ` Borislav Petkov
2011-10-10 18:08           ` tj
2011-10-10 18:34             ` Borislav Petkov
2011-10-10 18:45               ` Srivatsa S. Bhat
2011-10-10 18:53               ` tj
2011-10-10 19:00                 ` Srivatsa S. Bhat
2011-10-10 20:35                   ` Borislav Petkov
     [not found]                 ` <20111010202913.GA30798@aftab>
2011-10-10 21:13                   ` tj
2011-10-11  9:17       ` Peter Zijlstra
2011-10-10 16:57   ` Tejun Heo

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=4E972001.3080204@linux.vnet.ibm.com \
    --to=srivatsa.bhat@linux.vnet.ibm.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=ashok.raj@intel.com \
    --cc=bp@amd64.org \
    --cc=hpa@zytor.com \
    --cc=len.brown@intel.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lucas.demarchi@profusion.mobi \
    --cc=mingo@elte.hu \
    --cc=pavel@ucw.cz \
    --cc=rdunlap@xenotime.net \
    --cc=rjw@sisk.pl \
    --cc=rusty@rustcorp.com.au \
    --cc=suresh.b.siddha@intel.com \
    --cc=tglx@linutronix.de \
    --cc=tigran@aivazian.fsnet.co.uk \
    --cc=tj@kernel.org \
    --cc=vatsa@linux.vnet.ibm.com \
    /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