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 u32 __user *user_buf_add_len = (u32 __user *)&user_uvio_attest->add_data_len; in uvio_copy_attest_result_to_user()
113 void __user *user_buf_add = (void __user *)uvio_attest->add_data_addr; in uvio_copy_attest_result_to_user()
114 void __user *user_buf_meas = (void __user *)uvio_attest->meas_addr; in uvio_copy_attest_result_to_user()
115 void __user *user_buf_uid = &user_uvio_attest->config_uid; in uvio_copy_attest_result_to_user()
117 if (copy_to_user(user_buf_meas, measurement, uvio_attest->meas_len)) in uvio_copy_attest_result_to_user()
118 return -EFAULT; in uvio_copy_attest_result_to_user()
119 if (add_data && copy_to_user(user_buf_add, add_data, uvio_attest->add_data_len)) in uvio_copy_attest_result_to_user()
120 return -EFAULT; in uvio_copy_attest_result_to_user()
121 if (put_user(uvio_attest->add_data_len, user_buf_add_len)) in uvio_copy_attest_result_to_user()
122 return -EFAULT; in uvio_copy_attest_result_to_user()
123 if (copy_to_user(user_buf_uid, uvcb_attest->config_uid, sizeof(uvcb_attest->config_uid))) in uvio_copy_attest_result_to_user()
124 return -EFAULT; in uvio_copy_attest_result_to_user()
130 u8 __user *user_arg_buf = (u8 __user *)uv_ioctl->argument_addr; in get_uvio_attest()
133 return -EFAULT; in get_uvio_attest()
135 if (uvio_attest->arcb_len > UVIO_ATT_ARCB_MAX_LEN) in get_uvio_attest()
136 return -EINVAL; in get_uvio_attest()
137 if (uvio_attest->arcb_len == 0) in get_uvio_attest()
138 return -EINVAL; in get_uvio_attest()
139 if (uvio_attest->meas_len > UVIO_ATT_MEASUREMENT_MAX_LEN) in get_uvio_attest()
140 return -EINVAL; in get_uvio_attest()
141 if (uvio_attest->meas_len == 0) in get_uvio_attest()
142 return -EINVAL; in get_uvio_attest()
143 if (uvio_attest->add_data_len > UVIO_ATT_ADDITIONAL_MAX_LEN) in get_uvio_attest()
144 return -EINVAL; in get_uvio_attest()
145 if (uvio_attest->reserved136) in get_uvio_attest()
146 return -EINVAL; in get_uvio_attest()
151 * uvio_attestation() - Perform a Retrieve Attestation Measurement UVC.
159 * request, sends the UV-call, and copies the result to userspace.
161 * The Attestation Request has two input and two outputs.
163 * Measurement and Additional Data are outputs for userspace generated by UV.
191 ret = -EINVAL; in uvio_attestation()
192 if (uv_ioctl->argument_len != sizeof(*uvio_attest)) in uvio_attestation()
195 ret = -ENOMEM; in uvio_attestation()
204 ret = -ENOMEM; in uvio_attestation()
205 arcb = kvzalloc(uvio_attest->arcb_len, GFP_KERNEL); in uvio_attestation()
206 measurement = kvzalloc(uvio_attest->meas_len, GFP_KERNEL); in uvio_attestation()
210 if (uvio_attest->add_data_len) { in uvio_attestation()
211 add_data = kvzalloc(uvio_attest->add_data_len, GFP_KERNEL); in uvio_attestation()
226 uv_ioctl->uv_rc = uvcb_attest->header.rc; in uvio_attestation()
227 uv_ioctl->uv_rrc = uvcb_attest->header.rrc; in uvio_attestation()
240 /** uvio_add_secret() - perform an Add Secret UVC
249 * value. The request is then copied to kernelspace, the UV-call is
267 void __user *user_buf_arg = (void __user *)uv_ioctl->argument_addr; in uvio_add_secret()
275 if (uv_ioctl->argument_len > UVIO_ADD_SECRET_MAX_LEN) in uvio_add_secret()
276 return -EINVAL; in uvio_add_secret()
277 if (uv_ioctl->argument_len == 0) in uvio_add_secret()
278 return -EINVAL; in uvio_add_secret()
280 asrcb = kvzalloc(uv_ioctl->argument_len, GFP_KERNEL); in uvio_add_secret()
282 return -ENOMEM; in uvio_add_secret()
284 ret = -EFAULT; in uvio_add_secret()
285 if (copy_from_user(asrcb, user_buf_arg, uv_ioctl->argument_len)) in uvio_add_secret()
291 uv_ioctl->uv_rc = uvcb.header.rc; in uvio_add_secret()
292 uv_ioctl->uv_rrc = uvcb.header.rrc; in uvio_add_secret()
299 /** uvio_list_secrets() - perform a List Secret UVC
305 * negative return value. It builds the request, performs the UV-call, and
308 * The argument specifies the location for the result of the UV-Call.
320 void __user *user_buf_arg = (void __user *)uv_ioctl->argument_addr; in uvio_list_secrets()
328 if (uv_ioctl->argument_len != UVIO_LIST_SECRETS_LEN) in uvio_list_secrets()
329 return -EINVAL; in uvio_list_secrets()
333 return -ENOMEM; in uvio_list_secrets()
337 uv_ioctl->uv_rc = uvcb.header.rc; in uvio_list_secrets()
338 uv_ioctl->uv_rrc = uvcb.header.rrc; in uvio_list_secrets()
341 ret = -EFAULT; in uvio_list_secrets()
347 /** uvio_lock_secrets() - perform a Lock Secret Store UVC
351 * performs the UV-call and copies the return codes to the ioctl control block.
372 if (ioctl->argument_addr || ioctl->argument_len) in uvio_lock_secrets()
373 return -EINVAL; in uvio_lock_secrets()
376 ioctl->uv_rc = uvcb.header.rc; in uvio_lock_secrets()
377 ioctl->uv_rrc = uvcb.header.rrc; in uvio_lock_secrets()
385 u8 nr = _IOC_NR(cmd); in uvio_copy_and_check_ioctl() local
388 return -ENOIOCTLCMD; in uvio_copy_and_check_ioctl()
390 return -ENOIOCTLCMD; in uvio_copy_and_check_ioctl()
391 if (nr >= UVIO_IOCTL_NUM_IOCTLS) in uvio_copy_and_check_ioctl()
392 return -ENOIOCTLCMD; in uvio_copy_and_check_ioctl()
394 return -ENOIOCTLCMD; in uvio_copy_and_check_ioctl()
396 return -EFAULT; in uvio_copy_and_check_ioctl()
397 if (ioctl->flags != 0) in uvio_copy_and_check_ioctl()
398 return -EINVAL; in uvio_copy_and_check_ioctl()
399 if (memchr_inv(ioctl->reserved14, 0, sizeof(ioctl->reserved14))) in uvio_copy_and_check_ioctl()
400 return -EINVAL; in uvio_copy_and_check_ioctl()
402 return nr; in uvio_copy_and_check_ioctl()
413 int nr; in uvio_ioctl() local
415 nr = uvio_copy_and_check_ioctl(&uv_ioctl, argp, cmd); in uvio_ioctl()
416 if (nr < 0) in uvio_ioctl()
417 return nr; in uvio_ioctl()
419 switch (nr) { in uvio_ioctl()
436 ret = -ENOIOCTLCMD; in uvio_ioctl()
443 ret = -EFAULT; in uvio_ioctl()