xref: /openbmc/linux/arch/s390/include/asm/ctl_reg.h (revision caf83e49)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright IBM Corp. 1999, 2009
4  *
5  * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
6  */
7 
8 #ifndef __ASM_CTL_REG_H
9 #define __ASM_CTL_REG_H
10 
11 #include <linux/bits.h>
12 
13 #define CR0_CLOCK_COMPARATOR_SIGN	BIT(63 - 10)
14 #define CR0_LOW_ADDRESS_PROTECTION	BIT(63 - 35)
15 #define CR0_FETCH_PROTECTION_OVERRIDE	BIT(63 - 38)
16 #define CR0_STORAGE_PROTECTION_OVERRIDE	BIT(63 - 39)
17 #define CR0_EMERGENCY_SIGNAL_SUBMASK	BIT(63 - 49)
18 #define CR0_EXTERNAL_CALL_SUBMASK	BIT(63 - 50)
19 #define CR0_CLOCK_COMPARATOR_SUBMASK	BIT(63 - 52)
20 #define CR0_CPU_TIMER_SUBMASK		BIT(63 - 53)
21 #define CR0_SERVICE_SIGNAL_SUBMASK	BIT(63 - 54)
22 #define CR0_UNUSED_56			BIT(63 - 56)
23 #define CR0_INTERRUPT_KEY_SUBMASK	BIT(63 - 57)
24 #define CR0_MEASUREMENT_ALERT_SUBMASK	BIT(63 - 58)
25 
26 #define CR14_UNUSED_32			BIT(63 - 32)
27 #define CR14_UNUSED_33			BIT(63 - 33)
28 #define CR14_CHANNEL_REPORT_SUBMASK	BIT(63 - 35)
29 #define CR14_RECOVERY_SUBMASK		BIT(63 - 36)
30 #define CR14_DEGRADATION_SUBMASK	BIT(63 - 37)
31 #define CR14_EXTERNAL_DAMAGE_SUBMASK	BIT(63 - 38)
32 #define CR14_WARNING_SUBMASK		BIT(63 - 39)
33 
34 #ifndef __ASSEMBLY__
35 
36 #include <linux/bug.h>
37 
38 #define __ctl_load(array, low, high) do {				\
39 	typedef struct { char _[sizeof(array)]; } addrtype;		\
40 									\
41 	BUILD_BUG_ON(sizeof(addrtype) != (high - low + 1) * sizeof(long));\
42 	asm volatile(							\
43 		"	lctlg	%1,%2,%0\n"				\
44 		:							\
45 		: "Q" (*(addrtype *)(&array)), "i" (low), "i" (high)	\
46 		: "memory");						\
47 } while (0)
48 
49 #define __ctl_store(array, low, high) do {				\
50 	typedef struct { char _[sizeof(array)]; } addrtype;		\
51 									\
52 	BUILD_BUG_ON(sizeof(addrtype) != (high - low + 1) * sizeof(long));\
53 	asm volatile(							\
54 		"	stctg	%1,%2,%0\n"				\
55 		: "=Q" (*(addrtype *)(&array))				\
56 		: "i" (low), "i" (high));				\
57 } while (0)
58 
59 static __always_inline void __ctl_set_bit(unsigned int cr, unsigned int bit)
60 {
61 	unsigned long reg;
62 
63 	__ctl_store(reg, cr, cr);
64 	reg |= 1UL << bit;
65 	__ctl_load(reg, cr, cr);
66 }
67 
68 static __always_inline void __ctl_clear_bit(unsigned int cr, unsigned int bit)
69 {
70 	unsigned long reg;
71 
72 	__ctl_store(reg, cr, cr);
73 	reg &= ~(1UL << bit);
74 	__ctl_load(reg, cr, cr);
75 }
76 
77 void smp_ctl_set_clear_bit(int cr, int bit, bool set);
78 
79 static inline void ctl_set_bit(int cr, int bit)
80 {
81 	smp_ctl_set_clear_bit(cr, bit, true);
82 }
83 
84 static inline void ctl_clear_bit(int cr, int bit)
85 {
86 	smp_ctl_set_clear_bit(cr, bit, false);
87 }
88 
89 union ctlreg0 {
90 	unsigned long val;
91 	struct {
92 		unsigned long	   : 8;
93 		unsigned long tcx  : 1;	/* Transactional-Execution control */
94 		unsigned long pifo : 1;	/* Transactional-Execution Program-
95 					   Interruption-Filtering Override */
96 		unsigned long	   : 22;
97 		unsigned long	   : 3;
98 		unsigned long lap  : 1; /* Low-address-protection control */
99 		unsigned long	   : 4;
100 		unsigned long edat : 1; /* Enhanced-DAT-enablement control */
101 		unsigned long	   : 2;
102 		unsigned long iep  : 1; /* Instruction-Execution-Protection */
103 		unsigned long	   : 1;
104 		unsigned long afp  : 1; /* AFP-register control */
105 		unsigned long vx   : 1; /* Vector enablement control */
106 		unsigned long	   : 7;
107 		unsigned long sssm : 1; /* Service signal subclass mask */
108 		unsigned long	   : 9;
109 	};
110 };
111 
112 union ctlreg2 {
113 	unsigned long val;
114 	struct {
115 		unsigned long	    : 33;
116 		unsigned long ducto : 25;
117 		unsigned long	    : 1;
118 		unsigned long gse   : 1;
119 		unsigned long	    : 1;
120 		unsigned long tds   : 1;
121 		unsigned long tdc   : 2;
122 	};
123 };
124 
125 union ctlreg5 {
126 	unsigned long val;
127 	struct {
128 		unsigned long	    : 33;
129 		unsigned long pasteo: 25;
130 		unsigned long	    : 6;
131 	};
132 };
133 
134 union ctlreg15 {
135 	unsigned long val;
136 	struct {
137 		unsigned long lsea  : 61;
138 		unsigned long	    : 3;
139 	};
140 };
141 
142 #endif /* __ASSEMBLY__ */
143 #endif /* __ASM_CTL_REG_H */
144