Skip to content

Commit 2a0a1db

Browse files
hfreudeVasily Gorbik
authored andcommitted
s390/zcrypt: Slight rework on the agent_id field
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>
1 parent 0e72b78 commit 2a0a1db

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

drivers/s390/crypto/zcrypt_ccamisc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ static inline void prep_xcrb(struct ica_xcRB *pxcrb,
305305
struct CPRBX *prepcblk)
306306
{
307307
memset(pxcrb, 0, sizeof(*pxcrb));
308-
pxcrb->agent_ID = 0x4341; /* 'CA' */
308+
memcpy(&pxcrb->agent_ID, "CA", 2);
309309
pxcrb->user_defined = (cardnr == 0xFFFF ? AUTOSELECT : cardnr);
310310
pxcrb->request_control_blk_length =
311311
preqcblk->cprb_len + preqcblk->req_parml;

drivers/s390/crypto/zcrypt_msgtype6.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ struct function_and_rules_block {
6565
static const struct CPRBX static_cprbx = {
6666
.cprb_len = 0x00DC,
6767
.cprb_ver_id = 0x02,
68-
.func_id = {0x54, 0x32},
68+
.func_id = {'T', '2'},
6969
};
7070

7171
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
455455
.type = 0x06,
456456
.rqid = {0x00, 0x01},
457457
.function_code = {0x00, 0x00},
458-
.agent_id[0] = 0x58, /* {'X'} */
459-
.agent_id[1] = 0x43, /* {'C'} */
458+
.agent_id = {'X', 'C'},
460459
.offset1 = 0x00000058,
461460
};
462461

@@ -1285,7 +1284,7 @@ static inline void rng_type6cprb_msgx(struct ap_message *ap_msg,
12851284
static struct CPRBX local_cprbx = {
12861285
.cprb_len = 0x00dc,
12871286
.cprb_ver_id = 0x02,
1288-
.func_id = {0x54, 0x32},
1287+
.func_id = {'T', '2'},
12891288
.req_parml = sizeof(*msg) - sizeof(msg->hdr) -
12901289
sizeof(msg->cprbx),
12911290
.rpl_msgbl = sizeof(*msg) - sizeof(msg->hdr),

0 commit comments

Comments
 (0)