Skip to content

Commit ecd2fd1

Browse files
hfreudeVasily Gorbik
authored andcommitted
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: 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>
1 parent e2c6d91 commit ecd2fd1

3 files changed

Lines changed: 13 additions & 21 deletions

File tree

drivers/s390/crypto/zcrypt_error.h

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,13 @@ struct error_hdr {
7878
static inline int convert_error(struct zcrypt_queue *zq,
7979
struct ap_message *reply)
8080
{
81-
struct error_hdr *ehdr = reply->msg;
82-
int card = AP_QID_CARD(zq->queue->qid);
8381
int queue = AP_QID_QUEUE(zq->queue->qid);
82+
int card = AP_QID_CARD(zq->queue->qid);
83+
struct error_hdr *ehdr = reply->msg;
84+
struct {
85+
struct type86_hdr hdr;
86+
struct type86_fmt2_ext fmt2;
87+
} __packed * t86hdr = reply->msg;
8488

8589
switch (ehdr->reply_code) {
8690
case REP82_ERROR_INVALID_MSG_LEN: /* 0x23 */
@@ -100,19 +104,12 @@ static inline int convert_error(struct zcrypt_queue *zq,
100104
/* RY indicates malformed request */
101105
if (ehdr->reply_code == REP82_ERROR_FILTERED_BY_HYPERVISOR &&
102106
ehdr->type == TYPE86_RSP_CODE) {
103-
struct {
104-
struct type86_hdr hdr;
105-
struct type86_fmt2_ext fmt2;
106-
} __packed * head = reply->msg;
107-
unsigned int apfs = *((u32 *)head->fmt2.apfs);
108-
109107
ZCRYPT_DBF_WARN("%s dev=%02x.%04x RY=0x%02x apfs=0x%x => rc=EINVAL\n",
110108
__func__, card, queue,
111-
ehdr->reply_code, apfs);
109+
ehdr->reply_code, t86hdr->fmt2.apfs);
112110
} else {
113111
ZCRYPT_DBF_WARN("%s dev=%02x.%04x RY=0x%02x => rc=EINVAL\n",
114-
__func__, card, queue,
115-
ehdr->reply_code);
112+
__func__, card, queue, ehdr->reply_code);
116113
}
117114
return -EINVAL;
118115
case REP82_ERROR_MACHINE_FAILURE: /* 0x10 */
@@ -125,15 +122,10 @@ static inline int convert_error(struct zcrypt_queue *zq,
125122
/* For type 86 response show the apfs value (failure reason) */
126123
if (ehdr->reply_code == REP82_ERROR_TRANSPORT_FAIL &&
127124
ehdr->type == TYPE86_RSP_CODE) {
128-
struct {
129-
struct type86_hdr hdr;
130-
struct type86_fmt2_ext fmt2;
131-
} __packed * head = reply->msg;
132-
unsigned int apfs = *((u32 *)head->fmt2.apfs);
133-
134125
ZCRYPT_DBF_WARN(
135126
"%s dev=%02x.%04x RY=0x%02x apfs=0x%x => bus rescan, rc=EAGAIN\n",
136-
__func__, card, queue, ehdr->reply_code, apfs);
127+
__func__, card, queue, ehdr->reply_code,
128+
t86hdr->fmt2.apfs);
137129
} else {
138130
ZCRYPT_DBF_WARN("%s dev=%02x.%04x RY=0x%02x => bus rescan, rc=EAGAIN\n",
139131
__func__, card, queue,

drivers/s390/crypto/zcrypt_msgtype6.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ static int convert_response_xcrb(bool userspace, struct zcrypt_queue *zq,
753753
return convert_error(zq, reply);
754754
case TYPE86_RSP_CODE:
755755
if (msg->hdr.reply_code) {
756-
memcpy(&xcrb->status, msg->fmt2.apfs, sizeof(u32));
756+
xcrb->status = msg->fmt2.apfs;
757757
return convert_error(zq, reply);
758758
}
759759
if (msg->cprbx.cprb_ver_id == 0x02)

drivers/s390/crypto/zcrypt_msgtype6.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct type6_hdr {
3434
unsigned char right[4]; /* 0x00000000 */
3535
unsigned char reserved3[2]; /* 0x0000 */
3636
unsigned char reserved4[2]; /* 0x0000 */
37-
unsigned char apfs[4]; /* 0x00000000 */
37+
unsigned int apfs; /* 0x00000000 */
3838
unsigned int offset1; /* 0x00000058 (offset to CPRB) */
3939
unsigned int offset2; /* 0x00000000 */
4040
unsigned int offset3; /* 0x00000000 */
@@ -83,7 +83,7 @@ struct type86_hdr {
8383

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

0 commit comments

Comments
 (0)