aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/crypto
diff options
context:
space:
mode:
authorIngo Tuchscherer <ingo.tuchscherer@de.ibm.com>2015-01-23 07:27:04 -0500
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2015-01-23 09:17:10 -0500
commit5bc334bff9a6e189113140ed6dce0ce61d768943 (patch)
tree8783c3ecc27ad95c0dd13bb786dded0fae31a955 /drivers/s390/crypto
parent2c72a44ecdf2a7ceac73844226e97ed2d5dd1e82 (diff)
s390/zcrypt: Number of supported ap domains is not retrievable.
Upcoming versions of secure key management facilities (CCA and EP11) require information about the maximum number of supported ap domains in order to service TKE requests properly. With IBM z13 the number of available domains (so far 16) has increased up to 85. This number varies depending on machine types and models. Therefore the new sysfs attribute 'ap_max_domain_id' provides this limit of supported ap domains. Upcoming releases for CCA and EP11 will use this new information. Without this problem fix it is not possible to retrieve reliable information about the maximum number of supported ap domains. Thus, customers are not able to perform key management for CCA and EP11 coprocessor adapters. Signed-off-by: Ingo Tuchscherer <ingo.tuchscherer@de.ibm.com> Signed-off-by: Harald Freudenberger <freude@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'drivers/s390/crypto')
-rw-r--r--drivers/s390/crypto/ap_bus.c137
1 files changed, 96 insertions, 41 deletions
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c
index 4d41bf75c233..faa058016b5c 100644
--- a/drivers/s390/crypto/ap_bus.c
+++ b/drivers/s390/crypto/ap_bus.c
@@ -204,6 +204,24 @@ ap_test_queue(ap_qid_t qid, int *queue_depth, int *device_type)
204} 204}
205 205
206/** 206/**
207 * ap_query_facilities(): PQAP(TAPQ) query facilities.
208 * @qid: The AP queue number
209 *
210 * Returns content of general register 2 after the PQAP(TAPQ)
211 * instruction was called.
212 */
213static inline unsigned long ap_query_facilities(ap_qid_t qid)
214{
215 register unsigned long reg0 asm ("0") = qid | 0x00800000UL;
216 register unsigned long reg1 asm ("1");
217 register unsigned long reg2 asm ("2") = 0UL;
218
219 asm volatile(".long 0xb2af0000" /* PQAP(TAPQ) */
220 : "+d" (reg0), "=d" (reg1), "+d" (reg2) : : "cc");
221 return reg2;
222}
223
224/**
207 * ap_reset_queue(): Reset adjunct processor queue. 225 * ap_reset_queue(): Reset adjunct processor queue.
208 * @qid: The AP queue number 226 * @qid: The AP queue number
209 * 227 *
@@ -1007,6 +1025,47 @@ void ap_bus_force_rescan(void)
1007EXPORT_SYMBOL(ap_bus_force_rescan); 1025EXPORT_SYMBOL(ap_bus_force_rescan);
1008 1026
1009/* 1027/*
1028 * ap_test_config(): helper function to extract the nrth bit
1029 * within the unsigned int array field.
1030 */
1031static inline int ap_test_config(unsigned int *field, unsigned int nr)
1032{
1033 if (nr > 0xFFu)
1034 return 0;
1035 return ap_test_bit((field + (nr >> 5)), (nr & 0x1f));
1036}
1037
1038/*
1039 * ap_test_config_card_id(): Test, whether an AP card ID is configured.
1040 * @id AP card ID
1041 *
1042 * Returns 0 if the card is not configured
1043 * 1 if the card is configured or
1044 * if the configuration information is not available
1045 */
1046static inline int ap_test_config_card_id(unsigned int id)
1047{
1048 if (!ap_configuration)
1049 return 1;
1050 return ap_test_config(ap_configuration->apm, id);
1051}
1052
1053/*
1054 * ap_test_config_domain(): Test, whether an AP usage domain is configured.
1055 * @domain AP usage domain ID
1056 *
1057 * Returns 0 if the usage domain is not configured
1058 * 1 if the usage domain is configured or
1059 * if the configuration information is not available
1060 */
1061static inline int ap_test_config_domain(unsigned int domain)
1062{
1063 if (!ap_configuration)
1064 return 1;
1065 return ap_test_config(ap_configuration->aqm, domain);
1066}
1067
1068/*
1010 * AP bus attributes. 1069 * AP bus attributes.
1011 */ 1070 */
1012static ssize_t ap_domain_show(struct bus_type *bus, char *buf) 1071static ssize_t ap_domain_show(struct bus_type *bus, char *buf)
@@ -1121,6 +1180,42 @@ static ssize_t poll_timeout_store(struct bus_type *bus, const char *buf,
1121 1180
1122static BUS_ATTR(poll_timeout, 0644, poll_timeout_show, poll_timeout_store); 1181static BUS_ATTR(poll_timeout, 0644, poll_timeout_show, poll_timeout_store);
1123 1182
1183static ssize_t ap_max_domain_id_show(struct bus_type *bus, char *buf)
1184{
1185 ap_qid_t qid;
1186 int i, nd, max_domain_id = -1;
1187 unsigned long fbits;
1188
1189 if (ap_configuration) {
1190 if (ap_domain_index >= 0 && ap_domain_index < AP_DOMAINS) {
1191 for (i = 0; i < AP_DEVICES; i++) {
1192 if (!ap_test_config_card_id(i))
1193 continue;
1194 qid = AP_MKQID(i, ap_domain_index);
1195 fbits = ap_query_facilities(qid);
1196 if (fbits & (1UL << 57)) {
1197 /* the N bit is 0, Nd field is filled */
1198 nd = (int)((fbits & 0x00FF0000UL)>>16);
1199 if (nd > 0)
1200 max_domain_id = nd;
1201 else
1202 max_domain_id = 15;
1203 } else {
1204 /* N bit is 1, max 16 domains */
1205 max_domain_id = 15;
1206 }
1207 break;
1208 }
1209 }
1210 } else {
1211 /* no APXA support, older machines with max 16 domains */
1212 max_domain_id = 15;
1213 }
1214 return snprintf(buf, PAGE_SIZE, "%d\n", max_domain_id);
1215}
1216
1217static BUS_ATTR(ap_max_domain_id, 0444, ap_max_domain_id_show, NULL);
1218
1124static struct bus_attribute *const ap_bus_attrs[] = { 1219static struct bus_attribute *const ap_bus_attrs[] = {
1125 &bus_attr_ap_domain, 1220 &bus_attr_ap_domain,
1126 &bus_attr_ap_control_domain_mask, 1221 &bus_attr_ap_control_domain_mask,
@@ -1128,50 +1223,10 @@ static struct bus_attribute *const ap_bus_attrs[] = {
1128 &bus_attr_poll_thread, 1223 &bus_attr_poll_thread,
1129 &bus_attr_ap_interrupts, 1224 &bus_attr_ap_interrupts,
1130 &bus_attr_poll_timeout, 1225 &bus_attr_poll_timeout,
1226 &bus_attr_ap_max_domain_id,
1131 NULL, 1227 NULL,
1132}; 1228};
1133 1229
1134static inline int ap_test_config(unsigned int *field, unsigned int nr)
1135{
1136 if (nr > 0xFFu)
1137 return 0;
1138 return ap_test_bit((field + (nr >> 5)), (nr & 0x1f));
1139}
1140
1141/*
1142 * ap_test_config_card_id(): Test, whether an AP card ID is configured.
1143 * @id AP card ID
1144 *
1145 * Returns 0 if the card is not configured
1146 * 1 if the card is configured or
1147 * if the configuration information is not available
1148 */
1149static inline int ap_test_config_card_id(unsigned int id)
1150{
1151 if (!ap_configuration)
1152 return 1;
1153 return ap_test_config(ap_configuration->apm, id);
1154}
1155
1156/*
1157 * ap_test_config_domain(): Test, whether an AP usage domain is configured.
1158 * @domain AP usage domain ID
1159 *
1160 * Returns 0 if the usage domain is not configured
1161 * 1 if the usage domain is configured or
1162 * if the configuration information is not available
1163 */
1164static inline int ap_test_config_domain(unsigned int domain)
1165{
1166 if (!ap_configuration) /* QCI not supported */
1167 if (domain < 16)
1168 return 1; /* then domains 0...15 are configured */
1169 else
1170 return 0;
1171 else
1172 return ap_test_config(ap_configuration->aqm, domain);
1173}
1174
1175/** 1230/**
1176 * ap_query_configuration(): Query AP configuration information. 1231 * ap_query_configuration(): Query AP configuration information.
1177 * 1232 *