ctl_reg.h 3.8 KB

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