]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
s390/zcrypt: Slight rework on the agent_id field
authorHarald Freudenberger <freude@linux.ibm.com>
Wed, 18 Mar 2026 16:41:33 +0000 (17:41 +0100)
committerVasily Gorbik <gor@linux.ibm.com>
Tue, 24 Mar 2026 20:00:42 +0000 (21:00 +0100)
The agent_id field is a two byte ascii field addressing
the target agent on the crypto card. Some code however
addresses this field as unsigned short. Rework these
places to treat this field always as a two byte array.
Unfortunately this field also shows up as __u16 in
struct ica_xcRB as part of the zcrypt ioctl interface.
Leave this untouched as it would break the API.

There are two other places (func_id) where a byte array
gets assigned with hex values but in fact these are ascii
value. So replace these assignments with real ascii values
for more readability.

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_ccamisc.c
drivers/s390/crypto/zcrypt_msgtype6.c

index 3727e0df9827ef6401807a66f9384a9c9430da14..135033f94c36d2eba0472043e5ab8c60dad78199 100644 (file)
@@ -305,7 +305,7 @@ static inline void prep_xcrb(struct ica_xcRB *pxcrb,
                             struct CPRBX *prepcblk)
 {
        memset(pxcrb, 0, sizeof(*pxcrb));
-       pxcrb->agent_ID = 0x4341; /* 'CA' */
+       memcpy(&pxcrb->agent_ID, "CA", 2);
        pxcrb->user_defined = (cardnr == 0xFFFF ? AUTOSELECT : cardnr);
        pxcrb->request_control_blk_length =
                preqcblk->cprb_len + preqcblk->req_parml;
index 02648d0e838050849a49a41978f0fecde57aee38..bab8860417dee6190d161bfbf175a4fbff74f14c 100644 (file)
@@ -65,7 +65,7 @@ struct function_and_rules_block {
 static const struct CPRBX static_cprbx = {
        .cprb_len       =  0x00DC,
        .cprb_ver_id    =  0x02,
-       .func_id        = {0x54, 0x32},
+       .func_id        = {'T', '2'},
 };
 
 int speed_idx_cca(int req_type)
@@ -455,8 +455,7 @@ static int xcrb_msg_to_type6_ep11cprb_msgx(bool userspace, struct ap_message *ap
                .type           =  0x06,
                .rqid           = {0x00, 0x01},
                .function_code  = {0x00, 0x00},
-               .agent_id[0]    =  0x58,        /* {'X'} */
-               .agent_id[1]    =  0x43,        /* {'C'} */
+               .agent_id       = {'X', 'C'},
                .offset1        =  0x00000058,
        };
 
@@ -1285,7 +1284,7 @@ static inline void rng_type6cprb_msgx(struct ap_message *ap_msg,
        static struct CPRBX local_cprbx = {
                .cprb_len       = 0x00dc,
                .cprb_ver_id    = 0x02,
-               .func_id        = {0x54, 0x32},
+               .func_id        = {'T', '2'},
                .req_parml      = sizeof(*msg) - sizeof(msg->hdr) -
                                  sizeof(msg->cprbx),
                .rpl_msgbl      = sizeof(*msg) - sizeof(msg->hdr),