Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

s390/zcrypt: Rework domain processing within zcrypt device driver

Slight rework of the domain handling within the zcrypt dd:
Remove this curious construct to give a pointer to the
domain field within the CPRB struct to the zcrypt API and
later fill in the target domain via this pointer.
Now the domain is filled in with the send function when
the ready constructed AP message is about to be pushed
down into the software queue for AP queue processing.
So now the domain handling for CCA, EP11 and (internal) rng
CPRBs is the same. With this comes a slight reshuffle of the
code related to domain processing in the zcrypt API and the
message type 60 protocol implementation code.

Reviewed-by: Holger Dengler <dengler@linux.ibm.com>
Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>

authored by

Harald Freudenberger and committed by
Vasily Gorbik
e2c6d91e 23a4757d

+29 -31
+14 -22
drivers/s390/crypto/zcrypt_api.c
··· 854 854 struct ica_xcRB *xcrb) 855 855 { 856 856 bool userspace = xflags & ZCRYPT_XFLAG_USERSPACE; 857 - struct zcrypt_card *zc, *pref_zc; 858 - struct zcrypt_queue *zq, *pref_zq; 859 - struct ap_message ap_msg; 857 + unsigned int domain, func_code = 0; 860 858 unsigned int wgt = 0, pref_wgt = 0; 861 - unsigned int func_code = 0; 862 - unsigned short *domain, tdom; 859 + struct zcrypt_queue *zq, *pref_zq; 860 + struct zcrypt_card *zc, *pref_zc; 863 861 int cpen, qpen, qid = 0, rc; 862 + struct ap_message ap_msg; 864 863 struct module *mod; 865 864 866 865 trace_s390_zcrypt_req(xcrb, TB_ZSECSENDCPRB); ··· 877 878 print_hex_dump_debug("ccareq: ", DUMP_PREFIX_ADDRESS, 16, 1, 878 879 ap_msg.msg, ap_msg.len, false); 879 880 880 - tdom = *domain; 881 - if (perms != &ap_perms && tdom < AP_DOMAINS) { 881 + if (perms != &ap_perms && domain < AP_DOMAINS) { 882 882 if (ap_msg.flags & AP_MSG_FLAG_ADMIN) { 883 - if (!test_bit_inv(tdom, perms->adm)) { 883 + if (!test_bit_inv(domain, perms->adm)) { 884 884 rc = -ENODEV; 885 885 goto out; 886 886 } ··· 892 894 * If a valid target domain is set and this domain is NOT a usage 893 895 * domain but a control only domain, autoselect target domain. 894 896 */ 895 - if (tdom < AP_DOMAINS && 896 - !ap_test_config_usage_domain(tdom) && 897 - ap_test_config_ctrl_domain(tdom)) 898 - tdom = AUTOSEL_DOM; 897 + if (domain < AP_DOMAINS && 898 + !ap_test_config_usage_domain(domain) && 899 + ap_test_config_ctrl_domain(domain)) 900 + domain = AUTOSEL_DOM; 899 901 900 902 pref_zc = NULL; 901 903 pref_zq = NULL; ··· 927 929 /* check for device usable and eligible */ 928 930 if (!zq->online || !zq->ops->send_cprb || 929 931 !ap_queue_usable(zq->queue) || 930 - (tdom != AUTOSEL_DOM && 931 - tdom != AP_QID_QUEUE(zq->queue->qid))) 932 + (domain != AUTOSEL_DOM && 933 + domain != AP_QID_QUEUE(zq->queue->qid))) 932 934 continue; 933 935 /* check if device node has admission for this queue */ 934 936 if (!zcrypt_check_queue(perms, ··· 951 953 952 954 if (!pref_zq) { 953 955 pr_debug("no match for address %02x.%04x => ENODEV\n", 954 - xcrb->user_defined, *domain); 956 + xcrb->user_defined, domain); 955 957 rc = -ENODEV; 956 958 goto out; 957 959 } 958 - 959 - /* in case of auto select, provide the correct domain */ 960 - qid = pref_zq->queue->qid; 961 - if (*domain == AUTOSEL_DOM) 962 - *domain = AP_QID_QUEUE(qid); 963 960 964 961 rc = pref_zq->ops->send_cprb(userspace, pref_zq, xcrb, &ap_msg); 965 962 if (!rc) { ··· 1213 1220 unsigned int wgt = 0, pref_wgt = 0; 1214 1221 unsigned int func_code = 0; 1215 1222 struct ap_message ap_msg; 1216 - unsigned int domain; 1217 1223 int qid = 0, rc = -ENODEV; 1218 1224 struct module *mod; 1219 1225 ··· 1221 1229 rc = ap_init_apmsg(&ap_msg, 0); 1222 1230 if (rc) 1223 1231 goto out; 1224 - rc = prep_rng_ap_msg(&ap_msg, &func_code, &domain); 1232 + rc = prep_rng_ap_msg(&ap_msg, &func_code, NULL); 1225 1233 if (rc) 1226 1234 goto out; 1227 1235
+14 -8
drivers/s390/crypto/zcrypt_msgtype6.c
··· 328 328 static int xcrb_msg_to_type6cprb_msgx(bool userspace, struct ap_message *ap_msg, 329 329 struct ica_xcRB *xcrb, 330 330 unsigned int *fcode, 331 - unsigned short **dom) 331 + unsigned int *domain) 332 332 { 333 333 static struct type6_hdr static_type6_hdrX = { 334 334 .type = 0x06, ··· 412 412 sizeof(msg->hdr.function_code)); 413 413 414 414 *fcode = (msg->hdr.function_code[0] << 8) | msg->hdr.function_code[1]; 415 - *dom = (unsigned short *)&msg->cprbx.domain; 415 + if (domain) 416 + *domain = msg->cprbx.domain; 416 417 417 418 /* check subfunction, US and AU need special flag with NQAP */ 418 419 if (memcmp(function_code, "US", 2) == 0 || ··· 530 529 else 531 530 ap_msg->flags |= AP_MSG_FLAG_USAGE; 532 531 533 - *domain = msg->cprbx.target_id; 532 + if (domain) 533 + *domain = msg->cprbx.target_id; 534 534 535 535 return 0; 536 536 } ··· 1058 1056 */ 1059 1057 int prep_cca_ap_msg(bool userspace, struct ica_xcRB *xcrb, 1060 1058 struct ap_message *ap_msg, 1061 - unsigned int *func_code, unsigned short **dom) 1059 + unsigned int *func_code, unsigned int *domain) 1062 1060 { 1063 1061 struct ap_response_type *resp_type = &ap_msg->response; 1064 1062 ··· 1066 1064 ap_msg->psmid = (((unsigned long)current->pid) << 32) + 1067 1065 atomic_inc_return(&zcrypt_step); 1068 1066 resp_type->type = CEXXC_RESPONSE_TYPE_XCRB; 1069 - return xcrb_msg_to_type6cprb_msgx(userspace, ap_msg, xcrb, func_code, dom); 1067 + return xcrb_msg_to_type6cprb_msgx(userspace, ap_msg, 1068 + xcrb, func_code, domain); 1070 1069 } 1071 1070 1072 1071 /* ··· 1111 1108 } 1112 1109 msg->hdr.fromcardlen1 -= delta; 1113 1110 } 1111 + 1112 + /* update domain field within the CPRB struct */ 1113 + msg->cprbx.domain = AP_QID_QUEUE(zq->queue->qid); 1114 1114 1115 1115 init_completion(&resp_type->work); 1116 1116 rc = ap_queue_message(zq->queue, ap_msg); ··· 1220 1214 lfmt = 1; /* length format #1 */ 1221 1215 } 1222 1216 payload_hdr = (struct pld_hdr *)((&msg->pld_lenfmt) + lfmt); 1223 - payload_hdr->dom_val = (unsigned int) 1224 - AP_QID_QUEUE(zq->queue->qid); 1217 + payload_hdr->dom_val = AP_QID_QUEUE(zq->queue->qid); 1225 1218 } 1226 1219 1227 1220 /* ··· 1301 1296 msg->verb_length = 0x02; 1302 1297 msg->key_length = 0x02; 1303 1298 ap_msg->len = sizeof(*msg); 1304 - *domain = (unsigned short)msg->cprbx.domain; 1299 + if (domain) 1300 + *domain = msg->cprbx.domain; 1305 1301 } 1306 1302 1307 1303 /*
+1 -1
drivers/s390/crypto/zcrypt_msgtype6.h
··· 96 96 97 97 int prep_cca_ap_msg(bool userspace, struct ica_xcRB *xcrb, 98 98 struct ap_message *ap_msg, 99 - unsigned int *fc, unsigned short **dom); 99 + unsigned int *fc, unsigned int *dom); 100 100 int prep_ep11_ap_msg(bool userspace, struct ep11_urb *xcrb, 101 101 struct ap_message *ap_msg, 102 102 unsigned int *fc, unsigned int *dom);