blob: be9a0bebe61e7395d218310cf8dec1536573ac4e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
// SPDX-License-Identifier: GPL-2.0
#include <linux/kernel.h>
#include <linux/kgdb.h>
#include <linux/printk.h>
#include <linux/sched/debug.h>
#include <linux/delay.h>
#include <linux/reboot.h>
#include <asm/pdc.h>
#include <asm/pdc_chassis.h>
#include <asm/ldcw.h>
static unsigned int __aligned(16) toc_lock = 1;
DEFINE_PER_CPU_PAGE_ALIGNED(char [16384], toc_stack);
static void toc20_to_pt_regs(struct pt_regs *regs, struct pdc_toc_pim_20 *toc)
{
int i;
regs->gr[0] = (unsigned long)toc->cr[22];
for (i = 1; i < 32; i++)
regs->gr[i] = (unsigned long)toc->gr[i];
for (i = 0; i < 8; i++)
regs->sr[i] = (unsigned long)toc->sr[i];
regs->iasq[0] = (unsigned long)toc->cr[17];
regs->iasq[1] = (unsigned long)toc->iasq_back;
regs->iaoq[0] = (unsigned long)toc->cr[18];
regs->iaoq[1] = (unsigned long)toc->iaoq_back;
regs->sar = (unsigned long)toc->cr[11];
regs->iir = (unsigned long)toc->cr[19];
regs->isr = (unsigned long)toc->cr[20];
regs->ior = (unsigned long)toc->cr[21];
}
static void toc11_to_pt_regs(struct pt_regs *regs, struct pdc_toc_pim_11 *toc)
{
int i;
regs->gr[0] = toc->cr[22];
for (i = 1; i < 32; i++)
regs->gr[i] = toc->gr[i];
for (i = 0; i < 8; i++)
regs->sr[i] = toc->sr[i];
regs->iasq[0] = toc->cr[17];
regs->iasq[1] = toc->iasq_back;
regs->iaoq[0] = toc->cr[18];
regs->iaoq[1] = toc->iaoq_back;
regs->sar = toc->cr[11];
regs->iir = toc->cr[19];
regs->isr = toc->cr[20];
regs->ior = toc->cr[21];
}
void notrace __noreturn __cold toc_intr(struct pt_regs *regs)
{
struct pdc_toc_pim_20 pim_data20;
struct pdc_toc_pim_11 pim_data11;
/* verify we wrote regs to the correct stack */
BUG_ON(regs != (struct pt_regs *)&per_cpu(toc_stack, raw_smp_processor_id()));
if (boot_cpu_data.cpu_type >= pcxu) {
if (pdc_pim_toc20(&pim_data20))
panic("Failed to get PIM data");
toc20_to_pt_regs(regs, &pim_data20);
} else {
if (pdc_pim_toc11(&pim_data11))
panic("Failed to get PIM data");
toc11_to_pt_regs(regs, &pim_data11);
}
#ifdef CONFIG_KGDB
nmi_enter();
if (atomic_read(&kgdb_active) != -1)
kgdb_nmicallback(raw_smp_processor_id(), regs);
kgdb_handle_exception(9, SIGTRAP, 0, regs);
#endif
/* serialize output, otherwise all CPUs write backtrace at once */
while (__ldcw(&toc_lock) == 0)
; /* wait */
show_regs(regs);
toc_lock = 1; /* release lock for next CPU */
if (raw_smp_processor_id() != 0)
while (1) ; /* all but monarch CPU will wait endless. */
/* give other CPUs time to show their backtrace */
mdelay(2000);
machine_restart("TOC");
/* should never reach this */
panic("TOC");
}
static __init int setup_toc(void)
{
unsigned int csum = 0;
unsigned long toc_code = (unsigned long)dereference_function_descriptor(toc_handler);
int i;
PAGE0->vec_toc = __pa(toc_code) & 0xffffffff;
#ifdef CONFIG_64BIT
PAGE0->vec_toc_hi = __pa(toc_code) >> 32;
#endif
PAGE0->vec_toclen = toc_handler_size;
for (i = 0; i < toc_handler_size/4; i++)
csum += ((u32 *)toc_code)[i];
toc_handler_csum = -csum;
pr_info("TOC handler registered\n");
return 0;
}
early_initcall(setup_toc);
|