Commit ecd2fd11 authored by Harald Freudenberger's avatar Harald Freudenberger Committed by Vasily Gorbik
Browse files

s390/zcrypt: Make apfs a real unsigned int field



Slight rework on the apfs field: Instead of unsigned char[4]
make this a real 32 bit unsigned int field. With that done,
some assignments and some printouts can be simplified.
With that comes a slight move of the anonymous struct covering
the message type 86 header to dedupe some code lines.

Reviewed-by: default avatarHolger Dengler <dengler@linux.ibm.com>
Signed-off-by: default avatarHarald Freudenberger <freude@linux.ibm.com>
Acked-by: default avatarHeiko Carstens <hca@linux.ibm.com>
Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
parent e2c6d91e
Loading
Loading
Loading
Loading
+10 −18
Original line number Diff line number Diff line
@@ -78,9 +78,13 @@ struct error_hdr {
static inline int convert_error(struct zcrypt_queue *zq,
				struct ap_message *reply)
{
	struct error_hdr *ehdr = reply->msg;
	int card = AP_QID_CARD(zq->queue->qid);
	int queue = AP_QID_QUEUE(zq->queue->qid);
	int card = AP_QID_CARD(zq->queue->qid);
	struct error_hdr *ehdr = reply->msg;
	struct {
		struct type86_hdr hdr;
		struct type86_fmt2_ext fmt2;
	} __packed * t86hdr = reply->msg;

	switch (ehdr->reply_code) {
	case REP82_ERROR_INVALID_MSG_LEN:	 /* 0x23 */
@@ -100,19 +104,12 @@ static inline int convert_error(struct zcrypt_queue *zq,
		/* RY indicates malformed request */
		if (ehdr->reply_code == REP82_ERROR_FILTERED_BY_HYPERVISOR &&
		    ehdr->type == TYPE86_RSP_CODE) {
			struct {
				struct type86_hdr hdr;
				struct type86_fmt2_ext fmt2;
			} __packed * head = reply->msg;
			unsigned int apfs = *((u32 *)head->fmt2.apfs);

			ZCRYPT_DBF_WARN("%s dev=%02x.%04x RY=0x%02x apfs=0x%x => rc=EINVAL\n",
					__func__, card, queue,
					ehdr->reply_code, apfs);
					ehdr->reply_code, t86hdr->fmt2.apfs);
		} else {
			ZCRYPT_DBF_WARN("%s dev=%02x.%04x RY=0x%02x => rc=EINVAL\n",
					__func__, card, queue,
					ehdr->reply_code);
					__func__, card, queue, ehdr->reply_code);
		}
		return -EINVAL;
	case REP82_ERROR_MACHINE_FAILURE:	 /* 0x10 */
@@ -125,15 +122,10 @@ static inline int convert_error(struct zcrypt_queue *zq,
		/* For type 86 response show the apfs value (failure reason) */
		if (ehdr->reply_code == REP82_ERROR_TRANSPORT_FAIL &&
		    ehdr->type == TYPE86_RSP_CODE) {
			struct {
				struct type86_hdr hdr;
				struct type86_fmt2_ext fmt2;
			} __packed * head = reply->msg;
			unsigned int apfs = *((u32 *)head->fmt2.apfs);

			ZCRYPT_DBF_WARN(
				"%s dev=%02x.%04x RY=0x%02x apfs=0x%x => bus rescan, rc=EAGAIN\n",
				__func__, card, queue, ehdr->reply_code, apfs);
				__func__, card, queue, ehdr->reply_code,
				t86hdr->fmt2.apfs);
		} else {
			ZCRYPT_DBF_WARN("%s dev=%02x.%04x RY=0x%02x => bus rescan, rc=EAGAIN\n",
					__func__, card, queue,
+1 −1
Original line number Diff line number Diff line
@@ -753,7 +753,7 @@ static int convert_response_xcrb(bool userspace, struct zcrypt_queue *zq,
		return convert_error(zq, reply);
	case TYPE86_RSP_CODE:
		if (msg->hdr.reply_code) {
			memcpy(&xcrb->status, msg->fmt2.apfs, sizeof(u32));
			xcrb->status = msg->fmt2.apfs;
			return convert_error(zq, reply);
		}
		if (msg->cprbx.cprb_ver_id == 0x02)
+2 −2
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ struct type6_hdr {
	unsigned char right[4];		/* 0x00000000			*/
	unsigned char reserved3[2];	/* 0x0000			*/
	unsigned char reserved4[2];	/* 0x0000			*/
	unsigned char apfs[4];		/* 0x00000000			*/
	unsigned int  apfs;		/* 0x00000000			*/
	unsigned int  offset1;		/* 0x00000058 (offset to CPRB)	*/
	unsigned int  offset2;		/* 0x00000000			*/
	unsigned int  offset3;		/* 0x00000000			*/
@@ -83,7 +83,7 @@ struct type86_hdr {

struct type86_fmt2_ext {
	unsigned char	  reserved[4];	/* 0x00000000			*/
	unsigned char	  apfs[4];	/* final status			*/
	unsigned int	  apfs;		/* final status			*/
	unsigned int	  count1;	/* length of CPRB + parameters	*/
	unsigned int	  offset1;	/* offset to CPRB		*/
	unsigned int	  count2;	/* 0x00000000			*/