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 0, /* N3 instructions */
31 1, /* z/Arch mode installed */
32 18, /* long displacement facility */
33 21, /* extended-immediate facility */
34 25, /* store clock fast */
36 32, /* compare and swap and store */
37 33, /* compare and swap and store 2 */
38 34, /* general instructions extension */
39 35, /* execute extensions */
40 #ifdef CONFIG_HAVE_MARCH_Z196_FEATURES
41 45, /* fast-BCR, etc. */
43 #ifdef CONFIG_HAVE_MARCH_ZEC12_FEATURES
44 49, /* misc-instruction-extensions */
45 52, /* interlocked facility 2 */
47 #ifdef CONFIG_HAVE_MARCH_Z13_FEATURES
48 53, /* load-and-zero-rightmost-byte, etc. */
51 #ifdef CONFIG_HAVE_MARCH_Z14_FEATURES
52 58, /* miscellaneous-instruction-extension 2 */
54 #ifdef CONFIG_HAVE_MARCH_Z15_FEATURES
55 61, /* miscellaneous-instruction-extension 3 */
62 * FACILITIES_KVM contains the list of facilities that are part
63 * of the default facility mask and list that are passed to the
64 * initial CPU model. If no CPU model is used, this, together
65 * with the non-hypervisor managed bits, is the maximum list of
66 * guest facilities supported by KVM.
68 .name = "FACILITIES_KVM",
70 0, /* N3 instructions */
71 1, /* z/Arch mode installed */
72 2, /* z/Arch mode active */
73 3, /* DAT-enhancement */
74 4, /* idte segment table */
75 5, /* idte region table */
76 6, /* ASN-and-LX reuse */
78 8, /* enhanced-DAT 1 */
79 9, /* sense-running-status */
80 10, /* conditional sske */
82 14, /* nonquiescing key-setting */
83 73, /* transactional execution */
84 75, /* access-exception-fetch/store indication */
85 76, /* msa extension 3 */
86 77, /* msa extension 4 */
87 78, /* enhanced-DAT 2 */
88 130, /* instruction-execution-protection */
89 131, /* enhanced-SOP 2 and side-effect */
90 139, /* multiple epoch facility */
91 146, /* msa extension 8 */
92 150, /* enhanced sort */
93 151, /* deflate conversion */
94 155, /* msa extension 9 */
100 * FACILITIES_KVM_CPUMODEL contains the list of facilities
101 * that can be enabled by CPU model code if the host supports
102 * it. These facilities are not passed to the guest without
106 .name = "FACILITIES_KVM_CPUMODEL",
108 12, /* AP Query Configuration Information */
109 15, /* AP Facilities Test */
110 156, /* etoken facility */
111 165, /* nnpa facility */
112 193, /* bear enhancement facility */
113 194, /* rdp enhancement facility */
114 196, /* processor activity instrumentation facility */
115 197, /* processor activity instrumentation extension 1 */
121 static void print_facility_list(struct facility_def *def)
123 unsigned int high, bit, dword, i;
124 unsigned long long *array;
126 array = calloc(1, 8);
130 for (i = 0; def->bits[i] != -1; i++) {
131 bit = 63 - (def->bits[i] & 63);
132 dword = def->bits[i] / 64;
134 array = realloc(array, (dword + 1) * 8);
137 memset(array + high + 1, 0, (dword - high) * 8);
140 array[dword] |= 1ULL << bit;
142 printf("#define %s ", def->name);
143 for (i = 0; i <= high; i++)
144 printf("_AC(0x%016llx,UL)%c", array[i], i < high ? ',' : '\n');
148 static void print_facility_lists(void)
152 for (i = 0; i < sizeof(facility_defs) / sizeof(facility_defs[0]); i++)
153 print_facility_list(&facility_defs[i]);
156 int main(int argc, char **argv)
158 printf("#ifndef __ASM_S390_FACILITY_DEFS__\n");
159 printf("#define __ASM_S390_FACILITY_DEFS__\n");
161 printf(" * DO NOT MODIFY.\n");
163 printf(" * This file was generated by %s\n", __FILE__);
165 printf("#include <linux/const.h>\n\n");
166 print_facility_lists();
167 printf("\n#endif\n");