s390/pkey: fix paes selftest failure with paes and pkey static build
When both the paes and the pkey kernel module are statically build
into the kernel, the paes cipher selftests run before the pkey
kernel module is initialized. So a static variable set in the pkey
init function and used in the pkey_clr2protkey function is not
initialized when the paes cipher's selftests request to call pckmo for
transforming a clear key value into a protected key.
This patch moves the initial setup of the static variable into
the function pck_clr2protkey. So it's possible, to use the function
for transforming a clear to a protected key even before the pkey
init function has been called and the paes selftests may run
successful.
Reported-by: Alexander Egorenkov <Alexander.Egorenkov@ibm.com>
Cc: <stable@vger.kernel.org> # 4.20
Fixes: f822ad2c2c
("s390/pkey: move pckmo subfunction available checks away from module init")
Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
This commit is contained in:
Родитель
c3d9cdca73
Коммит
5b35047eb4
|
@ -35,9 +35,6 @@ MODULE_DESCRIPTION("s390 protected key interface");
|
||||||
#define PROTKEYBLOBBUFSIZE 256 /* protected key buffer size used internal */
|
#define PROTKEYBLOBBUFSIZE 256 /* protected key buffer size used internal */
|
||||||
#define MAXAPQNSINLIST 64 /* max 64 apqns within a apqn list */
|
#define MAXAPQNSINLIST 64 /* max 64 apqns within a apqn list */
|
||||||
|
|
||||||
/* mask of available pckmo subfunctions, fetched once at module init */
|
|
||||||
static cpacf_mask_t pckmo_functions;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* debug feature data and functions
|
* debug feature data and functions
|
||||||
*/
|
*/
|
||||||
|
@ -91,6 +88,9 @@ static int pkey_clr2protkey(u32 keytype,
|
||||||
const struct pkey_clrkey *clrkey,
|
const struct pkey_clrkey *clrkey,
|
||||||
struct pkey_protkey *protkey)
|
struct pkey_protkey *protkey)
|
||||||
{
|
{
|
||||||
|
/* mask of available pckmo subfunctions */
|
||||||
|
static cpacf_mask_t pckmo_functions;
|
||||||
|
|
||||||
long fc;
|
long fc;
|
||||||
int keysize;
|
int keysize;
|
||||||
u8 paramblock[64];
|
u8 paramblock[64];
|
||||||
|
@ -114,11 +114,13 @@ static int pkey_clr2protkey(u32 keytype,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Did we already check for PCKMO ? */
|
||||||
* Check if the needed pckmo subfunction is available.
|
if (!pckmo_functions.bytes[0]) {
|
||||||
* These subfunctions can be enabled/disabled by customers
|
/* no, so check now */
|
||||||
* in the LPAR profile or may even change on the fly.
|
if (!cpacf_query(CPACF_PCKMO, &pckmo_functions))
|
||||||
*/
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
/* check for the pckmo subfunction we need now */
|
||||||
if (!cpacf_test_func(&pckmo_functions, fc)) {
|
if (!cpacf_test_func(&pckmo_functions, fc)) {
|
||||||
DEBUG_ERR("%s pckmo functions not available\n", __func__);
|
DEBUG_ERR("%s pckmo functions not available\n", __func__);
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
@ -2058,7 +2060,7 @@ static struct miscdevice pkey_dev = {
|
||||||
*/
|
*/
|
||||||
static int __init pkey_init(void)
|
static int __init pkey_init(void)
|
||||||
{
|
{
|
||||||
cpacf_mask_t kmc_functions;
|
cpacf_mask_t func_mask;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The pckmo instruction should be available - even if we don't
|
* The pckmo instruction should be available - even if we don't
|
||||||
|
@ -2066,15 +2068,15 @@ static int __init pkey_init(void)
|
||||||
* is also the minimum level for the kmc instructions which
|
* is also the minimum level for the kmc instructions which
|
||||||
* are able to work with protected keys.
|
* are able to work with protected keys.
|
||||||
*/
|
*/
|
||||||
if (!cpacf_query(CPACF_PCKMO, &pckmo_functions))
|
if (!cpacf_query(CPACF_PCKMO, &func_mask))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
/* check for kmc instructions available */
|
/* check for kmc instructions available */
|
||||||
if (!cpacf_query(CPACF_KMC, &kmc_functions))
|
if (!cpacf_query(CPACF_KMC, &func_mask))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
if (!cpacf_test_func(&kmc_functions, CPACF_KMC_PAES_128) ||
|
if (!cpacf_test_func(&func_mask, CPACF_KMC_PAES_128) ||
|
||||||
!cpacf_test_func(&kmc_functions, CPACF_KMC_PAES_192) ||
|
!cpacf_test_func(&func_mask, CPACF_KMC_PAES_192) ||
|
||||||
!cpacf_test_func(&kmc_functions, CPACF_KMC_PAES_256))
|
!cpacf_test_func(&func_mask, CPACF_KMC_PAES_256))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
pkey_debug_init();
|
pkey_debug_init();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче