x86 microcode: revert some work_on_cpu

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Tuesday, April 14, 2009 - 11:59 am

Gitweb:     http://git.kernel.org/linus/6f66cbc63081fd70e3191b4dbb796746780e5ae1
Commit:     6f66cbc63081fd70e3191b4dbb796746780e5ae1
Parent:     610f26e75176aeb896618c26b16cbc0601f0e3cf
Author:     Hugh Dickins <hugh@veritas.com>
AuthorDate: Tue Apr 14 19:25:42 2009 +0100
Committer:  Linus Torvalds <torvalds@linux-foundation.org>
CommitDate: Tue Apr 14 11:45:59 2009 -0700

    x86 microcode: revert some work_on_cpu
    
    Revert part of af5c820a3169e81af869c113e18ec7588836cd50 ("x86: cpumask:
    use work_on_cpu in arch/x86/kernel/microcode_core.c")
    
    That change is causing only one Intel CPU's microcode to be updated e.g.
    microcode: CPU3 updated from revision 0x9 to 0x17, date = 2005-04-22
    where before it announced that also for CPU0 and CPU1 and CPU2.
    
    We cannot use work_on_cpu() in the CONFIG_MICROCODE_OLD_INTERFACE code,
    because Intel's request_microcode_user() involves a copy_from_user() from
    /sbin/microcode_ctl, which therefore needs to be on that CPU at the time.
    
    Signed-off-by: Hugh Dickins <hugh@veritas.com>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
 arch/x86/kernel/microcode_core.c |   33 +++++++++++----------------------
 1 files changed, 11 insertions(+), 22 deletions(-)

diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
index a0f3851..2e0eb41 100644
--- a/arch/x86/kernel/microcode_core.c
+++ b/arch/x86/kernel/microcode_core.c
@@ -108,40 +108,29 @@ struct ucode_cpu_info		ucode_cpu_info[NR_CPUS];
 EXPORT_SYMBOL_GPL(ucode_cpu_info);
 
 #ifdef CONFIG_MICROCODE_OLD_INTERFACE
-struct update_for_cpu {
-	const void __user	*buf;
-	size_t			size;
-};
-
-static long update_for_cpu(void *_ufc)
-{
-	struct update_for_cpu *ufc = _ufc;
-	int error;
-
-	error = microcode_ops->request_microcode_user(smp_processor_id(),
-						      ufc->buf, ufc->size);
-	if (error < 0)
-		return error;
-	if (!error)
-		microcode_ops->apply_microcode(smp_processor_id());
-	return error;
-}
-
 static int do_microcode_update(const void __user *buf, size_t size)
 {
+	cpumask_t old;
 	int error = 0;
 	int cpu;
-	struct update_for_cpu ufc = { .buf = buf, .size = size };
+
+	old = current->cpus_allowed;
 
 	for_each_online_cpu(cpu) {
 		struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
 
 		if (!uci->valid)
 			continue;
-		error = work_on_cpu(cpu, update_for_cpu, &ufc);
+
+		set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
+		error = microcode_ops->request_microcode_user(cpu, buf, size);
 		if (error < 0)
-			break;
+			goto out;
+		if (!error)
+			microcode_ops->apply_microcode(cpu);
 	}
+out:
+	set_cpus_allowed_ptr(current, &old);
 	return error;
 }
 
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
x86 microcode: revert some work_on_cpu, Linux Kernel Mailing ..., (Tue Apr 14, 11:59 am)