Skip to content

Commit 895ae58

Browse files
juergenchristVasily Gorbik
authored andcommitted
s390/zcrypt: Add admask to zcdn
Zcrypt custom devices now support control domain masks. Users can set and modify this mask to allow custom devices to access certain control domains. Signed-off-by: Juergen Christ <jchrist@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
1 parent d710d37 commit 895ae58

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

drivers/s390/crypto/ap_bus.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ struct ap_perms {
315315
unsigned long ioctlm[BITS_TO_LONGS(AP_IOCTLS)];
316316
unsigned long apm[BITS_TO_LONGS(AP_DEVICES)];
317317
unsigned long aqm[BITS_TO_LONGS(AP_DOMAINS)];
318+
unsigned long adm[BITS_TO_LONGS(AP_DOMAINS)];
318319
};
319320
extern struct ap_perms ap_perms;
320321
extern struct mutex ap_perms_mutex;

drivers/s390/crypto/zcrypt_api.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,53 @@ static ssize_t aqmask_store(struct device *dev,
285285

286286
static DEVICE_ATTR_RW(aqmask);
287287

288+
static ssize_t admask_show(struct device *dev,
289+
struct device_attribute *attr,
290+
char *buf)
291+
{
292+
int i, rc;
293+
struct zcdn_device *zcdndev = to_zcdn_dev(dev);
294+
295+
if (mutex_lock_interruptible(&ap_perms_mutex))
296+
return -ERESTARTSYS;
297+
298+
buf[0] = '0';
299+
buf[1] = 'x';
300+
for (i = 0; i < sizeof(zcdndev->perms.adm) / sizeof(long); i++)
301+
snprintf(buf + 2 + 2 * i * sizeof(long),
302+
PAGE_SIZE - 2 - 2 * i * sizeof(long),
303+
"%016lx", zcdndev->perms.adm[i]);
304+
buf[2 + 2 * i * sizeof(long)] = '\n';
305+
buf[2 + 2 * i * sizeof(long) + 1] = '\0';
306+
rc = 2 + 2 * i * sizeof(long) + 1;
307+
308+
mutex_unlock(&ap_perms_mutex);
309+
310+
return rc;
311+
}
312+
313+
static ssize_t admask_store(struct device *dev,
314+
struct device_attribute *attr,
315+
const char *buf, size_t count)
316+
{
317+
int rc;
318+
struct zcdn_device *zcdndev = to_zcdn_dev(dev);
319+
320+
rc = ap_parse_mask_str(buf, zcdndev->perms.adm,
321+
AP_DOMAINS, &ap_perms_mutex);
322+
if (rc)
323+
return rc;
324+
325+
return count;
326+
}
327+
328+
static DEVICE_ATTR_RW(admask);
329+
288330
static struct attribute *zcdn_dev_attrs[] = {
289331
&dev_attr_ioctlmask.attr,
290332
&dev_attr_apmask.attr,
291333
&dev_attr_aqmask.attr,
334+
&dev_attr_admask.attr,
292335
NULL
293336
};
294337

0 commit comments

Comments
 (0)