1 /* 2 * Copyright (C) 2020 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef _UAPI_LINUX_TRUSTY_IPC_H_ 18 #define _UAPI_LINUX_TRUSTY_IPC_H_ 19 20 #include <linux/ioctl.h> 21 #include <linux/types.h> 22 #include <linux/uio.h> 23 24 /** 25 * enum transfer_kind - How to send an fd to Trusty 26 * @TRUSTY_SHARE: Memory will be accessible by Linux and Trusty. On ARM it 27 * will be mapped as nonsecure. Suitable for shared memory. 28 * The paired fd must be a "dma_buf". 29 * @TRUSTY_LEND: Memory will be accessible only to Trusty. On ARM it will 30 * be transitioned to "Secure" memory if Trusty is in 31 * TrustZone. This transfer kind is suitable for donating 32 * video buffers or other similar resources. The paired fd 33 * may need to come from a platform-specific allocator for 34 * memory that may be transitioned to "Secure". 35 * @TRUSTY_SEND_SECURE: Send memory that is already "Secure". Memory will be 36 * accessible only to Trusty. The paired fd may need to 37 * come from a platform-specific allocator that returns 38 * "Secure" buffers. 39 * @TRUSTY_SEND_SECURE_OR_SHARE: Acts as TRUSTY_SEND_SECURE if the memory is already 40 * "Secure" and as TRUSTY_SHARE otherwise. 41 * 42 * Describes how the user would like the resource in question to be sent to 43 * Trusty. Options may be valid only for certain kinds of fds. 44 */ 45 enum transfer_kind { 46 TRUSTY_SHARE = 0, 47 TRUSTY_LEND = 1, 48 TRUSTY_SEND_SECURE = 2, 49 TRUSTY_SEND_SECURE_OR_SHARE = 3, 50 }; 51 52 /** 53 * struct trusty_shm - Describes a transfer of memory to Trusty 54 * @fd: The fd to transfer 55 * @transfer: How to transfer it - see &enum transfer_kind 56 */ 57 struct trusty_shm { 58 __s32 fd; 59 __u32 transfer; 60 }; 61 62 /** 63 * struct tipc_send_msg_req - Request struct for @TIPC_IOC_SEND_MSG 64 * @iov: Pointer to an array of &struct iovec describing data to be sent 65 * @shm: Pointer to an array of &struct trusty_shm describing any file 66 * descriptors to be transferred. 67 * @iov_cnt: Number of elements in the @iov array 68 * @shm_cnt: Number of elements in the @shm array 69 */ 70 struct tipc_send_msg_req { 71 __u64 iov; 72 __u64 shm; 73 __u64 iov_cnt; 74 __u64 shm_cnt; 75 }; 76 77 #define TIPC_IOC_MAGIC 'r' 78 #define TIPC_IOC_CONNECT _IOW(TIPC_IOC_MAGIC, 0x80, char*) 79 #define TIPC_IOC_SEND_MSG _IOW(TIPC_IOC_MAGIC, 0x81, struct tipc_send_msg_req) 80 81 #if defined(CONFIG_COMPAT) 82 #define TIPC_IOC_CONNECT_COMPAT _IOW(TIPC_IOC_MAGIC, 0x80, compat_uptr_t) 83 #endif 84 85 #endif 86