Skip to content

Commit

Permalink
powerpc: introduce die_mce
Browse files Browse the repository at this point in the history
As explained by commit daf00ae ("powerpc/traps: restore
recoverability of machine_check interrupts"), die() can't be called from
within nmi_enter to nicely kill a process context that was interrupted.
nmi_exit must be called first.

This adds a function die_mce which takes care of this for machine check
handlers.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210130130852.2952424-24-npiggin@gmail.com
  • Loading branch information
Nicholas Piggin authored and Michael Ellerman committed Feb 8, 2021
1 parent dcdb4f1 commit 209e9d5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions arch/powerpc/include/asm/bug.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ void do_bad_page_fault_segv(struct pt_regs *regs);
extern void _exception(int, struct pt_regs *, int, unsigned long);
extern void _exception_pkey(struct pt_regs *, unsigned long, int);
extern void die(const char *, struct pt_regs *, long);
void die_mce(const char *str, struct pt_regs *regs, long err);
extern bool die_will_crash(void);
extern void panic_flush_kmsg_start(void);
extern void panic_flush_kmsg_end(void);
Expand Down
21 changes: 15 additions & 6 deletions arch/powerpc/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,19 @@ int machine_check_generic(struct pt_regs *regs)
}
#endif /* everything else */

void die_mce(const char *str, struct pt_regs *regs, long err)
{
/*
* The machine check wants to kill the interrupted context, but
* do_exit() checks for in_interrupt() and panics in that case, so
* exit the irq/nmi before calling die.
*/
if (!IS_ENABLED(CONFIG_PPC_BOOK3S_64))
nmi_exit();
die(str, regs, err);
}
NOKPROBE_SYMBOL(die_mce);

void machine_check_exception(struct pt_regs *regs)
{
int recover = 0;
Expand Down Expand Up @@ -831,15 +844,11 @@ void machine_check_exception(struct pt_regs *regs)
if (check_io_access(regs))
goto bail;

if (nmi) nmi_exit();

die("Machine check", regs, SIGBUS);
die_mce("Machine check", regs, SIGBUS);

/* Must die if the interrupt is not recoverable */
if (!(regs->msr & MSR_RI))
die("Unrecoverable Machine check", regs, SIGBUS);

return;
die_mce("Unrecoverable Machine check", regs, SIGBUS);

bail:
if (nmi) nmi_exit();
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/powernv/opal.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ static int opal_recover_mce(struct pt_regs *regs,
*/
recovered = 0;
} else {
die("Machine check", regs, SIGBUS);
die_mce("Machine check", regs, SIGBUS);
recovered = 1;
}
}
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/pseries/ras.c
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ static int recover_mce(struct pt_regs *regs, struct machine_check_event *evt)
*/
recovered = 0;
} else {
die("Machine check", regs, SIGBUS);
die_mce("Machine check", regs, SIGBUS);
recovered = 1;
}
}
Expand Down

0 comments on commit 209e9d5

Please sign in to comment.