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