1 // SPDX-License-Identifier: GPL-2.0
3 * Simple program to generate defines out of facility lists that use the bit
4 * numbering scheme from the Princples of Operations: most significant bit
7 * Copyright IBM Corp. 2015, 2018
21 static struct facility_def facility_defs
[] = {
24 * FACILITIES_ALS contains the list of facilities that are
25 * required to run a kernel that is compiled e.g. with
28 .name
= "FACILITIES_ALS",
30 #ifdef CONFIG_HAVE_MARCH_Z900_FEATURES
31 0, /* N3 instructions */
32 1, /* z/Arch mode installed */
34 #ifdef CONFIG_HAVE_MARCH_Z990_FEATURES
35 18, /* long displacement facility */
37 #ifdef CONFIG_HAVE_MARCH_Z9_109_FEATURES
38 21, /* extended-immediate facility */
39 25, /* store clock fast */
41 #ifdef CONFIG_HAVE_MARCH_Z10_FEATURES
43 32, /* compare and swap and store */
44 33, /* compare and swap and store 2 */
45 34, /* general instructions extension */
46 35, /* execute extensions */
48 #ifdef CONFIG_HAVE_MARCH_Z196_FEATURES
49 45, /* fast-BCR, etc. */
51 #ifdef CONFIG_HAVE_MARCH_ZEC12_FEATURES
52 49, /* misc-instruction-extensions */
53 52, /* interlocked facility 2 */
55 #ifdef CONFIG_HAVE_MARCH_Z13_FEATURES
56 53, /* load-and-zero-rightmost-byte, etc. */
58 #ifdef CONFIG_HAVE_MARCH_Z14_FEATURES
59 58, /* miscellaneous-instruction-extension 2 */
61 #ifdef CONFIG_HAVE_MARCH_Z15_FEATURES
62 61, /* miscellaneous-instruction-extension 3 */
69 * FACILITIES_KVM contains the list of facilities that are part
70 * of the default facility mask and list that are passed to the
71 * initial CPU model. If no CPU model is used, this, together
72 * with the non-hypervisor managed bits, is the maximum list of
73 * guest facilities supported by KVM.
75 .name
= "FACILITIES_KVM",
77 0, /* N3 instructions */
78 1, /* z/Arch mode installed */
79 2, /* z/Arch mode active */
80 3, /* DAT-enhancement */
81 4, /* idte segment table */
82 5, /* idte region table */
83 6, /* ASN-and-LX reuse */
85 8, /* enhanced-DAT 1 */
86 9, /* sense-running-status */
87 10, /* conditional sske */
89 14, /* nonquiescing key-setting */
90 73, /* transactional execution */
91 75, /* access-exception-fetch/store indication */
92 76, /* msa extension 3 */
93 77, /* msa extension 4 */
94 78, /* enhanced-DAT 2 */
95 130, /* instruction-execution-protection */
96 131, /* enhanced-SOP 2 and side-effect */
97 139, /* multiple epoch facility */
98 146, /* msa extension 8 */
99 150, /* enhanced sort */
100 151, /* deflate conversion */
101 155, /* msa extension 9 */
107 * FACILITIES_KVM_CPUMODEL contains the list of facilities
108 * that can be enabled by CPU model code if the host supports
109 * it. These facilities are not passed to the guest without
113 .name
= "FACILITIES_KVM_CPUMODEL",
115 12, /* AP Query Configuration Information */
116 15, /* AP Facilities Test */
117 156, /* etoken facility */
123 static void print_facility_list(struct facility_def
*def
)
125 unsigned int high
, bit
, dword
, i
;
126 unsigned long long *array
;
128 array
= calloc(1, 8);
132 for (i
= 0; def
->bits
[i
] != -1; i
++) {
133 bit
= 63 - (def
->bits
[i
] & 63);
134 dword
= def
->bits
[i
] / 64;
136 array
= realloc(array
, (dword
+ 1) * 8);
139 memset(array
+ high
+ 1, 0, (dword
- high
) * 8);
142 array
[dword
] |= 1ULL << bit
;
144 printf("#define %s ", def
->name
);
145 for (i
= 0; i
<= high
; i
++)
146 printf("_AC(0x%016llx,UL)%c", array
[i
], i
< high
? ',' : '\n');
150 static void print_facility_lists(void)
154 for (i
= 0; i
< sizeof(facility_defs
) / sizeof(facility_defs
[0]); i
++)
155 print_facility_list(&facility_defs
[i
]);
158 int main(int argc
, char **argv
)
160 printf("#ifndef __ASM_S390_FACILITY_DEFS__\n");
161 printf("#define __ASM_S390_FACILITY_DEFS__\n");
163 printf(" * DO NOT MODIFY.\n");
165 printf(" * This file was generated by %s\n", __FILE__
);
167 printf("#include <linux/const.h>\n\n");
168 print_facility_lists();
169 printf("\n#endif\n");