Lines Matching +full:nr +full:- +full:outputs

1 // SPDX-License-Identifier: GPL-2.0
14 * to existing UV-calls.
36 /* Mapping from IOCTL-nr to UVC-bit */
48 .supp_uvio_cmds = GENMASK_ULL(UVIO_IOCTL_NUM_IOCTLS - 1, 0),
65 * uvio_uvdev_info() - get information about the uvdevice
73 void __user *user_buf_arg = (void __user *)uv_ioctl->argument_addr; in uvio_uvdev_info()
75 if (uv_ioctl->argument_len < sizeof(uvdev_info)) in uvio_uvdev_info()
76 return -EINVAL; in uvio_uvdev_info()
78 return -EFAULT; in uvio_uvdev_info()
80 uv_ioctl->uv_rc = UVC_RC_EXECUTED; in uvio_uvdev_info()
87 void __user *user_buf_arcb = (void __user *)uvio_attest->arcb_addr; in uvio_build_uvcb_attest()
89 if (copy_from_user(arcb, user_buf_arcb, uvio_attest->arcb_len)) in uvio_build_uvcb_attest()
90 return -EFAULT; in uvio_build_uvcb_attest()
92 uvcb_attest->header.len = sizeof(*uvcb_attest); in uvio_build_uvcb_attest()
93 uvcb_attest->header.cmd = UVC_CMD_RETR_ATTEST; in uvio_build_uvcb_attest()
94 uvcb_attest->arcb_addr = (u64)arcb; in uvio_build_uvcb_attest()
95 uvcb_attest->cont_token = 0; in uvio_build_uvcb_attest()
96 uvcb_attest->user_data_len = uvio_attest->user_data_len; in uvio_build_uvcb_attest()
97 memcpy(uvcb_attest->user_data, uvio_attest->user_data, sizeof(uvcb_attest->user_data)); in uvio_build_uvcb_attest()
98 uvcb_attest->meas_len = uvio_attest->meas_len; in uvio_build_uvcb_attest()
99 uvcb_attest->meas_addr = (u64)meas; in uvio_build_uvcb_attest()
100 uvcb_attest->add_data_len = uvio_attest->add_data_len; in uvio_build_uvcb_attest()
101 uvcb_attest->add_data_addr = (u64)add_data; in uvio_build_uvcb_attest()
111 struct uvio_attest __user *user_uvio_attest = (void __user *)uv_ioctl->argument_addr; in uvio_copy_attest_result_to_user()
112 void __user *user_buf_add = (void __user *)uvio_attest->add_data_addr; in uvio_copy_attest_result_to_user()
113 void __user *user_buf_meas = (void __user *)uvio_attest->meas_addr; in uvio_copy_attest_result_to_user()
114 void __user *user_buf_uid = &user_uvio_attest->config_uid; in uvio_copy_attest_result_to_user()
116 if (copy_to_user(user_buf_meas, measurement, uvio_attest->meas_len)) in uvio_copy_attest_result_to_user()
117 return -EFAULT; in uvio_copy_attest_result_to_user()
118 if (add_data && copy_to_user(user_buf_add, add_data, uvio_attest->add_data_len)) in uvio_copy_attest_result_to_user()
119 return -EFAULT; in uvio_copy_attest_result_to_user()
120 if (copy_to_user(user_buf_uid, uvcb_attest->config_uid, sizeof(uvcb_attest->config_uid))) in uvio_copy_attest_result_to_user()
121 return -EFAULT; in uvio_copy_attest_result_to_user()
127 u8 __user *user_arg_buf = (u8 __user *)uv_ioctl->argument_addr; in get_uvio_attest()
130 return -EFAULT; in get_uvio_attest()
132 if (uvio_attest->arcb_len > UVIO_ATT_ARCB_MAX_LEN) in get_uvio_attest()
133 return -EINVAL; in get_uvio_attest()
134 if (uvio_attest->arcb_len == 0) in get_uvio_attest()
135 return -EINVAL; in get_uvio_attest()
136 if (uvio_attest->meas_len > UVIO_ATT_MEASUREMENT_MAX_LEN) in get_uvio_attest()
137 return -EINVAL; in get_uvio_attest()
138 if (uvio_attest->meas_len == 0) in get_uvio_attest()
139 return -EINVAL; in get_uvio_attest()
140 if (uvio_attest->add_data_len > UVIO_ATT_ADDITIONAL_MAX_LEN) in get_uvio_attest()
141 return -EINVAL; in get_uvio_attest()
142 if (uvio_attest->reserved136) in get_uvio_attest()
143 return -EINVAL; in get_uvio_attest()
148 * uvio_attestation() - Perform a Retrieve Attestation Measurement UVC.
156 * request, sends the UV-call, and copies the result to userspace.
158 * The Attestation Request has two input and two outputs.
160 * Measurement and Additional Data are outputs for userspace generated by UV.
188 ret = -EINVAL; in uvio_attestation()
189 if (uv_ioctl->argument_len != sizeof(*uvio_attest)) in uvio_attestation()
192 ret = -ENOMEM; in uvio_attestation()
201 ret = -ENOMEM; in uvio_attestation()
202 arcb = kvzalloc(uvio_attest->arcb_len, GFP_KERNEL); in uvio_attestation()
203 measurement = kvzalloc(uvio_attest->meas_len, GFP_KERNEL); in uvio_attestation()
207 if (uvio_attest->add_data_len) { in uvio_attestation()
208 add_data = kvzalloc(uvio_attest->add_data_len, GFP_KERNEL); in uvio_attestation()
223 uv_ioctl->uv_rc = uvcb_attest->header.rc; in uvio_attestation()
224 uv_ioctl->uv_rrc = uvcb_attest->header.rrc; in uvio_attestation()
237 /** uvio_add_secret() - perform an Add Secret UVC
246 * value. The request is then copied to kernelspace, the UV-call is
264 void __user *user_buf_arg = (void __user *)uv_ioctl->argument_addr; in uvio_add_secret()
272 if (uv_ioctl->argument_len > UVIO_ADD_SECRET_MAX_LEN) in uvio_add_secret()
273 return -EINVAL; in uvio_add_secret()
274 if (uv_ioctl->argument_len == 0) in uvio_add_secret()
275 return -EINVAL; in uvio_add_secret()
277 asrcb = kvzalloc(uv_ioctl->argument_len, GFP_KERNEL); in uvio_add_secret()
279 return -ENOMEM; in uvio_add_secret()
281 ret = -EFAULT; in uvio_add_secret()
282 if (copy_from_user(asrcb, user_buf_arg, uv_ioctl->argument_len)) in uvio_add_secret()
288 uv_ioctl->uv_rc = uvcb.header.rc; in uvio_add_secret()
289 uv_ioctl->uv_rrc = uvcb.header.rrc; in uvio_add_secret()
296 /** uvio_list_secrets() - perform a List Secret UVC
302 * negative return value. It builds the request, performs the UV-call, and
305 * The argument specifies the location for the result of the UV-Call.
317 void __user *user_buf_arg = (void __user *)uv_ioctl->argument_addr; in uvio_list_secrets()
325 if (uv_ioctl->argument_len != UVIO_LIST_SECRETS_LEN) in uvio_list_secrets()
326 return -EINVAL; in uvio_list_secrets()
330 return -ENOMEM; in uvio_list_secrets()
334 uv_ioctl->uv_rc = uvcb.header.rc; in uvio_list_secrets()
335 uv_ioctl->uv_rrc = uvcb.header.rrc; in uvio_list_secrets()
338 ret = -EFAULT; in uvio_list_secrets()
344 /** uvio_lock_secrets() - perform a Lock Secret Store UVC
348 * performs the UV-call and copies the return codes to the ioctl control block.
369 if (ioctl->argument_addr || ioctl->argument_len) in uvio_lock_secrets()
370 return -EINVAL; in uvio_lock_secrets()
373 ioctl->uv_rc = uvcb.header.rc; in uvio_lock_secrets()
374 ioctl->uv_rrc = uvcb.header.rrc; in uvio_lock_secrets()
382 u8 nr = _IOC_NR(cmd); in uvio_copy_and_check_ioctl() local
385 return -ENOIOCTLCMD; in uvio_copy_and_check_ioctl()
387 return -ENOIOCTLCMD; in uvio_copy_and_check_ioctl()
388 if (nr >= UVIO_IOCTL_NUM_IOCTLS) in uvio_copy_and_check_ioctl()
389 return -ENOIOCTLCMD; in uvio_copy_and_check_ioctl()
391 return -ENOIOCTLCMD; in uvio_copy_and_check_ioctl()
393 return -EFAULT; in uvio_copy_and_check_ioctl()
394 if (ioctl->flags != 0) in uvio_copy_and_check_ioctl()
395 return -EINVAL; in uvio_copy_and_check_ioctl()
396 if (memchr_inv(ioctl->reserved14, 0, sizeof(ioctl->reserved14))) in uvio_copy_and_check_ioctl()
397 return -EINVAL; in uvio_copy_and_check_ioctl()
399 return nr; in uvio_copy_and_check_ioctl()
410 int nr; in uvio_ioctl() local
412 nr = uvio_copy_and_check_ioctl(&uv_ioctl, argp, cmd); in uvio_ioctl()
413 if (nr < 0) in uvio_ioctl()
414 return nr; in uvio_ioctl()
416 switch (nr) { in uvio_ioctl()
433 ret = -ENOIOCTLCMD; in uvio_ioctl()
440 ret = -EFAULT; in uvio_ioctl()