lkml.org 
[lkml]   [2011]   [Oct]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH v2 2/3] Mutually exclude cpu online and suspend/hibernate
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


\
 
 \ /
  Last update: 2011-10-13 19:33    [W:0.318 / U:0.124 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site