Skip to content

Commit 2d8a26a

Browse files
steffen-eidenfrankjaa
authored andcommitted
s390/uvdevice: Add 'Lock Secret Store' UVC
Userspace can call the Lock Secret Store Ultravisor Call using IOCTLs on the uvdevice. The Lock Secret Store UV call disables all additions of secrets for the future. The uvdevice is merely transporting the request from userspace to the Ultravisor. Signed-off-by: Steffen Eiden <seiden@linux.ibm.com> Reviewed-by: Janosch Frank <frankja@linux.ibm.com> Link: https://lore.kernel.org/r/20230615100533.3996107-6-seiden@linux.ibm.com Signed-off-by: Janosch Frank <frankja@linux.ibm.com> Message-Id: <20230615100533.3996107-6-seiden@linux.ibm.com>
1 parent b96b3ce commit 2d8a26a

3 files changed

Lines changed: 44 additions & 0 deletions

File tree

arch/s390/include/asm/uv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
#define UVC_CMD_RETR_ATTEST 0x1020
6161
#define UVC_CMD_ADD_SECRET 0x1031
6262
#define UVC_CMD_LIST_SECRETS 0x1033
63+
#define UVC_CMD_LOCK_SECRETS 0x1034
6364

6465
/* Bits in installed uv calls */
6566
enum uv_cmds_inst {
@@ -92,6 +93,7 @@ enum uv_cmds_inst {
9293
BIT_UVC_CMD_RETR_ATTEST = 28,
9394
BIT_UVC_CMD_ADD_SECRET = 29,
9495
BIT_UVC_CMD_LIST_SECRETS = 30,
96+
BIT_UVC_CMD_LOCK_SECRETS = 31,
9597
};
9698

9799
enum uv_feat_ind {

arch/s390/include/uapi/asm/uvdevice.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ enum UVIO_IOCTL_NR {
8080
UVIO_IOCTL_ATT_NR,
8181
UVIO_IOCTL_ADD_SECRET_NR,
8282
UVIO_IOCTL_LIST_SECRETS_NR,
83+
UVIO_IOCTL_LOCK_SECRETS_NR,
8384
/* must be the last entry */
8485
UVIO_IOCTL_NUM_IOCTLS
8586
};
@@ -89,11 +90,13 @@ enum UVIO_IOCTL_NR {
8990
#define UVIO_IOCTL_ATT UVIO_IOCTL(UVIO_IOCTL_ATT_NR)
9091
#define UVIO_IOCTL_ADD_SECRET UVIO_IOCTL(UVIO_IOCTL_ADD_SECRET_NR)
9192
#define UVIO_IOCTL_LIST_SECRETS UVIO_IOCTL(UVIO_IOCTL_LIST_SECRETS_NR)
93+
#define UVIO_IOCTL_LOCK_SECRETS UVIO_IOCTL(UVIO_IOCTL_LOCK_SECRETS_NR)
9294

9395
#define UVIO_SUPP_CALL(nr) (1ULL << (nr))
9496
#define UVIO_SUPP_UDEV_INFO UVIO_SUPP_CALL(UVIO_IOCTL_UDEV_INFO_NR)
9597
#define UVIO_SUPP_ATT UVIO_SUPP_CALL(UVIO_IOCTL_ATT_NR)
9698
#define UVIO_SUPP_ADD_SECRET UVIO_SUPP_CALL(UVIO_IOCTL_ADD_SECRET_NR)
9799
#define UVIO_SUPP_LIST_SECRETS UVIO_SUPP_CALL(UVIO_IOCTL_LIST_SECRETS_NR)
100+
#define UVIO_SUPP_LOCK_SECRETS UVIO_SUPP_CALL(UVIO_IOCTL_LOCK_SECRETS_NR)
98101

99102
#endif /* __S390_ASM_UVDEVICE_H */

drivers/s390/char/uvdevice.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ static const u32 ioctl_nr_to_uvc_bit[] __initconst = {
3939
[UVIO_IOCTL_ATT_NR] = BIT_UVC_CMD_RETR_ATTEST,
4040
[UVIO_IOCTL_ADD_SECRET_NR] = BIT_UVC_CMD_ADD_SECRET,
4141
[UVIO_IOCTL_LIST_SECRETS_NR] = BIT_UVC_CMD_LIST_SECRETS,
42+
[UVIO_IOCTL_LOCK_SECRETS_NR] = BIT_UVC_CMD_LOCK_SECRETS,
4243
};
4344

4445
static_assert(ARRAY_SIZE(ioctl_nr_to_uvc_bit) == UVIO_IOCTL_NUM_IOCTLS);
@@ -340,6 +341,41 @@ static int uvio_list_secrets(struct uvio_ioctl_cb *uv_ioctl)
340341
return ret;
341342
}
342343

344+
/** uvio_lock_secrets() - perform a Lock Secret Store UVC
345+
* @uv_ioctl: ioctl control block
346+
*
347+
* uvio_lock_secrets() performs the Lock Secret Store Ultravisor Call. It
348+
* performs the UV-call and copies the return codes to the ioctl control block.
349+
* After this call was dispatched successfully every following Add Secret UVC
350+
* and Lock Secrets UVC will fail with return code 0x102.
351+
*
352+
* The argument address and size must be 0.
353+
*
354+
* If the Lock Secrets UV facility is not present, UV will return invalid
355+
* command rc. This won't be fenced in the driver and does not result in a
356+
* negative return value.
357+
*
358+
* Context: might sleep
359+
*
360+
* Return: 0 on success or a negative error code on error.
361+
*/
362+
static int uvio_lock_secrets(struct uvio_ioctl_cb *ioctl)
363+
{
364+
struct uv_cb_nodata uvcb = {
365+
.header.len = sizeof(uvcb),
366+
.header.cmd = UVC_CMD_LOCK_SECRETS,
367+
};
368+
369+
if (ioctl->argument_addr || ioctl->argument_len)
370+
return -EINVAL;
371+
372+
uv_call(0, (u64)&uvcb);
373+
ioctl->uv_rc = uvcb.header.rc;
374+
ioctl->uv_rrc = uvcb.header.rrc;
375+
376+
return 0;
377+
}
378+
343379
static int uvio_copy_and_check_ioctl(struct uvio_ioctl_cb *ioctl, void __user *argp,
344380
unsigned long cmd)
345381
{
@@ -390,6 +426,9 @@ static long uvio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
390426
case UVIO_IOCTL_LIST_SECRETS_NR:
391427
ret = uvio_list_secrets(&uv_ioctl);
392428
break;
429+
case UVIO_IOCTL_LOCK_SECRETS_NR:
430+
ret = uvio_lock_secrets(&uv_ioctl);
431+
break;
393432
default:
394433
ret = -ENOIOCTLCMD;
395434
break;

0 commit comments

Comments
 (0)