blob: 75f017ce0dffc14c5388390e1451903b88ce75a8 [file] [log] [blame]
Neeti Desai8dcc3642015-03-17 18:20:35 -07001/*
Patrick Dalyf92b0612018-02-06 17:38:54 -08002 * Copyright (c) 2015-2018, 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 Dalyf92b0612018-02-06 17:38:54 -080044 VMID_CP_CDSP = 0x2A,
Patrick Daly152e05a2016-07-08 14:34:44 -070045 VMID_LAST,
46 VMID_INVAL = -1
47};
Neeti Desai0e64e702015-03-31 15:33:54 -070048
49#define PERM_READ 0x4
50#define PERM_WRITE 0x2
Shrenuj Bansal395a3122015-07-02 16:08:53 -070051#define PERM_EXEC 0x1
Neeti Desai0e64e702015-03-31 15:33:54 -070052
Neeti Desai8dcc3642015-03-17 18:20:35 -070053#ifdef CONFIG_QCOM_SECURE_BUFFER
Charan Teja Reddy55c1de12017-11-01 19:50:18 +053054int msm_secure_table(struct sg_table *table);
55int msm_unsecure_table(struct sg_table *table);
Neeti Desai0e64e702015-03-31 15:33:54 -070056int hyp_assign_table(struct sg_table *table,
57 u32 *source_vm_list, int source_nelems,
58 int *dest_vmids, int *dest_perms,
59 int dest_nelems);
Sarada Prasanna Garnayak31539162017-03-14 19:14:05 +053060extern int hyp_assign_phys(phys_addr_t addr, u64 size,
Neeti Desaif85f5662015-06-05 18:44:24 -070061 u32 *source_vmlist, int source_nelems,
62 int *dest_vmids, int *dest_perms, int dest_nelems);
Charan Teja Reddy55c1de12017-11-01 19:50:18 +053063bool msm_secure_v2_is_supported(void);
Mitchel Humpherys5b8290a2015-07-30 19:24:15 -070064const char *msm_secure_vmid_to_string(int secure_vmid);
Neeti Desai8dcc3642015-03-17 18:20:35 -070065#else
Charan Teja Reddy55c1de12017-11-01 19:50:18 +053066static inline int msm_secure_table(struct sg_table *table)
67{
68 return -EINVAL;
69}
70
71static inline int msm_unsecure_table(struct sg_table *table)
72{
73 return -EINVAL;
74}
75
Jeremy Gebben33b9a212016-02-10 10:38:11 -070076static inline int hyp_assign_table(struct sg_table *table,
Neeti Desai0e64e702015-03-31 15:33:54 -070077 u32 *source_vm_list, int source_nelems,
78 int *dest_vmids, int *dest_perms,
79 int dest_nelems)
80{
81 return -EINVAL;
82}
Neeti Desaif85f5662015-06-05 18:44:24 -070083
84static inline int hyp_assign_phys(phys_addr_t addr, u64 size,
85 u32 *source_vmlist, int source_nelems,
86 int *dest_vmids, int *dest_perms, int dest_nelems)
Neeti Desai8dcc3642015-03-17 18:20:35 -070087{
88 return -EINVAL;
89}
Neeti Desaif85f5662015-06-05 18:44:24 -070090
Charan Teja Reddy55c1de12017-11-01 19:50:18 +053091static inline bool msm_secure_v2_is_supported(void)
92{
93 return false;
94}
95
Jeremy Gebben33b9a212016-02-10 10:38:11 -070096static inline const char *msm_secure_vmid_to_string(int secure_vmid)
Mitchel Humpherys5b8290a2015-07-30 19:24:15 -070097{
98 return "N/A";
99}
Neeti Desai8dcc3642015-03-17 18:20:35 -0700100#endif
101#endif