xref: /openbmc/linux/arch/s390/include/uapi/asm/uvdevice.h (revision 2d8a26ac)
14689752cSSteffen Eiden /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
24689752cSSteffen Eiden /*
34689752cSSteffen Eiden  *  Copyright IBM Corp. 2022
44689752cSSteffen Eiden  *  Author(s): Steffen Eiden <seiden@linux.ibm.com>
54689752cSSteffen Eiden  */
64689752cSSteffen Eiden #ifndef __S390_ASM_UVDEVICE_H
74689752cSSteffen Eiden #define __S390_ASM_UVDEVICE_H
84689752cSSteffen Eiden 
94689752cSSteffen Eiden #include <linux/types.h>
104689752cSSteffen Eiden 
114689752cSSteffen Eiden struct uvio_ioctl_cb {
124689752cSSteffen Eiden 	__u32 flags;
134689752cSSteffen Eiden 	__u16 uv_rc;			/* UV header rc value */
144689752cSSteffen Eiden 	__u16 uv_rrc;			/* UV header rrc value */
154689752cSSteffen Eiden 	__u64 argument_addr;		/* Userspace address of uvio argument */
164689752cSSteffen Eiden 	__u32 argument_len;
174689752cSSteffen Eiden 	__u8  reserved14[0x40 - 0x14];	/* must be zero */
184689752cSSteffen Eiden };
194689752cSSteffen Eiden 
204689752cSSteffen Eiden #define UVIO_ATT_USER_DATA_LEN		0x100
214689752cSSteffen Eiden #define UVIO_ATT_UID_LEN		0x10
224689752cSSteffen Eiden struct uvio_attest {
234689752cSSteffen Eiden 	__u64 arcb_addr;				/* 0x0000 */
244689752cSSteffen Eiden 	__u64 meas_addr;				/* 0x0008 */
254689752cSSteffen Eiden 	__u64 add_data_addr;				/* 0x0010 */
264689752cSSteffen Eiden 	__u8  user_data[UVIO_ATT_USER_DATA_LEN];	/* 0x0018 */
274689752cSSteffen Eiden 	__u8  config_uid[UVIO_ATT_UID_LEN];		/* 0x0118 */
284689752cSSteffen Eiden 	__u32 arcb_len;					/* 0x0128 */
294689752cSSteffen Eiden 	__u32 meas_len;					/* 0x012c */
304689752cSSteffen Eiden 	__u32 add_data_len;				/* 0x0130 */
314689752cSSteffen Eiden 	__u16 user_data_len;				/* 0x0134 */
324689752cSSteffen Eiden 	__u16 reserved136;				/* 0x0136 */
334689752cSSteffen Eiden };
344689752cSSteffen Eiden 
35ea9d9716SSteffen Eiden /**
36ea9d9716SSteffen Eiden  * uvio_uvdev_info - Information of supported functions
37ea9d9716SSteffen Eiden  * @supp_uvio_cmds - supported IOCTLs by this device
38ea9d9716SSteffen Eiden  * @supp_uv_cmds - supported UVCs corresponding to the IOCTL
39ea9d9716SSteffen Eiden  *
40ea9d9716SSteffen Eiden  * UVIO request to get information about supported request types by this
41ea9d9716SSteffen Eiden  * uvdevice and the Ultravisor.  Everything is output. Bits are in LSB0
42ea9d9716SSteffen Eiden  * ordering.  If the bit is set in both, @supp_uvio_cmds and @supp_uv_cmds, the
43ea9d9716SSteffen Eiden  * uvdevice and the Ultravisor support that call.
44ea9d9716SSteffen Eiden  *
45ea9d9716SSteffen Eiden  * Note that bit 0 (UVIO_IOCTL_UVDEV_INFO_NR) is always zero for `supp_uv_cmds`
46ea9d9716SSteffen Eiden  * as there is no corresponding UV-call.
47ea9d9716SSteffen Eiden  */
48ea9d9716SSteffen Eiden struct uvio_uvdev_info {
49ea9d9716SSteffen Eiden 	/*
50ea9d9716SSteffen Eiden 	 * If bit `n` is set, this device supports the IOCTL with nr `n`.
51ea9d9716SSteffen Eiden 	 */
52ea9d9716SSteffen Eiden 	__u64 supp_uvio_cmds;
53ea9d9716SSteffen Eiden 	/*
54ea9d9716SSteffen Eiden 	 * If bit `n` is set, the Ultravisor(UV) supports the UV-call
55ea9d9716SSteffen Eiden 	 * corresponding to the IOCTL with nr `n` in the calling contextx (host
56ea9d9716SSteffen Eiden 	 * or guest).  The value is only valid if the corresponding bit in
57ea9d9716SSteffen Eiden 	 * @supp_uvio_cmds is set as well.
58ea9d9716SSteffen Eiden 	 */
59ea9d9716SSteffen Eiden 	__u64 supp_uv_cmds;
60ea9d9716SSteffen Eiden };
61ea9d9716SSteffen Eiden 
624689752cSSteffen Eiden /*
634689752cSSteffen Eiden  * The following max values define an upper length for the IOCTL in/out buffers.
644689752cSSteffen Eiden  * However, they do not represent the maximum the Ultravisor allows which is
654689752cSSteffen Eiden  * often way smaller. By allowing larger buffer sizes we hopefully do not need
664689752cSSteffen Eiden  * to update the code with every machine update. It is therefore possible for
674689752cSSteffen Eiden  * userspace to request more memory than actually used by kernel/UV.
684689752cSSteffen Eiden  */
694689752cSSteffen Eiden #define UVIO_ATT_ARCB_MAX_LEN		0x100000
704689752cSSteffen Eiden #define UVIO_ATT_MEASUREMENT_MAX_LEN	0x8000
714689752cSSteffen Eiden #define UVIO_ATT_ADDITIONAL_MAX_LEN	0x8000
7244567ca2SSteffen Eiden #define UVIO_ADD_SECRET_MAX_LEN		0x100000
73b96b3ce2SSteffen Eiden #define UVIO_LIST_SECRETS_LEN		0x1000
744689752cSSteffen Eiden 
754689752cSSteffen Eiden #define UVIO_DEVICE_NAME "uv"
764689752cSSteffen Eiden #define UVIO_TYPE_UVC 'u'
774689752cSSteffen Eiden 
78ea9d9716SSteffen Eiden enum UVIO_IOCTL_NR {
79ea9d9716SSteffen Eiden 	UVIO_IOCTL_UVDEV_INFO_NR = 0x00,
80ea9d9716SSteffen Eiden 	UVIO_IOCTL_ATT_NR,
8144567ca2SSteffen Eiden 	UVIO_IOCTL_ADD_SECRET_NR,
82b96b3ce2SSteffen Eiden 	UVIO_IOCTL_LIST_SECRETS_NR,
83*2d8a26acSSteffen Eiden 	UVIO_IOCTL_LOCK_SECRETS_NR,
84ea9d9716SSteffen Eiden 	/* must be the last entry */
85ea9d9716SSteffen Eiden 	UVIO_IOCTL_NUM_IOCTLS
86ea9d9716SSteffen Eiden };
87ea9d9716SSteffen Eiden 
88ea9d9716SSteffen Eiden #define UVIO_IOCTL(nr)		_IOWR(UVIO_TYPE_UVC, nr, struct uvio_ioctl_cb)
89ea9d9716SSteffen Eiden #define UVIO_IOCTL_UVDEV_INFO	UVIO_IOCTL(UVIO_IOCTL_UVDEV_INFO_NR)
90ea9d9716SSteffen Eiden #define UVIO_IOCTL_ATT		UVIO_IOCTL(UVIO_IOCTL_ATT_NR)
9144567ca2SSteffen Eiden #define UVIO_IOCTL_ADD_SECRET	UVIO_IOCTL(UVIO_IOCTL_ADD_SECRET_NR)
92b96b3ce2SSteffen Eiden #define UVIO_IOCTL_LIST_SECRETS	UVIO_IOCTL(UVIO_IOCTL_LIST_SECRETS_NR)
93*2d8a26acSSteffen Eiden #define UVIO_IOCTL_LOCK_SECRETS	UVIO_IOCTL(UVIO_IOCTL_LOCK_SECRETS_NR)
94ea9d9716SSteffen Eiden 
95ea9d9716SSteffen Eiden #define UVIO_SUPP_CALL(nr)	(1ULL << (nr))
96ea9d9716SSteffen Eiden #define UVIO_SUPP_UDEV_INFO	UVIO_SUPP_CALL(UVIO_IOCTL_UDEV_INFO_NR)
97ea9d9716SSteffen Eiden #define UVIO_SUPP_ATT		UVIO_SUPP_CALL(UVIO_IOCTL_ATT_NR)
9844567ca2SSteffen Eiden #define UVIO_SUPP_ADD_SECRET	UVIO_SUPP_CALL(UVIO_IOCTL_ADD_SECRET_NR)
99b96b3ce2SSteffen Eiden #define UVIO_SUPP_LIST_SECRETS	UVIO_SUPP_CALL(UVIO_IOCTL_LIST_SECRETS_NR)
100*2d8a26acSSteffen Eiden #define UVIO_SUPP_LOCK_SECRETS	UVIO_SUPP_CALL(UVIO_IOCTL_LOCK_SECRETS_NR)
1014689752cSSteffen Eiden 
1024689752cSSteffen Eiden #endif /* __S390_ASM_UVDEVICE_H */
103