Skip to content

Commit 9bbd1bf

Browse files
fcalliesVasily Gorbik
authored andcommitted
s390/crypto: Add Support for Query Authentication Information
Introduce functions __cpacf_qai() and wrapper cpacf_qai() to the respective existing functions __cpacf_query() and cpacf_query() are introduced to support the Query Authentication Information feature of MSA 13. Suggested-by: Harald Freudenberger <freude@linux.ibm.com> Reviewed-by: Harald Freudenberger <freude@linux.ibm.com> Acked-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Finn Callies <fcallies@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
1 parent 27aad7f commit 9bbd1bf

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

arch/s390/include/asm/cpacf.h

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,10 @@
205205
#define CPACF_KDSA_ENC_EDDSA_SIGN_ED448 0x34
206206

207207
#define CPACF_FC_QUERY 0x00
208+
#define CPACF_FC_QUERY_AUTH_INFO 0x7F
208209

209210
typedef struct { unsigned char bytes[16]; } cpacf_mask_t;
211+
typedef struct { unsigned char bytes[256]; } cpacf_qai_t;
210212

211213
/*
212214
* Prototype for a not existing function to produce a link
@@ -349,7 +351,8 @@ static inline int cpacf_test_func(cpacf_mask_t *mask, unsigned int func)
349351
return (mask->bytes[func >> 3] & (0x80 >> (func & 7))) != 0;
350352
}
351353

352-
static __always_inline int cpacf_query_func(unsigned int opcode, unsigned int func)
354+
static __always_inline int cpacf_query_func(unsigned int opcode,
355+
unsigned int func)
353356
{
354357
cpacf_mask_t mask;
355358

@@ -358,6 +361,32 @@ static __always_inline int cpacf_query_func(unsigned int opcode, unsigned int fu
358361
return 0;
359362
}
360363

364+
static __always_inline void __cpacf_qai(unsigned int opcode, cpacf_qai_t *qai)
365+
{
366+
__cpacf_query_insn(opcode, qai, CPACF_FC_QUERY_AUTH_INFO);
367+
}
368+
369+
/**
370+
* cpacf_qai() - Get the query authentication information for a CPACF opcode
371+
* @opcode: the opcode of the crypto instruction
372+
* @mask: ptr to struct cpacf_qai_t
373+
*
374+
* Executes the query authentication information function for the given crypto
375+
* instruction @opcode and checks if @func is available
376+
*
377+
* On success 1 is returned and the mask is filled with the query authentication
378+
* information for this CPACF opcode, otherwise 0 is returned.
379+
*/
380+
static __always_inline int cpacf_qai(unsigned int opcode, cpacf_qai_t *qai)
381+
{
382+
if (cpacf_query_func(opcode, CPACF_FC_QUERY_AUTH_INFO)) {
383+
__cpacf_qai(opcode, qai);
384+
return 1;
385+
}
386+
memset(qai, 0, sizeof(*qai));
387+
return 0;
388+
}
389+
361390
/**
362391
* cpacf_km() - executes the KM (CIPHER MESSAGE) instruction
363392
* @func: the function code passed to KM; see CPACF_KM_xxx defines

0 commit comments

Comments
 (0)