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);
else
return AP_SM_WAIT_NONE;
spin_lock_bh(&aq->lock);
aq->dev_state = AP_DEV_STATE_OPERATING;
aq->sm_state = AP_SM_STATE_RESET_START;
+ aq->last_err_rc = 0;
ap_wait(ap_sm_event(aq, AP_SM_EVENT_POLL));
spin_unlock_bh(&aq->lock);
}
spin_unlock(&zcrypt_list_lock);
if (!pref_zq) {
+ ZCRYPT_DBF_DBG("%s no matching queue found => ENODEV\n",
+ __func__);
rc = -ENODEV;
goto out;
}
spin_unlock(&zcrypt_list_lock);
if (!pref_zq) {
+ ZCRYPT_DBF_DBG("%s no matching queue found => ENODEV\n",
+ __func__);
rc = -ENODEV;
goto out;
}
spin_unlock(&zcrypt_list_lock);
if (!pref_zq) {
+ ZCRYPT_DBF_DBG("%s no match for address %02x.%04x => ENODEV\n",
+ __func__, xcRB->user_defined, *domain);
rc = -ENODEV;
goto out;
}
spin_unlock(&zcrypt_list_lock);
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;
goto out_free;
}
spin_unlock(&zcrypt_list_lock);
if (!pref_zq) {
+ ZCRYPT_DBF_DBG("%s no matching queue found => ENODEV\n",
+ __func__);
rc = -ENODEV;
goto out;
}
ap_cancel_message(zq->queue, ap_msg);
out:
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;
}
ap_cancel_message(zq->queue, ap_msg);
out:
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;
}
char *data = reply->msg;
/* 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,
data + msg->fmt2.offset1, msg->fmt2.count1))
return -EFAULT;
xcRB->reply_control_blk_length = msg->fmt2.count1;
/* 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,
data + msg->fmt2.offset2, msg->fmt2.count2))
return -EFAULT;
+ }
xcRB->reply_data_length = msg->fmt2.count2;
+
return 0;
}
struct type86_fmt2_msg *msg = reply->msg;
char *data = reply->msg;
- if (xcRB->resp_len < msg->fmt2.count1)
- return -EINVAL;
+ if (xcRB->resp_len < msg->fmt2.count1) {
+ 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 */
if (z_copy_to_user(userspace, (char __force __user *)xcRB->resp,
/* Signal pending. */
ap_cancel_message(zq->queue, ap_msg);
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;
}
/* Signal pending. */
ap_cancel_message(zq->queue, ap_msg);
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;
}