Skip to content

Commit

Permalink
powerpc/book3s/mce: Move add_taint() later in virtual mode
Browse files Browse the repository at this point in the history
machine_check_early() gets called in real mode. The very first time when
add_taint() is called, it prints a warning which ends up calling opal
call (that uses OPAL_CALL wrapper) for writing it to console. If we get a
very first machine check while we are in opal we are doomed. OPAL_CALL
overwrites the PACASAVEDMSR in r13 and in this case when we are done with
MCE handling the original opal call will use this new MSR on it's way
back to opal_return. This usually leads to unexpected behaviour or the
kernel to panic. Instead move the add_taint() call later in the virtual
mode where it is safe to call.

This is broken with current FW level. We got lucky so far for not getting
very first MCE hit while in OPAL. But easily reproducible on Mambo.

Fixes: 27ea2c4 ("powerpc: Set the correct kernel taint on machine check errors.")
Cc: [email protected] # v4.2+
Signed-off-by: Mahesh Salgaonkar <[email protected]>
Signed-off-by: Michael Ellerman <[email protected]>
  • Loading branch information
maheshsal authored and mpe committed May 3, 2017
1 parent 3f2290e commit d93b0ac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions arch/powerpc/kernel/mce.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ static void machine_check_process_queued_event(struct irq_work *work)
{
int index;

add_taint(TAINT_MACHINE_CHECK, LOCKDEP_NOW_UNRELIABLE);

/*
* For now just print it to console.
* TODO: log this error event to FSP or nvram.
Expand Down
4 changes: 2 additions & 2 deletions arch/powerpc/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,6 @@ long machine_check_early(struct pt_regs *regs)

__this_cpu_inc(irq_stat.mce_exceptions);

add_taint(TAINT_MACHINE_CHECK, LOCKDEP_NOW_UNRELIABLE);

if (cur_cpu_spec && cur_cpu_spec->machine_check_early)
handled = cur_cpu_spec->machine_check_early(regs);
return handled;
Expand Down Expand Up @@ -758,6 +756,8 @@ void machine_check_exception(struct pt_regs *regs)

__this_cpu_inc(irq_stat.mce_exceptions);

add_taint(TAINT_MACHINE_CHECK, LOCKDEP_NOW_UNRELIABLE);

/* See if any machine dependent calls. In theory, we would want
* to call the CPU first, and call the ppc_md. one if the CPU
* one returns a positive number. However there is existing code
Expand Down

0 comments on commit d93b0ac

Please sign in to comment.