Neeti Desai | 8dcc364 | 2015-03-17 18:20:35 -0700 | [diff] [blame] | 1 | /* |
Sudarshan Rajagopalan | c934228 | 2017-05-18 00:11:06 -0700 | [diff] [blame] | 2 | * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved. |
Neeti Desai | 8dcc364 | 2015-03-17 18:20:35 -0700 | [diff] [blame] | 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 and |
| 6 | * only version 2 as published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | */ |
| 14 | |
| 15 | #ifndef __QCOM_SECURE_BUFFER_H__ |
| 16 | #define __QCOM_SECURE_BUFFER_H__ |
| 17 | |
Mitchel Humpherys | 5f2e343 | 2015-10-12 18:13:06 -0700 | [diff] [blame] | 18 | #include <linux/scatterlist.h> |
Neeti Desai | 8dcc364 | 2015-03-17 18:20:35 -0700 | [diff] [blame] | 19 | |
Mitchel Humpherys | 5b8290a | 2015-07-30 19:24:15 -0700 | [diff] [blame] | 20 | /* |
| 21 | * if you add a secure VMID here make sure you update |
Patrick Daly | 152e05a | 2016-07-08 14:34:44 -0700 | [diff] [blame] | 22 | * msm_secure_vmid_to_string. |
| 23 | * Make sure to keep the VMID_LAST as the last entry in the enum. |
| 24 | * This is needed in ion to create a list and it's sized using VMID_LAST. |
Mitchel Humpherys | 5b8290a | 2015-07-30 19:24:15 -0700 | [diff] [blame] | 25 | */ |
Patrick Daly | 152e05a | 2016-07-08 14:34:44 -0700 | [diff] [blame] | 26 | enum vmid { |
| 27 | VMID_HLOS = 0x3, |
| 28 | VMID_CP_TOUCH = 0x8, |
| 29 | VMID_CP_BITSTREAM = 0x9, |
| 30 | VMID_CP_PIXEL = 0xA, |
| 31 | VMID_CP_NON_PIXEL = 0xB, |
| 32 | VMID_CP_CAMERA = 0xD, |
| 33 | VMID_HLOS_FREE = 0xE, |
| 34 | VMID_MSS_MSA = 0xF, |
| 35 | VMID_MSS_NONMSA = 0x10, |
| 36 | VMID_CP_SEC_DISPLAY = 0x11, |
| 37 | VMID_CP_APP = 0x12, |
| 38 | VMID_WLAN = 0x18, |
| 39 | VMID_WLAN_CE = 0x19, |
Sudarshan Rajagopalan | c934228 | 2017-05-18 00:11:06 -0700 | [diff] [blame] | 40 | VMID_CP_SPSS_SP = 0x1A, |
Liam Mark | d9a5085 | 2016-09-22 11:30:51 -0700 | [diff] [blame] | 41 | VMID_CP_CAMERA_PREVIEW = 0x1D, |
Sudarshan Rajagopalan | 8e20679 | 2017-06-28 17:45:57 -0700 | [diff] [blame] | 42 | VMID_CP_SPSS_SP_SHARED = 0x22, |
Sudarshan Rajagopalan | e08afb6 | 2017-07-13 11:19:46 -0700 | [diff] [blame] | 43 | VMID_CP_SPSS_HLOS_SHARED = 0x24, |
Patrick Daly | 152e05a | 2016-07-08 14:34:44 -0700 | [diff] [blame] | 44 | VMID_LAST, |
| 45 | VMID_INVAL = -1 |
| 46 | }; |
Neeti Desai | 0e64e70 | 2015-03-31 15:33:54 -0700 | [diff] [blame] | 47 | |
| 48 | #define PERM_READ 0x4 |
| 49 | #define PERM_WRITE 0x2 |
Shrenuj Bansal | 395a312 | 2015-07-02 16:08:53 -0700 | [diff] [blame] | 50 | #define PERM_EXEC 0x1 |
Neeti Desai | 0e64e70 | 2015-03-31 15:33:54 -0700 | [diff] [blame] | 51 | |
Neeti Desai | 8dcc364 | 2015-03-17 18:20:35 -0700 | [diff] [blame] | 52 | #ifdef CONFIG_QCOM_SECURE_BUFFER |
Neeti Desai | 0e64e70 | 2015-03-31 15:33:54 -0700 | [diff] [blame] | 53 | int hyp_assign_table(struct sg_table *table, |
| 54 | u32 *source_vm_list, int source_nelems, |
| 55 | int *dest_vmids, int *dest_perms, |
| 56 | int dest_nelems); |
Sarada Prasanna Garnayak | 3153916 | 2017-03-14 19:14:05 +0530 | [diff] [blame] | 57 | extern int hyp_assign_phys(phys_addr_t addr, u64 size, |
Neeti Desai | f85f566 | 2015-06-05 18:44:24 -0700 | [diff] [blame] | 58 | u32 *source_vmlist, int source_nelems, |
| 59 | int *dest_vmids, int *dest_perms, int dest_nelems); |
Mitchel Humpherys | 5b8290a | 2015-07-30 19:24:15 -0700 | [diff] [blame] | 60 | const char *msm_secure_vmid_to_string(int secure_vmid); |
Neeti Desai | 8dcc364 | 2015-03-17 18:20:35 -0700 | [diff] [blame] | 61 | #else |
Jeremy Gebben | 33b9a21 | 2016-02-10 10:38:11 -0700 | [diff] [blame] | 62 | static inline int hyp_assign_table(struct sg_table *table, |
Neeti Desai | 0e64e70 | 2015-03-31 15:33:54 -0700 | [diff] [blame] | 63 | u32 *source_vm_list, int source_nelems, |
| 64 | int *dest_vmids, int *dest_perms, |
| 65 | int dest_nelems) |
| 66 | { |
| 67 | return -EINVAL; |
| 68 | } |
Neeti Desai | f85f566 | 2015-06-05 18:44:24 -0700 | [diff] [blame] | 69 | |
| 70 | static inline int hyp_assign_phys(phys_addr_t addr, u64 size, |
| 71 | u32 *source_vmlist, int source_nelems, |
| 72 | int *dest_vmids, int *dest_perms, int dest_nelems) |
Neeti Desai | 8dcc364 | 2015-03-17 18:20:35 -0700 | [diff] [blame] | 73 | { |
| 74 | return -EINVAL; |
| 75 | } |
Neeti Desai | f85f566 | 2015-06-05 18:44:24 -0700 | [diff] [blame] | 76 | |
Jeremy Gebben | 33b9a21 | 2016-02-10 10:38:11 -0700 | [diff] [blame] | 77 | static inline const char *msm_secure_vmid_to_string(int secure_vmid) |
Mitchel Humpherys | 5b8290a | 2015-07-30 19:24:15 -0700 | [diff] [blame] | 78 | { |
| 79 | return "N/A"; |
| 80 | } |
Neeti Desai | 8dcc364 | 2015-03-17 18:20:35 -0700 | [diff] [blame] | 81 | #endif |
| 82 | #endif |