18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci */
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include <linux/kernel.h>
68c2ecf20Sopenharmony_ci#include <linux/printk.h>
78c2ecf20Sopenharmony_ci#include <linux/ptrace.h>
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <asm/reg.h>
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ciint machine_check_8xx(struct pt_regs *regs)
128c2ecf20Sopenharmony_ci{
138c2ecf20Sopenharmony_ci	unsigned long reason = regs->msr;
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci	pr_err("Machine check in kernel mode.\n");
168c2ecf20Sopenharmony_ci	pr_err("Caused by (from SRR1=%lx): ", reason);
178c2ecf20Sopenharmony_ci	if (reason & 0x40000000)
188c2ecf20Sopenharmony_ci		pr_cont("Fetch error at address %lx\n", regs->nip);
198c2ecf20Sopenharmony_ci	else
208c2ecf20Sopenharmony_ci		pr_cont("Data access error at address %lx\n", regs->dar);
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#ifdef CONFIG_PCI
238c2ecf20Sopenharmony_ci	/* the qspan pci read routines can cause machine checks -- Cort
248c2ecf20Sopenharmony_ci	 *
258c2ecf20Sopenharmony_ci	 * yuck !!! that totally needs to go away ! There are better ways
268c2ecf20Sopenharmony_ci	 * to deal with that than having a wart in the mcheck handler.
278c2ecf20Sopenharmony_ci	 * -- BenH
288c2ecf20Sopenharmony_ci	 */
298c2ecf20Sopenharmony_ci	bad_page_fault(regs, regs->dar, SIGBUS);
308c2ecf20Sopenharmony_ci	return 1;
318c2ecf20Sopenharmony_ci#else
328c2ecf20Sopenharmony_ci	return 0;
338c2ecf20Sopenharmony_ci#endif
348c2ecf20Sopenharmony_ci}
35