mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 14:53:58 -04:00
s390/ap/zcrypt: New xflag parameter
Introduce a new flag parameter for the both cprb send functions
zcrypt_send_cprb() and zcrypt_send_ep11_cprb(). This new
xflags parameter ("execution flags") shall be used to provide
execution hints and flags for this crypto request.
There are two flags implemented to be used with these functions:
* ZCRYPT_XFLAG_USERSPACE - indicates to the lower layers that
all the ptrs address userspace. So when construction the ap msg
copy_from_user() is to be used. If this flag is NOT set, the ptrs
address kernel memory and thus memcpy() is to be used.
* ZCRYPT_XFLAG_NOMEMALLOC - indicates that this task must not
allocate memory which may be allocated with io operations.
For the AP bus and zcrypt message layer this means:
* The ZCRYPT_XFLAG_USERSPACE is mapped to the already existing
bool variable "userspace" which is propagated to the zcrypt
proto implementations.
* The ZCRYPT_XFLAG_NOMEMALLOC results in setting the AP flag
AP_MSG_FLAG_MEMPOOL when the AP msg buffer is initialized.
Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Reviewed-by: Holger Dengler <dengler@linux.ibm.com>
Link: https://lore.kernel.org/r/20250424133619.16495-6-freude@linux.ibm.com
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
This commit is contained in:
committed by
Heiko Carstens
parent
f91bb85d39
commit
80c20b2c6d
@@ -648,7 +648,7 @@ static long zcrypt_rsa_modexpo(struct ap_perms *perms,
|
||||
|
||||
trace_s390_zcrypt_req(mex, TP_ICARSAMODEXPO);
|
||||
|
||||
rc = ap_init_apmsg(&ap_msg, false);
|
||||
rc = ap_init_apmsg(&ap_msg, 0);
|
||||
if (rc)
|
||||
goto out;
|
||||
|
||||
@@ -753,7 +753,7 @@ static long zcrypt_rsa_crt(struct ap_perms *perms,
|
||||
|
||||
trace_s390_zcrypt_req(crt, TP_ICARSACRT);
|
||||
|
||||
rc = ap_init_apmsg(&ap_msg, false);
|
||||
rc = ap_init_apmsg(&ap_msg, 0);
|
||||
if (rc)
|
||||
goto out;
|
||||
|
||||
@@ -844,10 +844,11 @@ out:
|
||||
return rc;
|
||||
}
|
||||
|
||||
static long _zcrypt_send_cprb(bool userspace, struct ap_perms *perms,
|
||||
static long _zcrypt_send_cprb(u32 xflags, struct ap_perms *perms,
|
||||
struct zcrypt_track *tr,
|
||||
struct ica_xcRB *xcrb)
|
||||
{
|
||||
bool userspace = xflags & ZCRYPT_XFLAG_USERSPACE;
|
||||
struct zcrypt_card *zc, *pref_zc;
|
||||
struct zcrypt_queue *zq, *pref_zq;
|
||||
struct ap_message ap_msg;
|
||||
@@ -861,7 +862,8 @@ static long _zcrypt_send_cprb(bool userspace, struct ap_perms *perms,
|
||||
|
||||
xcrb->status = 0;
|
||||
|
||||
rc = ap_init_apmsg(&ap_msg, false);
|
||||
rc = ap_init_apmsg(&ap_msg, xflags & ZCRYPT_XFLAG_NOMEMALLOC ?
|
||||
AP_MSG_FLAG_MEMPOOL : 0);
|
||||
if (rc)
|
||||
goto out;
|
||||
|
||||
@@ -977,7 +979,7 @@ out:
|
||||
return rc;
|
||||
}
|
||||
|
||||
long zcrypt_send_cprb(struct ica_xcRB *xcrb)
|
||||
long zcrypt_send_cprb(struct ica_xcRB *xcrb, u32 xflags)
|
||||
{
|
||||
struct zcrypt_track tr;
|
||||
int rc;
|
||||
@@ -985,13 +987,13 @@ long zcrypt_send_cprb(struct ica_xcRB *xcrb)
|
||||
memset(&tr, 0, sizeof(tr));
|
||||
|
||||
do {
|
||||
rc = _zcrypt_send_cprb(false, &ap_perms, &tr, xcrb);
|
||||
rc = _zcrypt_send_cprb(xflags, &ap_perms, &tr, xcrb);
|
||||
} while (rc == -EAGAIN && ++tr.again_counter < TRACK_AGAIN_MAX);
|
||||
|
||||
/* on ENODEV failure: retry once again after a requested rescan */
|
||||
if (rc == -ENODEV && zcrypt_process_rescan())
|
||||
do {
|
||||
rc = _zcrypt_send_cprb(false, &ap_perms, &tr, xcrb);
|
||||
rc = _zcrypt_send_cprb(xflags, &ap_perms, &tr, xcrb);
|
||||
} while (rc == -EAGAIN && ++tr.again_counter < TRACK_AGAIN_MAX);
|
||||
if (rc == -EAGAIN && tr.again_counter >= TRACK_AGAIN_MAX)
|
||||
rc = -EIO;
|
||||
@@ -1029,10 +1031,11 @@ static bool is_desired_ep11_queue(unsigned int dev_qid,
|
||||
return false;
|
||||
}
|
||||
|
||||
static long _zcrypt_send_ep11_cprb(bool userspace, struct ap_perms *perms,
|
||||
static long _zcrypt_send_ep11_cprb(u32 xflags, struct ap_perms *perms,
|
||||
struct zcrypt_track *tr,
|
||||
struct ep11_urb *xcrb)
|
||||
{
|
||||
bool userspace = xflags & ZCRYPT_XFLAG_USERSPACE;
|
||||
struct zcrypt_card *zc, *pref_zc;
|
||||
struct zcrypt_queue *zq, *pref_zq;
|
||||
struct ep11_target_dev *targets = NULL;
|
||||
@@ -1045,7 +1048,8 @@ static long _zcrypt_send_ep11_cprb(bool userspace, struct ap_perms *perms,
|
||||
|
||||
trace_s390_zcrypt_req(xcrb, TP_ZSENDEP11CPRB);
|
||||
|
||||
rc = ap_init_apmsg(&ap_msg, false);
|
||||
rc = ap_init_apmsg(&ap_msg, xflags & ZCRYPT_XFLAG_NOMEMALLOC ?
|
||||
AP_MSG_FLAG_MEMPOOL : 0);
|
||||
if (rc)
|
||||
goto out;
|
||||
|
||||
@@ -1177,7 +1181,7 @@ out:
|
||||
return rc;
|
||||
}
|
||||
|
||||
long zcrypt_send_ep11_cprb(struct ep11_urb *xcrb)
|
||||
long zcrypt_send_ep11_cprb(struct ep11_urb *xcrb, u32 xflags)
|
||||
{
|
||||
struct zcrypt_track tr;
|
||||
int rc;
|
||||
@@ -1185,13 +1189,13 @@ long zcrypt_send_ep11_cprb(struct ep11_urb *xcrb)
|
||||
memset(&tr, 0, sizeof(tr));
|
||||
|
||||
do {
|
||||
rc = _zcrypt_send_ep11_cprb(false, &ap_perms, &tr, xcrb);
|
||||
rc = _zcrypt_send_ep11_cprb(xflags, &ap_perms, &tr, xcrb);
|
||||
} while (rc == -EAGAIN && ++tr.again_counter < TRACK_AGAIN_MAX);
|
||||
|
||||
/* on ENODEV failure: retry once again after a requested rescan */
|
||||
if (rc == -ENODEV && zcrypt_process_rescan())
|
||||
do {
|
||||
rc = _zcrypt_send_ep11_cprb(false, &ap_perms, &tr, xcrb);
|
||||
rc = _zcrypt_send_ep11_cprb(xflags, &ap_perms, &tr, xcrb);
|
||||
} while (rc == -EAGAIN && ++tr.again_counter < TRACK_AGAIN_MAX);
|
||||
if (rc == -EAGAIN && tr.again_counter >= TRACK_AGAIN_MAX)
|
||||
rc = -EIO;
|
||||
@@ -1215,7 +1219,7 @@ static long zcrypt_rng(char *buffer)
|
||||
|
||||
trace_s390_zcrypt_req(buffer, TP_HWRNGCPRB);
|
||||
|
||||
rc = ap_init_apmsg(&ap_msg, false);
|
||||
rc = ap_init_apmsg(&ap_msg, 0);
|
||||
if (rc)
|
||||
goto out;
|
||||
rc = prep_rng_ap_msg(&ap_msg, &func_code, &domain);
|
||||
@@ -1528,6 +1532,7 @@ static int zsecsendcprb_ioctl(struct ap_perms *perms, unsigned long arg)
|
||||
int rc;
|
||||
struct ica_xcRB xcrb;
|
||||
struct zcrypt_track tr;
|
||||
u32 xflags = ZCRYPT_XFLAG_USERSPACE;
|
||||
struct ica_xcRB __user *uxcrb = (void __user *)arg;
|
||||
|
||||
memset(&tr, 0, sizeof(tr));
|
||||
@@ -1535,13 +1540,13 @@ static int zsecsendcprb_ioctl(struct ap_perms *perms, unsigned long arg)
|
||||
return -EFAULT;
|
||||
|
||||
do {
|
||||
rc = _zcrypt_send_cprb(true, perms, &tr, &xcrb);
|
||||
rc = _zcrypt_send_cprb(xflags, perms, &tr, &xcrb);
|
||||
} while (rc == -EAGAIN && ++tr.again_counter < TRACK_AGAIN_MAX);
|
||||
|
||||
/* on ENODEV failure: retry once again after a requested rescan */
|
||||
if (rc == -ENODEV && zcrypt_process_rescan())
|
||||
do {
|
||||
rc = _zcrypt_send_cprb(true, perms, &tr, &xcrb);
|
||||
rc = _zcrypt_send_cprb(xflags, perms, &tr, &xcrb);
|
||||
} while (rc == -EAGAIN && ++tr.again_counter < TRACK_AGAIN_MAX);
|
||||
if (rc == -EAGAIN && tr.again_counter >= TRACK_AGAIN_MAX)
|
||||
rc = -EIO;
|
||||
@@ -1558,6 +1563,7 @@ static int zsendep11cprb_ioctl(struct ap_perms *perms, unsigned long arg)
|
||||
int rc;
|
||||
struct ep11_urb xcrb;
|
||||
struct zcrypt_track tr;
|
||||
u32 xflags = ZCRYPT_XFLAG_USERSPACE;
|
||||
struct ep11_urb __user *uxcrb = (void __user *)arg;
|
||||
|
||||
memset(&tr, 0, sizeof(tr));
|
||||
@@ -1565,13 +1571,13 @@ static int zsendep11cprb_ioctl(struct ap_perms *perms, unsigned long arg)
|
||||
return -EFAULT;
|
||||
|
||||
do {
|
||||
rc = _zcrypt_send_ep11_cprb(true, perms, &tr, &xcrb);
|
||||
rc = _zcrypt_send_ep11_cprb(xflags, perms, &tr, &xcrb);
|
||||
} while (rc == -EAGAIN && ++tr.again_counter < TRACK_AGAIN_MAX);
|
||||
|
||||
/* on ENODEV failure: retry once again after a requested rescan */
|
||||
if (rc == -ENODEV && zcrypt_process_rescan())
|
||||
do {
|
||||
rc = _zcrypt_send_ep11_cprb(true, perms, &tr, &xcrb);
|
||||
rc = _zcrypt_send_ep11_cprb(xflags, perms, &tr, &xcrb);
|
||||
} while (rc == -EAGAIN && ++tr.again_counter < TRACK_AGAIN_MAX);
|
||||
if (rc == -EAGAIN && tr.again_counter >= TRACK_AGAIN_MAX)
|
||||
rc = -EIO;
|
||||
@@ -1832,6 +1838,7 @@ static long trans_xcrb32(struct ap_perms *perms, struct file *filp,
|
||||
unsigned int cmd, unsigned long arg)
|
||||
{
|
||||
struct compat_ica_xcrb __user *uxcrb32 = compat_ptr(arg);
|
||||
u32 xflags = ZCRYPT_XFLAG_USERSPACE;
|
||||
struct compat_ica_xcrb xcrb32;
|
||||
struct zcrypt_track tr;
|
||||
struct ica_xcRB xcrb64;
|
||||
@@ -1861,13 +1868,13 @@ static long trans_xcrb32(struct ap_perms *perms, struct file *filp,
|
||||
xcrb64.priority_window = xcrb32.priority_window;
|
||||
xcrb64.status = xcrb32.status;
|
||||
do {
|
||||
rc = _zcrypt_send_cprb(true, perms, &tr, &xcrb64);
|
||||
rc = _zcrypt_send_cprb(xflags, perms, &tr, &xcrb64);
|
||||
} while (rc == -EAGAIN && ++tr.again_counter < TRACK_AGAIN_MAX);
|
||||
|
||||
/* on ENODEV failure: retry once again after a requested rescan */
|
||||
if (rc == -ENODEV && zcrypt_process_rescan())
|
||||
do {
|
||||
rc = _zcrypt_send_cprb(true, perms, &tr, &xcrb64);
|
||||
rc = _zcrypt_send_cprb(xflags, perms, &tr, &xcrb64);
|
||||
} while (rc == -EAGAIN && ++tr.again_counter < TRACK_AGAIN_MAX);
|
||||
if (rc == -EAGAIN && tr.again_counter >= TRACK_AGAIN_MAX)
|
||||
rc = -EIO;
|
||||
|
||||
Reference in New Issue
Block a user