secure_buffer.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef __QCOM_SECURE_BUFFER_H__
  7. #define __QCOM_SECURE_BUFFER_H__
  8. #include <linux/scatterlist.h>
  9. /*
  10. * if you add a secure VMID here make sure you update
  11. * msm_secure_vmid_to_string.
  12. * Make sure to keep the VMID_LAST as the last entry in the enum.
  13. * This is needed in ion to create a list and it's sized using VMID_LAST.
  14. */
  15. enum vmid {
  16. VMID_TZ = 0x1,
  17. VMID_HLOS = 0x3,
  18. VMID_CP_TOUCH = 0x8,
  19. VMID_CP_BITSTREAM = 0x9,
  20. VMID_CP_PIXEL = 0xA,
  21. VMID_CP_NON_PIXEL = 0xB,
  22. VMID_CP_CAMERA = 0xD,
  23. VMID_HLOS_FREE = 0xE,
  24. VMID_MSS_MSA = 0xF,
  25. VMID_MSS_NONMSA = 0x10,
  26. VMID_CP_SEC_DISPLAY = 0x11,
  27. VMID_CP_APP = 0x12,
  28. VMID_LPASS = 0x16,
  29. VMID_WLAN = 0x18,
  30. VMID_WLAN_CE = 0x19,
  31. VMID_CP_SPSS_SP = 0x1A,
  32. VMID_CP_CAMERA_PREVIEW = 0x1D,
  33. VMID_CP_SPSS_SP_SHARED = 0x22,
  34. VMID_CP_SPSS_HLOS_SHARED = 0x24,
  35. VMID_ADSP_HEAP = 0x25,
  36. VMID_CP_CDSP = 0x2A,
  37. VMID_NAV = 0x2B,
  38. VMID_TVM = 0x2D,
  39. VMID_OEMVM = 0x31,
  40. VMID_LAST,
  41. VMID_INVAL = -1
  42. };
  43. #define PERM_READ 0x4
  44. #define PERM_WRITE 0x2
  45. #define PERM_EXEC 0x1
  46. #if IS_ENABLED(CONFIG_QCOM_SECURE_BUFFER)
  47. int hyp_assign_table(struct sg_table *table,
  48. u32 *source_vm_list, int source_nelems,
  49. int *dest_vmids, int *dest_perms,
  50. int dest_nelems);
  51. const char *msm_secure_vmid_to_string(int secure_vmid);
  52. u32 msm_secure_get_vmid_perms(u32 vmid);
  53. int page_accessible(unsigned long pfn);
  54. #else
  55. static inline int 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)
  59. {
  60. return -EINVAL;
  61. }
  62. static inline const char *msm_secure_vmid_to_string(int secure_vmid)
  63. {
  64. return "N/A";
  65. }
  66. static inline u32 msm_secure_get_vmid_perms(u32 vmid)
  67. {
  68. return 0;
  69. }
  70. static inline int page_accessible(unsigned long pfn)
  71. {
  72. return 1;
  73. }
  74. #endif
  75. #endif