Skip to content

Commit f36fdb9

Browse files
groeckgregkh
authored andcommitted
i8k: Force SMM to run on CPU 0
On Studio 1555 with dual-core CPU, reading sensor attributes exported by this driver resulted in random failures combined with system hangups and forced logouts. Information in drivers/firmware/dcdbas.c suggests that SMM accesses must run on CPU 0. With this patch, the problems are gone, suggesting that this is in fact the case. Code derived from drivers/firmware/dcdbas.c. Cc: Jean Delvare <khali@linux-fr.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 14d3238 commit f36fdb9

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

‎drivers/char/i8k.c‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <linux/hwmon-sysfs.h>
3232
#include <linux/uaccess.h>
3333
#include <linux/io.h>
34+
#include <linux/sched.h>
3435

3536
#include <linux/i8k.h>
3637

@@ -130,6 +131,17 @@ static int i8k_smm(struct smm_regs *regs)
130131
{
131132
int rc;
132133
int eax = regs->eax;
134+
cpumask_var_t old_mask;
135+
136+
/* SMM requires CPU 0 */
137+
if (!alloc_cpumask_var(&old_mask, GFP_KERNEL))
138+
return -ENOMEM;
139+
cpumask_copy(old_mask, &current->cpus_allowed);
140+
set_cpus_allowed_ptr(current, cpumask_of(0));
141+
if (smp_processor_id() != 0) {
142+
rc = -EBUSY;
143+
goto out;
144+
}
133145

134146
#if defined(CONFIG_X86_64)
135147
asm volatile("pushq %%rax\n\t"
@@ -185,9 +197,12 @@ static int i8k_smm(struct smm_regs *regs)
185197
: "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory");
186198
#endif
187199
if (rc != 0 || (regs->eax & 0xffff) == 0xffff || regs->eax == eax)
188-
return -EINVAL;
200+
rc = -EINVAL;
189201

190-
return 0;
202+
out:
203+
set_cpus_allowed_ptr(current, old_mask);
204+
free_cpumask_var(old_mask);
205+
return rc;
191206
}
192207

193208
/*

0 commit comments

Comments
 (0)