xref: /qemu/target/s390x/cpu_features.c (revision 3d1cfc3c)
1fcf5ef2aSThomas Huth /*
2fcf5ef2aSThomas Huth  * CPU features/facilities for s390x
3fcf5ef2aSThomas Huth  *
4fcf5ef2aSThomas Huth  * Copyright 2016 IBM Corp.
5fcf5ef2aSThomas Huth  *
6fcf5ef2aSThomas Huth  * Author(s): David Hildenbrand <dahi@linux.vnet.ibm.com>
7fcf5ef2aSThomas Huth  *
8fcf5ef2aSThomas Huth  * This work is licensed under the terms of the GNU GPL, version 2 or (at
9fcf5ef2aSThomas Huth  * your option) any later version. See the COPYING file in the top-level
10fcf5ef2aSThomas Huth  * directory.
11fcf5ef2aSThomas Huth  */
12fcf5ef2aSThomas Huth 
13fcf5ef2aSThomas Huth #include "qemu/osdep.h"
14fcf5ef2aSThomas Huth #include "qemu/module.h"
15fcf5ef2aSThomas Huth #include "cpu_features.h"
16fcf5ef2aSThomas Huth #include "gen-features.h"
17fcf5ef2aSThomas Huth 
18fcf5ef2aSThomas Huth #define FEAT_INIT(_name, _type, _bit, _desc) \
19fcf5ef2aSThomas Huth     {                                                \
20fcf5ef2aSThomas Huth         .name = _name,                               \
21fcf5ef2aSThomas Huth         .type = _type,                               \
22fcf5ef2aSThomas Huth         .bit = _bit,                                 \
23fcf5ef2aSThomas Huth         .desc = _desc,                               \
24fcf5ef2aSThomas Huth     }
25fcf5ef2aSThomas Huth 
26fcf5ef2aSThomas Huth /* indexed by feature number for easy lookup */
27fcf5ef2aSThomas Huth static const S390FeatDef s390_features[] = {
28fcf5ef2aSThomas Huth     FEAT_INIT("esan3", S390_FEAT_TYPE_STFL, 0, "Instructions marked as n3"),
29fcf5ef2aSThomas Huth     FEAT_INIT("zarch", S390_FEAT_TYPE_STFL, 1, "z/Architecture architectural mode"),
30fcf5ef2aSThomas Huth     FEAT_INIT("dateh", S390_FEAT_TYPE_STFL, 3, "DAT-enhancement facility"),
31fcf5ef2aSThomas Huth     FEAT_INIT("idtes", S390_FEAT_TYPE_STFL, 4, "IDTE selective TLB segment-table clearing"),
32fcf5ef2aSThomas Huth     FEAT_INIT("idter", S390_FEAT_TYPE_STFL, 5, "IDTE selective TLB region-table clearing"),
33fcf5ef2aSThomas Huth     FEAT_INIT("asnlxr", S390_FEAT_TYPE_STFL, 6, "ASN-and-LX reuse facility"),
34fcf5ef2aSThomas Huth     FEAT_INIT("stfle", S390_FEAT_TYPE_STFL, 7, "Store-facility-list-extended facility"),
35fcf5ef2aSThomas Huth     FEAT_INIT("edat", S390_FEAT_TYPE_STFL, 8, "Enhanced-DAT facility"),
36fcf5ef2aSThomas Huth     FEAT_INIT("srs", S390_FEAT_TYPE_STFL, 9, "Sense-running-status facility"),
37fcf5ef2aSThomas Huth     FEAT_INIT("csske", S390_FEAT_TYPE_STFL, 10, "Conditional-SSKE facility"),
38fcf5ef2aSThomas Huth     FEAT_INIT("ctop", S390_FEAT_TYPE_STFL, 11, "Configuration-topology facility"),
39fcf5ef2aSThomas Huth     FEAT_INIT("ipter", S390_FEAT_TYPE_STFL, 13, "IPTE-range facility"),
40fcf5ef2aSThomas Huth     FEAT_INIT("nonqks", S390_FEAT_TYPE_STFL, 14, "Nonquiescing key-setting facility"),
41fcf5ef2aSThomas Huth     FEAT_INIT("etf2", S390_FEAT_TYPE_STFL, 16, "Extended-translation facility 2"),
42fcf5ef2aSThomas Huth     FEAT_INIT("msa-base", S390_FEAT_TYPE_STFL, 17, "Message-security-assist facility (excluding subfunctions)"),
43fcf5ef2aSThomas Huth     FEAT_INIT("ldisp", S390_FEAT_TYPE_STFL, 18, "Long-displacement facility"),
44fcf5ef2aSThomas Huth     FEAT_INIT("ldisphp", S390_FEAT_TYPE_STFL, 19, "Long-displacement facility has high performance"),
45fcf5ef2aSThomas Huth     FEAT_INIT("hfpm", S390_FEAT_TYPE_STFL, 20, "HFP-multiply-add/subtract facility"),
46fcf5ef2aSThomas Huth     FEAT_INIT("eimm", S390_FEAT_TYPE_STFL, 21, "Extended-immediate facility"),
47fcf5ef2aSThomas Huth     FEAT_INIT("etf3", S390_FEAT_TYPE_STFL, 22, "Extended-translation facility 3"),
48fcf5ef2aSThomas Huth     FEAT_INIT("hfpue", S390_FEAT_TYPE_STFL, 23, "HFP-unnormalized-extension facility"),
49fcf5ef2aSThomas Huth     FEAT_INIT("etf2eh", S390_FEAT_TYPE_STFL, 24, "ETF2-enhancement facility"),
50fcf5ef2aSThomas Huth     FEAT_INIT("stckf", S390_FEAT_TYPE_STFL, 25, "Store-clock-fast facility"),
51fcf5ef2aSThomas Huth     FEAT_INIT("parseh", S390_FEAT_TYPE_STFL, 26, "Parsing-enhancement facility"),
52fcf5ef2aSThomas Huth     FEAT_INIT("mvcos", S390_FEAT_TYPE_STFL, 27, "Move-with-optional-specification facility"),
53fcf5ef2aSThomas Huth     FEAT_INIT("tods-base", S390_FEAT_TYPE_STFL, 28, "TOD-clock-steering facility (excluding subfunctions)"),
54fcf5ef2aSThomas Huth     FEAT_INIT("etf3eh", S390_FEAT_TYPE_STFL, 30, "ETF3-enhancement facility"),
55fcf5ef2aSThomas Huth     FEAT_INIT("ectg", S390_FEAT_TYPE_STFL, 31, "Extract-CPU-time facility"),
56fcf5ef2aSThomas Huth     FEAT_INIT("csst", S390_FEAT_TYPE_STFL, 32, "Compare-and-swap-and-store facility"),
57fcf5ef2aSThomas Huth     FEAT_INIT("csst2", S390_FEAT_TYPE_STFL, 33, "Compare-and-swap-and-store facility 2"),
58fcf5ef2aSThomas Huth     FEAT_INIT("ginste", S390_FEAT_TYPE_STFL, 34, "General-instructions-extension facility"),
59fcf5ef2aSThomas Huth     FEAT_INIT("exrl", S390_FEAT_TYPE_STFL, 35, "Execute-extensions facility"),
60fcf5ef2aSThomas Huth     FEAT_INIT("emon", S390_FEAT_TYPE_STFL, 36, "Enhanced-monitor facility"),
61fcf5ef2aSThomas Huth     FEAT_INIT("fpe", S390_FEAT_TYPE_STFL, 37, "Floating-point extension facility"),
626da5c593SJason J. Herne     FEAT_INIT("opc", S390_FEAT_TYPE_STFL, 38, "Order Preserving Compression facility"),
63fcf5ef2aSThomas Huth     FEAT_INIT("sprogp", S390_FEAT_TYPE_STFL, 40, "Set-program-parameters facility"),
64fcf5ef2aSThomas Huth     FEAT_INIT("fpseh", S390_FEAT_TYPE_STFL, 41, "Floating-point-support-enhancement facilities"),
65fcf5ef2aSThomas Huth     FEAT_INIT("dfp", S390_FEAT_TYPE_STFL, 42, "DFP (decimal-floating-point) facility"),
66fcf5ef2aSThomas Huth     FEAT_INIT("dfphp", S390_FEAT_TYPE_STFL, 43, "DFP (decimal-floating-point) facility has high performance"),
67fcf5ef2aSThomas Huth     FEAT_INIT("pfpo", S390_FEAT_TYPE_STFL, 44, "PFPO instruction"),
68fcf5ef2aSThomas Huth     FEAT_INIT("stfle45", S390_FEAT_TYPE_STFL, 45, "Various facilities introduced with z196"),
69fcf5ef2aSThomas Huth     FEAT_INIT("cmpsceh", S390_FEAT_TYPE_STFL, 47, "CMPSC-enhancement facility"),
70fcf5ef2aSThomas Huth     FEAT_INIT("dfpzc", S390_FEAT_TYPE_STFL, 48, "Decimal-floating-point zoned-conversion facility"),
71fcf5ef2aSThomas Huth     FEAT_INIT("stfle49", S390_FEAT_TYPE_STFL, 49, "Various facilities introduced with zEC12"),
72fcf5ef2aSThomas Huth     FEAT_INIT("cte", S390_FEAT_TYPE_STFL, 50, "Constrained transactional-execution facility"),
73fcf5ef2aSThomas Huth     FEAT_INIT("ltlbc", S390_FEAT_TYPE_STFL, 51, "Local-TLB-clearing facility"),
74fcf5ef2aSThomas Huth     FEAT_INIT("iacc2", S390_FEAT_TYPE_STFL, 52, "Interlocked-access facility 2"),
75fcf5ef2aSThomas Huth     FEAT_INIT("stfle53", S390_FEAT_TYPE_STFL, 53, "Various facilities introduced with z13"),
766da5c593SJason J. Herne     FEAT_INIT("eec", S390_FEAT_TYPE_STFL, 54, "Entropy encoding compression facility"),
77fcf5ef2aSThomas Huth     FEAT_INIT("msa5-base", S390_FEAT_TYPE_STFL, 57, "Message-security-assist-extension-5 facility (excluding subfunctions)"),
786da5c593SJason J. Herne     FEAT_INIT("minste2", S390_FEAT_TYPE_STFL, 58, "Miscellaneous-instruction-extensions facility 2"),
796da5c593SJason J. Herne     FEAT_INIT("sema", S390_FEAT_TYPE_STFL, 59, "Semaphore-assist facility"),
806da5c593SJason J. Herne     FEAT_INIT("tsi", S390_FEAT_TYPE_STFL, 60, "Time-slice Instrumentation facility"),
81fcf5ef2aSThomas Huth     FEAT_INIT("ri", S390_FEAT_TYPE_STFL, 64, "CPU runtime-instrumentation facility"),
823b00f702SYi Min Zhao     FEAT_INIT("zpci", S390_FEAT_TYPE_STFL, 69, "z/PCI facility"),
833b00f702SYi Min Zhao     FEAT_INIT("aen", S390_FEAT_TYPE_STFL, 71, "General-purpose-adapter-event-notification facility"),
843b00f702SYi Min Zhao     FEAT_INIT("ais", S390_FEAT_TYPE_STFL, 72, "General-purpose-adapter-interruption-suppression facility"),
85fcf5ef2aSThomas Huth     FEAT_INIT("te", S390_FEAT_TYPE_STFL, 73, "Transactional-execution facility"),
86fcf5ef2aSThomas Huth     FEAT_INIT("sthyi", S390_FEAT_TYPE_STFL, 74, "Store-hypervisor-information facility"),
87fcf5ef2aSThomas Huth     FEAT_INIT("aefsi", S390_FEAT_TYPE_STFL, 75, "Access-exception-fetch/store-indication facility"),
88fcf5ef2aSThomas Huth     FEAT_INIT("msa3-base", S390_FEAT_TYPE_STFL, 76, "Message-security-assist-extension-3 facility (excluding subfunctions)"),
89fcf5ef2aSThomas Huth     FEAT_INIT("msa4-base", S390_FEAT_TYPE_STFL, 77, "Message-security-assist-extension-4 facility (excluding subfunctions)"),
90fcf5ef2aSThomas Huth     FEAT_INIT("edat2", S390_FEAT_TYPE_STFL, 78, "Enhanced-DAT facility 2"),
91fcf5ef2aSThomas Huth     FEAT_INIT("dfppc", S390_FEAT_TYPE_STFL, 80, "Decimal-floating-point packed-conversion facility"),
92fcf5ef2aSThomas Huth     FEAT_INIT("vx", S390_FEAT_TYPE_STFL, 129, "Vector facility"),
936da5c593SJason J. Herne     FEAT_INIT("iep", S390_FEAT_TYPE_STFL, 130, "Instruction-execution-protection facility"),
946da5c593SJason J. Herne     FEAT_INIT("sea_esop2", S390_FEAT_TYPE_STFL, 131, "Side-effect-access facility and Enhanced-suppression-on-protection facility 2"),
956da5c593SJason J. Herne     FEAT_INIT("gs", S390_FEAT_TYPE_STFL, 133, "Guarded-storage facility"),
966da5c593SJason J. Herne     FEAT_INIT("vxpd", S390_FEAT_TYPE_STFL, 134, "Vector packed decimal facility"),
976da5c593SJason J. Herne     FEAT_INIT("vxeh", S390_FEAT_TYPE_STFL, 135, "Vector enhancements facility"),
986da5c593SJason J. Herne     FEAT_INIT("mepoch", S390_FEAT_TYPE_STFL, 139, "Multiple-epoch facility"),
996da5c593SJason J. Herne     FEAT_INIT("tpei", S390_FEAT_TYPE_STFL, 144, "Test-pending-external-interruption facility"),
1006da5c593SJason J. Herne     FEAT_INIT("irbm", S390_FEAT_TYPE_STFL, 145, "Insert-reference-bits-multiple facility"),
1016da5c593SJason J. Herne     FEAT_INIT("msa8-base", S390_FEAT_TYPE_STFL, 146, "Message-security-assist-extension-8 facility (excluding subfunctions)"),
1026da5c593SJason J. Herne     FEAT_INIT("cmmnt", S390_FEAT_TYPE_STFL, 147, "CMM: ESSA-enhancement (no translate) facility"),
103fcf5ef2aSThomas Huth 
104ec3aadb1SJason J. Herne     /* SCLP SCCB Byte 80 - 98  (bit numbers relative to byte-80) */
105fcf5ef2aSThomas Huth     FEAT_INIT("gsls", S390_FEAT_TYPE_SCLP_CONF_CHAR, 40, "SIE: Guest-storage-limit-suppression facility"),
106fcf5ef2aSThomas Huth     FEAT_INIT("esop", S390_FEAT_TYPE_SCLP_CONF_CHAR, 46, "Enhanced-suppression-on-protection facility"),
1076da5c593SJason J. Herne     FEAT_INIT("hpma2", S390_FEAT_TYPE_SCLP_CONF_CHAR, 90, "Host page management assist 2 Facility"), /* 91-2 */
1086da5c593SJason J. Herne     FEAT_INIT("kss", S390_FEAT_TYPE_SCLP_CONF_CHAR, 151, "SIE: Keyless-subset facility"),  /* 98-7 */
109fcf5ef2aSThomas Huth 
110ec3aadb1SJason J. Herne     /* SCLP SCCB Byte 116 - 119 (bit numbers relative to byte-116) */
111fcf5ef2aSThomas Huth     FEAT_INIT("64bscao", S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT, 0, "SIE: 64-bit-SCAO facility"),
112fcf5ef2aSThomas Huth     FEAT_INIT("cmma", S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT, 1, "SIE: Collaborative-memory-management assist"),
113fcf5ef2aSThomas Huth     FEAT_INIT("pfmfi", S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT, 9, "SIE: PFMF interpretation facility"),
114fcf5ef2aSThomas Huth     FEAT_INIT("ibs", S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT, 10, "SIE: Interlock-and-broadcast-suppression facility"),
115fcf5ef2aSThomas Huth 
116fcf5ef2aSThomas Huth     FEAT_INIT("sief2", S390_FEAT_TYPE_SCLP_CPU, 4, "SIE: interception format 2 (Virtual SIE)"),
117fcf5ef2aSThomas Huth     FEAT_INIT("skey", S390_FEAT_TYPE_SCLP_CPU, 5, "SIE: Storage-key facility"),
118fcf5ef2aSThomas Huth     FEAT_INIT("gpereh", S390_FEAT_TYPE_SCLP_CPU, 10, "SIE: Guest-PER enhancement facility"),
119fcf5ef2aSThomas Huth     FEAT_INIT("siif", S390_FEAT_TYPE_SCLP_CPU, 11, "SIE: Shared IPTE-interlock facility"),
120fcf5ef2aSThomas Huth     FEAT_INIT("sigpif", S390_FEAT_TYPE_SCLP_CPU, 12, "SIE: SIGP interpretation facility"),
121fcf5ef2aSThomas Huth     FEAT_INIT("ib", S390_FEAT_TYPE_SCLP_CPU, 42, "SIE: Intervention bypass facility"),
122fcf5ef2aSThomas Huth     FEAT_INIT("cei", S390_FEAT_TYPE_SCLP_CPU, 43, "SIE: Conditional-external-interception facility"),
123fcf5ef2aSThomas Huth 
124fcf5ef2aSThomas Huth     FEAT_INIT("dateh2", S390_FEAT_TYPE_MISC, 0, "DAT-enhancement facility 2"),
125fcf5ef2aSThomas Huth     FEAT_INIT("cmm", S390_FEAT_TYPE_MISC, 0, "Collaborative-memory-management facility"),
126fcf5ef2aSThomas Huth 
127fcf5ef2aSThomas Huth     FEAT_INIT("plo-cl", S390_FEAT_TYPE_PLO, 0, "PLO Compare and load (32 bit in general registers)"),
128fcf5ef2aSThomas Huth     FEAT_INIT("plo-clg", S390_FEAT_TYPE_PLO, 1, "PLO Compare and load (64 bit in parameter list)"),
129fcf5ef2aSThomas Huth     FEAT_INIT("plo-clgr", S390_FEAT_TYPE_PLO, 2, "PLO Compare and load (32 bit in general registers)"),
130fcf5ef2aSThomas Huth     FEAT_INIT("plo-clx", S390_FEAT_TYPE_PLO, 3, "PLO Compare and load (128 bit in parameter list)"),
131fcf5ef2aSThomas Huth     FEAT_INIT("plo-cs", S390_FEAT_TYPE_PLO, 4, "PLO Compare and swap (32 bit in general registers)"),
132fcf5ef2aSThomas Huth     FEAT_INIT("plo-csg", S390_FEAT_TYPE_PLO, 5, "PLO Compare and swap (64 bit in parameter list)"),
133fcf5ef2aSThomas Huth     FEAT_INIT("plo-csgr", S390_FEAT_TYPE_PLO, 6, "PLO Compare and swap (32 bit in general registers)"),
134fcf5ef2aSThomas Huth     FEAT_INIT("plo-csx", S390_FEAT_TYPE_PLO, 7, "PLO Compare and swap (128 bit in parameter list)"),
135fcf5ef2aSThomas Huth     FEAT_INIT("plo-dcs", S390_FEAT_TYPE_PLO, 8, "PLO Double compare and swap (32 bit in general registers)"),
136fcf5ef2aSThomas Huth     FEAT_INIT("plo-dcsg", S390_FEAT_TYPE_PLO, 9, "PLO Double compare and swap (64 bit in parameter list)"),
137fcf5ef2aSThomas Huth     FEAT_INIT("plo-dcsgr", S390_FEAT_TYPE_PLO, 10, "PLO Double compare and swap (32 bit in general registers)"),
138fcf5ef2aSThomas Huth     FEAT_INIT("plo-dcsx", S390_FEAT_TYPE_PLO, 11, "PLO Double compare and swap (128 bit in parameter list)"),
139fcf5ef2aSThomas Huth     FEAT_INIT("plo-csst", S390_FEAT_TYPE_PLO, 12, "PLO Compare and swap and store (32 bit in general registers)"),
140fcf5ef2aSThomas Huth     FEAT_INIT("plo-csstg", S390_FEAT_TYPE_PLO, 13, "PLO Compare and swap and store (64 bit in parameter list)"),
141fcf5ef2aSThomas Huth     FEAT_INIT("plo-csstgr", S390_FEAT_TYPE_PLO, 14, "PLO Compare and swap and store (32 bit in general registers)"),
142fcf5ef2aSThomas Huth     FEAT_INIT("plo-csstx", S390_FEAT_TYPE_PLO, 15, "PLO Compare and swap and store (128 bit in parameter list)"),
143fcf5ef2aSThomas Huth     FEAT_INIT("plo-csdst", S390_FEAT_TYPE_PLO, 16, "PLO Compare and swap and double store (32 bit in general registers)"),
144fcf5ef2aSThomas Huth     FEAT_INIT("plo-csdstg", S390_FEAT_TYPE_PLO, 17, "PLO Compare and swap and double store (64 bit in parameter list)"),
145fcf5ef2aSThomas Huth     FEAT_INIT("plo-csdstgr", S390_FEAT_TYPE_PLO, 18, "PLO Compare and swap and double store (32 bit in general registers)"),
146fcf5ef2aSThomas Huth     FEAT_INIT("plo-csdstx", S390_FEAT_TYPE_PLO, 19, "PLO Compare and swap and double store (128 bit in parameter list)"),
147fcf5ef2aSThomas Huth     FEAT_INIT("plo-cstst", S390_FEAT_TYPE_PLO, 20, "PLO Compare and swap and triple store (32 bit in general registers)"),
148fcf5ef2aSThomas Huth     FEAT_INIT("plo-cststg", S390_FEAT_TYPE_PLO, 21, "PLO Compare and swap and triple store (64 bit in parameter list)"),
149fcf5ef2aSThomas Huth     FEAT_INIT("plo-cststgr", S390_FEAT_TYPE_PLO, 22, "PLO Compare and swap and triple store (32 bit in general registers)"),
150fcf5ef2aSThomas Huth     FEAT_INIT("plo-cststx", S390_FEAT_TYPE_PLO, 23, "PLO Compare and swap and triple store (128 bit in parameter list)"),
151fcf5ef2aSThomas Huth 
152fcf5ef2aSThomas Huth     FEAT_INIT("ptff-qto", S390_FEAT_TYPE_PTFF, 1, "PTFF Query TOD Offset"),
153fcf5ef2aSThomas Huth     FEAT_INIT("ptff-qsi", S390_FEAT_TYPE_PTFF, 2, "PTFF Query Steering Information"),
154fcf5ef2aSThomas Huth     FEAT_INIT("ptff-qpc", S390_FEAT_TYPE_PTFF, 3, "PTFF Query Physical Clock"),
155fcf5ef2aSThomas Huth     FEAT_INIT("ptff-qui", S390_FEAT_TYPE_PTFF, 4, "PTFF Query UTC Information"),
156fcf5ef2aSThomas Huth     FEAT_INIT("ptff-qtou", S390_FEAT_TYPE_PTFF, 5, "PTFF Query TOD Offset User"),
157fcf5ef2aSThomas Huth     FEAT_INIT("ptff-sto", S390_FEAT_TYPE_PTFF, 65, "PTFF Set TOD Offset"),
158fcf5ef2aSThomas Huth     FEAT_INIT("ptff-stou", S390_FEAT_TYPE_PTFF, 69, "PTFF Set TOD Offset User"),
159fcf5ef2aSThomas Huth 
160fcf5ef2aSThomas Huth     FEAT_INIT("kmac-dea", S390_FEAT_TYPE_KMAC, 1, "KMAC DEA"),
161fcf5ef2aSThomas Huth     FEAT_INIT("kmac-tdea-128", S390_FEAT_TYPE_KMAC, 2, "KMAC TDEA-128"),
162fcf5ef2aSThomas Huth     FEAT_INIT("kmac-tdea-192", S390_FEAT_TYPE_KMAC, 3, "KMAC TDEA-192"),
163fcf5ef2aSThomas Huth     FEAT_INIT("kmac-edea", S390_FEAT_TYPE_KMAC, 9, "KMAC Encrypted-DEA"),
164fcf5ef2aSThomas Huth     FEAT_INIT("kmac-etdea-128", S390_FEAT_TYPE_KMAC, 10, "KMAC Encrypted-TDEA-128"),
165fcf5ef2aSThomas Huth     FEAT_INIT("kmac-etdea-192", S390_FEAT_TYPE_KMAC, 11, "KMAC Encrypted-TDEA-192"),
166fcf5ef2aSThomas Huth     FEAT_INIT("kmac-aes-128", S390_FEAT_TYPE_KMAC, 18, "KMAC AES-128"),
167fcf5ef2aSThomas Huth     FEAT_INIT("kmac-aes-192", S390_FEAT_TYPE_KMAC, 19, "KMAC AES-192"),
168fcf5ef2aSThomas Huth     FEAT_INIT("kmac-aes-256", S390_FEAT_TYPE_KMAC, 20, "KMAC AES-256"),
169fcf5ef2aSThomas Huth     FEAT_INIT("kmac-eaes-128", S390_FEAT_TYPE_KMAC, 26, "KMAC Encrypted-AES-128"),
170fcf5ef2aSThomas Huth     FEAT_INIT("kmac-eaes-192", S390_FEAT_TYPE_KMAC, 27, "KMAC Encrypted-AES-192"),
171fcf5ef2aSThomas Huth     FEAT_INIT("kmac-eaes-256", S390_FEAT_TYPE_KMAC, 28, "KMAC Encrypted-AES-256"),
172fcf5ef2aSThomas Huth 
173fcf5ef2aSThomas Huth     FEAT_INIT("kmc-dea", S390_FEAT_TYPE_KMC, 1, "KMC DEA"),
174fcf5ef2aSThomas Huth     FEAT_INIT("kmc-tdea-128", S390_FEAT_TYPE_KMC, 2, "KMC TDEA-128"),
175fcf5ef2aSThomas Huth     FEAT_INIT("kmc-tdea-192", S390_FEAT_TYPE_KMC, 3, "KMC TDEA-192"),
176fcf5ef2aSThomas Huth     FEAT_INIT("kmc-edea", S390_FEAT_TYPE_KMC, 9, "KMC Encrypted-DEA"),
177fcf5ef2aSThomas Huth     FEAT_INIT("kmc-etdea-128", S390_FEAT_TYPE_KMC, 10, "KMC Encrypted-TDEA-128"),
178fcf5ef2aSThomas Huth     FEAT_INIT("kmc-etdea-192", S390_FEAT_TYPE_KMC, 11, "KMC Encrypted-TDEA-192"),
179fcf5ef2aSThomas Huth     FEAT_INIT("kmc-aes-128", S390_FEAT_TYPE_KMC, 18, "KMC AES-128"),
180fcf5ef2aSThomas Huth     FEAT_INIT("kmc-aes-192", S390_FEAT_TYPE_KMC, 19, "KMC AES-192"),
181fcf5ef2aSThomas Huth     FEAT_INIT("kmc-aes-256", S390_FEAT_TYPE_KMC, 20, "KMC AES-256"),
182fcf5ef2aSThomas Huth     FEAT_INIT("kmc-eaes-128", S390_FEAT_TYPE_KMC, 26, "KMC Encrypted-AES-128"),
183fcf5ef2aSThomas Huth     FEAT_INIT("kmc-eaes-192", S390_FEAT_TYPE_KMC, 27, "KMC Encrypted-AES-192"),
184fcf5ef2aSThomas Huth     FEAT_INIT("kmc-eaes-256", S390_FEAT_TYPE_KMC, 28, "KMC Encrypted-AES-256"),
185fcf5ef2aSThomas Huth     FEAT_INIT("kmc-prng", S390_FEAT_TYPE_KMC, 67, "KMC PRNG"),
186fcf5ef2aSThomas Huth 
187fcf5ef2aSThomas Huth     FEAT_INIT("km-dea", S390_FEAT_TYPE_KM, 1, "KM DEA"),
188fcf5ef2aSThomas Huth     FEAT_INIT("km-tdea-128", S390_FEAT_TYPE_KM, 2, "KM TDEA-128"),
189fcf5ef2aSThomas Huth     FEAT_INIT("km-tdea-192", S390_FEAT_TYPE_KM, 3, "KM TDEA-192"),
190fcf5ef2aSThomas Huth     FEAT_INIT("km-edea", S390_FEAT_TYPE_KM, 9, "KM Encrypted-DEA"),
191fcf5ef2aSThomas Huth     FEAT_INIT("km-etdea-128", S390_FEAT_TYPE_KM, 10, "KM Encrypted-TDEA-128"),
192fcf5ef2aSThomas Huth     FEAT_INIT("km-etdea-192", S390_FEAT_TYPE_KM, 11, "KM Encrypted-TDEA-192"),
193fcf5ef2aSThomas Huth     FEAT_INIT("km-aes-128", S390_FEAT_TYPE_KM, 18, "KM AES-128"),
194fcf5ef2aSThomas Huth     FEAT_INIT("km-aes-192", S390_FEAT_TYPE_KM, 19, "KM AES-192"),
195fcf5ef2aSThomas Huth     FEAT_INIT("km-aes-256", S390_FEAT_TYPE_KM, 20, "KM AES-256"),
196fcf5ef2aSThomas Huth     FEAT_INIT("km-eaes-128", S390_FEAT_TYPE_KM, 26, "KM Encrypted-AES-128"),
197fcf5ef2aSThomas Huth     FEAT_INIT("km-eaes-192", S390_FEAT_TYPE_KM, 27, "KM Encrypted-AES-192"),
198fcf5ef2aSThomas Huth     FEAT_INIT("km-eaes-256", S390_FEAT_TYPE_KM, 28, "KM Encrypted-AES-256"),
199fcf5ef2aSThomas Huth     FEAT_INIT("km-xts-aes-128", S390_FEAT_TYPE_KM, 50, "KM XTS-AES-128"),
200fcf5ef2aSThomas Huth     FEAT_INIT("km-xts-aes-256", S390_FEAT_TYPE_KM, 52, "KM XTS-AES-256"),
201fcf5ef2aSThomas Huth     FEAT_INIT("km-xts-eaes-128", S390_FEAT_TYPE_KM, 58, "KM XTS-Encrypted-AES-128"),
202fcf5ef2aSThomas Huth     FEAT_INIT("km-xts-eaes-256", S390_FEAT_TYPE_KM, 60, "KM XTS-Encrypted-AES-256"),
203fcf5ef2aSThomas Huth 
204fcf5ef2aSThomas Huth     FEAT_INIT("kimd-sha-1", S390_FEAT_TYPE_KIMD, 1, "KIMD SHA-1"),
205fcf5ef2aSThomas Huth     FEAT_INIT("kimd-sha-256", S390_FEAT_TYPE_KIMD, 2, "KIMD SHA-256"),
206fcf5ef2aSThomas Huth     FEAT_INIT("kimd-sha-512", S390_FEAT_TYPE_KIMD, 3, "KIMD SHA-512"),
2076da5c593SJason J. Herne     FEAT_INIT("kimd-sha3-224", S390_FEAT_TYPE_KIMD, 32, "KIMD SHA3-224"),
2086da5c593SJason J. Herne     FEAT_INIT("kimd-sha3-256", S390_FEAT_TYPE_KIMD, 33, "KIMD SHA3-256"),
2096da5c593SJason J. Herne     FEAT_INIT("kimd-sha3-384", S390_FEAT_TYPE_KIMD, 34, "KIMD SHA3-384"),
2106da5c593SJason J. Herne     FEAT_INIT("kimd-sha3-512", S390_FEAT_TYPE_KIMD, 35, "KIMD SHA3-512"),
2116da5c593SJason J. Herne     FEAT_INIT("kimd-shake-128", S390_FEAT_TYPE_KIMD, 36, "KIMD SHAKE-128"),
2126da5c593SJason J. Herne     FEAT_INIT("kimd-shake-256", S390_FEAT_TYPE_KIMD, 37, "KIMD SHAKE-256"),
213fcf5ef2aSThomas Huth     FEAT_INIT("kimd-ghash", S390_FEAT_TYPE_KIMD, 65, "KIMD GHASH"),
214ec3aadb1SJason J. Herne 
215fcf5ef2aSThomas Huth     FEAT_INIT("klmd-sha-1", S390_FEAT_TYPE_KLMD, 1, "KLMD SHA-1"),
216fcf5ef2aSThomas Huth     FEAT_INIT("klmd-sha-256", S390_FEAT_TYPE_KLMD, 2, "KLMD SHA-256"),
217fcf5ef2aSThomas Huth     FEAT_INIT("klmd-sha-512", S390_FEAT_TYPE_KLMD, 3, "KLMD SHA-512"),
2186da5c593SJason J. Herne     FEAT_INIT("klmd-sha3-224", S390_FEAT_TYPE_KLMD, 32, "KLMD SHA3-224"),
2196da5c593SJason J. Herne     FEAT_INIT("klmd-sha3-256", S390_FEAT_TYPE_KLMD, 33, "KLMD SHA3-256"),
2206da5c593SJason J. Herne     FEAT_INIT("klmd-sha3-384", S390_FEAT_TYPE_KLMD, 34, "KLMD SHA3-384"),
2216da5c593SJason J. Herne     FEAT_INIT("klmd-sha3-512", S390_FEAT_TYPE_KLMD, 35, "KLMD SHA3-512"),
2226da5c593SJason J. Herne     FEAT_INIT("klmd-shake-128", S390_FEAT_TYPE_KLMD, 36, "KLMD SHAKE-128"),
2236da5c593SJason J. Herne     FEAT_INIT("klmd-shake-256", S390_FEAT_TYPE_KLMD, 37, "KLMD SHAKE-256"),
224fcf5ef2aSThomas Huth 
225fcf5ef2aSThomas Huth     FEAT_INIT("pckmo-edea", S390_FEAT_TYPE_PCKMO, 1, "PCKMO Encrypted-DEA-Key"),
226fcf5ef2aSThomas Huth     FEAT_INIT("pckmo-etdea-128", S390_FEAT_TYPE_PCKMO, 2, "PCKMO Encrypted-TDEA-128-Key"),
227fcf5ef2aSThomas Huth     FEAT_INIT("pckmo-etdea-192", S390_FEAT_TYPE_PCKMO, 3, "PCKMO Encrypted-TDEA-192-Key"),
228fcf5ef2aSThomas Huth     FEAT_INIT("pckmo-aes-128", S390_FEAT_TYPE_PCKMO, 18, "PCKMO Encrypted-AES-128-Key"),
229fcf5ef2aSThomas Huth     FEAT_INIT("pckmo-aes-192", S390_FEAT_TYPE_PCKMO, 19, "PCKMO Encrypted-AES-192-Key"),
230fcf5ef2aSThomas Huth     FEAT_INIT("pckmo-aes-256", S390_FEAT_TYPE_PCKMO, 20, "PCKMO Encrypted-AES-256-Key"),
231fcf5ef2aSThomas Huth 
232fcf5ef2aSThomas Huth     FEAT_INIT("kmctr-dea", S390_FEAT_TYPE_KMCTR, 1, "KMCTR DEA"),
233fcf5ef2aSThomas Huth     FEAT_INIT("kmctr-tdea-128", S390_FEAT_TYPE_KMCTR, 2, "KMCTR TDEA-128"),
234fcf5ef2aSThomas Huth     FEAT_INIT("kmctr-tdea-192", S390_FEAT_TYPE_KMCTR, 3, "KMCTR TDEA-192"),
235fcf5ef2aSThomas Huth     FEAT_INIT("kmctr-edea", S390_FEAT_TYPE_KMCTR, 9, "KMCTR Encrypted-DEA"),
236fcf5ef2aSThomas Huth     FEAT_INIT("kmctr-etdea-128", S390_FEAT_TYPE_KMCTR, 10, "KMCTR Encrypted-TDEA-128"),
237fcf5ef2aSThomas Huth     FEAT_INIT("kmctr-etdea-192", S390_FEAT_TYPE_KMCTR, 11, "KMCTR Encrypted-TDEA-192"),
238fcf5ef2aSThomas Huth     FEAT_INIT("kmctr-aes-128", S390_FEAT_TYPE_KMCTR, 18, "KMCTR AES-128"),
239fcf5ef2aSThomas Huth     FEAT_INIT("kmctr-aes-192", S390_FEAT_TYPE_KMCTR, 19, "KMCTR AES-192"),
240fcf5ef2aSThomas Huth     FEAT_INIT("kmctr-aes-256", S390_FEAT_TYPE_KMCTR, 20, "KMCTR AES-256"),
241fcf5ef2aSThomas Huth     FEAT_INIT("kmctr-eaes-128", S390_FEAT_TYPE_KMCTR, 26, "KMCTR Encrypted-AES-128"),
242fcf5ef2aSThomas Huth     FEAT_INIT("kmctr-eaes-192", S390_FEAT_TYPE_KMCTR, 27, "KMCTR Encrypted-AES-192"),
243fcf5ef2aSThomas Huth     FEAT_INIT("kmctr-eaes-256", S390_FEAT_TYPE_KMCTR, 28, "KMCTR Encrypted-AES-256"),
244fcf5ef2aSThomas Huth 
245fcf5ef2aSThomas Huth     FEAT_INIT("kmf-dea", S390_FEAT_TYPE_KMF, 1, "KMF DEA"),
246fcf5ef2aSThomas Huth     FEAT_INIT("kmf-tdea-128", S390_FEAT_TYPE_KMF, 2, "KMF TDEA-128"),
247fcf5ef2aSThomas Huth     FEAT_INIT("kmf-tdea-192", S390_FEAT_TYPE_KMF, 3, "KMF TDEA-192"),
248fcf5ef2aSThomas Huth     FEAT_INIT("kmf-edea", S390_FEAT_TYPE_KMF, 9, "KMF Encrypted-DEA"),
249fcf5ef2aSThomas Huth     FEAT_INIT("kmf-etdea-128", S390_FEAT_TYPE_KMF, 10, "KMF Encrypted-TDEA-128"),
250fcf5ef2aSThomas Huth     FEAT_INIT("kmf-etdea-192", S390_FEAT_TYPE_KMF, 11, "KMF Encrypted-TDEA-192"),
251fcf5ef2aSThomas Huth     FEAT_INIT("kmf-aes-128", S390_FEAT_TYPE_KMF, 18, "KMF AES-128"),
252fcf5ef2aSThomas Huth     FEAT_INIT("kmf-aes-192", S390_FEAT_TYPE_KMF, 19, "KMF AES-192"),
253fcf5ef2aSThomas Huth     FEAT_INIT("kmf-aes-256", S390_FEAT_TYPE_KMF, 20, "KMF AES-256"),
254fcf5ef2aSThomas Huth     FEAT_INIT("kmf-eaes-128", S390_FEAT_TYPE_KMF, 26, "KMF Encrypted-AES-128"),
255fcf5ef2aSThomas Huth     FEAT_INIT("kmf-eaes-192", S390_FEAT_TYPE_KMF, 27, "KMF Encrypted-AES-192"),
256fcf5ef2aSThomas Huth     FEAT_INIT("kmf-eaes-256", S390_FEAT_TYPE_KMF, 28, "KMF Encrypted-AES-256"),
257fcf5ef2aSThomas Huth 
258fcf5ef2aSThomas Huth     FEAT_INIT("kmo-dea", S390_FEAT_TYPE_KMO, 1, "KMO DEA"),
259fcf5ef2aSThomas Huth     FEAT_INIT("kmo-tdea-128", S390_FEAT_TYPE_KMO, 2, "KMO TDEA-128"),
260fcf5ef2aSThomas Huth     FEAT_INIT("kmo-tdea-192", S390_FEAT_TYPE_KMO, 3, "KMO TDEA-192"),
261fcf5ef2aSThomas Huth     FEAT_INIT("kmo-edea", S390_FEAT_TYPE_KMO, 9, "KMO Encrypted-DEA"),
262fcf5ef2aSThomas Huth     FEAT_INIT("kmo-etdea-128", S390_FEAT_TYPE_KMO, 10, "KMO Encrypted-TDEA-128"),
263fcf5ef2aSThomas Huth     FEAT_INIT("kmo-etdea-192", S390_FEAT_TYPE_KMO, 11, "KMO Encrypted-TDEA-192"),
264fcf5ef2aSThomas Huth     FEAT_INIT("kmo-aes-128", S390_FEAT_TYPE_KMO, 18, "KMO AES-128"),
265fcf5ef2aSThomas Huth     FEAT_INIT("kmo-aes-192", S390_FEAT_TYPE_KMO, 19, "KMO AES-192"),
266fcf5ef2aSThomas Huth     FEAT_INIT("kmo-aes-256", S390_FEAT_TYPE_KMO, 20, "KMO AES-256"),
267fcf5ef2aSThomas Huth     FEAT_INIT("kmo-eaes-128", S390_FEAT_TYPE_KMO, 26, "KMO Encrypted-AES-128"),
268fcf5ef2aSThomas Huth     FEAT_INIT("kmo-eaes-192", S390_FEAT_TYPE_KMO, 27, "KMO Encrypted-AES-192"),
269fcf5ef2aSThomas Huth     FEAT_INIT("kmo-eaes-256", S390_FEAT_TYPE_KMO, 28, "KMO Encrypted-AES-256"),
270fcf5ef2aSThomas Huth 
271fcf5ef2aSThomas Huth     FEAT_INIT("pcc-cmac-dea", S390_FEAT_TYPE_PCC, 1, "PCC Compute-Last-Block-CMAC-Using-DEA"),
272fcf5ef2aSThomas Huth     FEAT_INIT("pcc-cmac-tdea-128", S390_FEAT_TYPE_PCC, 2, "PCC Compute-Last-Block-CMAC-Using-TDEA-128"),
273fcf5ef2aSThomas Huth     FEAT_INIT("pcc-cmac-tdea-192", S390_FEAT_TYPE_PCC, 3, "PCC Compute-Last-Block-CMAC-Using-TDEA-192"),
274fcf5ef2aSThomas Huth     FEAT_INIT("pcc-cmac-edea", S390_FEAT_TYPE_PCC, 9, "PCC Compute-Last-Block-CMAC-Using-Encrypted-DEA"),
275fcf5ef2aSThomas Huth     FEAT_INIT("pcc-cmac-etdea-128", S390_FEAT_TYPE_PCC, 10, "PCC Compute-Last-Block-CMAC-Using-Encrypted-TDEA-128"),
276fcf5ef2aSThomas Huth     FEAT_INIT("pcc-cmac-etdea-192", S390_FEAT_TYPE_PCC, 11, "PCC Compute-Last-Block-CMAC-Using-EncryptedTDEA-192"),
277fcf5ef2aSThomas Huth     FEAT_INIT("pcc-cmac-aes-128", S390_FEAT_TYPE_PCC, 18, "PCC Compute-Last-Block-CMAC-Using-AES-128"),
278fcf5ef2aSThomas Huth     FEAT_INIT("pcc-cmac-aes-192", S390_FEAT_TYPE_PCC, 19, "PCC Compute-Last-Block-CMAC-Using-AES-192"),
279fcf5ef2aSThomas Huth     FEAT_INIT("pcc-cmac-eaes-256", S390_FEAT_TYPE_PCC, 20, "PCC Compute-Last-Block-CMAC-Using-AES-256"),
280fcf5ef2aSThomas Huth     FEAT_INIT("pcc-cmac-eaes-128", S390_FEAT_TYPE_PCC, 26, "PCC Compute-Last-Block-CMAC-Using-Encrypted-AES-128"),
281fcf5ef2aSThomas Huth     FEAT_INIT("pcc-cmac-eaes-192", S390_FEAT_TYPE_PCC, 27, "PCC Compute-Last-Block-CMAC-Using-Encrypted-AES-192"),
282fcf5ef2aSThomas Huth     FEAT_INIT("pcc-cmac-eaes-256", S390_FEAT_TYPE_PCC, 28, "PCC Compute-Last-Block-CMAC-Using-Encrypted-AES-256"),
283fcf5ef2aSThomas Huth     FEAT_INIT("pcc-xts-aes-128", S390_FEAT_TYPE_PCC, 50, "PCC Compute-XTS-Parameter-Using-AES-128"),
284fcf5ef2aSThomas Huth     FEAT_INIT("pcc-xts-aes-256", S390_FEAT_TYPE_PCC, 52, "PCC Compute-XTS-Parameter-Using-AES-256"),
285fcf5ef2aSThomas Huth     FEAT_INIT("pcc-xts-eaes-128", S390_FEAT_TYPE_PCC, 58, "PCC Compute-XTS-Parameter-Using-Encrypted-AES-128"),
286fcf5ef2aSThomas Huth     FEAT_INIT("pcc-xts-eaes-256", S390_FEAT_TYPE_PCC, 60, "PCC Compute-XTS-Parameter-Using-Encrypted-AES-256"),
287fcf5ef2aSThomas Huth 
288fcf5ef2aSThomas Huth     FEAT_INIT("ppno-sha-512-drng", S390_FEAT_TYPE_PPNO, 3, "PPNO SHA-512-DRNG"),
2896da5c593SJason J. Herne     FEAT_INIT("prno-trng-qrtcr", S390_FEAT_TYPE_PPNO, 112, "PRNO TRNG-Query-Raw-to-Conditioned-Ratio"),
2906da5c593SJason J. Herne     FEAT_INIT("prno-trng", S390_FEAT_TYPE_PPNO, 114, "PRNO TRNG"),
2916da5c593SJason J. Herne 
2926da5c593SJason J. Herne     FEAT_INIT("kma-gcm-aes-128", S390_FEAT_TYPE_KMA, 18, "KMA GCM-AES-128"),
2936da5c593SJason J. Herne     FEAT_INIT("kma-gcm-aes-192", S390_FEAT_TYPE_KMA, 19, "KMA GCM-AES-192"),
2946da5c593SJason J. Herne     FEAT_INIT("kma-gcm-aes-256", S390_FEAT_TYPE_KMA, 20, "KMA GCM-AES-256"),
2956da5c593SJason J. Herne     FEAT_INIT("kma-gcm-eaes-128", S390_FEAT_TYPE_KMA, 26, "KMA GCM-Encrypted-AES-128"),
2966da5c593SJason J. Herne     FEAT_INIT("kma-gcm-eaes-192", S390_FEAT_TYPE_KMA, 27, "KMA GCM-Encrypted-AES-192"),
2976da5c593SJason J. Herne     FEAT_INIT("kma-gcm-eaes-256", S390_FEAT_TYPE_KMA, 28, "KMA GCM-Encrypted-AES-256"),
298fcf5ef2aSThomas Huth };
299fcf5ef2aSThomas Huth 
300fcf5ef2aSThomas Huth const S390FeatDef *s390_feat_def(S390Feat feat)
301fcf5ef2aSThomas Huth {
302fcf5ef2aSThomas Huth     return &s390_features[feat];
303fcf5ef2aSThomas Huth }
304fcf5ef2aSThomas Huth 
305fcf5ef2aSThomas Huth S390Feat s390_feat_by_type_and_bit(S390FeatType type, int bit)
306fcf5ef2aSThomas Huth {
307fcf5ef2aSThomas Huth     S390Feat feat;
308fcf5ef2aSThomas Huth 
309fcf5ef2aSThomas Huth     for (feat = 0; feat < ARRAY_SIZE(s390_features); feat++) {
310fcf5ef2aSThomas Huth         if (s390_features[feat].type == type &&
311fcf5ef2aSThomas Huth             s390_features[feat].bit == bit) {
312fcf5ef2aSThomas Huth             return feat;
313fcf5ef2aSThomas Huth         }
314fcf5ef2aSThomas Huth     }
315fcf5ef2aSThomas Huth     return S390_FEAT_MAX;
316fcf5ef2aSThomas Huth }
317fcf5ef2aSThomas Huth 
318fcf5ef2aSThomas Huth void s390_init_feat_bitmap(const S390FeatInit init, S390FeatBitmap bitmap)
319fcf5ef2aSThomas Huth {
320fcf5ef2aSThomas Huth     int i, j;
321fcf5ef2aSThomas Huth 
322fcf5ef2aSThomas Huth     for (i = 0; i < (S390_FEAT_MAX / 64 + 1); i++) {
323fcf5ef2aSThomas Huth         if (init[i]) {
324fcf5ef2aSThomas Huth             for (j = 0; j < 64; j++) {
325fcf5ef2aSThomas Huth                 if (init[i] & 1ULL << j) {
326fcf5ef2aSThomas Huth                     set_bit(i * 64 + j, bitmap);
327fcf5ef2aSThomas Huth                 }
328fcf5ef2aSThomas Huth             }
329fcf5ef2aSThomas Huth         }
330fcf5ef2aSThomas Huth     }
331fcf5ef2aSThomas Huth }
332fcf5ef2aSThomas Huth 
333fcf5ef2aSThomas Huth void s390_fill_feat_block(const S390FeatBitmap features, S390FeatType type,
334fcf5ef2aSThomas Huth                           uint8_t *data)
335fcf5ef2aSThomas Huth {
336fcf5ef2aSThomas Huth     S390Feat feat;
337fcf5ef2aSThomas Huth     int bit_nr;
338fcf5ef2aSThomas Huth 
339cc18f907SDavid Hildenbrand     switch (type) {
340cc18f907SDavid Hildenbrand     case S390_FEAT_TYPE_STFL:
341cc18f907SDavid Hildenbrand         if (test_bit(S390_FEAT_ZARCH, features)) {
342075e52b8SJason J. Herne             /* Features that are always active */
343*3d1cfc3cSDavid Hildenbrand             set_be_bit(2, data);   /* z/Architecture */
344*3d1cfc3cSDavid Hildenbrand             set_be_bit(138, data); /* Configuration-z-architectural-mode */
345fcf5ef2aSThomas Huth         }
346cc18f907SDavid Hildenbrand         break;
347cc18f907SDavid Hildenbrand     case S390_FEAT_TYPE_PTFF:
348cc18f907SDavid Hildenbrand     case S390_FEAT_TYPE_KMAC:
349cc18f907SDavid Hildenbrand     case S390_FEAT_TYPE_KMC:
350cc18f907SDavid Hildenbrand     case S390_FEAT_TYPE_KM:
351cc18f907SDavid Hildenbrand     case S390_FEAT_TYPE_KIMD:
352cc18f907SDavid Hildenbrand     case S390_FEAT_TYPE_KLMD:
353cc18f907SDavid Hildenbrand     case S390_FEAT_TYPE_PCKMO:
354cc18f907SDavid Hildenbrand     case S390_FEAT_TYPE_KMCTR:
355cc18f907SDavid Hildenbrand     case S390_FEAT_TYPE_KMF:
356cc18f907SDavid Hildenbrand     case S390_FEAT_TYPE_KMO:
357cc18f907SDavid Hildenbrand     case S390_FEAT_TYPE_PCC:
358cc18f907SDavid Hildenbrand     case S390_FEAT_TYPE_PPNO:
359cc18f907SDavid Hildenbrand     case S390_FEAT_TYPE_KMA:
360*3d1cfc3cSDavid Hildenbrand         set_be_bit(0, data); /* query is always available */
361cc18f907SDavid Hildenbrand         break;
362cc18f907SDavid Hildenbrand     default:
363cc18f907SDavid Hildenbrand         break;
364cc18f907SDavid Hildenbrand     };
365fcf5ef2aSThomas Huth 
366fcf5ef2aSThomas Huth     feat = find_first_bit(features, S390_FEAT_MAX);
367fcf5ef2aSThomas Huth     while (feat < S390_FEAT_MAX) {
368fcf5ef2aSThomas Huth         if (s390_features[feat].type == type) {
369fcf5ef2aSThomas Huth             bit_nr = s390_features[feat].bit;
370fcf5ef2aSThomas Huth             /* big endian on uint8_t array */
371*3d1cfc3cSDavid Hildenbrand             set_be_bit(bit_nr, data);
372fcf5ef2aSThomas Huth         }
373fcf5ef2aSThomas Huth         feat = find_next_bit(features, S390_FEAT_MAX, feat + 1);
374fcf5ef2aSThomas Huth     }
375fcf5ef2aSThomas Huth }
376fcf5ef2aSThomas Huth 
377fcf5ef2aSThomas Huth void s390_add_from_feat_block(S390FeatBitmap features, S390FeatType type,
378fcf5ef2aSThomas Huth                               uint8_t *data)
379fcf5ef2aSThomas Huth {
380fcf5ef2aSThomas Huth     int nr_bits, le_bit;
381fcf5ef2aSThomas Huth 
382fcf5ef2aSThomas Huth     switch (type) {
383fcf5ef2aSThomas Huth     case S390_FEAT_TYPE_STFL:
384fcf5ef2aSThomas Huth        nr_bits = 2048;
385fcf5ef2aSThomas Huth        break;
386fcf5ef2aSThomas Huth     case S390_FEAT_TYPE_PLO:
387fcf5ef2aSThomas Huth        nr_bits = 256;
388fcf5ef2aSThomas Huth        break;
389fcf5ef2aSThomas Huth     default:
390fcf5ef2aSThomas Huth        /* all cpu subfunctions have 128 bit */
391fcf5ef2aSThomas Huth        nr_bits = 128;
392fcf5ef2aSThomas Huth     };
393fcf5ef2aSThomas Huth 
394fcf5ef2aSThomas Huth     le_bit = find_first_bit((unsigned long *) data, nr_bits);
395fcf5ef2aSThomas Huth     while (le_bit < nr_bits) {
396fcf5ef2aSThomas Huth         /* convert the bit number to a big endian bit nr */
397fcf5ef2aSThomas Huth         S390Feat feat = s390_feat_by_type_and_bit(type, BE_BIT_NR(le_bit));
398fcf5ef2aSThomas Huth         /* ignore unknown bits */
399fcf5ef2aSThomas Huth         if (feat < S390_FEAT_MAX) {
400fcf5ef2aSThomas Huth             set_bit(feat, features);
401fcf5ef2aSThomas Huth         }
402fcf5ef2aSThomas Huth         le_bit = find_next_bit((unsigned long *) data, nr_bits, le_bit + 1);
403fcf5ef2aSThomas Huth     }
404fcf5ef2aSThomas Huth }
405fcf5ef2aSThomas Huth 
406fcf5ef2aSThomas Huth void s390_feat_bitmap_to_ascii(const S390FeatBitmap features, void *opaque,
407fcf5ef2aSThomas Huth                                void (*fn)(const char *name, void *opaque))
408fcf5ef2aSThomas Huth {
409fcf5ef2aSThomas Huth     S390FeatBitmap bitmap, tmp;
410fcf5ef2aSThomas Huth     S390FeatGroup group;
411fcf5ef2aSThomas Huth     S390Feat feat;
412fcf5ef2aSThomas Huth 
413fcf5ef2aSThomas Huth     bitmap_copy(bitmap, features, S390_FEAT_MAX);
414fcf5ef2aSThomas Huth 
415fcf5ef2aSThomas Huth     /* process whole groups first */
416fcf5ef2aSThomas Huth     for (group = 0; group < S390_FEAT_GROUP_MAX; group++) {
417fcf5ef2aSThomas Huth         const S390FeatGroupDef *def = s390_feat_group_def(group);
418fcf5ef2aSThomas Huth 
419fcf5ef2aSThomas Huth         bitmap_and(tmp, bitmap, def->feat, S390_FEAT_MAX);
420fcf5ef2aSThomas Huth         if (bitmap_equal(tmp, def->feat, S390_FEAT_MAX)) {
421fcf5ef2aSThomas Huth             bitmap_andnot(bitmap, bitmap, def->feat, S390_FEAT_MAX);
422fcf5ef2aSThomas Huth             fn(def->name, opaque);
423fcf5ef2aSThomas Huth         }
424fcf5ef2aSThomas Huth     }
425fcf5ef2aSThomas Huth 
426fcf5ef2aSThomas Huth     /* report leftovers as separate features */
427fcf5ef2aSThomas Huth     feat = find_first_bit(bitmap, S390_FEAT_MAX);
428fcf5ef2aSThomas Huth     while (feat < S390_FEAT_MAX) {
429fcf5ef2aSThomas Huth         fn(s390_feat_def(feat)->name, opaque);
430fcf5ef2aSThomas Huth         feat = find_next_bit(bitmap, S390_FEAT_MAX, feat + 1);
431fcf5ef2aSThomas Huth     };
432fcf5ef2aSThomas Huth }
433fcf5ef2aSThomas Huth 
434fcf5ef2aSThomas Huth #define FEAT_GROUP_INIT(_name, _group, _desc)        \
435fcf5ef2aSThomas Huth     {                                                \
436fcf5ef2aSThomas Huth         .name = _name,                               \
437fcf5ef2aSThomas Huth         .desc = _desc,                               \
438fcf5ef2aSThomas Huth         .init = { S390_FEAT_GROUP_LIST_ ## _group }, \
439fcf5ef2aSThomas Huth     }
440fcf5ef2aSThomas Huth 
441fcf5ef2aSThomas Huth /* indexed by feature group number for easy lookup */
442fcf5ef2aSThomas Huth static S390FeatGroupDef s390_feature_groups[] = {
443fcf5ef2aSThomas Huth     FEAT_GROUP_INIT("plo", PLO, "Perform-locked-operation facility"),
444fcf5ef2aSThomas Huth     FEAT_GROUP_INIT("tods", TOD_CLOCK_STEERING, "Tod-clock-steering facility"),
445fcf5ef2aSThomas Huth     FEAT_GROUP_INIT("gen13ptff", GEN13_PTFF, "PTFF enhancements introduced with z13"),
446fcf5ef2aSThomas Huth     FEAT_GROUP_INIT("msa", MSA, "Message-security-assist facility"),
447fcf5ef2aSThomas Huth     FEAT_GROUP_INIT("msa1", MSA_EXT_1, "Message-security-assist-extension 1 facility"),
448fcf5ef2aSThomas Huth     FEAT_GROUP_INIT("msa2", MSA_EXT_2, "Message-security-assist-extension 2 facility"),
449fcf5ef2aSThomas Huth     FEAT_GROUP_INIT("msa3", MSA_EXT_3, "Message-security-assist-extension 3 facility"),
450fcf5ef2aSThomas Huth     FEAT_GROUP_INIT("msa4", MSA_EXT_4, "Message-security-assist-extension 4 facility"),
451fcf5ef2aSThomas Huth     FEAT_GROUP_INIT("msa5", MSA_EXT_5, "Message-security-assist-extension 5 facility"),
4526da5c593SJason J. Herne     FEAT_GROUP_INIT("msa6", MSA_EXT_6, "Message-security-assist-extension 6 facility"),
4536da5c593SJason J. Herne     FEAT_GROUP_INIT("msa7", MSA_EXT_7, "Message-security-assist-extension 7 facility"),
4546da5c593SJason J. Herne     FEAT_GROUP_INIT("msa8", MSA_EXT_8, "Message-security-assist-extension 8 facility"),
455fcf5ef2aSThomas Huth };
456fcf5ef2aSThomas Huth 
457fcf5ef2aSThomas Huth const S390FeatGroupDef *s390_feat_group_def(S390FeatGroup group)
458fcf5ef2aSThomas Huth {
459fcf5ef2aSThomas Huth     return &s390_feature_groups[group];
460fcf5ef2aSThomas Huth }
461fcf5ef2aSThomas Huth 
462fcf5ef2aSThomas Huth static void init_groups(void)
463fcf5ef2aSThomas Huth {
464fcf5ef2aSThomas Huth     int i;
465fcf5ef2aSThomas Huth 
466fcf5ef2aSThomas Huth     /* init all bitmaps from gnerated data initially */
467fcf5ef2aSThomas Huth     for (i = 0; i < ARRAY_SIZE(s390_feature_groups); i++) {
468fcf5ef2aSThomas Huth         s390_init_feat_bitmap(s390_feature_groups[i].init,
469fcf5ef2aSThomas Huth                               s390_feature_groups[i].feat);
470fcf5ef2aSThomas Huth     }
471fcf5ef2aSThomas Huth }
472fcf5ef2aSThomas Huth 
473fcf5ef2aSThomas Huth type_init(init_groups)
474