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/const.h> 12 13 #define CR2_GUARDED_STORAGE _BITUL(63 - 59) 14 15 #define CR14_CHANNEL_REPORT_SUBMASK _BITUL(63 - 35) 16 #define CR14_RECOVERY_SUBMASK _BITUL(63 - 36) 17 #define CR14_DEGRADATION_SUBMASK _BITUL(63 - 37) 18 #define CR14_EXTERNAL_DAMAGE_SUBMASK _BITUL(63 - 38) 19 #define CR14_WARNING_SUBMASK _BITUL(63 - 39) 20 21 #ifndef __ASSEMBLY__ 22 23 #include <linux/bug.h> 24 25 #define __ctl_load(array, low, high) do { \ 26 typedef struct { char _[sizeof(array)]; } addrtype; \ 27 \ 28 BUILD_BUG_ON(sizeof(addrtype) != (high - low + 1) * sizeof(long));\ 29 asm volatile( \ 30 " lctlg %1,%2,%0\n" \ 31 : \ 32 : "Q" (*(addrtype *)(&array)), "i" (low), "i" (high) \ 33 : "memory"); \ 34 } while (0) 35 36 #define __ctl_store(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 " stctg %1,%2,%0\n" \ 42 : "=Q" (*(addrtype *)(&array)) \ 43 : "i" (low), "i" (high)); \ 44 } while (0) 45 46 static inline void __ctl_set_bit(unsigned int cr, unsigned int bit) 47 { 48 unsigned long reg; 49 50 __ctl_store(reg, cr, cr); 51 reg |= 1UL << bit; 52 __ctl_load(reg, cr, cr); 53 } 54 55 static inline void __ctl_clear_bit(unsigned int cr, unsigned int bit) 56 { 57 unsigned long reg; 58 59 __ctl_store(reg, cr, cr); 60 reg &= ~(1UL << bit); 61 __ctl_load(reg, cr, cr); 62 } 63 64 void smp_ctl_set_bit(int cr, int bit); 65 void smp_ctl_clear_bit(int cr, int bit); 66 67 union ctlreg0 { 68 unsigned long val; 69 struct { 70 unsigned long : 8; 71 unsigned long tcx : 1; /* Transactional-Execution control */ 72 unsigned long pifo : 1; /* Transactional-Execution Program- 73 Interruption-Filtering Override */ 74 unsigned long : 22; 75 unsigned long : 3; 76 unsigned long lap : 1; /* Low-address-protection control */ 77 unsigned long : 4; 78 unsigned long edat : 1; /* Enhanced-DAT-enablement control */ 79 unsigned long : 2; 80 unsigned long iep : 1; /* Instruction-Execution-Protection */ 81 unsigned long : 1; 82 unsigned long afp : 1; /* AFP-register control */ 83 unsigned long vx : 1; /* Vector enablement control */ 84 unsigned long : 7; 85 unsigned long sssm : 1; /* Service signal subclass mask */ 86 unsigned long : 9; 87 }; 88 }; 89 90 union ctlreg2 { 91 unsigned long val; 92 struct { 93 unsigned long : 33; 94 unsigned long ducto : 25; 95 unsigned long : 1; 96 unsigned long gse : 1; 97 unsigned long : 1; 98 unsigned long tds : 1; 99 unsigned long tdc : 2; 100 }; 101 }; 102 103 #ifdef CONFIG_SMP 104 # define ctl_set_bit(cr, bit) smp_ctl_set_bit(cr, bit) 105 # define ctl_clear_bit(cr, bit) smp_ctl_clear_bit(cr, bit) 106 #else 107 # define ctl_set_bit(cr, bit) __ctl_set_bit(cr, bit) 108 # define ctl_clear_bit(cr, bit) __ctl_clear_bit(cr, bit) 109 #endif 110 111 #endif /* __ASSEMBLY__ */ 112 #endif /* __ASM_CTL_REG_H */ 113