xref: /linux/arch/s390/kernel/nmi.c (revision dc6e15556a9f21d640a62ae6de3cbfa68ec687a4)
1f5daba1dSHeiko Carstens /*
2f5daba1dSHeiko Carstens  *   Machine check handler
3f5daba1dSHeiko Carstens  *
4f5daba1dSHeiko Carstens  *    Copyright IBM Corp. 2000, 2009
5f5daba1dSHeiko Carstens  *    Author(s): Ingo Adlung <adlung@de.ibm.com>,
6f5daba1dSHeiko Carstens  *		 Martin Schwidefsky <schwidefsky@de.ibm.com>,
7f5daba1dSHeiko Carstens  *		 Cornelia Huck <cornelia.huck@de.ibm.com>,
8f5daba1dSHeiko Carstens  *		 Heiko Carstens <heiko.carstens@de.ibm.com>,
9f5daba1dSHeiko Carstens  */
10f5daba1dSHeiko Carstens 
11052ff461SHeiko Carstens #include <linux/kernel_stat.h>
12f5daba1dSHeiko Carstens #include <linux/init.h>
13f5daba1dSHeiko Carstens #include <linux/errno.h>
1481f64b87SHeiko Carstens #include <linux/hardirq.h>
15f5daba1dSHeiko Carstens #include <linux/time.h>
16f5daba1dSHeiko Carstens #include <linux/module.h>
17f5daba1dSHeiko Carstens #include <asm/lowcore.h>
18f5daba1dSHeiko Carstens #include <asm/smp.h>
19f5daba1dSHeiko Carstens #include <asm/etr.h>
2076d4e00aSMartin Schwidefsky #include <asm/cputime.h>
21f5daba1dSHeiko Carstens #include <asm/nmi.h>
22f5daba1dSHeiko Carstens #include <asm/crw.h>
2380703617SMartin Schwidefsky #include <asm/switch_to.h>
24cad49cfcSHeiko Carstens #include <asm/ctl_reg.h>
25f5daba1dSHeiko Carstens 
26f5daba1dSHeiko Carstens struct mcck_struct {
27f5daba1dSHeiko Carstens 	int kill_task;
28f5daba1dSHeiko Carstens 	int channel_report;
29f5daba1dSHeiko Carstens 	int warning;
3029b0a825SHeiko Carstens 	unsigned int etr_queue : 1;
3129b0a825SHeiko Carstens 	unsigned int stp_queue : 1;
32*dc6e1555SHeiko Carstens 	unsigned long mcck_code;
33f5daba1dSHeiko Carstens };
34f5daba1dSHeiko Carstens 
35f5daba1dSHeiko Carstens static DEFINE_PER_CPU(struct mcck_struct, cpu_mcck);
36f5daba1dSHeiko Carstens 
373d68286aSHeiko Carstens static void s390_handle_damage(void)
38f5daba1dSHeiko Carstens {
39f5daba1dSHeiko Carstens 	smp_send_stop();
40f5daba1dSHeiko Carstens 	disabled_wait((unsigned long) __builtin_return_address(0));
41f5daba1dSHeiko Carstens 	while (1);
42f5daba1dSHeiko Carstens }
43f5daba1dSHeiko Carstens 
44f5daba1dSHeiko Carstens /*
45f5daba1dSHeiko Carstens  * Main machine check handler function. Will be called with interrupts enabled
46f5daba1dSHeiko Carstens  * or disabled and machine checks enabled or disabled.
47f5daba1dSHeiko Carstens  */
48f5daba1dSHeiko Carstens void s390_handle_mcck(void)
49f5daba1dSHeiko Carstens {
50f5daba1dSHeiko Carstens 	unsigned long flags;
51f5daba1dSHeiko Carstens 	struct mcck_struct mcck;
52f5daba1dSHeiko Carstens 
53f5daba1dSHeiko Carstens 	/*
54f5daba1dSHeiko Carstens 	 * Disable machine checks and get the current state of accumulated
55f5daba1dSHeiko Carstens 	 * machine checks. Afterwards delete the old state and enable machine
56f5daba1dSHeiko Carstens 	 * checks again.
57f5daba1dSHeiko Carstens 	 */
58f5daba1dSHeiko Carstens 	local_irq_save(flags);
59f5daba1dSHeiko Carstens 	local_mcck_disable();
602cb4a182SSebastian Ott 	mcck = *this_cpu_ptr(&cpu_mcck);
612cb4a182SSebastian Ott 	memset(this_cpu_ptr(&cpu_mcck), 0, sizeof(mcck));
62d3a73acbSMartin Schwidefsky 	clear_cpu_flag(CIF_MCCK_PENDING);
63f5daba1dSHeiko Carstens 	local_mcck_enable();
64f5daba1dSHeiko Carstens 	local_irq_restore(flags);
65f5daba1dSHeiko Carstens 
66f5daba1dSHeiko Carstens 	if (mcck.channel_report)
67f5daba1dSHeiko Carstens 		crw_handle_channel_report();
68f5daba1dSHeiko Carstens 	/*
697b886416SHeiko Carstens 	 * A warning may remain for a prolonged period on the bare iron.
707b886416SHeiko Carstens 	 * (actually until the machine is powered off, or the problem is gone)
717b886416SHeiko Carstens 	 * So we just stop listening for the WARNING MCH and avoid continuously
72f5daba1dSHeiko Carstens 	 * being interrupted.  One caveat is however, that we must do this per
73f5daba1dSHeiko Carstens 	 * processor and cannot use the smp version of ctl_clear_bit().
74f5daba1dSHeiko Carstens 	 * On VM we only get one interrupt per virtally presented machinecheck.
757b886416SHeiko Carstens 	 * Though one suffices, we may get one interrupt per (virtual) cpu.
76f5daba1dSHeiko Carstens 	 */
77f5daba1dSHeiko Carstens 	if (mcck.warning) {	/* WARNING pending ? */
78f5daba1dSHeiko Carstens 		static int mchchk_wng_posted = 0;
797b886416SHeiko Carstens 
807b886416SHeiko Carstens 		/* Use single cpu clear, as we cannot handle smp here. */
81f5daba1dSHeiko Carstens 		__ctl_clear_bit(14, 24);	/* Disable WARNING MCH */
82f5daba1dSHeiko Carstens 		if (xchg(&mchchk_wng_posted, 1) == 0)
83f5daba1dSHeiko Carstens 			kill_cad_pid(SIGPWR, 1);
84f5daba1dSHeiko Carstens 	}
8529b0a825SHeiko Carstens 	if (mcck.etr_queue)
8629b0a825SHeiko Carstens 		etr_queue_work();
8729b0a825SHeiko Carstens 	if (mcck.stp_queue)
8829b0a825SHeiko Carstens 		stp_queue_work();
89f5daba1dSHeiko Carstens 	if (mcck.kill_task) {
90f5daba1dSHeiko Carstens 		local_irq_enable();
91f5daba1dSHeiko Carstens 		printk(KERN_EMERG "mcck: Terminating task because of machine "
92*dc6e1555SHeiko Carstens 		       "malfunction (code 0x%016lx).\n", mcck.mcck_code);
93f5daba1dSHeiko Carstens 		printk(KERN_EMERG "mcck: task: %s, pid: %d.\n",
94f5daba1dSHeiko Carstens 		       current->comm, current->pid);
95f5daba1dSHeiko Carstens 		do_exit(SIGSEGV);
96f5daba1dSHeiko Carstens 	}
97f5daba1dSHeiko Carstens }
98f5daba1dSHeiko Carstens EXPORT_SYMBOL_GPL(s390_handle_mcck);
99f5daba1dSHeiko Carstens 
100f5daba1dSHeiko Carstens /*
101f5daba1dSHeiko Carstens  * returns 0 if all registers could be validated
102f5daba1dSHeiko Carstens  * returns 1 otherwise
103f5daba1dSHeiko Carstens  */
104*dc6e1555SHeiko Carstens static int notrace s390_revalidate_registers(union mci mci)
105f5daba1dSHeiko Carstens {
106f5daba1dSHeiko Carstens 	int kill_task;
107f5daba1dSHeiko Carstens 	u64 zero;
108f5daba1dSHeiko Carstens 	void *fpt_save_area, *fpt_creg_save_area;
109f5daba1dSHeiko Carstens 
110f5daba1dSHeiko Carstens 	kill_task = 0;
111f5daba1dSHeiko Carstens 	zero = 0;
112f5daba1dSHeiko Carstens 
113*dc6e1555SHeiko Carstens 	if (!mci.gr) {
114f5daba1dSHeiko Carstens 		/*
115f5daba1dSHeiko Carstens 		 * General purpose registers couldn't be restored and have
116f5daba1dSHeiko Carstens 		 * unknown contents. Process needs to be terminated.
117f5daba1dSHeiko Carstens 		 */
118f5daba1dSHeiko Carstens 		kill_task = 1;
119f5daba1dSHeiko Carstens 	}
120*dc6e1555SHeiko Carstens 	if (!mci.fp) {
121f5daba1dSHeiko Carstens 		/*
122f5daba1dSHeiko Carstens 		 * Floating point registers can't be restored and
123f5daba1dSHeiko Carstens 		 * therefore the process needs to be terminated.
124f5daba1dSHeiko Carstens 		 */
125f5daba1dSHeiko Carstens 		kill_task = 1;
126f5daba1dSHeiko Carstens 	}
127f5daba1dSHeiko Carstens 	fpt_save_area = &S390_lowcore.floating_pt_save_area;
128f5daba1dSHeiko Carstens 	fpt_creg_save_area = &S390_lowcore.fpt_creg_save_area;
129*dc6e1555SHeiko Carstens 	if (!mci.fc) {
130f5daba1dSHeiko Carstens 		/*
131f5daba1dSHeiko Carstens 		 * Floating point control register can't be restored.
132f5daba1dSHeiko Carstens 		 * Task will be terminated.
133f5daba1dSHeiko Carstens 		 */
134f5daba1dSHeiko Carstens 		asm volatile("lfpc 0(%0)" : : "a" (&zero), "m" (zero));
135f5daba1dSHeiko Carstens 		kill_task = 1;
136f5daba1dSHeiko Carstens 	} else
137f5daba1dSHeiko Carstens 		asm volatile("lfpc 0(%0)" : : "a" (fpt_creg_save_area));
138f5daba1dSHeiko Carstens 
139cad49cfcSHeiko Carstens 	if (!MACHINE_HAS_VX) {
140cad49cfcSHeiko Carstens 		/* Revalidate floating point registers */
141f5daba1dSHeiko Carstens 		asm volatile(
142f5daba1dSHeiko Carstens 			"	ld	0,0(%0)\n"
143f5daba1dSHeiko Carstens 			"	ld	1,8(%0)\n"
144f5daba1dSHeiko Carstens 			"	ld	2,16(%0)\n"
145f5daba1dSHeiko Carstens 			"	ld	3,24(%0)\n"
146f5daba1dSHeiko Carstens 			"	ld	4,32(%0)\n"
147f5daba1dSHeiko Carstens 			"	ld	5,40(%0)\n"
148f5daba1dSHeiko Carstens 			"	ld	6,48(%0)\n"
149f5daba1dSHeiko Carstens 			"	ld	7,56(%0)\n"
150f5daba1dSHeiko Carstens 			"	ld	8,64(%0)\n"
151f5daba1dSHeiko Carstens 			"	ld	9,72(%0)\n"
152f5daba1dSHeiko Carstens 			"	ld	10,80(%0)\n"
153f5daba1dSHeiko Carstens 			"	ld	11,88(%0)\n"
154f5daba1dSHeiko Carstens 			"	ld	12,96(%0)\n"
155f5daba1dSHeiko Carstens 			"	ld	13,104(%0)\n"
156f5daba1dSHeiko Carstens 			"	ld	14,112(%0)\n"
157f5daba1dSHeiko Carstens 			"	ld	15,120(%0)\n"
158f5daba1dSHeiko Carstens 			: : "a" (fpt_save_area));
159cad49cfcSHeiko Carstens 	} else {
16080703617SMartin Schwidefsky 		/* Revalidate vector registers */
161cad49cfcSHeiko Carstens 		union ctlreg0 cr0;
162cad49cfcSHeiko Carstens 
163*dc6e1555SHeiko Carstens 		if (!mci.vr) {
16480703617SMartin Schwidefsky 			/*
16580703617SMartin Schwidefsky 			 * Vector registers can't be restored and therefore
16680703617SMartin Schwidefsky 			 * the process needs to be terminated.
16780703617SMartin Schwidefsky 			 */
16880703617SMartin Schwidefsky 			kill_task = 1;
16980703617SMartin Schwidefsky 		}
170cad49cfcSHeiko Carstens 		cr0.val = S390_lowcore.cregs_save_area[0];
171cad49cfcSHeiko Carstens 		cr0.afp = cr0.vx = 1;
172cad49cfcSHeiko Carstens 		__ctl_load(cr0.val, 0, 0);
1739977e886SHendrik Brueckner 		asm volatile(
1749977e886SHendrik Brueckner 			"	la	1,%0\n"
1759977e886SHendrik Brueckner 			"	.word	0xe70f,0x1000,0x0036\n"	/* vlm 0,15,0(1) */
1769977e886SHendrik Brueckner 			"	.word	0xe70f,0x1100,0x0c36\n"	/* vlm 16,31,256(1) */
1779977e886SHendrik Brueckner 			: : "Q" (*(struct vx_array *)
1789977e886SHendrik Brueckner 				 &S390_lowcore.vector_save_area) : "1");
179cad49cfcSHeiko Carstens 		__ctl_load(S390_lowcore.cregs_save_area[0], 0, 0);
18080703617SMartin Schwidefsky 	}
181f5daba1dSHeiko Carstens 	/* Revalidate access registers */
182f5daba1dSHeiko Carstens 	asm volatile(
183f5daba1dSHeiko Carstens 		"	lam	0,15,0(%0)"
184f5daba1dSHeiko Carstens 		: : "a" (&S390_lowcore.access_regs_save_area));
185*dc6e1555SHeiko Carstens 	if (!mci.ar) {
186f5daba1dSHeiko Carstens 		/*
187f5daba1dSHeiko Carstens 		 * Access registers have unknown contents.
188f5daba1dSHeiko Carstens 		 * Terminating task.
189f5daba1dSHeiko Carstens 		 */
190f5daba1dSHeiko Carstens 		kill_task = 1;
191f5daba1dSHeiko Carstens 	}
192f5daba1dSHeiko Carstens 	/* Revalidate control registers */
193*dc6e1555SHeiko Carstens 	if (!mci.cr) {
194f5daba1dSHeiko Carstens 		/*
195f5daba1dSHeiko Carstens 		 * Control registers have unknown contents.
196f5daba1dSHeiko Carstens 		 * Can't recover and therefore stopping machine.
197f5daba1dSHeiko Carstens 		 */
1983d68286aSHeiko Carstens 		s390_handle_damage();
199f5daba1dSHeiko Carstens 	} else {
200f5daba1dSHeiko Carstens 		asm volatile(
201f5daba1dSHeiko Carstens 			"	lctlg	0,15,0(%0)"
202f5daba1dSHeiko Carstens 			: : "a" (&S390_lowcore.cregs_save_area));
203f5daba1dSHeiko Carstens 	}
204f5daba1dSHeiko Carstens 	/*
205f5daba1dSHeiko Carstens 	 * We don't even try to revalidate the TOD register, since we simply
206f5daba1dSHeiko Carstens 	 * can't write something sensible into that register.
207f5daba1dSHeiko Carstens 	 */
208f5daba1dSHeiko Carstens 	/*
209f5daba1dSHeiko Carstens 	 * See if we can revalidate the TOD programmable register with its
210f5daba1dSHeiko Carstens 	 * old contents (should be zero) otherwise set it to zero.
211f5daba1dSHeiko Carstens 	 */
212*dc6e1555SHeiko Carstens 	if (!mci.pr)
213f5daba1dSHeiko Carstens 		asm volatile(
214f5daba1dSHeiko Carstens 			"	sr	0,0\n"
215f5daba1dSHeiko Carstens 			"	sckpf"
216f5daba1dSHeiko Carstens 			: : : "0", "cc");
217f5daba1dSHeiko Carstens 	else
218f5daba1dSHeiko Carstens 		asm volatile(
219f5daba1dSHeiko Carstens 			"	l	0,0(%0)\n"
220f5daba1dSHeiko Carstens 			"	sckpf"
221f5daba1dSHeiko Carstens 			: : "a" (&S390_lowcore.tod_progreg_save_area)
222f5daba1dSHeiko Carstens 			: "0", "cc");
223f5daba1dSHeiko Carstens 	/* Revalidate clock comparator register */
224e8129c64SHeiko Carstens 	set_clock_comparator(S390_lowcore.clock_comparator);
225f5daba1dSHeiko Carstens 	/* Check if old PSW is valid */
226*dc6e1555SHeiko Carstens 	if (!mci.wp)
227f5daba1dSHeiko Carstens 		/*
228f5daba1dSHeiko Carstens 		 * Can't tell if we come from user or kernel mode
229f5daba1dSHeiko Carstens 		 * -> stopping machine.
230f5daba1dSHeiko Carstens 		 */
2313d68286aSHeiko Carstens 		s390_handle_damage();
232f5daba1dSHeiko Carstens 
233*dc6e1555SHeiko Carstens 	if (!mci.ms || !mci.pm || !mci.ia)
234f5daba1dSHeiko Carstens 		kill_task = 1;
235f5daba1dSHeiko Carstens 
236f5daba1dSHeiko Carstens 	return kill_task;
237f5daba1dSHeiko Carstens }
238f5daba1dSHeiko Carstens 
239f5daba1dSHeiko Carstens #define MAX_IPD_COUNT	29
240f5daba1dSHeiko Carstens #define MAX_IPD_TIME	(5 * 60 * USEC_PER_SEC) /* 5 minutes */
241f5daba1dSHeiko Carstens 
242f5daba1dSHeiko Carstens #define ED_STP_ISLAND	6	/* External damage STP island check */
243f5daba1dSHeiko Carstens #define ED_STP_SYNC	7	/* External damage STP sync check */
244f5daba1dSHeiko Carstens #define ED_ETR_SYNC	12	/* External damage ETR sync check */
245f5daba1dSHeiko Carstens #define ED_ETR_SWITCH	13	/* External damage ETR switch to local */
246f5daba1dSHeiko Carstens 
247f5daba1dSHeiko Carstens /*
248f5daba1dSHeiko Carstens  * machine check handler.
249f5daba1dSHeiko Carstens  */
250f5daba1dSHeiko Carstens void notrace s390_do_machine_check(struct pt_regs *regs)
251f5daba1dSHeiko Carstens {
252f5daba1dSHeiko Carstens 	static int ipd_count;
253f5daba1dSHeiko Carstens 	static DEFINE_SPINLOCK(ipd_lock);
254f5daba1dSHeiko Carstens 	static unsigned long long last_ipd;
255f5daba1dSHeiko Carstens 	struct mcck_struct *mcck;
256f5daba1dSHeiko Carstens 	unsigned long long tmp;
257*dc6e1555SHeiko Carstens 	union mci mci;
258f5daba1dSHeiko Carstens 	int umode;
259f5daba1dSHeiko Carstens 
26081f64b87SHeiko Carstens 	nmi_enter();
261420f42ecSHeiko Carstens 	inc_irq_stat(NMI_NMI);
262*dc6e1555SHeiko Carstens 	mci.val = S390_lowcore.mcck_interruption_code;
263eb7e7d76SChristoph Lameter 	mcck = this_cpu_ptr(&cpu_mcck);
264f5daba1dSHeiko Carstens 	umode = user_mode(regs);
265f5daba1dSHeiko Carstens 
266*dc6e1555SHeiko Carstens 	if (mci.sd) {
267f5daba1dSHeiko Carstens 		/* System damage -> stopping machine */
2683d68286aSHeiko Carstens 		s390_handle_damage();
269f5daba1dSHeiko Carstens 	}
270*dc6e1555SHeiko Carstens 	if (mci.pd) {
271*dc6e1555SHeiko Carstens 		if (mci.b) {
272f5daba1dSHeiko Carstens 			/* Processing backup -> verify if we can survive this */
273f5daba1dSHeiko Carstens 			u64 z_mcic, o_mcic, t_mcic;
274f5daba1dSHeiko Carstens 			z_mcic = (1ULL<<63 | 1ULL<<59 | 1ULL<<29);
275f5daba1dSHeiko Carstens 			o_mcic = (1ULL<<43 | 1ULL<<42 | 1ULL<<41 | 1ULL<<40 |
276f5daba1dSHeiko Carstens 				  1ULL<<36 | 1ULL<<35 | 1ULL<<34 | 1ULL<<32 |
277f5daba1dSHeiko Carstens 				  1ULL<<30 | 1ULL<<21 | 1ULL<<20 | 1ULL<<17 |
278f5daba1dSHeiko Carstens 				  1ULL<<16);
279*dc6e1555SHeiko Carstens 			t_mcic = mci.val;
280f5daba1dSHeiko Carstens 
281f5daba1dSHeiko Carstens 			if (((t_mcic & z_mcic) != 0) ||
282f5daba1dSHeiko Carstens 			    ((t_mcic & o_mcic) != o_mcic)) {
2833d68286aSHeiko Carstens 				s390_handle_damage();
284f5daba1dSHeiko Carstens 			}
285f5daba1dSHeiko Carstens 
286f5daba1dSHeiko Carstens 			/*
287f5daba1dSHeiko Carstens 			 * Nullifying exigent condition, therefore we might
288f5daba1dSHeiko Carstens 			 * retry this instruction.
289f5daba1dSHeiko Carstens 			 */
290f5daba1dSHeiko Carstens 			spin_lock(&ipd_lock);
2911aae0560SHeiko Carstens 			tmp = get_tod_clock();
292f5daba1dSHeiko Carstens 			if (((tmp - last_ipd) >> 12) < MAX_IPD_TIME)
293f5daba1dSHeiko Carstens 				ipd_count++;
294f5daba1dSHeiko Carstens 			else
295f5daba1dSHeiko Carstens 				ipd_count = 1;
296f5daba1dSHeiko Carstens 			last_ipd = tmp;
297f5daba1dSHeiko Carstens 			if (ipd_count == MAX_IPD_COUNT)
2983d68286aSHeiko Carstens 				s390_handle_damage();
299f5daba1dSHeiko Carstens 			spin_unlock(&ipd_lock);
300f5daba1dSHeiko Carstens 		} else {
301f5daba1dSHeiko Carstens 			/* Processing damage -> stopping machine */
3023d68286aSHeiko Carstens 			s390_handle_damage();
303f5daba1dSHeiko Carstens 		}
304f5daba1dSHeiko Carstens 	}
305f5daba1dSHeiko Carstens 	if (s390_revalidate_registers(mci)) {
306f5daba1dSHeiko Carstens 		if (umode) {
307f5daba1dSHeiko Carstens 			/*
308f5daba1dSHeiko Carstens 			 * Couldn't restore all register contents while in
309f5daba1dSHeiko Carstens 			 * user mode -> mark task for termination.
310f5daba1dSHeiko Carstens 			 */
311f5daba1dSHeiko Carstens 			mcck->kill_task = 1;
312*dc6e1555SHeiko Carstens 			mcck->mcck_code = mci.val;
313d3a73acbSMartin Schwidefsky 			set_cpu_flag(CIF_MCCK_PENDING);
314f5daba1dSHeiko Carstens 		} else {
315f5daba1dSHeiko Carstens 			/*
316f5daba1dSHeiko Carstens 			 * Couldn't restore all register contents while in
317f5daba1dSHeiko Carstens 			 * kernel mode -> stopping machine.
318f5daba1dSHeiko Carstens 			 */
3193d68286aSHeiko Carstens 			s390_handle_damage();
320f5daba1dSHeiko Carstens 		}
321f5daba1dSHeiko Carstens 	}
322*dc6e1555SHeiko Carstens 	if (mci.cd) {
323f5daba1dSHeiko Carstens 		/* Timing facility damage */
3243d68286aSHeiko Carstens 		s390_handle_damage();
325f5daba1dSHeiko Carstens 	}
326*dc6e1555SHeiko Carstens 	if (mci.ed && mci.ec) {
327f5daba1dSHeiko Carstens 		/* External damage */
328f5daba1dSHeiko Carstens 		if (S390_lowcore.external_damage_code & (1U << ED_ETR_SYNC))
32929b0a825SHeiko Carstens 			mcck->etr_queue |= etr_sync_check();
330f5daba1dSHeiko Carstens 		if (S390_lowcore.external_damage_code & (1U << ED_ETR_SWITCH))
33129b0a825SHeiko Carstens 			mcck->etr_queue |= etr_switch_to_local();
332f5daba1dSHeiko Carstens 		if (S390_lowcore.external_damage_code & (1U << ED_STP_SYNC))
33329b0a825SHeiko Carstens 			mcck->stp_queue |= stp_sync_check();
334f5daba1dSHeiko Carstens 		if (S390_lowcore.external_damage_code & (1U << ED_STP_ISLAND))
33529b0a825SHeiko Carstens 			mcck->stp_queue |= stp_island_check();
33629b0a825SHeiko Carstens 		if (mcck->etr_queue || mcck->stp_queue)
33729b0a825SHeiko Carstens 			set_cpu_flag(CIF_MCCK_PENDING);
338f5daba1dSHeiko Carstens 	}
339*dc6e1555SHeiko Carstens 	if (mci.se)
340f5daba1dSHeiko Carstens 		/* Storage error uncorrected */
3413d68286aSHeiko Carstens 		s390_handle_damage();
342*dc6e1555SHeiko Carstens 	if (mci.ke)
343f5daba1dSHeiko Carstens 		/* Storage key-error uncorrected */
3443d68286aSHeiko Carstens 		s390_handle_damage();
345*dc6e1555SHeiko Carstens 	if (mci.ds && mci.fa)
346f5daba1dSHeiko Carstens 		/* Storage degradation */
3473d68286aSHeiko Carstens 		s390_handle_damage();
348*dc6e1555SHeiko Carstens 	if (mci.cp) {
349f5daba1dSHeiko Carstens 		/* Channel report word pending */
350f5daba1dSHeiko Carstens 		mcck->channel_report = 1;
351d3a73acbSMartin Schwidefsky 		set_cpu_flag(CIF_MCCK_PENDING);
352f5daba1dSHeiko Carstens 	}
353*dc6e1555SHeiko Carstens 	if (mci.w) {
354f5daba1dSHeiko Carstens 		/* Warning pending */
355f5daba1dSHeiko Carstens 		mcck->warning = 1;
356d3a73acbSMartin Schwidefsky 		set_cpu_flag(CIF_MCCK_PENDING);
357f5daba1dSHeiko Carstens 	}
35881f64b87SHeiko Carstens 	nmi_exit();
359f5daba1dSHeiko Carstens }
360f5daba1dSHeiko Carstens 
361f5daba1dSHeiko Carstens static int __init machine_check_init(void)
362f5daba1dSHeiko Carstens {
363f5daba1dSHeiko Carstens 	ctl_set_bit(14, 25);	/* enable external damage MCH */
364f5daba1dSHeiko Carstens 	ctl_set_bit(14, 27);	/* enable system recovery MCH */
365f5daba1dSHeiko Carstens 	ctl_set_bit(14, 24);	/* enable warning MCH */
366f5daba1dSHeiko Carstens 	return 0;
367f5daba1dSHeiko Carstens }
36824d05ff8SHeiko Carstens early_initcall(machine_check_init);
369