blob: d9a526daeb357a790f9476b526568b420a261770 [file] [log] [blame]
Neeti Desai8dcc3642015-03-17 18:20:35 -07001/*
Sudarshan Rajagopalanc9342282017-05-18 00:11:06 -07002 * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
Neeti Desai8dcc3642015-03-17 18:20:35 -07003 *
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 Humpherys5f2e3432015-10-12 18:13:06 -070018#include <linux/scatterlist.h>
Neeti Desai8dcc3642015-03-17 18:20:35 -070019
Mitchel Humpherys5b8290a2015-07-30 19:24:15 -070020/*
21 * if you add a secure VMID here make sure you update
Patrick Daly152e05a2016-07-08 14:34:44 -070022 * 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 Humpherys5b8290a2015-07-30 19:24:15 -070025 */
Patrick Daly152e05a2016-07-08 14:34:44 -070026enum 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 Rajagopalanc9342282017-05-18 00:11:06 -070040 VMID_CP_SPSS_SP = 0x1A,
Liam Markd9a50852016-09-22 11:30:51 -070041 VMID_CP_CAMERA_PREVIEW = 0x1D,
Sudarshan Rajagopalan8e206792017-06-28 17:45:57 -070042 VMID_CP_SPSS_SP_SHARED = 0x22,
Sudarshan Rajagopalane08afb62017-07-13 11:19:46 -070043 VMID_CP_SPSS_HLOS_SHARED = 0x24,
Patrick Daly152e05a2016-07-08 14:34:44 -070044 VMID_LAST,
45 VMID_INVAL = -1
46};
Neeti Desai0e64e702015-03-31 15:33:54 -070047
48#define PERM_READ 0x4
49#define PERM_WRITE 0x2
Shrenuj Bansal395a3122015-07-02 16:08:53 -070050#define PERM_EXEC 0x1
Neeti Desai0e64e702015-03-31 15:33:54 -070051
Neeti Desai8dcc3642015-03-17 18:20:35 -070052#ifdef CONFIG_QCOM_SECURE_BUFFER
Charan Teja Reddy55c1de12017-11-01 19:50:18 +053053int msm_secure_table(struct sg_table *table);
54int msm_unsecure_table(struct sg_table *table);
Neeti Desai0e64e702015-03-31 15:33:54 -070055int hyp_assign_table(struct sg_table *table,
56 u32 *source_vm_list, int source_nelems,
57 int *dest_vmids, int *dest_perms,
58 int dest_nelems);
Sarada Prasanna Garnayak31539162017-03-14 19:14:05 +053059extern int hyp_assign_phys(phys_addr_t addr, u64 size,
Neeti Desaif85f5662015-06-05 18:44:24 -070060 u32 *source_vmlist, int source_nelems,
61 int *dest_vmids, int *dest_perms, int dest_nelems);
Charan Teja Reddy55c1de12017-11-01 19:50:18 +053062bool msm_secure_v2_is_supported(void);
Mitchel Humpherys5b8290a2015-07-30 19:24:15 -070063const char *msm_secure_vmid_to_string(int secure_vmid);
Neeti Desai8dcc3642015-03-17 18:20:35 -070064#else
Charan Teja Reddy55c1de12017-11-01 19:50:18 +053065static inline int msm_secure_table(struct sg_table *table)
66{
67 return -EINVAL;
68}
69
70static inline int msm_unsecure_table(struct sg_table *table)
71{
72 return -EINVAL;
73}
74
Jeremy Gebben33b9a212016-02-10 10:38:11 -070075static inline int hyp_assign_table(struct sg_table *table,
Neeti Desai0e64e702015-03-31 15:33:54 -070076 u32 *source_vm_list, int source_nelems,
77 int *dest_vmids, int *dest_perms,
78 int dest_nelems)
79{
80 return -EINVAL;
81}
Neeti Desaif85f5662015-06-05 18:44:24 -070082
83static inline int hyp_assign_phys(phys_addr_t addr, u64 size,
84 u32 *source_vmlist, int source_nelems,
85 int *dest_vmids, int *dest_perms, int dest_nelems)
Neeti Desai8dcc3642015-03-17 18:20:35 -070086{
87 return -EINVAL;
88}
Neeti Desaif85f5662015-06-05 18:44:24 -070089
Charan Teja Reddy55c1de12017-11-01 19:50:18 +053090static inline bool msm_secure_v2_is_supported(void)
91{
92 return false;
93}
94
Jeremy Gebben33b9a212016-02-10 10:38:11 -070095static inline const char *msm_secure_vmid_to_string(int secure_vmid)
Mitchel Humpherys5b8290a2015-07-30 19:24:15 -070096{
97 return "N/A";
98}
Neeti Desai8dcc3642015-03-17 18:20:35 -070099#endif
100#endif