Joel Stanley | 968bb76 | 2017-10-04 14:12:27 +1030 | [diff] [blame] | 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| 2 | From: Michael Ellerman <mpe@ellerman.id.au> |
| 3 | Date: Wed, 4 Oct 2017 13:42:51 +1100 |
| 4 | Subject: [PATCH 2/4] powerpc/mce: Move 64-bit machine check code into mce.c |
| 5 | |
| 6 | We already have mce.c which is built for 64bit and contains other parts |
| 7 | of the machine check code, so move these bits in there too. |
| 8 | |
| 9 | Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> |
| 10 | (cherry picked from commit ccd3cd361341b71ae2afa596f6b470fcb32a916e) |
| 11 | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com> |
| 12 | Signed-off-by: Joel Stanley <joel@jms.id.au> |
| 13 | --- |
| 14 | arch/powerpc/kernel/mce.c | 33 +++++++++++++++++++++++++++++++++ |
| 15 | arch/powerpc/kernel/traps.c | 33 --------------------------------- |
| 16 | 2 files changed, 33 insertions(+), 33 deletions(-) |
| 17 | |
| 18 | diff --git a/arch/powerpc/kernel/mce.c b/arch/powerpc/kernel/mce.c |
| 19 | index e0e131e662ed..9b2ea7e71c06 100644 |
| 20 | --- a/arch/powerpc/kernel/mce.c |
| 21 | +++ b/arch/powerpc/kernel/mce.c |
| 22 | @@ -22,11 +22,14 @@ |
| 23 | #undef DEBUG |
| 24 | #define pr_fmt(fmt) "mce: " fmt |
| 25 | |
| 26 | +#include <linux/hardirq.h> |
| 27 | #include <linux/types.h> |
| 28 | #include <linux/ptrace.h> |
| 29 | #include <linux/percpu.h> |
| 30 | #include <linux/export.h> |
| 31 | #include <linux/irq_work.h> |
| 32 | + |
| 33 | +#include <asm/machdep.h> |
| 34 | #include <asm/mce.h> |
| 35 | |
| 36 | static DEFINE_PER_CPU(int, mce_nest_count); |
| 37 | @@ -446,3 +449,33 @@ uint64_t get_mce_fault_addr(struct machine_check_event *evt) |
| 38 | return 0; |
| 39 | } |
| 40 | EXPORT_SYMBOL(get_mce_fault_addr); |
| 41 | + |
| 42 | +/* |
| 43 | + * This function is called in real mode. Strictly no printk's please. |
| 44 | + * |
| 45 | + * regs->nip and regs->msr contains srr0 and ssr1. |
| 46 | + */ |
| 47 | +long machine_check_early(struct pt_regs *regs) |
| 48 | +{ |
| 49 | + long handled = 0; |
| 50 | + |
| 51 | + __this_cpu_inc(irq_stat.mce_exceptions); |
| 52 | + |
| 53 | + if (cur_cpu_spec && cur_cpu_spec->machine_check_early) |
| 54 | + handled = cur_cpu_spec->machine_check_early(regs); |
| 55 | + return handled; |
| 56 | +} |
| 57 | + |
| 58 | +long hmi_exception_realmode(struct pt_regs *regs) |
| 59 | +{ |
| 60 | + __this_cpu_inc(irq_stat.hmi_exceptions); |
| 61 | + |
| 62 | + wait_for_subcore_guest_exit(); |
| 63 | + |
| 64 | + if (ppc_md.hmi_exception_early) |
| 65 | + ppc_md.hmi_exception_early(regs); |
| 66 | + |
| 67 | + wait_for_tb_resync(); |
| 68 | + |
| 69 | + return 0; |
| 70 | +} |
| 71 | diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c |
| 72 | index bfcfd9ef09f2..559664e75fb5 100644 |
| 73 | --- a/arch/powerpc/kernel/traps.c |
| 74 | +++ b/arch/powerpc/kernel/traps.c |
| 75 | @@ -312,39 +312,6 @@ void system_reset_exception(struct pt_regs *regs) |
| 76 | /* What should we do here? We could issue a shutdown or hard reset. */ |
| 77 | } |
| 78 | |
| 79 | -#ifdef CONFIG_PPC64 |
| 80 | -/* |
| 81 | - * This function is called in real mode. Strictly no printk's please. |
| 82 | - * |
| 83 | - * regs->nip and regs->msr contains srr0 and ssr1. |
| 84 | - */ |
| 85 | -long machine_check_early(struct pt_regs *regs) |
| 86 | -{ |
| 87 | - long handled = 0; |
| 88 | - |
| 89 | - __this_cpu_inc(irq_stat.mce_exceptions); |
| 90 | - |
| 91 | - if (cur_cpu_spec && cur_cpu_spec->machine_check_early) |
| 92 | - handled = cur_cpu_spec->machine_check_early(regs); |
| 93 | - return handled; |
| 94 | -} |
| 95 | - |
| 96 | -long hmi_exception_realmode(struct pt_regs *regs) |
| 97 | -{ |
| 98 | - __this_cpu_inc(irq_stat.hmi_exceptions); |
| 99 | - |
| 100 | - wait_for_subcore_guest_exit(); |
| 101 | - |
| 102 | - if (ppc_md.hmi_exception_early) |
| 103 | - ppc_md.hmi_exception_early(regs); |
| 104 | - |
| 105 | - wait_for_tb_resync(); |
| 106 | - |
| 107 | - return 0; |
| 108 | -} |
| 109 | - |
| 110 | -#endif |
| 111 | - |
| 112 | /* |
| 113 | * I/O accesses can cause machine checks on powermacs. |
| 114 | * Check if the NIP corresponds to the address of a sync |