]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
s390/zcrypt: Make apfs a real unsigned int field
authorHarald Freudenberger <freude@linux.ibm.com>
Wed, 18 Mar 2026 16:41:30 +0000 (17:41 +0100)
committerVasily Gorbik <gor@linux.ibm.com>
Tue, 24 Mar 2026 20:00:41 +0000 (21:00 +0100)
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>
drivers/s390/crypto/zcrypt_error.h
drivers/s390/crypto/zcrypt_msgtype6.c
drivers/s390/crypto/zcrypt_msgtype6.h

index 46e27b43a8afe7df13dc43af6aaf35e31918f253..fd10302e68d36b80ed04399bad28eb42bd112fc0 100644 (file)
@@ -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,
index 3bd24bceebd442578c52dd6601c6febccdb9617c..02648d0e838050849a49a41978f0fecde57aee38 100644 (file)
@@ -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)
index 9cbe6e2b2d33c6858ad32656dd428d7269d4055e..8cc227df55c8834894e3d78c3466638da537df12 100644 (file)
@@ -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                   */