Skip to content

Commit

Permalink
x86: mce: Serialize mce injection
Browse files Browse the repository at this point in the history
raise_mce() fiddles with global state, but lacks any kind of
serialization.

Add a mutex around the raise_mce() call, so concurrent writers do not
stomp on each other toes.

Signed-off-by: Thomas Gleixner <[email protected]>
Signed-off-by: Chen Gong <[email protected]>
Signed-off-by: Tony Luck <[email protected]>
  • Loading branch information
KAGA-KOKO authored and aegl committed Aug 3, 2012
1 parent ea22571 commit b597591
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions arch/x86/kernel/cpu/mcheck/mce-inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ static void raise_exception(struct mce *m, struct pt_regs *pregs)
}

static cpumask_var_t mce_inject_cpumask;
static DEFINE_MUTEX(mce_inject_mutex);

static int mce_raise_notify(unsigned int cmd, struct pt_regs *regs)
{
Expand Down Expand Up @@ -229,7 +230,10 @@ static ssize_t mce_write(struct file *filp, const char __user *ubuf,
* so do it a jiffie or two later everywhere.
*/
schedule_timeout(2);

mutex_lock(&mce_inject_mutex);
raise_mce(&m);
mutex_unlock(&mce_inject_mutex);
return usize;
}

Expand Down

0 comments on commit b597591

Please sign in to comment.