Skip to content

Commit

Permalink
i8k: Force SMM to run on CPU 0
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Guenter Roeck authored and Greg Kroah-Hartman committed Dec 19, 2013
1 parent 14d3238 commit f36fdb9
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions drivers/char/i8k.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <linux/hwmon-sysfs.h>
#include <linux/uaccess.h>
#include <linux/io.h>
#include <linux/sched.h>

#include <linux/i8k.h>

Expand Down Expand Up @@ -130,6 +131,17 @@ static int i8k_smm(struct smm_regs *regs)
{
int rc;
int eax = regs->eax;
cpumask_var_t old_mask;

/* SMM requires CPU 0 */
if (!alloc_cpumask_var(&old_mask, GFP_KERNEL))
return -ENOMEM;
cpumask_copy(old_mask, &current->cpus_allowed);
set_cpus_allowed_ptr(current, cpumask_of(0));
if (smp_processor_id() != 0) {
rc = -EBUSY;
goto out;
}

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

return 0;
out:
set_cpus_allowed_ptr(current, old_mask);
free_cpumask_var(old_mask);
return rc;
}

/*
Expand Down

0 comments on commit f36fdb9

Please sign in to comment.