Commit d64e5e91 authored by Harald Freudenberger's avatar Harald Freudenberger Committed by Vasily Gorbik

s390/ap/zcrypt: debug feature improvements

This patch adds some debug feature improvements related
to some failures happened in the past. With CEX8 the max
request and response sizes have been extended but the
user space applications did not rework their code and
thus ran into receive buffer issues. This ffdc patch
here helps with additional checks and debug feature
messages in debugging and pointing to the root cause of
some failures related to wrong buffer sizes.
Signed-off-by: default avatarHarald Freudenberger <freude@linux.ibm.com>
Reviewed-by: default avatarJürgen Christ <jchrist@linux.ibm.com>
Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
parent 966ffbd8
...@@ -455,7 +455,7 @@ static ap_func_t *ap_jumptable[NR_AP_SM_STATES][NR_AP_SM_EVENTS] = { ...@@ -455,7 +455,7 @@ static ap_func_t *ap_jumptable[NR_AP_SM_STATES][NR_AP_SM_EVENTS] = {
enum ap_sm_wait ap_sm_event(struct ap_queue *aq, enum ap_sm_event event) enum ap_sm_wait ap_sm_event(struct ap_queue *aq, enum ap_sm_event event)
{ {
if (aq->dev_state > AP_DEV_STATE_UNINITIATED) if (aq->config && aq->dev_state > AP_DEV_STATE_UNINITIATED)
return ap_jumptable[aq->sm_state][event](aq); return ap_jumptable[aq->sm_state][event](aq);
else else
return AP_SM_WAIT_NONE; return AP_SM_WAIT_NONE;
...@@ -915,6 +915,7 @@ void ap_queue_init_state(struct ap_queue *aq) ...@@ -915,6 +915,7 @@ void ap_queue_init_state(struct ap_queue *aq)
spin_lock_bh(&aq->lock); spin_lock_bh(&aq->lock);
aq->dev_state = AP_DEV_STATE_OPERATING; aq->dev_state = AP_DEV_STATE_OPERATING;
aq->sm_state = AP_SM_STATE_RESET_START; aq->sm_state = AP_SM_STATE_RESET_START;
aq->last_err_rc = 0;
ap_wait(ap_sm_event(aq, AP_SM_EVENT_POLL)); ap_wait(ap_sm_event(aq, AP_SM_EVENT_POLL));
spin_unlock_bh(&aq->lock); spin_unlock_bh(&aq->lock);
} }
......
...@@ -714,6 +714,8 @@ static long zcrypt_rsa_modexpo(struct ap_perms *perms, ...@@ -714,6 +714,8 @@ static long zcrypt_rsa_modexpo(struct ap_perms *perms,
spin_unlock(&zcrypt_list_lock); spin_unlock(&zcrypt_list_lock);
if (!pref_zq) { if (!pref_zq) {
ZCRYPT_DBF_DBG("%s no matching queue found => ENODEV\n",
__func__);
rc = -ENODEV; rc = -ENODEV;
goto out; goto out;
} }
...@@ -822,6 +824,8 @@ static long zcrypt_rsa_crt(struct ap_perms *perms, ...@@ -822,6 +824,8 @@ static long zcrypt_rsa_crt(struct ap_perms *perms,
spin_unlock(&zcrypt_list_lock); spin_unlock(&zcrypt_list_lock);
if (!pref_zq) { if (!pref_zq) {
ZCRYPT_DBF_DBG("%s no matching queue found => ENODEV\n",
__func__);
rc = -ENODEV; rc = -ENODEV;
goto out; goto out;
} }
...@@ -940,6 +944,8 @@ static long _zcrypt_send_cprb(bool userspace, struct ap_perms *perms, ...@@ -940,6 +944,8 @@ static long _zcrypt_send_cprb(bool userspace, struct ap_perms *perms,
spin_unlock(&zcrypt_list_lock); spin_unlock(&zcrypt_list_lock);
if (!pref_zq) { if (!pref_zq) {
ZCRYPT_DBF_DBG("%s no match for address %02x.%04x => ENODEV\n",
__func__, xcRB->user_defined, *domain);
rc = -ENODEV; rc = -ENODEV;
goto out; goto out;
} }
...@@ -1112,6 +1118,17 @@ static long _zcrypt_send_ep11_cprb(bool userspace, struct ap_perms *perms, ...@@ -1112,6 +1118,17 @@ static long _zcrypt_send_ep11_cprb(bool userspace, struct ap_perms *perms,
spin_unlock(&zcrypt_list_lock); spin_unlock(&zcrypt_list_lock);
if (!pref_zq) { if (!pref_zq) {
if (targets && target_num == 1) {
ZCRYPT_DBF_DBG("%s no match for address %02x.%04x => ENODEV\n",
__func__, (int) targets->ap_id,
(int) targets->dom_id);
} else if (targets) {
ZCRYPT_DBF_DBG("%s no match for %d target addrs => ENODEV\n",
__func__, (int) target_num);
} else {
ZCRYPT_DBF_DBG("%s no match for address ff.ffff => ENODEV\n",
__func__);
}
rc = -ENODEV; rc = -ENODEV;
goto out_free; goto out_free;
} }
...@@ -1188,6 +1205,8 @@ static long zcrypt_rng(char *buffer) ...@@ -1188,6 +1205,8 @@ static long zcrypt_rng(char *buffer)
spin_unlock(&zcrypt_list_lock); spin_unlock(&zcrypt_list_lock);
if (!pref_zq) { if (!pref_zq) {
ZCRYPT_DBF_DBG("%s no matching queue found => ENODEV\n",
__func__);
rc = -ENODEV; rc = -ENODEV;
goto out; goto out;
} }
......
...@@ -497,6 +497,10 @@ static long zcrypt_cex2a_modexpo(struct zcrypt_queue *zq, ...@@ -497,6 +497,10 @@ static long zcrypt_cex2a_modexpo(struct zcrypt_queue *zq,
ap_cancel_message(zq->queue, ap_msg); ap_cancel_message(zq->queue, ap_msg);
out: out:
ap_msg->private = NULL; ap_msg->private = NULL;
if (rc)
ZCRYPT_DBF_DBG("%s send me cprb at dev=%02x.%04x rc=%d\n",
__func__, AP_QID_CARD(zq->queue->qid),
AP_QID_QUEUE(zq->queue->qid), rc);
return rc; return rc;
} }
...@@ -542,6 +546,10 @@ static long zcrypt_cex2a_modexpo_crt(struct zcrypt_queue *zq, ...@@ -542,6 +546,10 @@ static long zcrypt_cex2a_modexpo_crt(struct zcrypt_queue *zq,
ap_cancel_message(zq->queue, ap_msg); ap_cancel_message(zq->queue, ap_msg);
out: out:
ap_msg->private = NULL; ap_msg->private = NULL;
if (rc)
ZCRYPT_DBF_DBG("%s send crt cprb at dev=%02x.%04x rc=%d\n",
__func__, AP_QID_CARD(zq->queue->qid),
AP_QID_QUEUE(zq->queue->qid), rc);
return rc; return rc;
} }
......
...@@ -714,17 +714,31 @@ static int convert_type86_xcrb(bool userspace, struct zcrypt_queue *zq, ...@@ -714,17 +714,31 @@ static int convert_type86_xcrb(bool userspace, struct zcrypt_queue *zq,
char *data = reply->msg; char *data = reply->msg;
/* Copy CPRB to user */ /* Copy CPRB to user */
if (xcRB->reply_control_blk_length < msg->fmt2.count1) {
ZCRYPT_DBF_DBG("%s reply_control_blk_length %u < required %u => EMSGSIZE\n",
__func__, xcRB->reply_control_blk_length,
msg->fmt2.count1);
return -EMSGSIZE;
}
if (z_copy_to_user(userspace, xcRB->reply_control_blk_addr, if (z_copy_to_user(userspace, xcRB->reply_control_blk_addr,
data + msg->fmt2.offset1, msg->fmt2.count1)) data + msg->fmt2.offset1, msg->fmt2.count1))
return -EFAULT; return -EFAULT;
xcRB->reply_control_blk_length = msg->fmt2.count1; xcRB->reply_control_blk_length = msg->fmt2.count1;
/* Copy data buffer to user */ /* Copy data buffer to user */
if (msg->fmt2.count2) if (msg->fmt2.count2) {
if (xcRB->reply_data_length < msg->fmt2.count2) {
ZCRYPT_DBF_DBG("%s reply_data_length %u < required %u => EMSGSIZE\n",
__func__, xcRB->reply_data_length,
msg->fmt2.count2);
return -EMSGSIZE;
}
if (z_copy_to_user(userspace, xcRB->reply_data_addr, if (z_copy_to_user(userspace, xcRB->reply_data_addr,
data + msg->fmt2.offset2, msg->fmt2.count2)) data + msg->fmt2.offset2, msg->fmt2.count2))
return -EFAULT; return -EFAULT;
}
xcRB->reply_data_length = msg->fmt2.count2; xcRB->reply_data_length = msg->fmt2.count2;
return 0; return 0;
} }
...@@ -744,8 +758,12 @@ static int convert_type86_ep11_xcrb(bool userspace, struct zcrypt_queue *zq, ...@@ -744,8 +758,12 @@ static int convert_type86_ep11_xcrb(bool userspace, struct zcrypt_queue *zq,
struct type86_fmt2_msg *msg = reply->msg; struct type86_fmt2_msg *msg = reply->msg;
char *data = reply->msg; char *data = reply->msg;
if (xcRB->resp_len < msg->fmt2.count1) if (xcRB->resp_len < msg->fmt2.count1) {
return -EINVAL; ZCRYPT_DBF_DBG("%s resp_len %u < required %u => EMSGSIZE\n",
__func__, (unsigned int)xcRB->resp_len,
msg->fmt2.count1);
return -EMSGSIZE;
}
/* Copy response CPRB to user */ /* Copy response CPRB to user */
if (z_copy_to_user(userspace, (char __force __user *)xcRB->resp, if (z_copy_to_user(userspace, (char __force __user *)xcRB->resp,
...@@ -1167,6 +1185,10 @@ static long zcrypt_msgtype6_send_cprb(bool userspace, struct zcrypt_queue *zq, ...@@ -1167,6 +1185,10 @@ static long zcrypt_msgtype6_send_cprb(bool userspace, struct zcrypt_queue *zq,
/* Signal pending. */ /* Signal pending. */
ap_cancel_message(zq->queue, ap_msg); ap_cancel_message(zq->queue, ap_msg);
out: out:
if (rc)
ZCRYPT_DBF_DBG("%s send cprb at dev=%02x.%04x rc=%d\n",
__func__, AP_QID_CARD(zq->queue->qid),
AP_QID_QUEUE(zq->queue->qid), rc);
return rc; return rc;
} }
...@@ -1272,6 +1294,10 @@ static long zcrypt_msgtype6_send_ep11_cprb(bool userspace, struct zcrypt_queue * ...@@ -1272,6 +1294,10 @@ static long zcrypt_msgtype6_send_ep11_cprb(bool userspace, struct zcrypt_queue *
/* Signal pending. */ /* Signal pending. */
ap_cancel_message(zq->queue, ap_msg); ap_cancel_message(zq->queue, ap_msg);
out: out:
if (rc)
ZCRYPT_DBF_DBG("%s send cprb at dev=%02x.%04x rc=%d\n",
__func__, AP_QID_CARD(zq->queue->qid),
AP_QID_QUEUE(zq->queue->qid), rc);
return rc; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment