18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *   Machine check handler definitions
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *    Copyright IBM Corp. 2000, 2009
68c2ecf20Sopenharmony_ci *    Author(s): Ingo Adlung <adlung@de.ibm.com>,
78c2ecf20Sopenharmony_ci *		 Martin Schwidefsky <schwidefsky@de.ibm.com>,
88c2ecf20Sopenharmony_ci *		 Cornelia Huck <cornelia.huck@de.ibm.com>,
98c2ecf20Sopenharmony_ci *		 Heiko Carstens <heiko.carstens@de.ibm.com>,
108c2ecf20Sopenharmony_ci */
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#ifndef _ASM_S390_NMI_H
138c2ecf20Sopenharmony_ci#define _ASM_S390_NMI_H
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#include <linux/bits.h>
168c2ecf20Sopenharmony_ci#include <linux/types.h>
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#define MCIC_SUBCLASS_MASK	(1ULL<<63 | 1ULL<<62 | 1ULL<<61 | \
198c2ecf20Sopenharmony_ci				1ULL<<59 | 1ULL<<58 | 1ULL<<56 | \
208c2ecf20Sopenharmony_ci				1ULL<<55 | 1ULL<<54 | 1ULL<<53 | \
218c2ecf20Sopenharmony_ci				1ULL<<52 | 1ULL<<47 | 1ULL<<46 | \
228c2ecf20Sopenharmony_ci				1ULL<<45 | 1ULL<<44)
238c2ecf20Sopenharmony_ci#define MCCK_CODE_SYSTEM_DAMAGE		BIT(63)
248c2ecf20Sopenharmony_ci#define MCCK_CODE_EXT_DAMAGE		BIT(63 - 5)
258c2ecf20Sopenharmony_ci#define MCCK_CODE_CP			BIT(63 - 9)
268c2ecf20Sopenharmony_ci#define MCCK_CODE_CPU_TIMER_VALID	BIT(63 - 46)
278c2ecf20Sopenharmony_ci#define MCCK_CODE_PSW_MWP_VALID		BIT(63 - 20)
288c2ecf20Sopenharmony_ci#define MCCK_CODE_PSW_IA_VALID		BIT(63 - 23)
298c2ecf20Sopenharmony_ci#define MCCK_CODE_CR_VALID		BIT(63 - 29)
308c2ecf20Sopenharmony_ci#define MCCK_CODE_GS_VALID		BIT(63 - 36)
318c2ecf20Sopenharmony_ci#define MCCK_CODE_FC_VALID		BIT(63 - 43)
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ciunion mci {
368c2ecf20Sopenharmony_ci	unsigned long val;
378c2ecf20Sopenharmony_ci	struct {
388c2ecf20Sopenharmony_ci		u64 sd :  1; /* 00 system damage */
398c2ecf20Sopenharmony_ci		u64 pd :  1; /* 01 instruction-processing damage */
408c2ecf20Sopenharmony_ci		u64 sr :  1; /* 02 system recovery */
418c2ecf20Sopenharmony_ci		u64    :  1; /* 03 */
428c2ecf20Sopenharmony_ci		u64 cd :  1; /* 04 timing-facility damage */
438c2ecf20Sopenharmony_ci		u64 ed :  1; /* 05 external damage */
448c2ecf20Sopenharmony_ci		u64    :  1; /* 06 */
458c2ecf20Sopenharmony_ci		u64 dg :  1; /* 07 degradation */
468c2ecf20Sopenharmony_ci		u64 w  :  1; /* 08 warning pending */
478c2ecf20Sopenharmony_ci		u64 cp :  1; /* 09 channel-report pending */
488c2ecf20Sopenharmony_ci		u64 sp :  1; /* 10 service-processor damage */
498c2ecf20Sopenharmony_ci		u64 ck :  1; /* 11 channel-subsystem damage */
508c2ecf20Sopenharmony_ci		u64    :  2; /* 12-13 */
518c2ecf20Sopenharmony_ci		u64 b  :  1; /* 14 backed up */
528c2ecf20Sopenharmony_ci		u64    :  1; /* 15 */
538c2ecf20Sopenharmony_ci		u64 se :  1; /* 16 storage error uncorrected */
548c2ecf20Sopenharmony_ci		u64 sc :  1; /* 17 storage error corrected */
558c2ecf20Sopenharmony_ci		u64 ke :  1; /* 18 storage-key error uncorrected */
568c2ecf20Sopenharmony_ci		u64 ds :  1; /* 19 storage degradation */
578c2ecf20Sopenharmony_ci		u64 wp :  1; /* 20 psw mwp validity */
588c2ecf20Sopenharmony_ci		u64 ms :  1; /* 21 psw mask and key validity */
598c2ecf20Sopenharmony_ci		u64 pm :  1; /* 22 psw program mask and cc validity */
608c2ecf20Sopenharmony_ci		u64 ia :  1; /* 23 psw instruction address validity */
618c2ecf20Sopenharmony_ci		u64 fa :  1; /* 24 failing storage address validity */
628c2ecf20Sopenharmony_ci		u64 vr :  1; /* 25 vector register validity */
638c2ecf20Sopenharmony_ci		u64 ec :  1; /* 26 external damage code validity */
648c2ecf20Sopenharmony_ci		u64 fp :  1; /* 27 floating point register validity */
658c2ecf20Sopenharmony_ci		u64 gr :  1; /* 28 general register validity */
668c2ecf20Sopenharmony_ci		u64 cr :  1; /* 29 control register validity */
678c2ecf20Sopenharmony_ci		u64    :  1; /* 30 */
688c2ecf20Sopenharmony_ci		u64 st :  1; /* 31 storage logical validity */
698c2ecf20Sopenharmony_ci		u64 ie :  1; /* 32 indirect storage error */
708c2ecf20Sopenharmony_ci		u64 ar :  1; /* 33 access register validity */
718c2ecf20Sopenharmony_ci		u64 da :  1; /* 34 delayed access exception */
728c2ecf20Sopenharmony_ci		u64    :  1; /* 35 */
738c2ecf20Sopenharmony_ci		u64 gs :  1; /* 36 guarded storage registers validity */
748c2ecf20Sopenharmony_ci		u64    :  5; /* 37-41 */
758c2ecf20Sopenharmony_ci		u64 pr :  1; /* 42 tod programmable register validity */
768c2ecf20Sopenharmony_ci		u64 fc :  1; /* 43 fp control register validity */
778c2ecf20Sopenharmony_ci		u64 ap :  1; /* 44 ancillary report */
788c2ecf20Sopenharmony_ci		u64    :  1; /* 45 */
798c2ecf20Sopenharmony_ci		u64 ct :  1; /* 46 cpu timer validity */
808c2ecf20Sopenharmony_ci		u64 cc :  1; /* 47 clock comparator validity */
818c2ecf20Sopenharmony_ci		u64    : 16; /* 47-63 */
828c2ecf20Sopenharmony_ci	};
838c2ecf20Sopenharmony_ci};
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci#define MCESA_ORIGIN_MASK	(~0x3ffUL)
868c2ecf20Sopenharmony_ci#define MCESA_LC_MASK		(0xfUL)
878c2ecf20Sopenharmony_ci#define MCESA_MIN_SIZE		(1024)
888c2ecf20Sopenharmony_ci#define MCESA_MAX_SIZE		(2048)
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_cistruct mcesa {
918c2ecf20Sopenharmony_ci	u8 vector_save_area[1024];
928c2ecf20Sopenharmony_ci	u8 guarded_storage_save_area[32];
938c2ecf20Sopenharmony_ci};
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_cistruct pt_regs;
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_civoid nmi_alloc_boot_cpu(struct lowcore *lc);
988c2ecf20Sopenharmony_ciint nmi_alloc_per_cpu(struct lowcore *lc);
998c2ecf20Sopenharmony_civoid nmi_free_per_cpu(struct lowcore *lc);
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_civoid s390_handle_mcck(void);
1028c2ecf20Sopenharmony_ciint s390_do_machine_check(struct pt_regs *regs);
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci#endif /* __ASSEMBLY__ */
1058c2ecf20Sopenharmony_ci#endif /* _ASM_S390_NMI_H */
106